Complete the code to enter low-power sleep mode.
void enter_sleep_mode() {
__[1]();
}The WFI instruction puts the processor into sleep mode until an interrupt occurs, saving power.
Complete the code to disable the peripheral clock to save power.
void disable_peripheral_clock() {
RCC->APB1ENR &= ~[1];
}Disabling the I2C1 peripheral clock saves power when the I2C1 peripheral is not used.
Fix the error in the code to correctly configure the microcontroller to enter STOP mode.
void enter_stop_mode() {
PWR->CR |= PWR_CR_LPDS;
PWR->CR &= ~[1];
SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
__WFI();
}Clearing PWR_CR_PDDS bit configures the device to enter STOP mode instead of STANDBY mode.
Complete the code to create a dictionary comprehension that maps sensor names to their power states only if the sensor is active.
sensor_power = {name: state for name, state in sensors.items() if state [1] 1}The comprehension includes sensors where state == 1, meaning active sensors. No operator is needed after state in the value expression.
Fill all three blanks to create a dictionary comprehension that maps device IDs (uppercase) to their power levels only if the level is above zero.
power_levels = [1]: [2] for id, level in devices.items() if level [3] 0}
id.lower() instead of uppercase.< or == instead of >.The comprehension maps uppercase device IDs to their power levels only if the level is greater than zero.