Introduce "peripheral" abstraction to share state between main and interrupt.
This commit is contained in:
@ -20,8 +20,4 @@ rustflags = [
|
||||
]
|
||||
|
||||
[build]
|
||||
# Pick ONE of these compilation targets
|
||||
# target = "thumbv6m-none-eabi" # Cortex-M0 and Cortex-M0+
|
||||
# target = "thumbv7m-none-eabi" # Cortex-M3
|
||||
# target = "thumbv7em-none-eabi" # Cortex-M4 and Cortex-M7 (no FPU)
|
||||
target = "thumbv7em-none-eabihf" # Cortex-M4F and Cortex-M7F (with FPU)
|
||||
target = "thumbv7em-none-eabi"
|
||||
|
@ -8,15 +8,17 @@ use example_common::*;
|
||||
|
||||
use cortex_m_rt::entry;
|
||||
use defmt::panic;
|
||||
use futures::pin_mut;
|
||||
use nrf52840_hal::gpio;
|
||||
|
||||
use embassy::executor::{task, Executor};
|
||||
use embassy::io::{AsyncBufRead, AsyncBufReadExt, AsyncWrite, AsyncWriteExt};
|
||||
use embassy::io::{AsyncBufReadExt, AsyncWriteExt};
|
||||
use embassy::util::Forever;
|
||||
use embassy_nrf::buffered_uarte;
|
||||
use embassy_nrf::interrupt;
|
||||
|
||||
static mut TX_BUFFER: [u8; 4096] = [0; 4096];
|
||||
static mut RX_BUFFER: [u8; 4096] = [0; 4096];
|
||||
|
||||
#[task]
|
||||
async fn run() {
|
||||
let p = unwrap!(embassy_nrf::pac::Peripherals::take());
|
||||
@ -34,14 +36,15 @@ async fn run() {
|
||||
};
|
||||
|
||||
let irq = interrupt::take!(UARTE0_UART0);
|
||||
let u = buffered_uarte::BufferedUarte::new(
|
||||
let mut u = buffered_uarte::BufferedUarte::new(
|
||||
p.UARTE0,
|
||||
irq,
|
||||
unsafe { &mut RX_BUFFER },
|
||||
unsafe { &mut TX_BUFFER },
|
||||
pins,
|
||||
buffered_uarte::Parity::EXCLUDED,
|
||||
buffered_uarte::Baudrate::BAUD115200,
|
||||
);
|
||||
pin_mut!(u);
|
||||
|
||||
info!("uarte initialized!");
|
||||
|
||||
|
Reference in New Issue
Block a user