PSoC 4: SCB SPI operation - how to properly write and read data | Cypress Semiconductor
PSoC 4: SCB SPI operation - how to properly write and read data
I'm working with a module that requires me to keep the CS pin active during the whole transmission process that consists of sending a few commands in order to do one task. The module is NRF24L01.
For example, if I want to write data to a register, I have to bring CS pin low, send a write-to-register command with the register's address, send another byte of data with the values I want to put in that particular register, and then bring the CS pin high. I assume that this can be simply done with the SCB_SpiUartPutArray(const uint16/uint8 wrBuf, uint32 count) command.
However, when I want to read data from a register, I have to bring the CS pin low, send a read-from-register command with the register's address, send dummy byte(s), receive data, and then bring the CS pin high. I probably don't understand SPI communication good enough, but I'd like to know how I'm supposed to do such operation.
With the CS pin active, the NRF module sends data back after receiving commands* etc., so I'm assuming I simply have to use the aforementioned SCB_SpiUartPutArray function to send the command and dummy bytes, and the data received will be already waiting in the RX FIFO to be read out using SCB_SpiUartReadRxData() command.
Is this the correct way it works? Please, correct me if I'm wrong, and thanks in advance.
* Actually it sends data back after every command. It ALWAYS sends back the STATUS register.