Skip to content

Commit 62760e0

Browse files
committed
stm32/qspi.c: Allow qspi_write_cmd_data to write cmd with 1 data byte.
The existing qspi for stm32 implementation can only send a spi command with exactly 0 or 2 data bytes. Certain spiflash chips (e.g. AT25SF321B) have commands that only take a single data byte, and will ignore the command if more than that is sent. This allows sending a command with a single data byte. Would be nicer to have a general function to send `n` bytes, but there probably aren't many commands that require this. Signed-off-by: Victor Rajewski <victor@allumeenergy.com.au>
1 parent 813d559 commit 62760e0

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

ports/stm32/qspi.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -232,8 +232,12 @@ STATIC int qspi_write_cmd_data(void *self_in, uint8_t cmd, size_t len, uint32_t
232232
while (!(QUADSPI->SR & QUADSPI_SR_FTF)) {
233233
}
234234

235-
// This assumes len==2
236-
*(uint16_t *)&QUADSPI->DR = data;
235+
if (len == 1) {
236+
*(uint8_t *)&QUADSPI->DR = data;
237+
} else {
238+
// This assumes len==2
239+
*(uint16_t *)&QUADSPI->DR = data;
240+
}
237241
}
238242

239243
// Wait for write to finish

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy