Skip to content

Commit

Permalink
Rename QUADSPI change_bank and check for business
Browse files Browse the repository at this point in the history
  • Loading branch information
ElouanPetereau committed Oct 5, 2023
1 parent 2be75bf commit 460d213
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/xspi/qspi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use crate::{
stm32,
};

use super::{common::BankSelect, Bank, Config, Qspi, SamplingEdge};
use super::{common::BankSelect, Bank, Config, Qspi, QspiError, SamplingEdge};

/// Used to indicate that an IO pin is not used by the QSPI interface.
pub struct NoIo {}
Expand Down Expand Up @@ -229,12 +229,21 @@ pub trait QspiExt {
}

impl Qspi<stm32::QUADSPI> {
pub fn change_bank(&mut self, bank: BankSelect) {
pub fn change_bank_unchecked(
&mut self,
bank: BankSelect,
) -> Result<(), QspiError> {
// Ensure that the peripheral is no longer busy before changing FSEL and DFM bits
if self.is_busy().is_err() {
return Err(QspiError::Busy);
};

self.rb.cr.modify(|_, w| w.dfm().clear_bit());
match bank {
BankSelect::One => self.rb.cr.modify(|_, w| w.fsel().clear_bit()),
BankSelect::Two => self.rb.cr.modify(|_, w| w.fsel().set_bit()),
}
Ok(())
}

pub fn qspi_unchecked<CONFIG>(
Expand Down

0 comments on commit 460d213

Please sign in to comment.