I'm trying to put STM32L0 into a low power sleep mode. I want it to sleep for 9.5s and wake up for 0.5s. Once it's awake it needs to switch on LEDs, check for any interrupts from a Lora radio module and process the data which cannot be done inside an interrupt routine. I'm using LPTIM interrupts to wake up the system. STM32 Workbench and CubeMX have been used for development. My question is where I should implement the tasks that need to be done once its awake?
/* LPTIMER interrrupt will be used to wakeup the system from SLEEP mode. */
/* Clear LPTIM to be sure there is no ongoing interrupt of line */
/* Enable the power down mode during Sleep mode */
//Disable all interrupts except for LPTIM interrupt
/* Suspend Tick increment to prevent wakeup by Systick interrupt. */
/* Otherwise the Systick interrupt will wake up the device within 1ms */
/* (HAL time base). */
/* Enter Sleep Mode , wake up is done once LPTimer interrupt occured */
/* Resume Tick interrupt if disabled prior to sleep mode entry */
Inside an initialisation function, I'm starting the low power timer.
/* Set the Maximum value of the counter (Auto-Reload) that defines the Period */
#define LPTIM_Period (uint32_t) 43938
/* Set the Timeout value */
#define LPTIM_Timeout (uint32_t) (21969 - 1)
if (HAL_LPTIM_TimeOut_Start_IT(&hlptim1, LPTIM_Period, LPTIM_Timeout) != HAL_OK)