This branch assumes you use Zig 0.11.0-dev.538+bf316e550 (the last post-0.10 version that supports async
).
Make LEDs blink, and hopefully more, on an STM32F3DISCOVERY board using only Zig (and a linker script).
The starting point was rbino's zig-stm32-blink written for the STM32F4DISCOVERY board. See rbino's blogpost for a more thorough explanation of what's going on.
Since then, this project has been updated to build on top of microzig.
To build the ELF file just run:
zig build -Drelease-small=true
The easiest way to flash the board is to install stlink
tools. Most Linux distributions should have them in their
repos, the build system will try to use the st-flash
program.
The command to flash the board is:
zig build flash -Drelease-small=true
After flashing the board, as you tilt it, you should see the LEDs following gravity.
-
Switch to an eventloop-like
async
based implementation, where there is for example- One 'process' for each led, or pattern of leds, going around the circle;
- That process 'yields' and asks to be woken after a specific time;
- A central data structure that stores, for each led, how many processes want it to be switched on.
-
Explore how to have useful
test
s. Presumably the HAL layer of microzig can help with this. -
How to use hardware timers and PWM (pulse width modulation) to set the leds '40% on', for example?
-
How to let the STM32F3DISCOVERY board run at a faster speed, enabling the code that initially was in
systemInit()
in main.zig? -
(How) can std's event loop +
pub cons io_mode = .evented
be used? -
How can more of microzig be used?
-
Can I do my own panic handler, letting e.g. invert all leds at a regular interval?
-
Try to do some more creative blinking.
-
Try out the other hardware on the STM32F3DISCOVERY board, by using I2C and then SPI.