Support for STM32L1
* Add RCC * Fix more issues with dash in chip names * Update stm32-data version * Add blinky and spi example
This commit is contained in:
30
examples/stm32l1/src/bin/blinky.rs
Normal file
30
examples/stm32l1/src/bin/blinky.rs
Normal file
@ -0,0 +1,30 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embassy_stm32::Peripherals;
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use example_common::*;
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
info!("Hello World!");
|
||||
|
||||
let mut led = Output::new(p.PA12, Level::High, Speed::Low);
|
||||
|
||||
loop {
|
||||
info!("high");
|
||||
unwrap!(led.set_high());
|
||||
Timer::after(Duration::from_millis(1000)).await;
|
||||
|
||||
info!("low");
|
||||
unwrap!(led.set_low());
|
||||
Timer::after(Duration::from_millis(1000)).await;
|
||||
}
|
||||
}
|
43
examples/stm32l1/src/bin/spi.rs
Normal file
43
examples/stm32l1/src/bin/spi.rs
Normal file
@ -0,0 +1,43 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
|
||||
use embassy::executor::Spawner;
|
||||
use embassy_stm32::gpio::{Level, Output, Speed};
|
||||
use embedded_hal::digital::v2::OutputPin;
|
||||
use example_common::*;
|
||||
|
||||
use embassy_stm32::dma::NoDma;
|
||||
use embassy_stm32::spi::{Config, Spi};
|
||||
use embassy_stm32::time::Hertz;
|
||||
use embassy_stm32::Peripherals;
|
||||
use embedded_hal::blocking::spi::Transfer;
|
||||
|
||||
#[embassy::main]
|
||||
async fn main(_spawner: Spawner, p: Peripherals) {
|
||||
info!("Hello World, folks!");
|
||||
|
||||
let mut spi = Spi::new(
|
||||
p.SPI1,
|
||||
p.PA5,
|
||||
p.PA7,
|
||||
p.PA6,
|
||||
NoDma,
|
||||
NoDma,
|
||||
Hertz(1_000_000),
|
||||
Config::default(),
|
||||
);
|
||||
|
||||
let mut cs = Output::new(p.PA4, Level::High, Speed::VeryHigh);
|
||||
|
||||
loop {
|
||||
let mut buf = [0x0Au8; 4];
|
||||
unwrap!(cs.set_low());
|
||||
unwrap!(spi.transfer(&mut buf));
|
||||
unwrap!(cs.set_high());
|
||||
info!("xfer {=[u8]:x}", buf);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user