• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (C) 2022 Beken Corporation
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 //     http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14 
15 #pragma once
16 
17 #ifdef __cplusplus
18 extern "C" {
19 #endif
20 
21 #ifdef  BK_DEEP_SLEEP_DEBUG
22 #define BK_DEEP_SLEEP_PRT  bk_printf
23 #else
24 #define BK_DEEP_SLEEP_PRT   os_null_printf
25 #endif
26 
27     typedef enum {
28         PS_DEEP_WAKEUP_GPIO = 1,
29         PS_DEEP_WAKEUP_RTC = 2,
30         PS_DEEP_WAKEUP_USB = 4,
31     }
32     PS_DEEP_WAKEUP_WAY;
33 
34     typedef struct  ps_deep_ctrl {
35 
36         /*deep_sleep wakeup mode */
37         PS_DEEP_WAKEUP_WAY wake_up_way;
38 
39         /** @brief	Request deep sleep,and wakeup by gpio.
40          *
41          *	@param	gpio_index_map:The gpio bitmap which set 1 enable wakeup deep sleep.
42          *				gpio_index_map is hex and every bits is map to gpio0-gpio31.
43          *				ps:gpio1 as uart RX pin must be wake up from falling
44          *			gpio_edge_map:The gpio edge bitmap for wakeup gpios,
45          *				gpio_edge_map is hex and every bits is map to gpio0-gpio31.
46          *				0:rising,1:falling.
47          *		gpio_stay_lo_map:The gpio bitmap which need stay ,not change in deep sleep.
48          * 			 gpio_index_lo_map is hex and every bits is map to gpio0-gpio31.
49         			gpio_last_index_map:The gpio bitmap which set 1 enable wakeup deep sleep.
50           * 			 gpio_index_map is hex and every bits is map to gpio32-gpio39.
51           * 		gpio_last_edge_map:The gpio edge bitmap for wakeup gpios,
52           * 			 gpio_edge_map is hex and every bits is map to gpio32-gpio39.
53           * 			 0:rising,1:falling.
54          *		gpio_stay_hi_map:The gpio bitmap which need stay ,not change in deep sleep.
55          * 			 gpio_index_lo_map is hex and every bits is map to gpio32-gpio39.
56          *
57          *      sleep_time:the time secound when use PS_DEEP_WAKEUP_RTC wakeup.
58          *      lpo_32k_src:the RTC wakeup source.LPO_SELECT_ROSC or LPO_SELECT_32K_XTAL.
59          */
60 
61         UINT32 gpio_index_map;
62         UINT32 gpio_edge_map;
63         UINT32 gpio_stay_lo_map;
64         UINT32 gpio_last_index_map;
65         UINT32 gpio_last_edge_map;
66         UINT32 gpio_stay_hi_map;
67 
68         UINT32 sleep_time;
69         UINT32 lpo_32k_src;
70     } PS_DEEP_CTRL_PARAM;
71 
72 
73     typedef enum {
74         MANUAL_MODE_NORMAL = 0,
75         MANUAL_MODE_IDLE = 1,
76     } MANUAL_MODE;
77 
78 #define     PS_SUPPORT_MANUAL_SLEEP     0
79     typedef void ( *ps_wakeup_cb ) ( void );
80     extern void bk_enter_deep_sleep_mode ( PS_DEEP_CTRL_PARAM *deep_param );
81 
82 #ifdef __cplusplus
83 }
84 #endif
85