control
FreeRTOS peripheral control functions for the SPI peripheral
Modules | |
Related Project(s) | |
In this section you can find all the projects related to the FreeRTOS SPI peripheral. | |
Macros | |
#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_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.
freertos_spi_write_packet() is an ASF specific FreeRTOS driver function. It configures the SPI peripheral DMA controller (PDC) to transmit data on the SPI port, then waits until the transmission is complete. Other RTOS tasks execute while the transmission is in progress.
freertos_spi_write_packet_async() is a version that does not wait for the transmission 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_write_packet() can only be used if the freertos_driver_parameters.options_flags parameter passed to the initialization function had the WAIT_TX_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 data to be transmitted. |
len | The number of bytes to transmit. |
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_TX_ACCESS_SEM bit set, then the driver will only write to 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 write 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. |
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.
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.
freertos_spi_full_duplex_packet_async() is an ASF specific FreeRTOS driver function. It configures the SPI peripheral DMA controller (PDC) to read/write data from the SPI port, then returns. freertos_spi_full_duplex_packet_async() does not wait for the reception and transmission 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_full_duplex_packet_async() can only be used if the freertos_driver_parameters.options_flags parameter passed to the initialization function had the WAIT_RX_COMPLETE and WAIT_TX_COMPLETE bit clear.
freertos_spi_full_duplex_packet_async() is an advanced function and 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. |
rx_data | A pointer to the buffer into which received data is to be written. |
tx_data | A pointer to the data to be transmitted. |
len | The number of bytes to receive/transmit. |
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. |
notification_semaphore | The RTOS task that calls the receive function exits the receive function as soon as the reception starts. The data being received by the PDC cannot normally be processed until after the reception has completed. The PDC interrupt (handled internally by the FreeRTOS ASF driver) 'gives' the semaphore when the PDC transfer completes. The notification_semaphore therefore provides a mechanism for the calling task to know when the PDC has read the requested number of bytes. The calling task can call standard FreeRTOS functions to block on the semaphore until the PDC interrupt occurs. Other RTOS tasks will execute while the the calling task is in the Blocked state. The semaphore must be created using the FreeRTOS vSemaphoreCreateBinary() API function before it is used as a parameter. |
References ERR_INVALID_ARG, freertos_obtain_peripheral_access_semphore(), freertos_optionally_wait_transfer_completion(), freertos_start_pdc_rx, get_pdc_peripheral_details(), NULL, pdc_disable_transfer(), pdc_enable_transfer(), pdc_tx_init(), spi_enable_interrupt(), spi_is_rx_full(), STATUS_OK, pdc_packet::ul_addr, and pdc_packet::ul_size.
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.
freertos_spi_master_init() is an ASF specific FreeRTOS driver function. It must be called before any other ASF specific FreeRTOS driver functions attempt to access the same SPI port.
If freertos_driver_parameters->operation_mode equals SPI_MASTER then freertos_spi_master_init() will configure the SPI port for master mode operation and enable the peripheral. If freertos_driver_parameters->operation_mode equals any other value then freertos_spi_master_init() will not take any action.
Other ASF SPI functions, such as those to set the SPI clock rate and other bus parameters, can be called after freertos_spi_master_init() has completed successfully.
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.
This driver is provided with an application note, and an example project that demonstrates the use of this function.
p_spi | The SPI peripheral being initialized. |
freertos_driver_parameters | Defines the driver behavior. See the freertos_peripheral_options_t documentation, and the application note that accompanies the ASF specific FreeRTOS functions. |
References check_requested_operating_mode(), configASSERT, configure_interrupt_controller(), create_peripheral_control_semaphores(), get_pdc_peripheral_details(), IER_ERROR_INTERRUPTS, freertos_peripheral_options::interrupt_priority, MASK_ALL_INTERRUPTS, NULL, freertos_peripheral_options::operation_mode, freertos_peripheral_options::options_flags, pdc_disable_transfer(), spi_disable(), spi_disable_interrupt(), spi_enable(), spi_enable_interrupt(), SPI_MASTER, and spi_master_init().
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.
freertos_spi_read_packet_async() is an ASF specific FreeRTOS driver function. It configures the SPI peripheral DMA controller (PDC) to read data from the SPI port, then returns. freertos_spi_read_packet_async() 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_async() can only be used if the freertos_driver_parameters.options_flags parameter passed to the initialization function had the WAIT_RX_COMPLETE bit clear.
freertos_spi_read_packet_async() is an advanced function and readers are recommended to also reference the application note and examples that accompany the FreeRTOS ASF drivers. freertos_spi_read_packet() is a version that does not exit until the PDC transfer is complete, but still allows other RTOS tasks to execute while the transmission is in progress.
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. |
notification_semaphore | The RTOS task that calls the receive function exits the receive function as soon as the reception starts. The data being received by the PDC cannot normally be processed until after the reception has completed. The PDC interrupt (handled internally by the FreeRTOS ASF driver) 'gives' the semaphore when the PDC transfer completes. The notification_semaphore therefore provides a mechanism for the calling task to know when the PDC has read the requested number of bytes. The calling task can call standard FreeRTOS functions to block on the semaphore until the PDC interrupt occurs. Other RTOS tasks will execute while the the calling task is in the Blocked state. The semaphore must be created using the FreeRTOS vSemaphoreCreateBinary() API function before it is used as a parameter. |
References ERR_INVALID_ARG, freertos_obtain_peripheral_access_semphore(), freertos_optionally_wait_transfer_completion(), freertos_start_pdc_rx, get_pdc_peripheral_details(), NULL, pdc_disable_transfer(), pdc_enable_transfer(), pdc_tx_init(), spi_enable_interrupt(), spi_is_rx_full(), STATUS_OK, pdc_packet::ul_addr, and pdc_packet::ul_size.
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.
freertos_spi_write_packet_async() is an ASF specific FreeRTOS driver function. It configures the SPI peripheral DMA controller (PDC) to transmit data on the SPI port, then returns. freertos_spi_write_packet_async() does not wait for the transmission to complete before returning.
The FreeRTOS 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_write_packet_async() can only be used if the freertos_driver_parameters.options_flags parameter passed to the initialization function had the WAIT_TX_COMPLETE bit clear.
freertos_spi_write_packet_async() is an advanced function and readers are recommended to also reference the application note and examples that accompany the FreeRTOS ASF drivers. freertos_spi_write_packet() is a version that does not exit until the PDC transfer is complete, but still allows other RTOS tasks to execute while the transmission is in progress.
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 peripheral returned by the freertos_spi_master_init() call used to initialise the peripheral. |
data | A pointer to the data to be transmitted. |
len | The number of bytes to transmit. |
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_TX_ACCESS_SEM bit set, then the driver will only write to 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 write 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. |
notification_semaphore | The RTOS task that calls the transmit function exits the transmit function as soon as the transmission starts. The data being transmitted by the PDC must not be modified until after the transmission has completed. The PDC interrupt (handled internally by the FreeRTOS ASF driver) 'gives' the semaphore when the PDC transfer completes. The notification_semaphore therefore provides a mechanism for the calling task to know when the PDC has finished accessing the data. The calling task can call standard FreeRTOS functions to block on the semaphore until the PDC interrupt occurs. Other RTOS tasks will execute while the the calling task is in the Blocked state. The semaphore must be created using the FreeRTOS vSemaphoreCreateBinary() API function before it is used as a parameter. |
References ERR_INVALID_ARG, freertos_obtain_peripheral_access_semphore(), freertos_optionally_wait_transfer_completion(), freertos_start_pdc_tx, get_pdc_peripheral_details(), spi_enable_interrupt(), and STATUS_OK.