/**************************************************************************
|
* @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__ */
|