Hello,
* HW: nrf52840DK
* SDK: ncs v2.8.0
* APP: spi-master-slave example
In this example, I am interested in slave rx. Seeing this example, it apears slave makes data reception by using these two functions:
static int spi_slave_write_test_msg(void)
{
static uint8_t counter = 0;
const struct spi_buf s_tx_buf = {
.buf = slave_tx_buffer,
.len = sizeof(slave_tx_buffer)
};
const struct spi_buf_set s_tx = {
.buffers = &s_tx_buf,
.count = 1
};
struct spi_buf s_rx_buf = {
.buf = slave_rx_buffer,
.len = sizeof(slave_rx_buffer),
};
const struct spi_buf_set s_rx = {
.buffers = &s_rx_buf,
.count = 1
};
// Update the TX buffer with a rolling counter
slave_tx_buffer[1] = counter++;
// Reset signal
k_poll_signal_reset(&spi_slave_done_sig);
// Start transaction
int error = spi_transceive_signal(spi_slave_dev, &spi_slave_cfg, &s_tx, &s_rx, &spi_slave_done_sig);
if(error != 0){
printk("SPI slave transceive error: %i\n", error);
return error;
}
return 0;
}
static int spi_slave_check_for_message(void)
{
int signaled, result;
k_poll_signal_check(&spi_slave_done_sig, &signaled, &result);
if(signaled != 0){
return 0;
}
else return -1;
}
When I ran this example on nrf52840dk connecting wires between two SPIs, slave seems to receive data from master. Seeing slave_rx_buffer when spi_slave_check_for_message returns 0, the received data seats in there. But I don't see any information about rx data length.
Q) How can I get received data length in slave mode?
Thanks for your support in advance,
Robin