pwrmgr.h 3.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /**************************************************************************************************
  2. Phyplus Microelectronics Limited confidential and proprietary.
  3. All rights reserved.
  4. IMPORTANT: All rights of this software belong to Phyplus Microelectronics
  5. Limited ("Phyplus"). Your use of this Software is limited to those
  6. specific rights granted under the terms of the business contract, the
  7. confidential agreement, the non-disclosure agreement and any other forms
  8. of agreements as a customer or a partner of Phyplus. You may not use this
  9. Software unless you agree to abide by the terms of these agreements.
  10. You acknowledge that the Software may not be modified, copied,
  11. distributed or disclosed unless embedded on a Phyplus Bluetooth Low Energy
  12. (BLE) integrated circuit, either as a product or is integrated into your
  13. products. Other than for the aforementioned purposes, you may not use,
  14. reproduce, copy, prepare derivative works of, modify, distribute, perform,
  15. display or sell this Software and/or its documentation for any purposes.
  16. YOU FURTHER ACKNOWLEDGE AND AGREE THAT THE SOFTWARE AND DOCUMENTATION ARE
  17. PROVIDED AS IS WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED,
  18. INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, TITLE,
  19. NON-INFRINGEMENT AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL
  20. PHYPLUS OR ITS SUBSIDIARIES BE LIABLE OR OBLIGATED UNDER CONTRACT,
  21. NEGLIGENCE, STRICT LIABILITY, CONTRIBUTION, BREACH OF WARRANTY, OR OTHER
  22. LEGAL EQUITABLE THEORY ANY DIRECT OR INDIRECT DAMAGES OR EXPENSES
  23. INCLUDING BUT NOT LIMITED TO ANY INCIDENTAL, SPECIAL, INDIRECT, PUNITIVE
  24. OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF PROCUREMENT
  25. OF SUBSTITUTE GOODS, TECHNOLOGY, SERVICES, OR ANY CLAIMS BY THIRD PARTIES
  26. (INCLUDING BUT NOT LIMITED TO ANY DEFENSE THEREOF), OR OTHER SIMILAR COSTS.
  27. **************************************************************************************************/
  28. #ifndef _HAL_PWRMGR_HD
  29. #define _HAL_PWRMGR_HD
  30. #include "hal_mcu.h"
  31. #include "gpio.h"
  32. #define PWR_MODE_NO_SLEEP 1
  33. #define PWR_MODE_SLEEP 2
  34. #define PWR_MODE_PWROFF 3
  35. #define PWR_MODE_PWROFF_NO_SLEEP 4
  36. #define HAL_PWRMGR_TASK_MAX_NUM 10
  37. #define RET_SRAM0 BIT(0) /*32K, 0x1fff0000~0x1fff7fff*/
  38. #define RET_SRAM1 BIT(1) /*32K, 0x1fff8000~0x1fffffff*/
  39. #define RET_SRAM2 BIT(2) /*64K, 0x20000000~0x2000ffff*/
  40. #define RET_SRAM3 BIT(3) /*8K, 0x20010000~0x20011fff*/
  41. #define RET_SRAM4 BIT(4) /*2K, 0x20012000~0x200127ff*/
  42. typedef struct{
  43. GPIO_Pin_e pin;
  44. IO_Wakeup_Pol_e type;
  45. }pwroff_cfg_t;
  46. typedef void (*pwrmgr_Hdl_t)(void);
  47. int hal_pwrmgr_init(void);
  48. bool hal_pwrmgr_is_lock(MODULE_e mod);
  49. int hal_pwrmgr_lock(MODULE_e mod);
  50. int hal_pwrmgr_unlock(MODULE_e mod);
  51. int hal_pwrmgr_register(MODULE_e mod, pwrmgr_Hdl_t sleepHandle, pwrmgr_Hdl_t wakeupHandle);
  52. int hal_pwrmgr_unregister(MODULE_e mod);
  53. int hal_pwrmgr_wakeup_process(void) __attribute__((weak));
  54. int hal_pwrmgr_sleep_process(void) __attribute__((weak));
  55. int hal_pwrmgr_RAM_retention(uint32_t sram);
  56. int hal_pwrmgr_RAM_retention_clr(void);
  57. int hal_pwrmgr_RAM_retention_set(void);
  58. int hal_pwrmgr_LowCurrentLdo_enable(void);
  59. int hal_pwrmgr_LowCurrentLdo_disable(void);
  60. int hal_pwrmgr_poweroff(pwroff_cfg_t* pcfg, uint8_t wakeup_pin_num);
  61. void system_on_handler(GPIO_Pin_e pin,uint32_t timer);
  62. #endif