tmedicci commented on issue #13855: URL: https://github.com/apache/nuttx/issues/13855#issuecomment-2450667315
> Hello @tmedicci , **I still couldn't get it: what is the behavior of the slave device if you call write on the SPI slave peripheral? (without any workarounds in the lower-half).** When I call "write", slave will send nbytes requested in write command and fill other bytes with trash (consider master sending 10 bytes and nbytes = 5 ). > > **For instance, example writes back the read content. If you modify it to write any other data, does the tx_buffer behave as expected?** > > The result only is the expected if slave always write exactly number of bytes than master. With master write 10 bytes and slave write 5, master will receive 5 "true" bytes and 5 "echoed" bytes. Yes, this is the expected behavior. Check section 28.5.5 of https://www.espressif.com/sites/default/files/documentation/esp32-c6_technical_reference_manual_en.pdf > GP-SPI2 provides 16 x 32-bit data buffers, i.e., SPI_W0_REG ~ SPI_W15_REG, as shown in Figure 28-2. CPU-controlled transfer indicates the transfer in which the data to send is from GP-SPI2 data buffer and the received data is stored to GP-SPI2 data buffer. In such transfer, every single transaction needs to be triggered by the CPU after its related registers are configured. This is the case if `CONFIG_ESPRESSIF_SPI2_DMA` isn't enabled (and it isn't by default). For master device, the data from this buffer is sent to MOSI and received data on MISO overwrites this same buffer. For slave devices, it's the opposite: if you just write 5 bytes to the transmit buffer and master sends 10 bytes, the first 5 written bytes in the transmit buffer will be sent and the next 5 bytes represents any content in that buffer. That content is just the received content of the last transmission. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
