VSF Documented
|
Go to the source code of this file.
Data Structures | |
struct | vsf_spi_status_t |
Predefined VSF SPI status that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these features, these status must be kept. More... | |
struct | vsf_spi_capability_t |
Predefined VSF SPI capability that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these features, these capabilities must be kept. More... | |
struct | vsf_spi_isr_t |
SPI interrupt service routine configuration structure. More... | |
struct | vsf_spi_cfg_t |
Configuration structure for SPI. More... | |
struct | vsf_spi_op_t |
SPI operation function pointer type, used for SPI Multi Class support. More... | |
struct | vsf_spi_t |
SPI instance structure, used for SPI Multi Class support, not needed in non Multi Class mode. More... | |
Macros | |
#define | VSF_SPI_CFG_MULTI_CLASS ENABLED |
Enable multi-class support by default for maximum availability. | |
#define | VSF_SPI_CFG_PREFIX vsf |
Define SPI hardware mask if count is defined. | |
#define | VSF_SPI_CFG_FUNCTION_RENAME ENABLED |
Disable VSF_SPI_CFG_FUNCTION_RENAME to use the original function names (e.g., vsf_spi_init()). | |
#define | VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE DISABLED |
Enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE in specific hardware drivers to redefine enum vsf_spi_mode_t. | |
#define | VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK to redefine enum vsf_spi_irq_mask_t. | |
#define | VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_spi_status_t. | |
#define | VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG to redefine struct vsf_spi_cfg_t. For compatibility, members should not be deleted when redefining vsf_spi_cfg_t. The type vsf_spi_isr_handler_t also needs to be redefined. | |
#define | VSF_SPI_CFG_REIMPLEMENT_TYPE_CTRL DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_CTRL to redefine enum vsf_spi_ctrl_t. | |
#define | VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY to redefine struct vsf_spi_capability_t. For compatibility, members should not be deleted. | |
#define | VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS to reimplement the function vsf_spi_mode_to_data_bits(). | |
#define | VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE to reimplement the function vsf_spi_data_bits_to_mode(). | |
#define | VSF_SPI_CFG_REIMPLEMENT_MODE_TO_BYTES DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_MODE_TO_BYTES to reimplement the function vsf_spi_mode_to_data_bytes(). | |
#define | VSF_SPI_CFG_INHERIT_HAL_CAPABILITY ENABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_INHERIT_HAL_CAPABILITY to inherit the structure vsf_peripheral_capability_t. | |
#define | VSF_SPI_APIS(__prefix) |
SPI API template, used to generate SPI type, specific prefix function declarations, etc. | |
Typedefs | |
typedef enum vsf_spi_mode_t | vsf_spi_mode_t |
Predefined VSF SPI modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time. | |
typedef enum vsf_spi_irq_mask_t | vsf_spi_irq_mask_t |
Predefined VSF SPI interrupt masks that can be reimplemented in specific HAL drivers. Optional interrupts need to provide one or more enum options and a macro with the same name to determine if they are supported at runtime. If multiple options are supported, a corresponding MASK option should be provided to allow switching between modes at runtime. | |
typedef struct vsf_spi_status_t | vsf_spi_status_t |
Predefined VSF SPI status that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these features, these status must be kept. | |
typedef struct vsf_spi_capability_t | vsf_spi_capability_t |
Predefined VSF SPI capability that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these features, these capabilities must be kept. | |
typedef struct vsf_spi_t | vsf_spi_t |
SPI forward declaration. | |
typedef void | vsf_spi_isr_handler_t(void *target_ptr, vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
SPI interrupt handler type declaration. | |
typedef struct vsf_spi_isr_t | vsf_spi_isr_t |
SPI interrupt service routine configuration structure. | |
typedef struct vsf_spi_cfg_t | vsf_spi_cfg_t |
Configuration structure for SPI. | |
typedef enum vsf_spi_ctrl_t | vsf_spi_ctrl_t |
Predefined VSF SPI control commands that can be reimplemented in specific HAL drivers.Optional control commands require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can check for supported features at compile-time. | |
typedef struct vsf_spi_op_t | vsf_spi_op_t |
SPI operation function pointer type, used for SPI Multi Class support. | |
Enumerations | |
enum | vsf_spi_mode_t { VSF_SPI_MASTER = 0x00ul << 0 , VSF_SPI_SLAVE = 0x01ul << 0 , VSF_SPI_MSB_FIRST = 0x00ul << 1 , VSF_SPI_LSB_FIRST = 0x01ul << 1 , VSF_SPI_CPOL_LOW = 0x00ul << 2 , VSF_SPI_CPOL_HIGH = 0x01ul << 2 , VSF_SPI_CPHA_LOW = 0x00ul << 2 , VSF_SPI_CPHA_HIGH = 0x01ul << 2 , VSF_SPI_MODE_0 = VSF_SPI_CPOL_LOW | VSF_SPI_CPHA_LOW , VSF_SPI_MODE_1 = VSF_SPI_CPOL_LOW | VSF_SPI_CPHA_HIGH , VSF_SPI_MODE_2 = VSF_SPI_CPOL_HIGH | VSF_SPI_CPHA_LOW , VSF_SPI_MODE_3 = VSF_SPI_CPOL_HIGH | VSF_SPI_CPHA_HIGH , VSF_SPI_CS_SOFTWARE_MODE = 0x00ul << 4 , VSF_SPI_CS_HARDWARE_MODE = 0x01ul << 4 , VSF_SPI_DATASIZE_8 = 0x00ul << 8 , VSF_SPI_DATASIZE_16 = 0x01ul << 8 , VSF_SPI_DATASIZE_32 = 0x02ul << 8 } |
Predefined VSF SPI modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time. More... | |
enum | { VSF_SPI_DIR_MODE_MASK , VSF_SPI_BIT_ORDER_MASK , VSF_SPI_MODE_MASK , VSF_SPI_CS_MODE_MASK , VSF_SPI_DATASIZE_MASK , VSF_SPI_MODE_ALL_BITS_MASK } |
SPI mode completion, used to simplify the definition of SPI mode. More... | |
enum | vsf_spi_irq_mask_t { VSF_SPI_IRQ_MASK_TX = 0x01ul << 0 , VSF_SPI_IRQ_MASK_RX = 0x01ul << 1 , VSF_SPI_IRQ_MASK_TX_CPL = 0x01ul << 2 , VSF_SPI_IRQ_MASK_CPL = 0x01ul << 3 , VSF_SPI_IRQ_MASK_OVERFLOW_ERR = 0x01ul << 4 } |
Predefined VSF SPI interrupt masks that can be reimplemented in specific HAL drivers. Optional interrupts need to provide one or more enum options and a macro with the same name to determine if they are supported at runtime. If multiple options are supported, a corresponding MASK option should be provided to allow switching between modes at runtime. More... | |
enum | { VSF_SPI_IRQ_MASK_TX_FIFO_THRESHOLD = VSF_SPI_IRQ_MASK_TX , VSF_SPI_IRQ_MASK_RX_FIFO_THRESHOLD = VSF_SPI_IRQ_MASK_RX , VSF_SPI_IRQ_MASK_RX_CPL = VSF_SPI_IRQ_MASK_CPL , VSF_SPI_IRQ_MASK_ERR = VSF_SPI_IRQ_MASK_OVERFLOW_ERR , VSF_SPI_IRQ_ALL_BITS_MASK } |
SPI IRQ mask completion, used to simplify the definition of SPI IRQ mask. More... | |
enum | vsf_spi_ctrl_t { __VSF_SPI_CTRL_DUMMY = 0 } |
Predefined VSF SPI control commands that can be reimplemented in specific HAL drivers.Optional control commands require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can check for supported features at compile-time. More... | |
Functions | |
vsf_err_t | vsf_spi_init (vsf_spi_t *spi_ptr, vsf_spi_cfg_t *cfg_ptr) |
Initialize a SPI instance. | |
void | vsf_spi_fini (vsf_spi_t *spi_ptr) |
Finalize (deinitialize) a SPI instance. | |
fsm_rt_t | vsf_spi_enable (vsf_spi_t *spi_ptr) |
Enable a SPI instance for operation. | |
fsm_rt_t | vsf_spi_disable (vsf_spi_t *spi_ptr) |
Disable a SPI instance from operation. | |
void | vsf_spi_irq_enable (vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
Enable specific interrupts for a SPI instance. | |
void | vsf_spi_irq_disable (vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
Disable specific interrupts for a SPI instance. | |
vsf_err_t | vsf_spi_cs_active (vsf_spi_t *spi_ptr, uint_fast8_t index) |
Activate (assert) a SPI chip select line. | |
vsf_err_t | vsf_spi_cs_inactive (vsf_spi_t *spi_ptr, uint_fast8_t index) |
Deactivate (deassert) a SPI chip select line. | |
vsf_spi_status_t | vsf_spi_status (vsf_spi_t *spi_ptr) |
Get the current status of a SPI instance. | |
vsf_spi_capability_t | vsf_spi_capability (vsf_spi_t *spi_ptr) |
Get the capabilities of a SPI instance. | |
void | vsf_spi_fifo_transfer (vsf_spi_t *spi_ptr, void *out_buffer_ptr, uint_fast32_t *out_offset_ptr, void *in_buffer_ptr, uint_fast32_t *in_offset_ptr, uint_fast32_t count) |
Perform FIFO-based data transfer on a SPI instance. | |
vsf_err_t | vsf_spi_request_transfer (vsf_spi_t *spi_ptr, void *out_buffer_ptr, void *in_buffer_ptr, uint_fast32_t count) |
Request a SPI data transfer operation. | |
vsf_err_t | vsf_spi_cancel_transfer (vsf_spi_t *spi_ptr) |
Cancel an ongoing SPI transfer operation. | |
void | vsf_spi_get_transferred_count (vsf_spi_t *spi_ptr, uint_fast32_t *sent_count, uint_fast32_t *received_count) |
Get the number of data units transferred in the current or last SPI operation. | |
vsf_err_t | vsf_spi_ctrl (vsf_spi_t *spi_ptr, vsf_spi_ctrl_t ctrl, void *param) |
Execute a control command on the SPI instance. | |
#define VSF_SPI_CFG_MULTI_CLASS ENABLED |
Enable multi-class support by default for maximum availability.
#define VSF_SPI_CFG_PREFIX vsf |
Define SPI hardware mask if count is defined.
Define SPI hardware count if mask is defined
We can redefine macro VSF_SPI_CFG_PREFIX to specify a prefix to call a specific driver directly in the application code.
#define VSF_SPI_CFG_FUNCTION_RENAME ENABLED |
Disable VSF_SPI_CFG_FUNCTION_RENAME to use the original function names (e.g., vsf_spi_init()).
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE DISABLED |
Enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_MODE in specific hardware drivers to redefine enum vsf_spi_mode_t.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_IRQ_MASK to redefine enum vsf_spi_irq_mask_t.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_spi_status_t.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_CFG to redefine struct vsf_spi_cfg_t. For compatibility, members should not be deleted when redefining vsf_spi_cfg_t. The type vsf_spi_isr_handler_t also needs to be redefined.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_CTRL DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_CTRL to redefine enum vsf_spi_ctrl_t.
#define VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_TYPE_CAPABILITY to redefine struct vsf_spi_capability_t. For compatibility, members should not be deleted.
#define VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_MODE_TO_DATA_BITS to reimplement the function vsf_spi_mode_to_data_bits().
#define VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_DATA_BITS_TO_MODE to reimplement the function vsf_spi_data_bits_to_mode().
#define VSF_SPI_CFG_REIMPLEMENT_MODE_TO_BYTES DISABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_REIMPLEMENT_MODE_TO_BYTES to reimplement the function vsf_spi_mode_to_data_bytes().
#define VSF_SPI_CFG_INHERIT_HAL_CAPABILITY ENABLED |
In specific hardware driver, enable macro VSF_SPI_CFG_INHERIT_HAL_CAPABILITY to inherit the structure vsf_peripheral_capability_t.
#define VSF_SPI_APIS | ( | __prefix | ) |
SPI API template, used to generate SPI type, specific prefix function declarations, etc.
[in] | __prefix | The prefix used for generating SPI functions. |
typedef enum vsf_spi_mode_t vsf_spi_mode_t |
Predefined VSF SPI modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time.
typedef enum vsf_spi_irq_mask_t vsf_spi_irq_mask_t |
Predefined VSF SPI interrupt masks that can be reimplemented in specific HAL drivers. Optional interrupts need to provide one or more enum options and a macro with the same name to determine if they are supported at runtime. If multiple options are supported, a corresponding MASK option should be provided to allow switching between modes at runtime.
typedef struct vsf_spi_status_t vsf_spi_status_t |
Predefined VSF SPI status that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these features, these status must be kept.
typedef struct vsf_spi_capability_t vsf_spi_capability_t |
Predefined VSF SPI capability that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these features, these capabilities must be kept.
typedef void vsf_spi_isr_handler_t(void *target_ptr, vsf_spi_t *spi_ptr, vsf_spi_irq_mask_t irq_mask) |
SPI interrupt handler type declaration.
[in,out] | target_ptr | User defined target pointer passed to the handler |
[in,out] | spi_ptr | SPI instance pointer vsf_spi_t |
[in] | irq_mask | Interrupt mask indicating which events occurred |
typedef struct vsf_spi_isr_t vsf_spi_isr_t |
SPI interrupt service routine configuration structure.
typedef struct vsf_spi_cfg_t vsf_spi_cfg_t |
Configuration structure for SPI.
typedef enum vsf_spi_ctrl_t vsf_spi_ctrl_t |
Predefined VSF SPI control commands that can be reimplemented in specific HAL drivers.Optional control commands require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can check for supported features at compile-time.
typedef struct vsf_spi_op_t vsf_spi_op_t |
SPI operation function pointer type, used for SPI Multi Class support.
enum vsf_spi_mode_t |
Predefined VSF SPI modes that can be reimplemented in specific HAL drivers.If we want to add optional modes in the specific driver, we need to provide one or more enum options, and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it also needs to provide the corresponding MASK option, so that the user can switch to different modes at compile-time.
anonymous enum |
SPI mode completion, used to simplify the definition of SPI mode.
enum vsf_spi_irq_mask_t |
Predefined VSF SPI interrupt masks that can be reimplemented in specific HAL drivers. Optional interrupts need to provide one or more enum options and a macro with the same name to determine if they are supported at runtime. If multiple options are supported, a corresponding MASK option should be provided to allow switching between modes at runtime.
anonymous enum |
SPI IRQ mask completion, used to simplify the definition of SPI IRQ mask.
enum vsf_spi_ctrl_t |
Predefined VSF SPI control commands that can be reimplemented in specific HAL drivers.Optional control commands require one or more enumeration options and a macro with the same name to determine if they are supported at runtime. If the feature supports more than one option, it is recommended to provide the corresponding MASK option, so that the user can check for supported features at compile-time.
Enumerator | |
---|---|
__VSF_SPI_CTRL_DUMMY | Dummy value for compilation. |
|
extern |
Initialize a SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | cfg_ptr | Pointer to SPI configuration structure vsf_spi_cfg_t |
|
extern |
Finalize (deinitialize) a SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
Enable a SPI instance for operation.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
Disable a SPI instance from operation.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
|
extern |
Enable specific interrupts for a SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | irq_mask | Interrupt mask(s) to enable from vsf_spi_irq_mask_t |
|
extern |
Disable specific interrupts for a SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | irq_mask | Interrupt mask(s) to disable from vsf_spi_irq_mask_t |
|
extern |
Activate (assert) a SPI chip select line.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | index | Chip select line index (0 to cs_count-1) |
|
extern |
Deactivate (deassert) a SPI chip select line.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | index | Chip select line index (0 to cs_count-1) |
|
extern |
Get the current status of a SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
|
extern |
Get the capabilities of a SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
|
extern |
Perform FIFO-based data transfer on a SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | out_buffer_ptr | Pointer to transmit data buffer (can be NULL for receive-only) |
[in,out] | out_offset_ptr | Pointer to transmit buffer offset |
[out] | in_buffer_ptr | Pointer to receive data buffer (can be NULL for transmit-only) |
[in,out] | in_offset_ptr | Pointer to receive buffer offset |
[in] | count | Number of data units to transfer |
|
extern |
Request a SPI data transfer operation.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | out_buffer_ptr | Pointer to output data buffer (NULL for receive-only) |
[in] | in_buffer_ptr | Pointer to input data buffer (NULL for transmit-only) |
[in] | count | Number of data units to transfer |
Cancel an ongoing SPI transfer operation.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
|
extern |
Get the number of data units transferred in the current or last SPI operation.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[out] | sent_count | Pointer to store the number of data units transmitted (can be NULL if not needed) |
[out] | received_count | Pointer to store the number of data units received (can be NULL if not needed) |
|
extern |
Execute a control command on the SPI instance.
[in,out] | spi_ptr | Pointer to SPI instance structure vsf_spi_t |
[in] | ctrl | Control command from vsf_spi_ctrl_t enumeration |
[in] | param | Command-specific parameter (can be NULL depending on command) |