Use this forum to chat about hardware specific topics for the ESP8266 (peripherals, memory, clocks, JTAG, programming)

User avatar
By someother
#44537 Hello!

I'm using the MetalPhreak's (H)SPI library for ESP8266 and it looks good.

Since I need to send commands to another device (nRF24L01), I have something like this:

Code: Select alluint8_t ICACHE_FLASH_ATTR nRF24_RWReg(uint8_t reg, uint8_t value) {
   CSN_L();
   uint8_t statusreg = spi_transaction( HSPI, 8, reg, 0, 0, 8, value, 0, 0 );
   //CSN_H();
   gpio_output_set(BIT4, 0, BIT4, 0);
   return statusreg;
}


The problem is that the GPIO port overlaps the SPI ports and destroys the timing. Please see the attached image.

Any ideas? If I repeat several times CSN_L() for example, right before CSN_H, it gives some delay for the CSN IO pin, but it is awful solution.
User avatar
By someother
#44560 I don't know why my attached image is missing.

However, if you look at the SPI driver code you'll notice that it returns immediately after the data registers are loaded. Therefore the function returns before all the data is sent over the SPI bus.
[SOLUTION]: Just check if the SPI is busy and then continue:
Code: Select all   while( spi_busy( HSPI ) );
   CSN_H();