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>
This commit is contained in:
Victor Rajewski 2023-07-04 15:11:06 +10:00 committed by Damien George
parent 409978a1fb
commit 730525cec9

View File

@ -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