luat_pm_air101.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. #include "luat_base.h"
  2. #include "luat_pm.h"
  3. #include "wm_pmu.h"
  4. #include "wm_regs.h"
  5. #define LUAT_LOG_TAG "pm"
  6. #include "luat_log.h"
  7. int luat_pm_request(int mode) {
  8. if (mode == LUAT_PM_SLEEP_MODE_LIGHT) {
  9. tls_pmu_sleep_start();
  10. return 0;
  11. }
  12. else if (mode == LUAT_PM_SLEEP_MODE_DEEP || mode == LUAT_PM_SLEEP_MODE_STANDBY) {
  13. tls_pmu_standby_start();
  14. return 0;
  15. }
  16. return -1;
  17. }
  18. //int luat_pm_release(int mode);
  19. int luat_pm_dtimer_start(int id, size_t timeout) {
  20. if (id == 0 && timeout > 0) {
  21. // 单位秒
  22. tls_pmu_timer0_start((timeout + 999) / 1000);
  23. return 0;
  24. }
  25. else if (id == 1 && timeout > 0) {
  26. // 单位毫妙
  27. tls_pmu_timer1_start(timeout);
  28. return 0;
  29. }
  30. return -1;
  31. }
  32. int luat_pm_dtimer_stop(int id) {
  33. if (id == 0) {
  34. tls_pmu_timer0_stop();
  35. return 0;
  36. }
  37. else if (id == 1) {
  38. tls_pmu_timer1_stop();
  39. return 0;
  40. }
  41. return -1;
  42. }
  43. int luat_pm_dtimer_check(int id) {
  44. return -1;
  45. }
  46. //void luat_pm_cb(int event, int arg, void* args);
  47. extern int rst_sta;
  48. // extern int wake_src;
  49. int luat_pm_last_state(int *lastState, int *rtcOrPad) {
  50. *rtcOrPad = 0; // 暂不支持
  51. if (rst_sta & 0x01) { // bit 0 , watchdog 复位
  52. *lastState = 8;
  53. }
  54. else if (rst_sta & 0x02) { // bit 1, 软件重启
  55. *lastState = 3;
  56. }
  57. else {
  58. *lastState = 0;
  59. }
  60. return 0;
  61. }
  62. int luat_pm_force(int mode) {
  63. return luat_pm_request(mode);
  64. }
  65. int luat_pm_check(void) {
  66. return 0;
  67. }
  68. int luat_pm_dtimer_wakeup_id(int* id) {
  69. return 0;
  70. }
  71. int luat_pm_dtimer_list(size_t* count, size_t* list) {
  72. *count = 0;
  73. return 0;
  74. }