Complete the code to enable the pull-up resistor on the input pin.
GPIO_PORT->PULLUP_EN = [1];The pull-up resistor is enabled by setting the correct bit mask. Here, 0x10 corresponds to the input pin.
Complete the code to configure the pin as input with pull-down resistor enabled.
GPIO_PORT->DIR &= ~[1]; // Set pin as input GPIO_PORT->PULLDOWN_EN = [1];
The pin mask 0x04 is used to clear the direction bit (input) and enable the pull-down resistor on that pin.
Fix the error in the code to correctly enable pull-up resistor on pin 5.
GPIO_PORT->PULLUP_EN |= [1]; // Enable pull-up on pin 5
Pin 5 corresponds to bit 5, which is 0x20 in hexadecimal.
Fill both blanks to configure pin 3 as input.
GPIO_PORT->DIR [1]= [2]0x08; // Configure pin 3 as input
To set pin 3 as input, clear bit 3 using bitwise AND with the complement (~) of the pin mask.
Fill all three blanks to create a dictionary mapping pin numbers to their pull-up status (1 for enabled, 0 for disabled) for pins 1, 2, and 3.
int pullup_status[] = { [1], [2], [3] };Each expression checks if the pull-up resistor is enabled on pins 1, 2, and 3 respectively by masking the correct bit.