Merge branch 'embassy-rs:master' into master

This commit is contained in:
Chuck Davis
2022-10-08 14:38:41 -05:00
committed by GitHub
102 changed files with 559 additions and 161 deletions

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-nrf-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-stm32f3-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }

View File

@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let flash = Flash::new(p.FLASH);
let mut flash = BlockingAsync::new(flash);
let button = Input::new(p.PC13, Pull::Up);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-stm32f7-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }

View File

@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut flash = Flash::unlock(p.FLASH);
let mut flash = Flash::new(p.FLASH);
let button = Input::new(p.PC13, Pull::Down);
let mut button = ExtiInput::new(button, p.EXTI13);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-stm32h7-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync" }

View File

@ -16,7 +16,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let mut flash = Flash::unlock(p.FLASH);
let mut flash = Flash::new(p.FLASH);
let button = Input::new(p.PC13, Pull::Down);
let mut button = ExtiInput::new(button, p.EXTI13);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-stm32l0-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }

View File

@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let flash = Flash::new(p.FLASH);
let mut flash = BlockingAsync::new(flash);
let button = Input::new(p.PB2, Pull::Up);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-stm32l1-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }

View File

@ -18,7 +18,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let flash = Flash::new(p.FLASH);
let mut flash = BlockingAsync::new(flash);
let button = Input::new(p.PB2, Pull::Up);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-stm32l4-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }

View File

@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let flash = Flash::new(p.FLASH);
let mut flash = BlockingAsync::new(flash);
let button = Input::new(p.PC13, Pull::Up);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-boot-stm32wl-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../../../embassy-sync", features = ["defmt"] }

View File

@ -17,7 +17,7 @@ static APP_B: &[u8] = include_bytes!("../../b.bin");
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
let flash = Flash::unlock(p.FLASH);
let flash = Flash::new(p.FLASH);
let mut flash = BlockingAsync::new(flash);
let button = Input::new(p.PA0, Pull::Up);

View File

@ -3,6 +3,7 @@ edition = "2021"
name = "nrf-bootloader-example"
version = "0.1.0"
description = "Bootloader for nRF chips"
license = "MIT OR Apache-2.0"
[dependencies]
defmt = { version = "0.3", optional = true }

View File

@ -3,6 +3,7 @@ edition = "2021"
name = "stm32-bootloader-example"
version = "0.1.0"
description = "Example bootloader for STM32 chips"
license = "MIT OR Apache-2.0"
[dependencies]
defmt = { version = "0.3", optional = true }

View File

@ -20,7 +20,7 @@ fn main() -> ! {
*/
let mut bl: BootLoader<ERASE_SIZE, WRITE_SIZE> = BootLoader::default();
let flash = Flash::unlock(p.FLASH);
let flash = Flash::new(p.FLASH);
let mut flash = BootFlash::<_, ERASE_SIZE, ERASE_VALUE>::new(flash);
let start = bl.prepare(&mut SingleFlashConfig::new(&mut flash));
core::mem::drop(flash);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-nrf-rtos-trace-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[features]
default = ["log", "nightly"]

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-nrf-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[features]
default = ["nightly"]

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-rp-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
@ -26,7 +27,7 @@ st7789 = "0.6.1"
display-interface = "0.4.1"
byte-slice-cast = { version = "1.2.0", default-features = false }
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" }
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "0.1.0-alpha.1" }
embedded-io = { version = "0.3.0", features = ["async", "defmt"] }
static_cell = "1.0.0"

View File

@ -0,0 +1,70 @@
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use defmt::*;
use embassy_executor::Spawner;
use embassy_rp::i2c::{self, Config};
use embassy_time::{Duration, Timer};
use embedded_hal_1::i2c::I2c;
use {defmt_rtt as _, panic_probe as _};
#[allow(dead_code)]
mod mcp23017 {
pub const ADDR: u8 = 0x20; // default addr
pub const IODIRA: u8 = 0x00;
pub const IPOLA: u8 = 0x02;
pub const GPINTENA: u8 = 0x04;
pub const DEFVALA: u8 = 0x06;
pub const INTCONA: u8 = 0x08;
pub const IOCONA: u8 = 0x0A;
pub const GPPUA: u8 = 0x0C;
pub const INTFA: u8 = 0x0E;
pub const INTCAPA: u8 = 0x10;
pub const GPIOA: u8 = 0x12;
pub const OLATA: u8 = 0x14;
pub const IODIRB: u8 = 0x01;
pub const IPOLB: u8 = 0x03;
pub const GPINTENB: u8 = 0x05;
pub const DEFVALB: u8 = 0x07;
pub const INTCONB: u8 = 0x09;
pub const IOCONB: u8 = 0x0B;
pub const GPPUB: u8 = 0x0D;
pub const INTFB: u8 = 0x0F;
pub const INTCAPB: u8 = 0x11;
pub const GPIOB: u8 = 0x13;
pub const OLATB: u8 = 0x15;
}
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());
let sda = p.PIN_14;
let scl = p.PIN_15;
info!("set up i2c ");
let mut i2c = i2c::I2c::new_blocking(p.I2C1, scl, sda, Config::default());
use mcp23017::*;
info!("init mcp23017 config for IxpandO");
// init - a outputs, b inputs
i2c.write(ADDR, &[IODIRA, 0x00]).unwrap();
i2c.write(ADDR, &[IODIRB, 0xff]).unwrap();
i2c.write(ADDR, &[GPPUB, 0xff]).unwrap(); // pullups
let mut val = 0xaa;
loop {
let mut portb = [0];
i2c.write(mcp23017::ADDR, &[GPIOA, val]).unwrap();
i2c.write_read(mcp23017::ADDR, &[GPIOB], &mut portb).unwrap();
info!("portb = {:02x}", portb[0]);
val = !val;
Timer::after(Duration::from_secs(1)).await;
}
}

