โ˜… Final Challenge

โ€บ An LED Driver

50 pts

Put 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 atomic GPIO_OE_SET alias.
  • led_set(sio, pin, on) โ€” drive the pin high when on is nonzero, low otherwise, using only the GPIO_OUT_SET / GPIO_OUT_CLR aliases.
  • led_get(sio, pin) โ€” return the pin's current output level (0 or 1) read from GPIO_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.