Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Commit a61e4cf

Browse files
robert-hhiwahdan88
authored andcommitted
mods/machspi.c: Fix the bug in spi.read()
Mentioned here: https://forum.pycom.io/topic/1260/spi-bug The parameter write=.. in spi.read() was ignored. Instead always 0x55 was sent. This is a fix of the previous commit, which was wrong
1 parent 5cf02dc commit a61e4cf

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

esp32/mods/machspi.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,14 @@ STATIC void pybspi_transfer (mach_spi_obj_t *self, const char *txdata, char *rxd
195195
for (int i = 0; i < len; i += self->wlen) {
196196
uint32_t _rxdata = 0;
197197
uint32_t _txdata;
198-
if (txchar) {
199-
_txdata = *txchar;
198+
if (txdata) {
199+
memcpy(&_txdata, &txdata[i], self->wlen);
200200
} else {
201-
_txdata = 0x55555555;
201+
if (txchar) {
202+
_txdata = *txchar;
203+
} else {
204+
_txdata = 0x55555555;
205+
}
202206
}
203207
spi_data_t spidata = {.cmd = 0, .cmdLen = 0, .addr = NULL, .addrLen = 0,
204208
.txData = &_txdata, .txDataLen = self->wlen,

0 commit comments

Comments
 (0)