]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/T-HEAD_CB2201_CDK/csi/csi_driver/include/drv_pmu.h
Introduce a port for T-HEAD CK802. A simple demo for T-HEAD CB2201 is also included.
[freertos] / FreeRTOS / Demo / T-HEAD_CB2201_CDK / csi / csi_driver / include / drv_pmu.h
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  = (EDRV_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_DORMANT                 ,   ///< Dormant mode
45     PMU_MODE_STDBY                   ,   ///< Standby mode
46     PMU_MODE_SHUTDOWN                    ///< Shutdown mode
47 } pmu_mode_e;
48
49 /*----- PMU Control Codes: Wakeup type -----*/
50 typedef enum {
51     PMU_WAKEUP_TYPE_PULSE   = 0,    ///< Pulse interrupt
52     PMU_WAKEUP_TYPE_LEVEL           ///< Level interrupt
53 } pmu_wakeup_type_e;
54
55 /*----- PMU Control Codes: Wakeup polarity -----*/
56 typedef enum {
57     PMU_WAKEUP_POL_LOW      = 0,       ///< Low or negedge
58     PMU_WAKEUP_POL_HIGH                ///< High or posedge
59 } pmu_wakeup_pol_e;
60
61 /****** PMU Event *****/
62 typedef enum {
63     PMU_EVENT_SLEEP_DONE        = 0,  ///< Send completed; however PMU may still transmit data
64     PMU_EVENT_BEFORE_SLEEP      = 1
65 } pmu_event_e;
66
67 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.
68
69 typedef int32_t (*pmu_action_cb_t)(pmu_event_e event);
70
71 /**
72   \brief       Initialize PMU Interface. 1. Initializes the resources needed for the PMU interface 2.registers event callback function
73   \param[in]   idx the id of the pmu
74   \param[in]   cb_event  Pointer to \ref pmu_event_cb_t
75   \return      return pmu handle if success
76 */
77 pmu_handle_t drv_pmu_initialize(int32_t idx, pmu_event_cb_t cb_event);
78
79 /**
80   \brief       De-initialize PMU Interface. stops operation and releases the software resources used by the interface
81   \param[in]   handle  pmu handle to operate.
82   \return      error code
83 */
84 int32_t drv_pmu_uninitialize(pmu_handle_t handle);
85
86 int32_t drv_pmu_power_control(int32_t idx, csi_power_stat_e state);
87
88 /**
89   \brief       choose the pmu mode to enter
90   \param[in]   handle  pmu handle to operate.
91   \param[in]   mode    \ref pmu_mode_e
92   \return      error code
93 */
94 int32_t drv_pmu_enter_sleep(pmu_handle_t handle, pmu_mode_e mode);
95
96 /**
97   \brief       choose the pmu mode to enter
98   \param[in]   handle  pmu handle to operate.
99   \param[in]   callback Pointer to \ref pmu_action_cb_t
100   \return      error code
101 */
102 int32_t drv_pmu_register_module(pmu_action_cb_t callback);
103
104 /**
105   \brief       exit the pmu mode
106   \param[in]   handle  pmu handle to operate.
107   \return      error code
108 */
109 int32_t drv_pmu_exit_sleep(pmu_handle_t handle);
110
111 /**
112   \brief       Config the wakeup source.
113   \param[in]   handle  pmu handle to operate
114   \param[in]   type    \ref pmu_wakeup_type
115   \param[in]   pol     \ref pmu_wakeup_pol
116   \param[in]   enable  flag control the wakeup source is enable or not
117   \return      error code
118 */
119 int32_t drv_pmu_config_wakeup_source(pmu_handle_t handle, uint32_t irq_num, pmu_wakeup_type_e type, pmu_wakeup_pol_e pol, uint8_t enable);
120
121 #ifdef __cplusplus
122 }
123 #endif
124
125 #endif /* _CSI_PMU_H_ */