pybsleep.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /*
  2. * This file is part of the MicroPython project, http://micropython.org/
  3. *
  4. * The MIT License (MIT)
  5. *
  6. * Copyright (c) 2015 Daniel Campora
  7. *
  8. * Permission is hereby granted, free of charge, to any person obtaining a copy
  9. * of this software and associated documentation files (the "Software"), to deal
  10. * in the Software without restriction, including without limitation the rights
  11. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  12. * copies of the Software, and to permit persons to whom the Software is
  13. * furnished to do so, subject to the following conditions:
  14. *
  15. * The above copyright notice and this permission notice shall be included in
  16. * all copies or substantial portions of the Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  21. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  22. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  23. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  24. * THE SOFTWARE.
  25. */
  26. #ifndef MICROPY_INCLUDED_CC3200_MODS_PYBSLEEP_H
  27. #define MICROPY_INCLUDED_CC3200_MODS_PYBSLEEP_H
  28. /******************************************************************************
  29. DEFINE CONSTANTS
  30. ******************************************************************************/
  31. #define PYB_PWR_MODE_ACTIVE (0x01)
  32. #define PYB_PWR_MODE_LPDS (0x02)
  33. #define PYB_PWR_MODE_HIBERNATE (0x04)
  34. /******************************************************************************
  35. DEFINE TYPES
  36. ******************************************************************************/
  37. typedef enum {
  38. PYB_SLP_PWRON_RESET = 0,
  39. PYB_SLP_HARD_RESET,
  40. PYB_SLP_WDT_RESET,
  41. PYB_SLP_HIB_RESET,
  42. PYB_SLP_SOFT_RESET
  43. } pybsleep_reset_cause_t;
  44. typedef enum {
  45. PYB_SLP_WAKED_PWRON = 0,
  46. PYB_SLP_WAKED_BY_WLAN,
  47. PYB_SLP_WAKED_BY_GPIO,
  48. PYB_SLP_WAKED_BY_RTC
  49. } pybsleep_wake_reason_t;
  50. typedef void (*WakeUpCB_t)(const mp_obj_t self);
  51. /******************************************************************************
  52. DECLARE FUNCTIONS
  53. ******************************************************************************/
  54. void pyb_sleep_pre_init (void);
  55. void pyb_sleep_init0 (void);
  56. void pyb_sleep_signal_soft_reset (void);
  57. void pyb_sleep_add (const mp_obj_t obj, WakeUpCB_t wakeup);
  58. void pyb_sleep_remove (const mp_obj_t obj);
  59. void pyb_sleep_set_gpio_lpds_callback (mp_obj_t cb_obj);
  60. void pyb_sleep_set_wlan_obj (mp_obj_t wlan_obj);
  61. void pyb_sleep_set_rtc_obj (mp_obj_t rtc_obj);
  62. void pyb_sleep_sleep (void);
  63. void pyb_sleep_deepsleep (void);
  64. pybsleep_reset_cause_t pyb_sleep_get_reset_cause (void);
  65. pybsleep_wake_reason_t pyb_sleep_get_wake_reason (void);
  66. #endif // MICROPY_INCLUDED_CC3200_MODS_PYBSLEEP_H