Hi,
I need to control an SPI chip which requires a first byte written indicating address and read/write operation, followed by the data to be written in case of a write operation, and the chip will send the data read after this first byte for a read operation.
I understand I can handle the read operation with a half-duplex transaction (write the address, read the data: hd.tx_len = 1, hd.rx_len=data length).
Regarding the write operation, address and data are on separate spaces and CS must be kept low for the entire frame (address + data). I imagine these possibilities:
- Manually handle CS, perform a 1-byte write and then write the rest of the data
- Combine address and data together and run a single full-duplex transaction with fd.tx_len = data length + 1 and fd.rx_data=NULL
Anything simpler ? Something I’m missing ?
Regards
PS: by “separate spaces” I mean this is a low-level driver for a high-level driver and the function receives address and data as separate arguments. I can’t (shouldn’t) modify the high-level driver.