Remove stm32.
stm32 developemnt continues in the `stm32-neo` branch for now.
This commit is contained in:
@ -1,28 +0,0 @@
|
||||
[target.'cfg(all(target_arch = "arm", target_os = "none"))']
|
||||
runner = "probe-run --chip STM32F401CCUx"
|
||||
|
||||
rustflags = [
|
||||
# LLD (shipped with the Rust toolchain) is used as the default linker
|
||||
"-C", "link-arg=--nmagic",
|
||||
"-C", "link-arg=-Tlink.x",
|
||||
"-C", "link-arg=-Tdefmt.x",
|
||||
|
||||
# if you run into problems with LLD switch to the GNU linker by commenting out
|
||||
# this line
|
||||
# "-C", "linker=arm-none-eabi-ld",
|
||||
|
||||
# if you need to link to pre-compiled C libraries provided by a C toolchain
|
||||
# use GCC as the linker by commenting out both lines above and then
|
||||
# uncommenting the three lines below
|
||||
# "-C", "linker=arm-none-eabi-gcc",
|
||||
# "-C", "link-arg=-Wl,-Tlink.x",
|
||||
# "-C", "link-arg=-nostartfiles",
|
||||
|
||||
# Code-size optimizations.
|
||||
"-Z", "trap-unreachable=no",
|
||||
"-C", "inline-threshold=5",
|
||||
"-C", "no-vectorize-loops",
|
||||
]
|
||||
|
||||
[build]
|
||||
target = "thumbv7em-none-eabi"
|
@ -1,53 +0,0 @@
|
||||
[package]
|
||||
authors = ["Dario Nieuwenhuis <dirbaio@dirbaio.net>"]
|
||||
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 = []
|
||||
|
||||
stm32f401 = ["embassy-stm32/stm32f401"]
|
||||
stm32f405 = ["embassy-stm32/stm32f405"]
|
||||
stm32f407 = ["embassy-stm32/stm32f407"]
|
||||
stm32f410 = ["embassy-stm32/stm32f410"]
|
||||
stm32f411 = ["embassy-stm32/stm32f411"]
|
||||
stm32f412 = ["embassy-stm32/stm32f412"]
|
||||
stm32f413 = ["embassy-stm32/stm32f413"]
|
||||
stm32f415 = ["embassy-stm32/stm32f405"]
|
||||
stm32f417 = ["embassy-stm32/stm32f407"]
|
||||
stm32f423 = ["embassy-stm32/stm32f413"]
|
||||
stm32f427 = ["embassy-stm32/stm32f427"]
|
||||
stm32f429 = ["embassy-stm32/stm32f429"]
|
||||
stm32f437 = ["embassy-stm32/stm32f427"]
|
||||
stm32f439 = ["embassy-stm32/stm32f429"]
|
||||
stm32f446 = ["embassy-stm32/stm32f446"]
|
||||
stm32f469 = ["embassy-stm32/stm32f469"]
|
||||
stm32f479 = ["embassy-stm32/stm32f469"]
|
||||
|
||||
|
||||
[dependencies]
|
||||
embassy = { version = "0.1.0", path = "../embassy", features = ["defmt", "defmt-trace"] }
|
||||
embassy-traits = { version = "0.1.0", path = "../embassy-traits", features = ["defmt"] }
|
||||
embassy-stm32 = { version = "0.1.0", path = "../embassy-stm32" }
|
||||
embassy-extras = {version = "0.1.0", path = "../embassy-extras" }
|
||||
|
||||
defmt = "0.2.0"
|
||||
defmt-rtt = "0.2.0"
|
||||
|
||||
cortex-m = "0.7.1"
|
||||
cortex-m-rt = "0.6.13"
|
||||
embedded-hal = { version = "0.2.4" }
|
||||
panic-probe = { version = "0.2.0", features = ["print-defmt"] }
|
||||
futures = { version = "0.3.8", default-features = false, features = ["async-await"] }
|
||||
rtt-target = { version = "0.3", features = ["cortex-m"] }
|
||||
bxcan = "0.5.0"
|
||||
usb-device = "0.2.7"
|
@ -1,31 +0,0 @@
|
||||
//! This build script copies the `memory.x` file from the crate root into
|
||||
//! a directory where the linker can always find it at build time.
|
||||
//! For many projects this is optional, as the linker always searches the
|
||||
//! project root directory -- wherever `Cargo.toml` is. However, if you
|
||||
//! are using a workspace or have a more complicated build setup, this
|
||||
//! build script becomes required. Additionally, by requesting that
|
||||
//! Cargo re-run the build script whenever `memory.x` is changed,
|
||||
//! updating `memory.x` ensures a rebuild of the application with the
|
||||
//! new memory settings.
|
||||
|
||||
use std::env;
|
||||
use std::fs::File;
|
||||
use std::io::Write;
|
||||
use std::path::PathBuf;
|
||||
|
||||
fn main() {
|
||||
// Put `memory.x` in our output directory and ensure it's
|
||||
// on the linker search path.
|
||||
let out = &PathBuf::from(env::var_os("OUT_DIR").unwrap());
|
||||
File::create(out.join("memory.x"))
|
||||
.unwrap()
|
||||
.write_all(include_bytes!("memory.x"))
|
||||
.unwrap();
|
||||
println!("cargo:rustc-link-search={}", out.display());
|
||||
|
||||
// By default, Cargo will re-run a build script whenever
|
||||
// any file in the project changes. By specifying `memory.x`
|
||||
// here, we ensure the build script is only re-run when
|
||||
// `memory.x` is changed.
|
||||
println!("cargo:rerun-if-changed=memory.x");
|
||||
}
|
@ -1,5 +0,0 @@
|
||||
MEMORY
|
||||
{
|
||||
FLASH : ORIGIN = 0x08000000, LENGTH = 64K
|
||||
RAM : ORIGIN = 0x20000000, LENGTH = 32K
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_bindings)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use example_common::{panic, *};
|
||||
|
||||
use bxcan::filter::Mask32;
|
||||
use cortex_m_rt::entry;
|
||||
use embassy::executor::Executor;
|
||||
use embassy::util::Forever;
|
||||
use embassy_stm32::hal::prelude::*;
|
||||
use embassy_stm32::hal::{can::Can, stm32};
|
||||
use embassy_stm32::{can, interrupt};
|
||||
|
||||
#[embassy::task]
|
||||
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
||||
let gpioa = dp.GPIOA.split();
|
||||
|
||||
let rx = gpioa.pa11.into_alternate_af9();
|
||||
let tx = gpioa.pa12.into_alternate_af9();
|
||||
let mut can = bxcan::Can::new(Can::new(dp.CAN1, (tx, rx)));
|
||||
|
||||
// APB1 (PCLK1): 24MHz, Bit rate: 20kBit/s, Sample Point 87.5%
|
||||
// Value was calculated with http://www.bittiming.can-wiki.info/
|
||||
can.modify_config().set_bit_timing(0x001c_004a);
|
||||
// Configure filters so that can frames can be received.
|
||||
can.modify_filters().enable_bank(0, Mask32::accept_all());
|
||||
|
||||
let mut can = can::Can::new(can, interrupt::take!(CAN1_TX), interrupt::take!(CAN1_RX0));
|
||||
|
||||
let _frame = can.receive().await;
|
||||
}
|
||||
|
||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let dp = stm32::Peripherals::take().unwrap();
|
||||
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
|
||||
|
||||
dp.DBGMCU.cr.modify(|_, w| {
|
||||
w.dbg_sleep().set_bit();
|
||||
w.dbg_standby().set_bit();
|
||||
w.dbg_stop().set_bit()
|
||||
});
|
||||
dp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
|
||||
|
||||
let executor = EXECUTOR.put(Executor::new());
|
||||
executor.run(|spawner| {
|
||||
unwrap!(spawner.spawn(run(dp, cp)));
|
||||
});
|
||||
}
|
@ -1,57 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_bindings)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use example_common::{panic, *};
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embassy::executor::Executor;
|
||||
use embassy::traits::gpio::*;
|
||||
use embassy::util::Forever;
|
||||
use embassy_stm32::exti::ExtiPin;
|
||||
use embassy_stm32::hal::prelude::*;
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::pac as stm32;
|
||||
use futures::pin_mut;
|
||||
|
||||
#[embassy::task]
|
||||
async fn run(dp: stm32::Peripherals, _cp: cortex_m::Peripherals) {
|
||||
let gpioa = dp.GPIOA.split();
|
||||
|
||||
let button = gpioa.pa0.into_pull_up_input();
|
||||
let mut syscfg = dp.SYSCFG.constrain();
|
||||
|
||||
let mut pin = ExtiPin::new(button, interrupt::take!(EXTI0), &mut syscfg);
|
||||
|
||||
info!("Starting loop");
|
||||
|
||||
loop {
|
||||
pin.wait_for_rising_edge().await;
|
||||
info!("edge detected!");
|
||||
}
|
||||
}
|
||||
|
||||
static EXECUTOR: Forever<Executor> = Forever::new();
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
let dp = stm32::Peripherals::take().unwrap();
|
||||
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
|
||||
|
||||
dp.DBGMCU.cr.modify(|_, w| {
|
||||
w.dbg_sleep().set_bit();
|
||||
w.dbg_standby().set_bit();
|
||||
w.dbg_stop().set_bit()
|
||||
});
|
||||
dp.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
|
||||
|
||||
let executor = EXECUTOR.put(Executor::new());
|
||||
executor.run(|spawner| {
|
||||
unwrap!(spawner.spawn(run(dp, cp)));
|
||||
});
|
||||
}
|
@ -1,42 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_bindings)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use example_common::*;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use embassy_stm32::hal::prelude::*;
|
||||
|
||||
#[entry]
|
||||
fn main() -> ! {
|
||||
info!("Hello World!");
|
||||
|
||||
let p = embassy_stm32::pac::Peripherals::take().unwrap();
|
||||
|
||||
p.DBGMCU.cr.modify(|_, w| {
|
||||
w.dbg_sleep().set_bit();
|
||||
w.dbg_standby().set_bit();
|
||||
w.dbg_stop().set_bit()
|
||||
});
|
||||
p.RCC.ahb1enr.modify(|_, w| w.dma1en().enabled());
|
||||
|
||||
let gpioa = p.GPIOA.split();
|
||||
let gpioc = p.GPIOC.split();
|
||||
|
||||
let mut led = gpioc.pc13.into_push_pull_output();
|
||||
let button = gpioa.pa0.into_pull_up_input();
|
||||
led.set_low().unwrap();
|
||||
|
||||
loop {
|
||||
if button.is_high().unwrap() {
|
||||
led.set_low().unwrap();
|
||||
} else {
|
||||
led.set_high().unwrap();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_bindings)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use example_common::*;
|
||||
|
||||
use defmt::panic;
|
||||
use embassy;
|
||||
|
||||
use embassy::executor::Spawner;
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy_stm32;
|
||||
use embassy_stm32::hal;
|
||||
|
||||
#[embassy::task]
|
||||
async fn run1() {
|
||||
loop {
|
||||
info!("BIG INFREQUENT TICK");
|
||||
Timer::after(Duration::from_ticks(32768 * 2 as u64)).await;
|
||||
}
|
||||
}
|
||||
|
||||
#[embassy::task]
|
||||
async fn run2() {
|
||||
loop {
|
||||
info!("tick");
|
||||
Timer::after(Duration::from_ticks(13000 as u64)).await;
|
||||
}
|
||||
}
|
||||
|
||||
#[embassy::main(config = "embassy_stm32::system::Config::new().use_hse(16)")]
|
||||
async fn main(spawner: Spawner) {
|
||||
let (dp, clocks) = embassy_stm32::Peripherals::take().unwrap();
|
||||
|
||||
spawner.spawn(run1()).unwrap();
|
||||
}
|
@ -1,80 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(trait_alias)]
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_bindings)]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use example_common::{panic, *};
|
||||
|
||||
use cortex_m::singleton;
|
||||
use cortex_m_rt::entry;
|
||||
use embassy::executor::{Executor, Spawner};
|
||||
use embassy::traits::uart::{Read, ReadUntilIdle, Write};
|
||||
use embassy::util::Forever;
|
||||
use embassy_stm32::hal::dma::StreamsTuple;
|
||||
use embassy_stm32::hal::prelude::*;
|
||||
use embassy_stm32::hal::serial::config::Config;
|
||||
use embassy_stm32::interrupt;
|
||||
use embassy_stm32::pac as stm32;
|
||||
use embassy_stm32::serial;
|
||||
use futures::pin_mut;
|
||||
|
||||
#[embassy::main(config = "embassy_stm32::system::Config::new().use_hse(16).sysclk(48).pclk1(24)")]
|
||||
async fn main(spawner: Spawner) {
|
||||
let (dp, clocks) = embassy_stm32::Peripherals::take().unwrap();
|
||||
let cp = cortex_m::peripheral::Peripherals::take().unwrap();
|
||||
|
||||
dp.DBGMCU.cr.modify(|_, w| {
|
||||
w.dbg_sleep().set_bit();
|
||||
w.dbg_standby().set_bit();
|
||||
w.dbg_stop().set_bit()
|
||||
});
|
||||
|
||||
// https://gist.github.com/thalesfragoso/a07340c5df6eee3b04c42fdc69ecdcb1
|
||||
let gpioa = dp.GPIOA.split();
|
||||
let streams = StreamsTuple::new(dp.DMA2);
|
||||
|
||||
let _serial = unsafe {
|
||||
serial::Serial::new(
|
||||
dp.USART1,
|
||||
(streams.7, streams.2),
|
||||
(
|
||||
gpioa.pa9.into_alternate_af7(),
|
||||
gpioa.pa10.into_alternate_af7(),
|
||||
),
|
||||
interrupt::take!(DMA2_STREAM7),
|
||||
interrupt::take!(DMA2_STREAM2),
|
||||
interrupt::take!(USART1),
|
||||
Config::default().baudrate(9600.bps()),
|
||||
clocks,
|
||||
)
|
||||
};
|
||||
|
||||
let streams = StreamsTuple::new(dp.DMA1);
|
||||
|
||||
let mut serial = unsafe {
|
||||
serial::Serial::new(
|
||||
dp.USART2,
|
||||
(streams.6, streams.5),
|
||||
(
|
||||
gpioa.pa2.into_alternate_af7(),
|
||||
gpioa.pa3.into_alternate_af7(),
|
||||
),
|
||||
interrupt::take!(DMA1_STREAM6),
|
||||
interrupt::take!(DMA1_STREAM5),
|
||||
interrupt::take!(USART2),
|
||||
Config::default().baudrate(9600.bps()),
|
||||
clocks,
|
||||
)
|
||||
};
|
||||
pin_mut!(serial);
|
||||
|
||||
let buf = singleton!(: [u8; 30] = [0; 30]).unwrap();
|
||||
|
||||
buf[5] = 0x01;
|
||||
serial.as_mut().write(buf).await.unwrap();
|
||||
serial.as_mut().read_until_idle(buf).await.unwrap();
|
||||
}
|
@ -1,119 +0,0 @@
|
||||
#![no_std]
|
||||
#![no_main]
|
||||
#![feature(type_alias_impl_trait)]
|
||||
#![feature(min_type_alias_impl_trait)]
|
||||
#![feature(impl_trait_in_bindings)]
|
||||
|
||||
#[path = "../example_common.rs"]
|
||||
mod example_common;
|
||||
use example_common::*;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::panic;
|
||||
use embassy::executor::{Executor, Spawner};
|
||||
use embassy::interrupt::InterruptExt;
|
||||
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
||||
use embassy::time::{Duration, Timer};
|
||||
use embassy::util::Forever;
|
||||
use embassy_extras::usb::usb_serial::UsbSerial;
|
||||
use embassy_extras::usb::Usb;
|
||||
use embassy_stm32::hal::otg_fs::{UsbBus, USB};
|
||||
use embassy_stm32::hal::prelude::*;
|
||||
use embassy_stm32::{interrupt, pac, rtc};
|
||||
use futures::future::{select, Either};
|
||||
use futures::pin_mut;
|
||||
use usb_device::bus::UsbBusAllocator;
|
||||
use usb_device::prelude::*;
|
||||
|
||||
#[embassy::task]
|
||||
async fn run1(bus: &'static mut UsbBusAllocator<UsbBus<USB>>) {
|
||||
info!("Async task");
|
||||
|
||||
let mut read_buf = [0u8; 128];
|
||||
let mut write_buf = [0u8; 128];
|
||||
let serial = UsbSerial::new(bus, &mut read_buf, &mut write_buf);
|
||||
|
||||
let device = UsbDeviceBuilder::new(bus, UsbVidPid(0x16c0, 0x27dd))
|
||||
.manufacturer("Fake company")
|
||||
.product("Serial port")
|
||||
.serial_number("TEST")
|
||||
.device_class(0x02)
|
||||
.build();
|
||||
|
||||
let irq = interrupt::take!(OTG_FS);
|
||||
irq.set_priority(interrupt::Priority::P3);
|
||||
|
||||
let usb = Usb::new(device, serial, irq);
|
||||
pin_mut!(usb);
|
||||
usb.as_mut().start();
|
||||
|
||||
let (mut read_interface, mut write_interface) = usb.as_ref().take_serial_0();
|
||||
|
||||
let mut buf = [0u8; 64];
|
||||
loop {
|
||||
let mut n = 0;
|
||||
let left = {
|
||||
let recv_fut = async {
|
||||
loop {
|
||||
let byte = unwrap!(read_interface.read_byte().await);
|
||||
unwrap!(write_interface.write_byte(byte).await);
|
||||
buf[n] = byte;
|
||||
|
||||
n += 1;
|
||||
if byte == b'\n' || byte == b'\r' || n == buf.len() {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
pin_mut!(recv_fut);
|
||||
|
||||
let timeout = Timer::after(Duration::from_ticks(32768 * 10));
|
||||
|
||||
match select(recv_fut, timeout).await {
|
||||
Either::Left(_) => true,
|
||||
Either::Right(_) => false,
|
||||
}
|
||||
};
|
||||
|
||||
if left {
|
||||
for c in buf[..n].iter_mut() {
|
||||
if 0x61 <= *c && *c <= 0x7a {
|
||||
*c &= !0x20;
|
||||
}
|
||||
}
|
||||
unwrap!(write_interface.write_byte(b'\n').await);
|
||||
unwrap!(write_interface.write_all(&buf[..n]).await);
|
||||
unwrap!(write_interface.write_byte(b'\n').await);
|
||||
} else {
|
||||
unwrap!(write_interface.write_all(b"\r\nSend something\r\n").await);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static USB_BUS: Forever<UsbBusAllocator<UsbBus<USB>>> = Forever::new();
|
||||
|
||||
#[embassy::main(
|
||||
config = "embassy_stm32::system::Config::new().use_hse(25).sysclk(48).require_pll48clk()"
|
||||
)]
|
||||
async fn main(spawner: Spawner) -> ! {
|
||||
static mut EP_MEMORY: [u32; 1024] = [0; 1024];
|
||||
|
||||
info!("Hello World!");
|
||||
|
||||
let (p, clocks) = embassy_stm32::Peripherals::take().unwrap();
|
||||
|
||||
let gpioa = p.GPIOA.split();
|
||||
let usb = USB {
|
||||
usb_global: p.OTG_FS_GLOBAL,
|
||||
usb_device: p.OTG_FS_DEVICE,
|
||||
usb_pwrclk: p.OTG_FS_PWRCLK,
|
||||
pin_dm: gpioa.pa11.into_alternate_af10(),
|
||||
pin_dp: gpioa.pa12.into_alternate_af10(),
|
||||
hclk: clocks.hclk(),
|
||||
};
|
||||
// Rust analyzer isn't recognizing the static ref magic `cortex-m` does
|
||||
#[allow(unused_unsafe)]
|
||||
let usb_bus = USB_BUS.put(UsbBus::new(usb, unsafe { &mut EP_MEMORY }));
|
||||
|
||||
spawner.spawn(run1(usb_bus)).unwrap();
|
||||
}
|
@ -1,17 +0,0 @@
|
||||
#![macro_use]
|
||||
|
||||
use defmt_rtt as _; // global logger
|
||||
use panic_probe as _;
|
||||
|
||||
pub use defmt::*;
|
||||
|
||||
use core::sync::atomic::{AtomicUsize, Ordering};
|
||||
|
||||
defmt::timestamp! {"{=u64}", {
|
||||
static COUNT: AtomicUsize = AtomicUsize::new(0);
|
||||
// NOTE(no-CAS) `timestamps` runs with interrupts disabled
|
||||
let n = COUNT.load(Ordering::Relaxed);
|
||||
COUNT.store(n + 1, Ordering::Relaxed);
|
||||
n as u64
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user