PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

SnoozeSkeletonDriverClass.cpp 1.8KB

il y a 3 ans
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. #include "SnoozeSkeletonDriverClass.h"
  2. /*
  3. */
  4. void SnoozeSkeletonDriverClass::enableDriver( uint8_t mode ) {
  5. // This function gets called before any sleep or
  6. // low power operation from the Snooze Class.
  7. // save current pin state before we change it to an OUTPUT
  8. volatile uint32_t *config;
  9. config = portConfigRegister( digital_pin );
  10. save_pin_config = *config;
  11. // turn pin to OUTPUT
  12. pinMode( digital_pin, OUTPUT );
  13. config = portConfigRegister( digital_pin );
  14. // blink led a few times
  15. for ( int i = 0; i < 3; i++ ) {
  16. digitalWriteFast( digital_pin, HIGH );
  17. delay( 50 );
  18. digitalWriteFast( digital_pin, LOW );
  19. delay( 50 );
  20. }
  21. }
  22. /*
  23. */
  24. void SnoozeSkeletonDriverClass::disableDriver( uint8_t mode ) {
  25. // This function gets called after any sleep or
  26. // low power operation from the Snooze Class.
  27. // since it is still configured OUTPUT toggle pin
  28. for ( int i = 0; i < 1; i++ ) {
  29. digitalWriteFast( digital_pin, HIGH );
  30. delay( 50 );
  31. digitalWriteFast( digital_pin, LOW );
  32. delay( 50 );
  33. }
  34. // restore pin to previous state
  35. #ifdef KINETISK
  36. *portModeRegister( digital_pin ) = 0;
  37. #else
  38. *portModeRegister( digital_pin ) &= ~digitalPinToBitMask( digital_pin );
  39. #endif
  40. volatile uint32_t *config;
  41. config = portConfigRegister( digital_pin );
  42. *config = save_pin_config;
  43. }
  44. /*
  45. */
  46. void SnoozeSkeletonDriverClass::clearIsrFlags( uint8_t mode ) {
  47. // This function gets called from wakeup Isr, you clear
  48. // any module flags that need to cleared here.
  49. // Nothing to do in this driver...
  50. }
  51. /*
  52. */
  53. void SnoozeSkeletonDriverClass::configure( int pin ) {
  54. // Configure which pin to use
  55. // save the pin
  56. digital_pin = pin;
  57. // let SnoozeBlock that this driver is configured and active
  58. // all classes must set the 'isUsed' variable = true.
  59. isUsed = true;
  60. }