Developing a driver to enter standby mode and wake up
Create a copy of your previous project in your IDE, following the steps outlined in earlier chapters. Rename this copied project StandByModeWithWakeupPin
. Next, create a new file named standby_mode.c
in the Src
folder, and then another file named standby_mode.h
in the Inc
folder.
Populate your standby_mode.c
file with the following code:
#include "standby_mode.h" #define PWR_MODE_STANDBY (PWR_CR_PDDS) #define WK_PIN (1U<<0) static void set_power_mode(uint32_t pwr_mode); void wakeup_pin_init(void) { //Enable clock for GPIOA RCC->AHB1ENR |= RCC_AHB1ENR_GPIOAEN; //Set PA0 as input pin GPIOA->MODER &= ~(1U<<0); GPIOA->MODER &= ~(1U...