Compare commits

..

No commits in common. "d7c906684cf7711a46ff8ed5205dd616d185fdd7" and "decf910b55fffca83c251504b16dc88d8b2088b3" have entirely different histories.

2 changed files with 8 additions and 32 deletions

View file

@ -6,7 +6,7 @@ type TxDma = dma::TxDma<serial::Tx<pac::USART1>, dma::dma1::C4>;
type DMXUniverse<const DMX_LEN: usize> = &'static mut [u8; DMX_LEN];
type DMXTransfer<const DMX_LEN: usize> = dma::Transfer<dma::R, DMXUniverse<DMX_LEN>, TxDma>;
pub enum DMX<const DMX_LEN: usize = DMX_LEN_MAX> {
pub enum DMX<const DMX_LEN: usize = 512> {
Idle(Option<TxDma>, Option<DMXUniverse<DMX_LEN>>),
Busy(Option<DMXTransfer<DMX_LEN>>),
}
@ -20,8 +20,6 @@ impl<const DMX_LEN: usize> DMX<DMX_LEN> {
where
PINS: serial::Pins<pac::USART1>,
{
assert!(DMX_LEN <= DMX_LEN_MAX);
serial.reconfigure(250_000.bps(), &clocks).unwrap();
Self::Idle(Some(serial.tx.with_dma(channel)), None)

View file

@ -1,4 +1,4 @@
// #![deny(unsafe_code)]
#![deny(unsafe_code)]
#![no_std]
#![no_main]
@ -36,7 +36,7 @@ mod app {
}
#[init]
fn init(mut cx: init::Context) -> (Shared, Local, init::Monotonics) {
fn init(cx: init::Context) -> (Shared, Local, init::Monotonics) {
// Take ownership over the raw flash and rcc devices and convert them into the corresponding
// HAL structs
let mut flash = cx.device.FLASH.constrain();
@ -63,23 +63,10 @@ mod app {
let mut afio = cx.device.AFIO.constrain();
let dma1 = cx.device.DMA1.split();
cx.device.EXTI.imr.write(|w| w.mr1().set_bit());
let _ = gpiob.pb10.into_pull_up_input(&mut gpiob.crh);
// enable EXTI10 for port B
afio.exticr3
.exticr3()
.write(|w| unsafe { w.exti10().bits(0b0001) });
// mask EXTI10
cx.device.EXTI.imr.write(|w| w.mr10().set_bit());
// EXTI10 on falling edge
cx.device.EXTI.ftsr.write(|w| w.tr10().set_bit());
// set EXTI10 priority
unsafe {
// pac::NVIC::unmask(pac::Interrupt::EXTI15_10);
cx.core.NVIC.set_priority(pac::Interrupt::EXTI15_10, 1);
}
// Serial config
let serial = serial::Serial::new(
cx.device.USART1,
@ -93,7 +80,6 @@ mod app {
);
// rtic::pend(pac::Interrupt::DMA1_CHANNEL4); // ???
// let nvic = cx.device.NVIC_STIR;
foo::spawn().unwrap();
(
@ -138,17 +124,9 @@ mod app {
foo::spawn().unwrap();
}
#[task(binds=EXTI15_10, local = [int_led], shared = [delay_us])]
#[task(binds=EXTI0, local = [int_led], shared = [delay_us])]
fn bar(mut cx: bar::Context) {
let dp = unsafe { pac::Peripherals::steal() };
// EXTI10 must be pending
if dp.EXTI.pr.read().pr10().bit() {
cx.local.int_led.toggle();
cx.shared.delay_us.lock(|d| d.delay(100.millis()));
// clear EXTI10 pending status
dp.EXTI.pr.write(|w| w.pr10().set_bit());
}
cx.local.int_led.toggle();
cx.shared.delay_us.lock(|d| d.delay(1.secs()));
}
}