status_led.h 1.4 KB

1234567891011121314151617181920212223242526272829303132
  1. // status_led.h -- LED indication of wake activity.
  2. //
  3. // The LED is DARK in all steady states -- including while wake is armed (host suspended) -- and flashes for
  4. // half a second when a wake is actually sent (USBDevice.remoteWakeup()). It's a wake debugger: flash + PC
  5. // stays asleep = resume signal was sent and the HOST ignored it (fix host-side: powercfg /deviceenablewake);
  6. // no flash = firmware never fired (didn't see the gesture, or didn't consider the bus suspended).
  7. //
  8. // Board note: built with the Feather nRF52840 variant, but the usual hardware is a SuperMini "Pro Micro"
  9. // clone. The Feather's user LED is P1.15 (D3, active high); the SuperMini's blue user LED is P0.15 (= D24 in
  10. // the Feather pin map -- SPI MISO, unused here). We drive BOTH pins so the indicator works on either board.
  11. // Override the pins/polarity below if your board differs.
  12. #pragma once
  13. #ifndef WAKE_LED_PIN_A
  14. // Feather: P1.15 user LED (harmless unconnected pad on SuperMini clones)
  15. #define WAKE_LED_PIN_A LED_BUILTIN
  16. #endif
  17. #ifndef WAKE_LED_PIN_B
  18. // SuperMini "Pro Micro" clone: P0.15 blue user LED (D24 in the Feather map)
  19. #define WAKE_LED_PIN_B 24
  20. #endif
  21. #ifndef WAKE_LED_ON
  22. #define WAKE_LED_ON HIGH // set LOW if your board's LED is wired active-low
  23. #endif
  24. void ledInit(); // call once from setup(): pins to output, LED off
  25. // call at each USBDevice.remoteWakeup() site: LED on now, off after 500ms
  26. void ledWakePulse();
  27. void ledTask(); // call every loop(): times out the pulse