I am currently trying to use SPI master driver.
With the help of esp-idf examples I succeeded sending my command.
However, they do not provide examples for reading from buffer.
To do it myself I configured my transaction structure like this :
Code: Select all
static spi_transaction_t trans;
trans.flags = 0; // Bitwise
trans.command = 0x01; // 0x01 = Reading request
trans.address = 0;
trans.length = 0;
trans.rxlength = bytesToReceive * 8;
trans.user = NULL;
trans.rx_buffer = data;
trans.tx_buffer = NULL;
I configured my bus driver like this :
Code: Select all
devcfg.command_bits = 8;
devcfg.address_bits = 0;
devcfg.dummy_bits = 0;
devcfg.mode = mode;
devcfg.duty_cycle_pos = 0;
devcfg.cs_ena_pretrans = 0;
devcfg.cs_ena_posttrans = 2;
devcfg.clock_speed_hz = clockRate;
devcfg.spics_io_num = SPI_SS;
devcfg.flags = 0;
devcfg.flags |= (SPI_DEVICE_TXBIT_LSBFIRST|SPI_DEVICE_RXBIT_LSBFIRST);
devcfg.queue_size = 1;
devcfg.pre_cb = NULL;
devcfg.post_cb = NULL;
Code: Select all
assertion "ret_trans==trans_desc" failed: file "...../esp-idf/components/driver/./spi_master.c", line 702, function: spi_device_transmit
abort() was called at PC 0x400f388b