Skip to content

Commit

Permalink
Merge pull request tock#4156 from alistair23/alistair/spi
Browse files Browse the repository at this point in the history
chips: apollo3: iom: Support non 4-byte alligned SPI writes
  • Loading branch information
alevy authored Aug 29, 2024
2 parents 64c6f11 + 363881b commit f2f7d87
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions chips/apollo3/src/iom.rs
Original file line number Diff line number Diff line change
Expand Up @@ -677,9 +677,15 @@ impl<'a> Iom<'_> {
&& transfered_bytes < 24
{
let idx = self.write_index.get();
let data = u32::from_le_bytes(
write_buffer[idx..(idx + 4)].try_into().unwrap_or([0; 4]),
);

let chunk = write_buffer[idx..].chunks(4).next().unwrap_or(&[]);

let data = u32::from_le_bytes([
chunk.get(0).copied().unwrap_or(0),
chunk.get(1).copied().unwrap_or(0),
chunk.get(2).copied().unwrap_or(0),
chunk.get(3).copied().unwrap_or(0),
]);

self.registers.fifopush.set(data);
self.write_index.set(idx + 4);
Expand Down

0 comments on commit f2f7d87

Please sign in to comment.