summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Rajewski <victor@allumeenergy.com.au>2023-07-04 15:11:06 +1000
committerDamien George <damien@micropython.org>2023-07-13 12:49:51 +1000
commit730525cec965a912354454ec015a3d043d5579d3 (patch)
treecf8395c31dcf7b84df2b8733a4f1f65766046725
parent409978a1fb85968ac3a5eb0bc33788eb507dee14 (diff)
stm32/qspi: 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 commit allows sending a command with a single data byte. Signed-off-by: Victor Rajewski <victor@allumeenergy.com.au>
-rw-r--r--ports/stm32/qspi.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/ports/stm32/qspi.c b/ports/stm32/qspi.c
index a79e692e0..c10bec236 100644
--- a/ports/stm32/qspi.c
+++ b/ports/stm32/qspi.c
@@ -232,8 +232,12 @@ STATIC int qspi_write_cmd_data(void *self_in, uint8_t cmd, size_t len, uint32_t
while (!(QUADSPI->SR & QUADSPI_SR_FTF)) {
}
- // This assumes len==2
- *(uint16_t *)&QUADSPI->DR = data;
+ if (len == 1) {
+ *(uint8_t *)&QUADSPI->DR = data;
+ } else {
+ // This assumes len==2
+ *(uint16_t *)&QUADSPI->DR = data;
+ }
}
// Wait for write to finish