| Crates.io | nucleo-l031k6-bsp |
| lib.rs | nucleo-l031k6-bsp |
| version | 0.3.0 |
| created_at | 2018-11-04 05:53:18.354053+00 |
| updated_at | 2022-11-16 05:04:38.519007+00 |
| description | Board support crate for the ST L031K6-NUCLEO |
| homepage | |
| repository | https://github.com/thenewwazoo/nucleo-l031k6-bsp/ |
| max_upload_size | |
| id | 94614 |
| size | 21,738 |
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.
openocd -f interface/stlink-v2-1.cfg -f target/stm32l0.cfgstlink-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.rustup update to get the latest stable version.rustup target add thumbv6m-none-eabigit clone https://github.com/thenewwazoo/nucleo-l031k6-bsp.gitcd nucleo-l031k6-bspcargo runThe current example code initializes the board:
let mut p = cortex_m::Peripherals::take().unwrap();
let d = hal::stm32l0x1::Peripherals::take().unwrap();
let mut board = bsp::init::<hal::power::VCoreRange1>(d.PWR, d.FLASH, d.RCC);
Starts a system clock:
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:
let pins = board.pins(d.GPIOA, d.GPIOB, d.GPIOC);
let mut user_led = board.user_led(pins.d13);
let input_line = pins.d12.into_input::<PullDown>();
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.