summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorRadomir Dopieralski <openstack@sheep.art.pl>2016-08-25 10:42:33 +0200
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2016-08-25 21:24:22 +0300
commit891479e62a8db32d5a6351e9e3eb9e5dd570ba9c (patch)
tree5da7247e3700908286acf651d44afefb900b91c7
parent9897bcaa731d9dfe62cac61b56698799c8e6bac8 (diff)
downloadmicropython-891479e62a8db32d5a6351e9e3eb9e5dd570ba9c.tar.gz
micropython-891479e62a8db32d5a6351e9e3eb9e5dd570ba9c.zip
esp8266/hspi: Enable duplex operation of hardware SPI
Without this, spi.read(1, 0xff) would use 16 clock cycles, first to send 0xff and then to receive one byte, as visible with a logic analyzer.
-rw-r--r--esp8266/hspi.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/esp8266/hspi.c b/esp8266/hspi.c
index 7315dc8a12..436fb4f6f4 100644
--- a/esp8266/hspi.c
+++ b/esp8266/hspi.c
@@ -199,7 +199,11 @@ uint32_t spi_transaction(uint8_t spi_no, uint8_t cmd_bits, uint16_t cmd_data,
// This is rather inefficient but allows for a very generic function.
// CMD ADDR and MOSI are set below to save on an extra if statement.
if (din_bits) {
- SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_MISO);
+ if (dout_bits) {
+ SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_DOUTDIN);
+ } else {
+ SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_MISO);
+ }
}
if (dummy_bits) {
SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_DUMMY);