From f3676e1eabc4f3079003d8a006d45db7d3afc742 Mon Sep 17 00:00:00 2001 From: xoviat Date: Mon, 4 Jan 2021 12:52:00 -0600 Subject: rename examples --- embassy-stm32f4-examples/Cargo.toml | 39 +++++++++++++++++++++ embassy-stm32f4-examples/src/serial.rs | 64 ++++++++++++++++++++++++++++++++++ examples-stm32f4/Cargo.toml | 39 --------------------- examples-stm32f4/src/serial.rs | 64 ---------------------------------- 4 files changed, 103 insertions(+), 103 deletions(-) create mode 100644 embassy-stm32f4-examples/Cargo.toml create mode 100644 embassy-stm32f4-examples/src/serial.rs delete mode 100644 examples-stm32f4/Cargo.toml delete mode 100644 examples-stm32f4/src/serial.rs diff --git a/embassy-stm32f4-examples/Cargo.toml b/embassy-stm32f4-examples/Cargo.toml new file mode 100644 index 000000000..6502a77a5 --- /dev/null +++ b/embassy-stm32f4-examples/Cargo.toml @@ -0,0 +1,39 @@ +[package] +authors = ["Dario Nieuwenhuis "] +edition = "2018" +name = "embassy-stm32f4-examples" +version = "0.1.0" + +[features] +default = [ + "defmt-default", +] +defmt-default = [] +defmt-trace = [] +defmt-debug = [] +defmt-info = [] +defmt-warn = [] +defmt-error = [] + + +[dependencies] +embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] } +embassy-stm32f4 = { version = "*", path = "../embassy-stm32f4", features = ["stm32f405"] } + +defmt = "0.1.3" +defmt-rtt = "0.1.0" + +cortex-m = { version = "0.6.3" } +cortex-m-rt = "0.6.13" +embedded-hal = { version = "0.2.4" } +panic-probe = "0.1.0" +stm32f4xx-hal = { version = "0.8.3", features = ["rt", "stm32f405"], git = "https://github.com/stm32-rs/stm32f4xx-hal.git"} +futures = { version = "0.3.8", default-features = false, features = ["async-await"] } +cortex-m-rtic = "0.5" +rtt-target = { version = "0.3", features = ["cortex-m"] } + + + +[[bin]] +name = "serial" +path = "src/serial.rs" \ No newline at end of file diff --git a/embassy-stm32f4-examples/src/serial.rs b/embassy-stm32f4-examples/src/serial.rs new file mode 100644 index 000000000..6c757dd2f --- /dev/null +++ b/embassy-stm32f4-examples/src/serial.rs @@ -0,0 +1,64 @@ +#![no_std] +#![no_main] +#![feature(trait_alias)] +#![feature(type_alias_impl_trait)] + +// extern crate panic_halt; + +use cortex_m::singleton; +use cortex_m_rt::entry; +use embassy::executor::{task, Executor}; +use embassy::util::Forever; +use embassy_stm32f4::interrupt; +use embassy_stm32f4::serial; +use stm32f4xx_hal::stm32; +use stm32f4xx_hal::{prelude::*, serial::config}; + +#[task] +async fn run(dp: stm32::Peripherals, cp: cortex_m::Peripherals) { + // https://gist.github.com/thalesfragoso/a07340c5df6eee3b04c42fdc69ecdcb1 + let gpioa = dp.GPIOA.split(); + let rcc = dp.RCC.constrain(); + + let clocks = rcc + .cfgr + .use_hse(16.mhz()) + .sysclk(48.mhz()) + .pclk1(24.mhz()) + .freeze(); + + let mut serial = serial::Serial::new( + gpioa.pa9.into_alternate_af7(), + gpioa.pa10.into_alternate_af7(), + interrupt::take!(DMA2_STREAM2), + interrupt::take!(DMA2_STREAM7), + interrupt::take!(USART1), + dp.DMA2, + dp.USART1, + config::Parity::ParityNone, + 9600.bps(), + clocks, + ); + + let buf = singleton!(: [u8; 30] = [0; 30]).unwrap(); + + buf[5] = 0x01; + + serial.send(buf).await; +} + +static EXECUTOR: Forever = Forever::new(); + +#[entry] +fn main() -> ! { + let dp = stm32::Peripherals::take().unwrap(); + let cp = cortex_m::peripheral::Peripherals::take().unwrap(); + + let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev)); + executor.spawn(run(dp, cp)); + + loop { + executor.run(); + cortex_m::asm::wfe(); + } +} diff --git a/examples-stm32f4/Cargo.toml b/examples-stm32f4/Cargo.toml deleted file mode 100644 index 5964cd7a5..000000000 --- a/examples-stm32f4/Cargo.toml +++ /dev/null @@ -1,39 +0,0 @@ -[package] -authors = ["Dario Nieuwenhuis "] -edition = "2018" -name = "embassy-examples-stm32f4" -version = "0.1.0" - -[features] -default = [ - "defmt-default", -] -defmt-default = [] -defmt-trace = [] -defmt-debug = [] -defmt-info = [] -defmt-warn = [] -defmt-error = [] - - -[dependencies] -embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] } -embassy-stm32f4 = { version = "*", path = "../embassy-stm32f4", features = ["stm32f405"] } - -defmt = "0.1.3" -defmt-rtt = "0.1.0" - -cortex-m = { version = "0.6.3" } -cortex-m-rt = "0.6.13" -embedded-hal = { version = "0.2.4" } -panic-probe = "0.1.0" -stm32f4xx-hal = { version = "0.8.3", features = ["rt", "stm32f405"], git = "https://github.com/stm32-rs/stm32f4xx-hal.git"} -futures = { version = "0.3.8", default-features = false, features = ["async-await"] } -cortex-m-rtic = "0.5" -rtt-target = { version = "0.3", features = ["cortex-m"] } - - - -[[bin]] -name = "serial" -path = "src/serial.rs" \ No newline at end of file diff --git a/examples-stm32f4/src/serial.rs b/examples-stm32f4/src/serial.rs deleted file mode 100644 index 6c757dd2f..000000000 --- a/examples-stm32f4/src/serial.rs +++ /dev/null @@ -1,64 +0,0 @@ -#![no_std] -#![no_main] -#![feature(trait_alias)] -#![feature(type_alias_impl_trait)] - -// extern crate panic_halt; - -use cortex_m::singleton; -use cortex_m_rt::entry; -use embassy::executor::{task, Executor}; -use embassy::util::Forever; -use embassy_stm32f4::interrupt; -use embassy_stm32f4::serial; -use stm32f4xx_hal::stm32; -use stm32f4xx_hal::{prelude::*, serial::config}; - -#[task] -async fn run(dp: stm32::Peripherals, cp: cortex_m::Peripherals) { - // https://gist.github.com/thalesfragoso/a07340c5df6eee3b04c42fdc69ecdcb1 - let gpioa = dp.GPIOA.split(); - let rcc = dp.RCC.constrain(); - - let clocks = rcc - .cfgr - .use_hse(16.mhz()) - .sysclk(48.mhz()) - .pclk1(24.mhz()) - .freeze(); - - let mut serial = serial::Serial::new( - gpioa.pa9.into_alternate_af7(), - gpioa.pa10.into_alternate_af7(), - interrupt::take!(DMA2_STREAM2), - interrupt::take!(DMA2_STREAM7), - interrupt::take!(USART1), - dp.DMA2, - dp.USART1, - config::Parity::ParityNone, - 9600.bps(), - clocks, - ); - - let buf = singleton!(: [u8; 30] = [0; 30]).unwrap(); - - buf[5] = 0x01; - - serial.send(buf).await; -} - -static EXECUTOR: Forever = Forever::new(); - -#[entry] -fn main() -> ! { - let dp = stm32::Peripherals::take().unwrap(); - let cp = cortex_m::peripheral::Peripherals::take().unwrap(); - - let executor = EXECUTOR.put(Executor::new(cortex_m::asm::sev)); - executor.spawn(run(dp, cp)); - - loop { - executor.run(); - cortex_m::asm::wfe(); - } -} -- cgit