I am still somewhat new to SPI communication, so please forgive me if this is a silly question. I am looking at a few different C code examples of SPI sensor communication. When sending commands, some implementations seem to create a new spi_transaction_t and set the tx_data field with the command, but not set the addr field. Other codes (those not written for a specific sensor, but rather SPI communication in general) usually have some sort of writeBytes command, and take a register address. I am basically trying to reconcile these two implementations: when the addr field is not set explicitly by me, what does the SPI driver set it to? I tried printing addr out (using code that works correctly), and it seems to be set to 0. Is this correct? Looking at sensor datasheets, I don't see registers that seem to take "cmd input", only config registers. Is this because when a sensor receives the data in its shift register, commands aren't "stored" in some other register--so their address is effectively 0x00?
Basically I'd like to be able to call a function similar to this, even to write a command to the device (in my case and ADC, to say start/stop:
Code: Select all
esp_err_t SPI::writeBytes(spi_device_handle_t handle, uint8_t regAddr, size_t length, const uint8_t *data);