Complete the code to enter the CPU into idle sleep mode.
void enter_sleep_mode() {
__asm__("[1]");
}The wfi instruction puts the CPU into idle sleep mode, waiting for an interrupt.
Complete the code to enable deep sleep mode by setting the SLEEPDEEP bit.
void enable_deep_sleep() {
SCB->SCR |= [1];
}SLEEPONEXIT which controls sleep on ISR exit.SLEEP_Msk.Setting the SLEEPDEEP bit in the System Control Block's SCR register enables deep sleep mode.
Fix the error in the code to correctly clear the SLEEPDEEP bit to exit deep sleep mode.
void disable_deep_sleep() {
SCB->SCR &= ~[1];
}SLEEPONEXIT.To exit deep sleep mode, clear the SLEEPDEEP bit by ANDing with its negation.
Fill both blanks to create a dictionary mapping sleep mode names to their descriptions.
const char* sleep_modes[] = {"Idle", "[1]", "[2]"};The common sleep modes after Idle are Standby and Hibernate.
Fill all three blanks to complete the function that sets the sleep mode and enters sleep.
void set_sleep_mode_and_enter(int mode) {
switch(mode) {
case 0:
SCB->SCR &= ~[1];
break;
case 1:
SCB->SCR |= [2];
break;
default:
return;
}
__asm__("[3]");
}Clearing or setting SLEEPDEEP bit controls sleep depth, and wfi enters sleep mode.