View File

@ -108,9 +108,9 @@ mod shared_spi {
use core::cell::RefCell;
use core::fmt::Debug;
use embedded_hal_1::digital::blocking::OutputPin;
use embedded_hal_1::digital::OutputPin;
use embedded_hal_1::spi;
use embedded_hal_1::spi::blocking::SpiDevice;
use embedded_hal_1::spi::SpiDevice;
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
pub enum SpiDeviceWithCsError<BUS, CS> {
@ -153,7 +153,7 @@ mod shared_spi {
impl<'a, BUS, CS> SpiDevice for SpiDeviceWithCs<'a, BUS, CS>
where
BUS: spi::blocking::SpiBusFlush,
BUS: spi::SpiBusFlush,
CS: OutputPin,
{
type Bus = BUS;
@ -182,7 +182,7 @@ mod shared_spi {
/// Driver for the XPT2046 resistive touchscreen sensor
mod touch {
use embedded_hal_1::spi::blocking::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice};
use embedded_hal_1::spi::{SpiBus, SpiBusRead, SpiBusWrite, SpiDevice};
struct Calibration {
x1: i32,
@ -246,8 +246,8 @@ mod touch {
mod my_display_interface {
use display_interface::{DataFormat, DisplayError, WriteOnlyDataCommand};
use embedded_hal_1::digital::blocking::OutputPin;
use embedded_hal_1::spi::blocking::{SpiBusWrite, SpiDevice};
use embedded_hal_1::digital::OutputPin;
use embedded_hal_1::spi::{SpiBusWrite, SpiDevice};
/// SPI display interface.
///

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-std-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["log"] }

View File

@ -2,6 +2,7 @@
name = "embassy-stm32f0-examples"
version = "0.1.0"
edition = "2021"
license = "MIT OR Apache-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32f1-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32f2-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32f3-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
const ADDR: u32 = 0x26000;
let mut f = Flash::unlock(p.FLASH);
let mut f = Flash::new(p.FLASH);
info!("Reading...");
let mut buf = [0u8; 8];

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32f4-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]

View File

@ -13,7 +13,7 @@ async fn main(_spawner: Spawner) {
let p = embassy_stm32::init(Default::default());
info!("Hello Flash!");
let mut f = Flash::unlock(p.FLASH);
let mut f = Flash::new(p.FLASH);
// Sector 5
test_flash(&mut f, 128 * 1024, 128 * 1024);

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32f7-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) {
// wait a bit before accessing the flash
Timer::after(Duration::from_millis(300)).await;
let mut f = Flash::unlock(p.FLASH);
let mut f = Flash::new(p.FLASH);
info!("Reading...");
let mut buf = [0u8; 32];

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32g0-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32g4-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32h7-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }
@ -17,8 +18,8 @@ defmt-rtt = "0.3"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
embedded-hal = "0.2.6"
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" }
embedded-hal-async = { version = "0.1.0-alpha.1" }
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "=0.1.0-alpha.2" }
embedded-nal-async = "0.2.0"
panic-probe = { version = "0.3", features = ["print-defmt"] }
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }

View File

@ -19,7 +19,7 @@ async fn main(_spawner: Spawner) {
// wait a bit before accessing the flash
Timer::after(Duration::from_millis(300)).await;
let mut f = Flash::unlock(p.FLASH);
let mut f = Flash::new(p.FLASH);
info!("Reading...");
let mut buf = [0u8; 32];

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32l0-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[features]
default = ["nightly"]

View File

@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
const ADDR: u32 = 0x26000;
let mut f = Flash::unlock(p.FLASH);
let mut f = Flash::new(p.FLASH);
info!("Reading...");
let mut buf = [0u8; 8];

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32l1-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
const ADDR: u32 = 0x26000;
let mut f = Flash::unlock(p.FLASH);
let mut f = Flash::new(p.FLASH);
info!("Reading...");
let mut buf = [0u8; 8];

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32l4-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[features]
@ -18,8 +19,8 @@ defmt-rtt = "0.3"
cortex-m = { version = "0.7.6", features = ["critical-section-single-core"] }
cortex-m-rt = "0.7.0"
embedded-hal = "0.2.6"
embedded-hal-1 = { package = "embedded-hal", version = "1.0.0-alpha.8" }
embedded-hal-async = { version = "0.1.0-alpha.1" }
embedded-hal-1 = { package = "embedded-hal", version = "=1.0.0-alpha.9" }
embedded-hal-async = { version = "=0.1.0-alpha.2" }
panic-probe = { version = "0.3", features = ["print-defmt"] }
futures = { version = "0.3.17", default-features = false, features = ["async-await"] }
heapless = { version = "0.7.5", default-features = false }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32l5-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[features]

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32u5-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32wb-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-stm32wl-examples"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-sync = { version = "0.1.0", path = "../../embassy-sync", features = ["defmt"] }

View File

@ -15,7 +15,7 @@ async fn main(_spawner: Spawner) {
const ADDR: u32 = 0x36000;
let mut f = Flash::unlock(p.FLASH);
let mut f = Flash::new(p.FLASH);
info!("Reading...");
let mut buf = [0u8; 8];

View File

@ -2,6 +2,7 @@
edition = "2021"
name = "embassy-wasm-example"
version = "0.1.0"
license = "MIT OR Apache-2.0"
[lib]
crate-type = ["cdylib"]