|
VSF Documented
|
#include "../vsf_espidf_cfg.h"#include "driver/spi_master.h"#include "../vsf_espidf.h"#include "kernel/vsf_kernel.h"#include "hal/driver/driver.h"#include "service/heap/vsf_heap.h"#include "FreeRTOS.h"#include "semphr.h"#include "task.h"#include <string.h>Data Structures | |
| struct | spi_device_t |
| struct | spi_host_state_t |
Macros | |
| #define | __SPI_MAX_DEVS_PER_HOST 8 |
| #define | __SPI_PREFIX_SCRATCH_MAX 16 |
| #define | __SPI_IRQ_ALL (VSF_SPI_IRQ_MASK_CPL | VSF_SPI_IRQ_MASK_ERR) |
| #define | __SPI_IRQ_ERR (VSF_SPI_IRQ_MASK_ERR) |
Typedefs | |
| typedef struct spi_host_state_t | spi_host_state_t |
| typedef struct spi_device_t | spi_device_t |
Functions | |
| void | vsf_espidf_spi_init (const vsf_espidf_spi_cfg_t *cfg) |
| esp_err_t | spi_bus_initialize (spi_host_device_t host_id, const spi_bus_config_t *bus_config, spi_common_dma_t dma_chan) |
| Initialise an SPI bus. | |
| esp_err_t | spi_bus_free (spi_host_device_t host_id) |
| Release an SPI bus. | |
| esp_err_t | spi_bus_add_device (spi_host_device_t host_id, const spi_device_interface_config_t *dev_config, spi_device_handle_t *handle) |
| Attach a device to an initialised bus. | |
| esp_err_t | spi_bus_remove_device (spi_device_handle_t handle) |
| Detach a device from its bus. | |
| esp_err_t | spi_device_transmit (spi_device_handle_t handle, spi_transaction_t *trans_desc) |
| Blocking, interrupt-backed transaction. | |
| esp_err_t | spi_device_polling_transmit (spi_device_handle_t handle, spi_transaction_t *trans_desc) |
| Blocking polling transaction (shim: same as spi_device_transmit). | |
| esp_err_t | spi_device_queue_trans (spi_device_handle_t handle, spi_transaction_t *trans_desc, uint32_t ticks_to_wait) |
| Queue a transaction for later completion. | |
| esp_err_t | spi_device_get_trans_result (spi_device_handle_t handle, spi_transaction_t **trans_desc, uint32_t ticks_to_wait) |
| Retrieve a previously queued transaction. | |
| esp_err_t | spi_device_polling_start (spi_device_handle_t handle, spi_transaction_t *trans_desc, uint32_t ticks_to_wait) |
| Start a polling transaction without blocking. | |
| esp_err_t | spi_device_polling_end (spi_device_handle_t handle, uint32_t ticks_to_wait) |
| Wait for a previously started polling transaction. | |
| esp_err_t | spi_device_acquire_bus (spi_device_handle_t device, uint32_t wait) |
| Acquire the bus for a series of back-to-back transactions. | |
| void | spi_device_release_bus (spi_device_handle_t dev) |
| Release a previously acquired bus. | |
| esp_err_t | spi_device_get_actual_freq (spi_device_handle_t handle, int *freq_khz) |
| Return the actual clock frequency used for a device. | |
| #define __SPI_MAX_DEVS_PER_HOST 8 |
| #define __SPI_PREFIX_SCRATCH_MAX 16 |
| #define __SPI_IRQ_ALL (VSF_SPI_IRQ_MASK_CPL | VSF_SPI_IRQ_MASK_ERR) |
| #define __SPI_IRQ_ERR (VSF_SPI_IRQ_MASK_ERR) |
| typedef struct spi_host_state_t spi_host_state_t |
| typedef struct spi_device_t spi_device_t |
|
extern |
| esp_err_t spi_bus_initialize | ( | spi_host_device_t | host_id, |
| const spi_bus_config_t * | bus_config, | ||
| spi_common_dma_t | dma_chan | ||
| ) |
Initialise an SPI bus.
| [in] | host_id | SPI host (index into the injected vsf_spi_t pool). |
| [in] | bus_config | Bus configuration (pin fields ignored). |
| [in] | dma_chan | DMA channel hint (accepted, ignored). |
| esp_err_t spi_bus_free | ( | spi_host_device_t | host_id | ) |
Release an SPI bus.
All devices attached to the host must be removed first.
| esp_err_t spi_bus_add_device | ( | spi_host_device_t | host_id, |
| const spi_device_interface_config_t * | dev_config, | ||
| spi_device_handle_t * | handle | ||
| ) |
Attach a device to an initialised bus.
| esp_err_t spi_bus_remove_device | ( | spi_device_handle_t | handle | ) |
Detach a device from its bus.
| esp_err_t spi_device_transmit | ( | spi_device_handle_t | handle, |
| spi_transaction_t * | trans_desc | ||
| ) |
Blocking, interrupt-backed transaction.
| esp_err_t spi_device_polling_transmit | ( | spi_device_handle_t | handle, |
| spi_transaction_t * | trans_desc | ||
| ) |
Blocking polling transaction (shim: same as spi_device_transmit).
| esp_err_t spi_device_queue_trans | ( | spi_device_handle_t | handle, |
| spi_transaction_t * | trans_desc, | ||
| uint32_t | ticks_to_wait | ||
| ) |
Queue a transaction for later completion.
This port executes queued transactions inline (synchronously). The ticks_to_wait parameter bounds the bus-lock wait; once the bus is held the transfer runs to completion and a matching spi_device_get_trans_result() call will return the same pointer immediately.
| esp_err_t spi_device_get_trans_result | ( | spi_device_handle_t | handle, |
| spi_transaction_t ** | trans_desc, | ||
| uint32_t | ticks_to_wait | ||
| ) |
Retrieve a previously queued transaction.
| esp_err_t spi_device_polling_start | ( | spi_device_handle_t | handle, |
| spi_transaction_t * | trans_desc, | ||
| uint32_t | ticks_to_wait | ||
| ) |
Start a polling transaction without blocking.
Must be matched by exactly one spi_device_polling_end() call.
| esp_err_t spi_device_polling_end | ( | spi_device_handle_t | handle, |
| uint32_t | ticks_to_wait | ||
| ) |
Wait for a previously started polling transaction.
| esp_err_t spi_device_acquire_bus | ( | spi_device_handle_t | device, |
| uint32_t | wait | ||
| ) |
Acquire the bus for a series of back-to-back transactions.
While the bus is acquired by one device, other devices sharing the same host will block inside spi_device_transmit() / queue_trans.
| void spi_device_release_bus | ( | spi_device_handle_t | dev | ) |
Release a previously acquired bus.
| esp_err_t spi_device_get_actual_freq | ( | spi_device_handle_t | handle, |
| int * | freq_khz | ||
| ) |
Return the actual clock frequency used for a device.
This port returns dev->clock_speed_hz rounded through the HAL's granularity (typically the configured value).
| bool is_inited |
| vsf_spi_t* const* pool |
| uint16_t pool_count |
| spi_host_state_t* hosts |