• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *   http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 /******************************************************************************
17  * @file     drv_pmu.h
18  * @brief    header file for pmu driver
19  * @version  V1.0
20  * @date     02. June 2017
21  ******************************************************************************/
22 
23 #ifndef _CSI_PMU_H_
24 #define _CSI_PMU_H_
25 
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29 
30 #include <drv_common.h>
31 
32 /// definition for pmu handle.
33 typedef void *pmu_handle_t;
34 
35 /****** PMU specific error codes *****/
36 typedef enum {
37     EDRV_PMU_MODE  = (DRV_ERROR_SPECIFIC + 1),      ///< Specified Mode not supported
38 } pmu_error_e;
39 
40 /*----- PMU Control Codes: Mode -----*/
41 typedef enum {
42     PMU_MODE_RUN                  = 0,   ///< Running mode
43     PMU_MODE_SLEEP,                      ///< Sleep mode
44     PMU_MODE_DOZE,                       ///< Doze mode
45     PMU_MODE_DORMANT,                    ///< Dormant mode
46     PMU_MODE_STANDBY,                    ///< Standby mode
47     PMU_MODE_SHUTDOWN                    ///< Shutdown mode
48 } pmu_mode_e;
49 
50 /*----- PMU Control Codes: Wakeup type -----*/
51 typedef enum {
52     PMU_WAKEUP_TYPE_PULSE   = 0,    ///< Pulse interrupt
53     PMU_WAKEUP_TYPE_LEVEL           ///< Level interrupt
54 } pmu_wakeup_type_e;
55 
56 /*----- PMU Control Codes: Wakeup polarity -----*/
57 typedef enum {
58     PMU_WAKEUP_POL_LOW      = 0,       ///< Low or negedge
59     PMU_WAKEUP_POL_HIGH                ///< High or posedge
60 } pmu_wakeup_pol_e;
61 
62 /****** PMU Event *****/
63 typedef enum {
64     PMU_EVENT_SLEEP_DONE        = 0,  ///< Send completed; however PMU may still transmit data
65     PMU_EVENT_PREPARE_SLEEP     = 1
66 } pmu_event_e;
67 
68 typedef void (*pmu_event_cb_t)(int32_t idx, pmu_event_e event, pmu_mode_e mode);   ///< Pointer to \ref pmu_event_cb_t : PMU Event call back.
69 
70 /**
71   \brief       Initialize PMU Interface. 1. Initializes the resources needed for the PMU interface 2.registers event callback function
72   \param[in]   idx the id of the pmu
73   \param[in]   cb_event  Pointer to \ref pmu_event_cb_t
74   \return      return pmu handle if success
75 */
76 pmu_handle_t csi_pmu_initialize(int32_t idx, pmu_event_cb_t cb_event);
77 
78 /**
79   \brief       De-initialize PMU Interface. stops operation and releases the software resources used by the interface
80   \param[in]   handle  pmu handle to operate.
81   \return      error code
82 */
83 int32_t csi_pmu_uninitialize(pmu_handle_t handle);
84 
85 /**
86   \brief       choose the pmu mode to enter
87   \param[in]   handle  pmu handle to operate.
88   \param[in]   mode    \ref pmu_mode_e
89   \return      error code
90 */
91 int32_t csi_pmu_enter_sleep(pmu_handle_t handle, pmu_mode_e mode);
92 
93 /**
94   \brief       control pmu power.
95   \param[in]   handle  pmu handle to operate.
96   \param[in]   state   power state.\ref csi_power_stat_e.
97   \return      error code
98 */
99 int32_t csi_pmu_power_control(pmu_handle_t handle, csi_power_stat_e state);
100 
101 /**
102   \brief       Config the wakeup source.
103   \param[in]   handle  pmu handle to operate
104   \param[in]   wakeup_num wakeup source num
105   \param[in]   type    \ref pmu_wakeup_type
106   \param[in]   pol     \ref pmu_wakeup_pol
107   \param[in]   enable  flag control the wakeup source is enable or not
108   \return      error code
109 */
110 int32_t csi_pmu_config_wakeup_source(pmu_handle_t handle, uint32_t wakeup_num, pmu_wakeup_type_e type, pmu_wakeup_pol_e pol, uint8_t enable);
111 
112 #ifdef __cplusplus
113 }
114 #endif
115 
116 #endif /* _CSI_PMU_H_ */
117