โ Final Challenge
โบ An LED Driver
50 ptsPut all four lessons together into the driver every embedded project starts
with: the blinking LED. On a real Pico this exact code โ pointed at
0xd0000000 and 0x40014000 instead of test memory โ drives the onboard
LED on GPIO 25.
Implement three functions:
led_init(sio, ctrl, pin)โ route the pin to the SIO (FUNCSEL 5, preserving the rest of the CTRL register), then enable output drive through the atomicGPIO_OE_SETalias.led_set(sio, pin, on)โ drive the pin high whenonis nonzero, low otherwise, using only theGPIO_OUT_SET/GPIO_OUT_CLRaliases.led_get(sio, pin)โ return the pin's current output level (0 or 1) read fromGPIO_OUT.
The tests emulate the SIO: after each of your calls they apply whatever you
wrote to the SET/CLR aliases onto gpio_out, exactly as the silicon would,
then clear the alias. If you write gpio_out directly, the emulation will
catch it.
Log in to submit a solution and earn points.