PlatformIO package of the Teensy core framework compatible with GCC 10 & C++20
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

73 行
1.8KB

  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. }