2 * Copyright (C) 2017 C-SKY Microsystems Co., Ltd. All rights reserved.
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
16 /******************************************************************************
18 * @brief header file for pmu driver
21 ******************************************************************************/
30 #include <drv_common.h>
32 /// definition for pmu handle.
33 typedef void *pmu_handle_t;
35 /****** PMU specific error codes *****/
37 EDRV_PMU_MODE = (EDRV_SPECIFIC + 1), ///< Specified Mode not supported
40 /*----- PMU Control Codes: Mode -----*/
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
49 /*----- PMU Control Codes: Wakeup type -----*/
51 PMU_WAKEUP_TYPE_PULSE = 0, ///< Pulse interrupt
52 PMU_WAKEUP_TYPE_LEVEL ///< Level interrupt
55 /*----- PMU Control Codes: Wakeup polarity -----*/
57 PMU_WAKEUP_POL_LOW = 0, ///< Low or negedge
58 PMU_WAKEUP_POL_HIGH ///< High or posedge
61 /****** PMU Event *****/
63 PMU_EVENT_SLEEP_DONE = 0, ///< Send completed; however PMU may still transmit data
64 PMU_EVENT_BEFORE_SLEEP = 1
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.
69 typedef int32_t (*pmu_action_cb_t)(pmu_event_e event);
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
77 pmu_handle_t drv_pmu_initialize(int32_t idx, pmu_event_cb_t cb_event);
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.
84 int32_t drv_pmu_uninitialize(pmu_handle_t handle);
86 int32_t drv_pmu_power_control(int32_t idx, csi_power_stat_e state);
89 \brief choose the pmu mode to enter
90 \param[in] handle pmu handle to operate.
91 \param[in] mode \ref pmu_mode_e
94 int32_t drv_pmu_enter_sleep(pmu_handle_t handle, pmu_mode_e mode);
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
102 int32_t drv_pmu_register_module(pmu_action_cb_t callback);
105 \brief exit the pmu mode
106 \param[in] handle pmu handle to operate.
109 int32_t drv_pmu_exit_sleep(pmu_handle_t handle);
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
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);
125 #endif /* _CSI_PMU_H_ */