Skip to content
Snippets Groups Projects
Commit 891479e6 authored by Radomir Dopieralski's avatar Radomir Dopieralski Committed by Paul Sokolovsky
Browse files

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.
parent 9897bcaa
No related branches found
No related tags found
No related merge requests found
...@@ -199,8 +199,12 @@ uint32_t spi_transaction(uint8_t spi_no, uint8_t cmd_bits, uint16_t cmd_data, ...@@ -199,8 +199,12 @@ 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. // 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. // CMD ADDR and MOSI are set below to save on an extra if statement.
if (din_bits) { if (din_bits) {
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); SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_MISO);
} }
}
if (dummy_bits) { if (dummy_bits) {
SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_DUMMY); SET_PERI_REG_MASK(SPI_USER(spi_no), SPI_USR_DUMMY);
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment