Would send one byte and receive one byte of a response.
Code like below cause assert error because ESP_ERR_INVALID_ARG returned from spi_device_polling_transmit.
Code: Select all
void readSingleRegister(spi_device_handle_t spi, char * rxBuffer, uint8_t address) {
spi_transaction_t transaction;
memset(&transaction, 0, sizeof(transaction));
transaction.cmd = RREG | (address<<2);
transaction.rxlength = 8;
transaction.rx_buffer = rxBuffer;
assert(spi_device_polling_transmit(spi, &transaction) == ESP_OK);
printf("Received (address %d): %s\n", address, rxBuffer);
}
Code: Select all
transaction.length = transaction.rxlength;