From 2553740729f1b9b52130ad7269a12260277747cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn-Michael?= <40151420+ldericher@users.noreply.github.com> Date: Sat, 23 Mar 2024 14:54:36 +0000 Subject: [PATCH] safety --- bluepill-rs/src/dmx.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bluepill-rs/src/dmx.rs b/bluepill-rs/src/dmx.rs index 01d8400..d5cbba8 100644 --- a/bluepill-rs/src/dmx.rs +++ b/bluepill-rs/src/dmx.rs @@ -6,7 +6,7 @@ type TxDma = dma::TxDma, dma::dma1::C4>; type DMXUniverse = &'static mut [u8; DMX_LEN]; type DMXTransfer = dma::Transfer, TxDma>; -pub enum DMX { +pub enum DMX { Idle(Option, Option>), Busy(Option>), } @@ -20,6 +20,8 @@ impl DMX { where PINS: serial::Pins, { + assert!(DMX_LEN <= DMX_LEN_MAX); + serial.reconfigure(250_000.bps(), &clocks).unwrap(); Self::Idle(Some(serial.tx.with_dma(channel)), None)