Skip to content

Commit

Permalink
Implemented SPI transfer function from here: atsamd-rs#657
Browse files Browse the repository at this point in the history
  • Loading branch information
sakian committed Apr 11, 2024
1 parent a917571 commit 63ec6f8
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions hal/src/sercom/spi/impl_ehal_thumbv7em.rs
Original file line number Diff line number Diff line change
Expand Up @@ -291,15 +291,16 @@ macro_rules! impl_blocking_spi_transfer {
let mut to_send = cells.iter();
let mut to_recv = cells.iter();
while to_recv.len() > 0 {
let flags = self.read_flags_errors()?;
if to_send.len() > 0 && flags.contains(Flags::DRE) {
if to_send.len() > 0 {
while !self.read_flags_errors()?.contains(Flags::DRE) {}
let word = match to_send.next() {
Some(cell) => cell.get(),
None => unreachable!(),
};
self.config.as_mut().regs.write_data(word as u32);
}
if to_recv.len() > to_send.len() && flags.contains(Flags::RXC) {
if to_recv.len() > to_send.len() {
while !self.read_flags_errors()?.contains(Flags::RXC) {}
let word = self.config.as_mut().regs.read_data() as Word<$Length>;
match to_recv.next() {
Some(cell) => cell.set(word),
Expand Down

0 comments on commit 63ec6f8

Please sign in to comment.