mark new unsafe

This commit is contained in:
xoviat 2021-01-06 14:31:43 -06:00
parent 1c3b7541cb
commit 31ba052f14
2 changed files with 20 additions and 18 deletions

View File

@ -8,6 +8,7 @@
use cortex_m::singleton;
use cortex_m_rt::entry;
use embassy::executor::{task, Executor};
use embassy::uart::Uart;
use embassy::util::Forever;
use embassy_stm32f4::interrupt;
use embassy_stm32f4::serial;
@ -27,6 +28,7 @@ async fn run(dp: stm32::Peripherals, cp: cortex_m::Peripherals) {
.pclk1(24.mhz())
.freeze();
unsafe {
let mut serial = serial::Serial::new(
gpioa.pa9.into_alternate_af7(),
gpioa.pa10.into_alternate_af7(),
@ -39,13 +41,12 @@ async fn run(dp: stm32::Peripherals, cp: cortex_m::Peripherals) {
9600.bps(),
clocks,
);
let buf = singleton!(: [u8; 30] = [0; 30]).unwrap();
buf[5] = 0x01;
serial.send(buf).await;
}
}
static EXECUTOR: Forever<Executor> = Forever::new();

View File

@ -57,7 +57,8 @@ static STATE: State = State {
static mut INSTANCE: *const Serial<USART1, Stream7<DMA2>, Stream2<DMA2>> = ptr::null_mut();
impl Serial<USART1, Stream7<DMA2>, Stream2<DMA2>> {
pub fn new(
// Leaking futures is forbidden!
pub unsafe fn new(
txd: PA9<Alternate<AF7>>,
rxd: PA10<Alternate<AF7>>,
tx_int: interrupt::DMA2_STREAM7Interrupt,