WXK
2024-12-16 78e84fcf264afd731cd66c807d9fcb690fe12126
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/**************************************************************************
 * @file     pan_lp.h
 * @version  V1.00
 * $Revision: 3 $
 * $Date:    2023/11/08 $  
 * @brief    Panchip series lowpower driver header file
 *
 * @note
 * Copyright (C) 2023 Panchip Technology Corp. All rights reserved.
 *****************************************************************************/
#ifndef        __PAN_LP_H__
#define        __PAN_LP_H__
 
/**
 * @brief Lowpower Interface
 * @defgroup lowpower_interface Lowpower Interface
 * @{
 */
#ifdef __cplusplus
extern "C"
{
#endif
 
 
#define    LP_EXT_P56_WK_EN                                (1)        /*!< Gpio p56 wake up enable */
#define    LP_EXT_P56_WK_DISABLE                            (0)        /*!< Gpio p56 wake up disable */
 
/**@defgroup LP_GPIO_WK_EDGE_FLAG Lowpower gpio wake up edge 
 * @brief       Lowpower gpio wake up edge select definitions
 * @{ */
#define    LP_EXT_P56_WK_EDGE_LOW                            (0)        /*!< Gpio p56 wake up by falling edge */
#define    LP_EXT_P56_WK_EDGE_HIGH                            (1)        /*!< Gpio p56 wake up by rising edge */
/**@} */
 
/**@defgroup LP_WK_SOURCE_FLAG Lowpower wakeup source select
 * @brief       Lowpower wakeup source select definitions
 * @{ */
#define LP_WKUP_MODE_SEL_EXT_GPIO                       (0)
#define LP_WKUP_MODE_SEL_32K                            (1)
#define LP_WKUP_MODE_SEL_GPIO                           (2)
#define LP_WKUP_MODE_SEL_WDT                            (3)
#define LP_WKUP_MODE_SEL_TIMER                          (4)
#define LP_WKUP_MODE_SEL_BOD                              (5)
#define LP_WKUP_MODE_SEL_LVR                              (6)
/**@} */
 
#define LP_MODE_SEL_SLEEP_MODE            (0)
#define LP_MODE_SEL_DEEPSLEEP_MODE        (1)
#define LP_MODE_SEL_STANDBY_M1_MODE        (2)
#define LP_MODE_SEL_STANDBY_M0_MODE        (3)
 
#define LP_DEEPSLEEP_MODE_SEL    LP_DEEPSLEEP_MODE1
#define LP_DEEPSLEEP_MODE1        (1)
#define LP_DEEPSLEEP_MODE2        (2)
#define LP_DEEPSLEEP_MODE3        (3)
 
#define LP_STANDBY_M1_MODE_SEL    LP_STANDBY_M1_MODE1
#define LP_STANDBY_M1_MODE1        (1)
#define LP_STANDBY_M1_MODE2        (2)
#define LP_STANDBY_M1_MODE3        (3)
 
/**
* @brief  This function enable lowpower intterrupt
* @param[in]  ana: where ana is analog module
* @param[in] NewState: new state of interrupt mask
*                    ANAC_INT_LP_INT_EN_Msk
* @return   none
*/
__STATIC_INLINE void LP_EnableInt(ANA_T *ana,FunctionalState NewState)
{
    (NewState == ENABLE)?(ana->LP_INT_CTRL |= ANAC_INT_LP_INT_EN_Msk):(ana->LP_INT_CTRL &= ~ANAC_INT_LP_INT_EN_Msk);
}
 
/**
* @brief  This function wait to clear wake up flag
* @param[in]  ana: where ana is analog module
* @param[in]  u32Mask: bit need to be cleared
* @return   none
*/
__STATIC_INLINE void LP_ClearWakeFlag(ANA_T *ana,uint32_t u32Mask)
{
    ana->LP_INT_CTRL |= u32Mask;
}
 
/**
* @brief  This function enable hpldo ready or not(0: need wait ready, 1: do not care ready)
* @param[in]  ana: where ana is analog module
* @param[in] NewState: new state of hpldo ready bypass signal
* @return   none
*/
__STATIC_INLINE void LP_HpldoRdyBypassEn(ANA_T *ana,FunctionalState NewState)
{
    (NewState == ENABLE)?(ana->LP_DLY_CTRL_3V |= ANAC_HPLDO_RDY_BYPASS_Msk):(ana->LP_DLY_CTRL_3V &= ~ANAC_HPLDO_RDY_BYPASS_Msk);
}
 
/**
* @brief  This function enable fast clk delay or not
* @param[in]  ana: where ana is analog module
* @param[in] NewState: new state of hpldo ready bypass signal
* @return   none
*/
__STATIC_INLINE void LP_FastClkDelayEn(ANA_T *ana,FunctionalState NewState)
{
    (NewState == ENABLE)?(ana->LP_DLY_CTRL_3V |= ANAC_32KCLK_DLY_EN_Msk):(ana->LP_DLY_CTRL_3V &= ~ANAC_32KCLK_DLY_EN_Msk);
}
 
/**
  * @brief  This function enable gpio p56 wake up 
  * @param[in]  ana: where ana is analog module base address
  * @param[in]  NewState: enable or disable
  * @param[in]  WkEdge: p56 wake up edge select,0-->low,1-->high 
  * @return   none
  */
void LP_SetExternalWake(ANA_T *ana,uint8_t WkEdge);
/**
  * @brief  This function set sleep time
  * @param[in]  ana: where ana is analog module base address
  * @param[in]  u32ClkCnt: where u32ClkCnt is 32k clock cnt num
  * @return   none
  */
void LP_SetSleepTime(ANA_T *ana,uint32_t u32ClkCnt,uint8_t idx);
 
/**
 * @brief  This function sets the LPLDOH (Low-Power Low-Dropout Regulator) delay count using 32kHz clock cycles.
 * @param[in]  ana: Analog module base address
 * @param[in]  u16Clk32Cnt: Number of 32kHz clock cycles for delay
 * @return   None
 */
void LP_SetLpldohDelay(ANA_T *ana,uint16_t u16Clk32Cnt);
/**
  * @brief  This function used to set digital reset time
  * @param[in]  ana: where ana is analog module base address
  * @param[in]  u8Clk32Cnt: where u8Clk32Cnt is 32k clock period cnt
  * @return   none
  */
void LP_SetWakeDelay(ANA_T *ana,uint16_t u16Clk32Cnt);
/**
 * @brief  This function sets the sleep mode for the specified analog module.
 * @param[in]  ana: Analog module base address
 * @param[in]  mode: Sleep mode configuration
 * @return   None
 */
void LP_SetSleepMode(ANA_T *ana,uint8_t mode);
    
/**
  * @brief  This function set sleep mode config
  * @param[in]  ana: where ana is analog module base address
  * @param[in]  wkMode: where wkMode determine which wakeup mode to choose
  * @param[in]  enterCyclically: where enterCyclically determine
  *              whether to cycle into low power    
  * @return   none
  */
void LP_SetSleepModeConfig(ANA_T *ana,uint32_t wkMode,bool enterCyclically);
/**
 * @brief  This function sets the deep sleep mode configuration.
 * @param[in]  ana: Analog module base address
 * @param[in]  wkMode: Wakeup mode selection
 * @param[in]  enterCyclically: Determines whether to cycle into low power
 * @param[in]  PowerCtrl: Power control configuration
 * @param[in]  dp_mode: Deep sleep mode configuration
 * @return   None
 */
 
void LP_SetDeepSleepConfig(ANA_T *ana,
                            uint32_t wkMode,
                            bool enterCyclically,
                            uint8_t PowerCtrl,
                            uint8_t dp_mode);
/**
 * @brief  This function sets the Standby Mode 0 configuration.
 */
void LP_SetStandbyMode0Config(void);
/**
 * @brief  This function sets the Standby Mode 0 configuration with BOD and LVR.
 */
void LP_SetStandbyMode0BodLvrConfig(void);
/**
 * @brief  This function sets the Standby Mode 1 configuration.
 * @param[in]  ana: Analog module base address
 * @param[in]  wkMode: Wakeup mode selection
 * @param[in]  PowerCtrl: Power control configuration
 * @param[in]  slpTimer: Sleep timer value
 * @param[in]  spaceIdx: Space index
 * @param[in]  stdy_mode: Standby mode configuration
 */
void LP_SetStandbyMode1Config(ANA_T *ana,
                            uint32_t wkMode,
                            uint8_t PowerCtrl,
                            uint32_t slpTimer,
                            uint8_t spaceIdx,
                            uint8_t stdy_mode);
/**@} */
#ifdef __cplusplus
}
#endif
#endif /* __PAN_LP_H__ */