FreeRTOS Peripheral Control API For the SPI.
Copyright (c) 2012-2018 Microchip Technology Inc. and its subsidiaries.
#include "FreeRTOS.h"
#include "task.h"
#include "semphr.h"
#include "spi_master.h"
#include "freertos_peripheral_control.h"
Macros | |
#define | freertos_spi_read_packet(p_spi, data, len, block_time_ticks) freertos_spi_read_packet_async((p_spi), (data), (len), (block_time_ticks), (NULL)) |
Initiate a multi-byte read operation on an SPI peripheral. More... | |
#define | freertos_spi_write_packet(p_spi, data, len, block_time_ticks) freertos_spi_write_packet_async((p_spi), (data), (len), (block_time_ticks), (NULL)) |
Initiate a multi-byte write operation on an SPI peripheral. More... | |
Typedefs | |
typedef void * | freertos_spi_if |
Type returned from a call to freertos_spi_master_init(), and then used to reference an SPI port in calls to FreeRTOS peripheral control functions. More... | |
Functions | |
status_code_t | freertos_spi_full_duplex_packet_async (freertos_spi_if p_spi, uint8_t *rx_data, uint8_t *tx_data, uint32_t len, portTickType block_time_ticks, xSemaphoreHandle notification_semaphore) |
Initiate a completely asynchronous multi-byte full duplex operation on an SPI peripheral. More... | |
freertos_spi_if | freertos_spi_master_init (Spi *p_spi, const freertos_peripheral_options_t *const freertos_driver_parameters) |
Initializes the FreeRTOS ASF SPI master driver for the specified SPI port. More... | |
status_code_t | freertos_spi_read_packet_async (freertos_spi_if p_spi, uint8_t *data, uint32_t len, portTickType block_time_ticks, xSemaphoreHandle notification_semaphore) |
Initiate a completely asynchronous multi-byte read operation on an SPI peripheral. More... | |
status_code_t | freertos_spi_write_packet_async (freertos_spi_if p_spi, const uint8_t *data, size_t len, portTickType block_time_ticks, xSemaphoreHandle notification_semaphore) |
Initiate a completely asynchronous multi-byte write operation on an SPI peripheral. More... | |
#define freertos_spi_read_packet | ( | p_spi, | |
data, | |||
len, | |||
block_time_ticks | |||
) | freertos_spi_read_packet_async((p_spi), (data), (len), (block_time_ticks), (NULL)) |
Initiate a multi-byte read operation on an SPI peripheral.
freertos_spi_read_packet() is an ASF specific FreeRTOS driver function. It configures the SPI peripheral DMA controller (PDC) to read data from the SPI port, then waits until the requested number of bytes have been received. Other RTOS tasks execute while the DMA transfer is in progress.
freertos_spi_read_packet_async() is a version that does not wait for the reception to complete before returning.
The FreeRTOS ASF SPI driver is initialized using a call to freertos_spi_master_init(). The freertos_driver_parameters.options_flags parameter passed into the initialization function defines the driver behavior. freertos_spi_read_packet() can only be used if the freertos_driver_parameters.options_flags parameter passed to the initialization function had the WAIT_RX_COMPLETE bit set.
Readers are recommended to also reference the application note and examples that accompany the FreeRTOS ASF drivers.
The FreeRTOS ASF driver both installs and handles the SPI PDC interrupts. Users do not need to concern themselves with interrupt handling, and must not install their own interrupt handler.
p_spi | The handle to the SPI port returned by the freertos_spi_master_init() call used to initialise the port. |
data | A pointer to the buffer into which received data is to be written. |
len | The number of bytes to receive. |
block_time_ticks | The FreeRTOS ASF SPI driver is initialized using a call to freertos_spi_master_init(). The freertos_driver_parameters.options_flags parameter passed to the initialization function defines the driver behavior. If freertos_driver_parameters.options_flags had the USE_RX_ACCESS_MUTEX bit set, then the driver will only read from the SPI peripheral if it has first gained exclusive access to it. block_time_ticks specifies the maximum amount of time the driver will wait to get exclusive access before aborting the read operation. Other tasks will execute during any waiting time. block_time_ticks is specified in RTOS tick periods. To specify a block time in milliseconds, divide the milliseconds value by portTICK_RATE_MS, and pass the result in block_time_ticks. portTICK_RATE_MS is defined by FreeRTOS. |