From 2d899a17e727a9b68ce01090b412c8211f055293 Mon Sep 17 00:00:00 2001 From: Dion Dokter Date: Tue, 29 Oct 2024 17:26:35 +0100 Subject: [PATCH] Add some sanity checks --- embassy-stm32/src/qspi/mod.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/embassy-stm32/src/qspi/mod.rs b/embassy-stm32/src/qspi/mod.rs index 715c260e9..6530b75b1 100644 --- a/embassy-stm32/src/qspi/mod.rs +++ b/embassy-stm32/src/qspi/mod.rs @@ -202,6 +202,18 @@ impl<'d, T: Instance, M: PeriMode> Qspi<'d, T, M> { } fn setup_transaction(&mut self, fmode: QspiMode, transaction: &TransferConfig, data_len: Option) { + if let (Some(_), QspiWidth::NONE) = (transaction.address, transaction.awidth) { + panic!("QSPI address can't be sent with an address width of NONE"); + } + + if let (Some(_), QspiWidth::NONE) = (data_len, transaction.dwidth) { + panic!("QSPI data can't be sent with a data width of NONE"); + } + + if let Some(0) = data_len { + panic!("QSPI data must be at least one byte"); + } + T::REGS.fcr().modify(|v| { v.set_csmf(true); v.set_ctcf(true);