Hi: I have write a spi slave, and write a spi master on STM32, It can receive data from STM32,But I have no time to prepare the response data.
as the code below, I can receive the command 0x01 from master, But the response data can only be response in next reqest, At the first request, m_rx_buf buffer have no data.
-
How can I parse the command and prepare the reply data at the same time?
void spis_event_handler(nrf_drv_spis_event_t event)
{
NRF_LOG_INFO("spis_event_handler\r\n");
if (event.evt_type == NRF_DRV_SPIS_XFER_DONE)
{
if(m_rx_buf[0] == 0x01)
{
NRF_LOG_INFO("receive read ID command\r\n");
m_tx_buf[0] = 0xE1;
m_tx_buf[1] = 0xE2;
}
....
memset(m_rx_buf, 0, BUFFER_LENGTH);
nrf_drv_spis_buffers_set(&spis, m_tx_buf, BUFFER_LENGTH, m_rx_buf, BUFFER_LENGTH);
}
}