diff options
Diffstat (limited to 'Utilities/lpm/tiny_lpm/stm32_lpm.c')
-rw-r--r-- | Utilities/lpm/tiny_lpm/stm32_lpm.c | 99 |
1 files changed, 90 insertions, 9 deletions
diff --git a/Utilities/lpm/tiny_lpm/stm32_lpm.c b/Utilities/lpm/tiny_lpm/stm32_lpm.c index 1cfd17aa8..73937af14 100644 --- a/Utilities/lpm/tiny_lpm/stm32_lpm.c +++ b/Utilities/lpm/tiny_lpm/stm32_lpm.c @@ -21,35 +21,104 @@ #include "stm32_lpm.h" #include "utilities_conf.h" +/** @addtogroup TINY_LPM + * @{ + */ + /* Private typedef -----------------------------------------------------------*/ /* Private macros ------------------------------------------------------------*/ -#define UTIL_LPM_NO_BIT_SET (0) +/** @defgroup TINY_LPM_Private_macros TINY LPM private macros + * @{ + */ +/** + * @brief macro used to initialized the critical section + */ #ifndef UTIL_LPM_INIT_CRITICAL_SECTION #define UTIL_LPM_INIT_CRITICAL_SECTION( ) #endif +/** + * @brief macro used to enter the critical section + */ #ifndef UTIL_LPM_ENTER_CRITICAL_SECTION #define UTIL_LPM_ENTER_CRITICAL_SECTION( ) UTILS_ENTER_CRITICAL_SECTION( ) #endif +/** + * @brief macro used to exit the critical section + */ #ifndef UTIL_LPM_EXIT_CRITICAL_SECTION #define UTIL_LPM_EXIT_CRITICAL_SECTION( ) UTILS_EXIT_CRITICAL_SECTION( ) #endif +/** + * @brief macro used to enter the critical section when Entering Low Power + * @note this macro is only called inside the function UTIL_LPM_EnterLowPower + * and in a basic configuration shall be identcal to the macro + * UTIL_LPM_EXIT_CRITICAL_SECTION. In general, the request to enter the + * low power mode is already done under a critical section and + * nesting it is useless (in specific implementations not even possible). + * So the users could define their own macro) + */ +#ifndef UTIL_LPM_ENTER_CRITICAL_SECTION_ELP + #define UTIL_LPM_ENTER_CRITICAL_SECTION_ELP( ) UTIL_LPM_ENTER_CRITICAL_SECTION( ) +#endif + +/** + * @brief macro used to exit the critical section when exting Low Power + * @note the behavior of the macro shall be symmetrical with the macro + * UTIL_LPM_ENTER_CRITICAL_SECTION_ELP + */ +#ifndef UTIL_LPM_EXIT_CRITICAL_SECTION_ELP + #define UTIL_LPM_EXIT_CRITICAL_SECTION_ELP( ) UTIL_LPM_EXIT_CRITICAL_SECTION( ) +#endif + +/** + * @} + */ /* Private function prototypes -----------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/ /* Private defines -----------------------------------------------------------*/ +/** @defgroup TINY_LPM_Private_define TINY LPM private defines + * @{ + */ + +/** + * @brief value used to reset the LPM mode + */ +#define UTIL_LPM_NO_BIT_SET (0UL) + +/** + * @} + */ /* Private macros ------------------------------------------------------------*/ /* Private variables ---------------------------------------------------------*/ +/** @defgroup TINY_LPM_Private_variables TINY LPM private variables + * @{ + */ + +/** + * @brief value used to represent the LPM state of stop mode + */ static UTIL_LPM_bm_t StopModeDisable = UTIL_LPM_NO_BIT_SET; + +/** + * @brief value used to represent the LPM state of off mode + */ static UTIL_LPM_bm_t OffModeDisable = UTIL_LPM_NO_BIT_SET; +/** + * @} + */ /* Global variables ----------------------------------------------------------*/ /* Private function prototypes -----------------------------------------------*/ /* Functions Definition ------------------------------------------------------*/ +/** @addtogroup TINY_LPM_Exported_function + * @{ + */ void UTIL_LPM_Init( void ) { StopModeDisable = UTIL_LPM_NO_BIT_SET; @@ -67,18 +136,20 @@ void UTIL_LPM_SetStopMode( UTIL_LPM_bm_t lpm_id_bm, UTIL_LPM_State_t state ) switch( state ) { - case UTIL_LPM_DISABLE: + case UTIL_LPM_DISABLE: { StopModeDisable |= lpm_id_bm; break; } - case UTIL_LPM_ENABLE: + case UTIL_LPM_ENABLE: { StopModeDisable &= ( ~lpm_id_bm ); break; } - default: + default : + { break; + } } UTIL_LPM_EXIT_CRITICAL_SECTION( ); @@ -90,18 +161,20 @@ void UTIL_LPM_SetOffMode( UTIL_LPM_bm_t lpm_id_bm, UTIL_LPM_State_t state ) switch(state) { - case UTIL_LPM_DISABLE: + case UTIL_LPM_DISABLE: { OffModeDisable |= lpm_id_bm; break; } - case UTIL_LPM_ENABLE: + case UTIL_LPM_ENABLE: { OffModeDisable &= ( ~lpm_id_bm ); break; } - default: + default : + { break; + } } UTIL_LPM_EXIT_CRITICAL_SECTION( ); @@ -142,7 +215,7 @@ UTIL_LPM_Mode_t UTIL_LPM_GetMode( void ) void UTIL_LPM_EnterLowPower( void ) { - UTIL_LPM_ENTER_CRITICAL_SECTION( ); + UTIL_LPM_ENTER_CRITICAL_SECTION_ELP( ); if( StopModeDisable != UTIL_LPM_NO_BIT_SET ) { @@ -174,7 +247,15 @@ void UTIL_LPM_EnterLowPower( void ) } } - UTIL_LPM_EXIT_CRITICAL_SECTION( ); + UTIL_LPM_EXIT_CRITICAL_SECTION_ELP( ); } +/** + * @} + */ + +/** + * @} + */ + /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |