summaryrefslogtreecommitdiff
path: root/examples/stm32l4/src
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2022-08-17 18:49:55 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2022-08-17 22:16:46 +0200
commitfc6e1e06b305d302d1b7ad17e8ef3a9be986c358 (patch)
tree545ad829660f6053d29a01da286d03ec3d49f5ca /examples/stm32l4/src
parentd881f3ad9186cf3279aa1ba27093bad94035c186 (diff)
downloadembassy-fc6e1e06b305d302d1b7ad17e8ef3a9be986c358.zip
Remove HAL initialization from #[embassy::main] macro.
Diffstat (limited to 'examples/stm32l4/src')
-rw-r--r--examples/stm32l4/src/bin/blinky.rs4
-rw-r--r--examples/stm32l4/src/bin/button_exti.rs4
-rw-r--r--examples/stm32l4/src/bin/i2c.rs5
-rw-r--r--examples/stm32l4/src/bin/i2c_blocking_async.rs5
-rw-r--r--examples/stm32l4/src/bin/i2c_dma.rs5
-rw-r--r--examples/stm32l4/src/bin/rng.rs7
-rw-r--r--examples/stm32l4/src/bin/spi_blocking_async.rs4
-rw-r--r--examples/stm32l4/src/bin/spi_dma.rs4
-rw-r--r--examples/stm32l4/src/bin/usart_dma.rs4
9 files changed, 23 insertions, 19 deletions
diff --git a/examples/stm32l4/src/bin/blinky.rs b/examples/stm32l4/src/bin/blinky.rs
index 3d689b5e..8e360149 100644
--- a/examples/stm32l4/src/bin/blinky.rs
+++ b/examples/stm32l4/src/bin/blinky.rs
@@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_executor::time::{Duration, Timer};
use embassy_stm32::gpio::{Level, Output, Speed};
-use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) {
+async fn main(_spawner: Spawner) {
+ let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut led = Output::new(p.PB14, Level::High, Speed::Low);
diff --git a/examples/stm32l4/src/bin/button_exti.rs b/examples/stm32l4/src/bin/button_exti.rs
index 0832386e..8909a1fe 100644
--- a/examples/stm32l4/src/bin/button_exti.rs
+++ b/examples/stm32l4/src/bin/button_exti.rs
@@ -6,11 +6,11 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::exti::ExtiInput;
use embassy_stm32::gpio::{Input, Pull};
-use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) {
+async fn main(_spawner: Spawner) {
+ let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let button = Input::new(p.PC13, Pull::Up);
diff --git a/examples/stm32l4/src/bin/i2c.rs b/examples/stm32l4/src/bin/i2c.rs
index 5bfa560d..177f6baf 100644
--- a/examples/stm32l4/src/bin/i2c.rs
+++ b/examples/stm32l4/src/bin/i2c.rs
@@ -6,15 +6,16 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::dma::NoDma;
use embassy_stm32::i2c::I2c;
+use embassy_stm32::interrupt;
use embassy_stm32::time::Hertz;
-use embassy_stm32::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
const ADDRESS: u8 = 0x5F;
const WHOAMI: u8 = 0x0F;
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) -> ! {
+async fn main(_spawner: Spawner) -> ! {
+ let p = embassy_stm32::init(Default::default());
let irq = interrupt::take!(I2C2_EV);
let mut i2c = I2c::new(
p.I2C2,
diff --git a/examples/stm32l4/src/bin/i2c_blocking_async.rs b/examples/stm32l4/src/bin/i2c_blocking_async.rs
index c924bc9c..8cc069d0 100644
--- a/examples/stm32l4/src/bin/i2c_blocking_async.rs
+++ b/examples/stm32l4/src/bin/i2c_blocking_async.rs
@@ -7,8 +7,8 @@ use embassy_embedded_hal::adapter::BlockingAsync;
use embassy_executor::executor::Spawner;
use embassy_stm32::dma::NoDma;
use embassy_stm32::i2c::I2c;
+use embassy_stm32::interrupt;
use embassy_stm32::time::Hertz;
-use embassy_stm32::{interrupt, Peripherals};
use embedded_hal_async::i2c::I2c as I2cTrait;
use {defmt_rtt as _, panic_probe as _};
@@ -16,7 +16,8 @@ const ADDRESS: u8 = 0x5F;
const WHOAMI: u8 = 0x0F;
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) -> ! {
+async fn main(_spawner: Spawner) -> ! {
+ let p = embassy_stm32::init(Default::default());
let irq = interrupt::take!(I2C2_EV);
let i2c = I2c::new(
p.I2C2,
diff --git a/examples/stm32l4/src/bin/i2c_dma.rs b/examples/stm32l4/src/bin/i2c_dma.rs
index 2b338427..9323fd53 100644
--- a/examples/stm32l4/src/bin/i2c_dma.rs
+++ b/examples/stm32l4/src/bin/i2c_dma.rs
@@ -5,15 +5,16 @@
use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::i2c::I2c;
+use embassy_stm32::interrupt;
use embassy_stm32::time::Hertz;
-use embassy_stm32::{interrupt, Peripherals};
use {defmt_rtt as _, panic_probe as _};
const ADDRESS: u8 = 0x5F;
const WHOAMI: u8 = 0x0F;
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) -> ! {
+async fn main(_spawner: Spawner) -> ! {
+ let p = embassy_stm32::init(Default::default());
let irq = interrupt::take!(I2C2_EV);
let mut i2c = I2c::new(
p.I2C2,
diff --git a/examples/stm32l4/src/bin/rng.rs b/examples/stm32l4/src/bin/rng.rs
index ed47fc6c..d0e1306a 100644
--- a/examples/stm32l4/src/bin/rng.rs
+++ b/examples/stm32l4/src/bin/rng.rs
@@ -6,7 +6,7 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::rcc::{ClockSrc, PLLClkDiv, PLLMul, PLLSource, PLLSrcDiv};
use embassy_stm32::rng::Rng;
-use embassy_stm32::{Config, Peripherals};
+use embassy_stm32::Config;
use {defmt_rtt as _, panic_probe as _};
fn config() -> Config {
@@ -22,8 +22,9 @@ fn config() -> Config {
config
}
-#[embassy_executor::main(config = "config()")]
-async fn main(_spawner: Spawner, p: Peripherals) {
+#[embassy_executor::main]
+async fn main(_spawner: Spawner) {
+ let p = embassy_stm32::init(config());
info!("Hello World!");
let mut rng = Rng::new(p.RNG);
diff --git a/examples/stm32l4/src/bin/spi_blocking_async.rs b/examples/stm32l4/src/bin/spi_blocking_async.rs
index e06b29b8..a893cef6 100644
--- a/examples/stm32l4/src/bin/spi_blocking_async.rs
+++ b/examples/stm32l4/src/bin/spi_blocking_async.rs
@@ -9,12 +9,12 @@ use embassy_stm32::dma::NoDma;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::spi::{Config, Spi};
use embassy_stm32::time::Hertz;
-use embassy_stm32::Peripherals;
use embedded_hal_async::spi::SpiBus;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) {
+async fn main(_spawner: Spawner) {
+ let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let spi = Spi::new(
diff --git a/examples/stm32l4/src/bin/spi_dma.rs b/examples/stm32l4/src/bin/spi_dma.rs
index e44754be..5b19433c 100644
--- a/examples/stm32l4/src/bin/spi_dma.rs
+++ b/examples/stm32l4/src/bin/spi_dma.rs
@@ -7,11 +7,11 @@ use embassy_executor::executor::Spawner;
use embassy_stm32::gpio::{Input, Level, Output, Pull, Speed};
use embassy_stm32::spi::{Config, Spi};
use embassy_stm32::time::Hertz;
-use embassy_stm32::Peripherals;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) {
+async fn main(_spawner: Spawner) {
+ let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let mut spi = Spi::new(
diff --git a/examples/stm32l4/src/bin/usart_dma.rs b/examples/stm32l4/src/bin/usart_dma.rs
index fdd5a85e..4b3a9b23 100644
--- a/examples/stm32l4/src/bin/usart_dma.rs
+++ b/examples/stm32l4/src/bin/usart_dma.rs
@@ -8,12 +8,12 @@ use defmt::*;
use embassy_executor::executor::Spawner;
use embassy_stm32::dma::NoDma;
use embassy_stm32::usart::{Config, Uart};
-use embassy_stm32::Peripherals;
use heapless::String;
use {defmt_rtt as _, panic_probe as _};
#[embassy_executor::main]
-async fn main(_spawner: Spawner, p: Peripherals) {
+async fn main(_spawner: Spawner) {
+ let p = embassy_stm32::init(Default::default());
info!("Hello World!");
let config = Config::default();