I am using Atmel SAM4S-EK EVB and FreeRTOS 7.3.0.
I want to work with the FreeRTOS SPI API.
When worked with the Atmel driver: spi_write() and spi_read(), everything seemed to be OK.
I connected an oscilloscope to the MOSI and CLK pins and saw that when writing, I saw the 16bit of what I wrote, when reading, I saw nothing – OK.
Now, I am using the FreeRTOS API:
static void spi_master_transfer(void *p_buf, uint32_t size)
const portTickType time_out_definition = (100UL / portTICK_RATE_MS);
uint16_t data16_tx, data16_rx;
memcpy(&data16_tx, p_buf, sizeof(data16_tx));
returned_status = freertos_spi_write_packet_async(freertos_spi, &data16_tx, sizeof(data16_tx), time_out_definition,NULL);
sprintf( str, “SPI master sent: 0x%x”, data16_tx );
memset(&data16_rx, 0, sizeof(data16_rx));
returned_status = freertos_spi_read_packet(freertos_spi, &data16_rx, sizeof(data16_rx), time_out_definition);
sprintf( str, “SPI master received: 0x%x\n”, data16_rx );
sprintf( str, “SPI master received: 0x%x\n”, *receive_buffer );
My questions are:
1. What is the purpose of receive_buffer that give in the driver_options on the spi_master_initialize()?
I don’t see its content changes at all…
2. Why when I use freertos_spi_write_packet_async(), I see 16bits of my data written, and then another 16bits of ‘0’ written?
3. Why when I am using freertos_spi_read_packet_async(), I see also two times of 16bit of writes. 16 bits of ‘1’ and another 16bits of ‘0’…