This crate implements a BSP for the ST NUCLEO-L031K6 development board. It is intended to ease development while relieving the programmer of tracking peripheral and pin combinations, as well as providing helper methods for instantiating peripherals.
An example of crate usage can be found in src/main.rs
Building this (and the dependent crates) requires Rust v1.30 or later.
Install or build from source the latest version of OpenOCD.
Launch OpenOCD and target your STM32 by executing the following command. openocd -f interface/stlink-v2-1.cfg -f target/stm32l0.cfg
NOTE: In OpenOCD's current tip of master, stlink-v2-1.cfg
(the config file needed when running OpenOCD from latest stable release, 0.10.0) has been deprecated, and is now replaced by stlink.cfg
.
Install or build from source Rust v1.30 or greater. NOTE: If you already have rust installed, feel free to run rustup update
to get the latest stable version.
rustup target add thumbv6m-none-eabi
git clone https://github.com/thenewwazoo/nucleo-l031k6-bsp.git
cd nucleo-l031k6-bsp
cargo run
The current example code
initializes the board:
```rust
let mut p = cortex_m::Peripherals::take().unwrap();
let d = hal::stm32l0x1::Peripherals::take().unwrap();
let mut board = bsp::init::
Starts a system clock:
rust
let ticks = board.rcc.cfgr.context().unwrap().sysclk().0;
board.systick_start(&mut p.SYST, SystClkSource::Core, ticks / 1000);
And initializes the D12 and D13 pins: ```rust let pins = board.pins(d.GPIOA, d.GPIOB, d.GPIOC);
let mut userled = board.userled(pins.d13);
let inputline = pins.d12.intoinput::
It then enters a loop with a few simple conditional check. If the D12 pin is set to HIGH
, then the D13 (LED) pin state toggles at a frequency of 5hz. If D12 is set to LOW, then nothing will happen.
To test the example code, flash a board using the setup instructions above, and short the D12 and 3.3v pins on your ST NUCLEO-L031K6.