VSF Documented
|
Go to the source code of this file.
Data Structures | |
struct | vsf_usart_isr_t |
USART interrupt configuration structure Contains all necessary information for configuring USART interrupts. More... | |
struct | vsf_usart_cfg_t |
USART configuration structure Contains all parameters needed to initialize and configure a USART instance. More... | |
struct | vsf_usart_status_t |
USART status information structure Contains the current status of USART operations and FIFO thresholds. More... | |
struct | vsf_usart_capability_t |
USART capability structure Defines the hardware capabilities and limitations of the USART interface. More... | |
struct | vsf_usart_op_t |
USART operation interface structure Contains function pointers for all USART operations. More... | |
struct | vsf_usart_t |
USART instance structure Used for USART Multi Class support. More... | |
Macros | |
#define | VSF_USART_CFG_MULTI_CLASS ENABLED |
Enable multi-class support by default for maximum availability. | |
#define | VSF_USART_CFG_PREFIX vsf |
Define USART hardware mask if count is defined. If VSF_HW_USART_COUNT is defined, this macro will generate the corresponding mask. | |
#define | VSF_USART_CFG_FUNCTION_RENAME ENABLED |
Disable VSF_USART_CFG_FUNCTION_RENAME to use the original function names (e.g., vsf_usart_init()) without prefix. | |
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_MODE DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_MODE to redefine vsf_usart_mode_t as needed. | |
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK to redefine vsf_usart_irq_mask_t as needed. | |
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_usart_status_t. | |
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_CTRL DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_CTRL to redefine vsf_usart_ctrl_t as needed. | |
#define | VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS to re-implement the function vsf_usart_mode_to_data_bits(). | |
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_CFG DISABLED |
Redefine struct vsf_usart_cfg_t. The vsf_usart_isr_handler_t type also needs to be redefined. For compatibility, members should not be deleted when struct vsf_usart_cfg_t redefining. | |
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED |
Redefine struct vsf_usart_capability_t. For compatibility, members should not be deleted when struct vsf_usart_capability_t redefining. | |
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_usart_status_t. | |
#define | VSF_USART_CFG_INHERIT_HAL_CAPABILITY ENABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_INHERIT_HAL_CAPABILITY to inherit capability from hal. | |
#define | VSF_USART_APIS(__prefix_name) |
USART API template, used to generate USART type, specific prefix function declarations, etc. | |
#define | VSF_USART_ADDITIONAL_APIS(__prefix_name) |
Typedefs | |
typedef enum vsf_usart_mode_t | vsf_usart_mode_t |
Predefined VSF USART modes that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these modes, the following modes must be kept. If the hardware supports more modes, e.g. more parity modes, more databits, more stopbits, more FIFO threshold size, we can implement it in the hardware driver. | |
typedef enum vsf_usart_irq_mask_t | vsf_usart_irq_mask_t |
USART interrupt mask definitions These interrupts provide status and event notifications for USART operations. | |
typedef struct vsf_usart_t | vsf_usart_t |
USART instance structure forward declaration. | |
typedef void | vsf_usart_isr_handler_t(void *target_ptr, vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask) |
USART interrupt handler function type declaration. | |
typedef struct vsf_usart_isr_t | vsf_usart_isr_t |
USART interrupt configuration structure Contains all necessary information for configuring USART interrupts. | |
typedef struct vsf_usart_cfg_t | vsf_usart_cfg_t |
USART configuration structure Contains all parameters needed to initialize and configure a USART instance. | |
typedef enum vsf_usart_ctrl_t | vsf_usart_ctrl_t |
USART control commands Defines the available control operations for USART instances. | |
typedef struct vsf_usart_status_t | vsf_usart_status_t |
USART status information structure Contains the current status of USART operations and FIFO thresholds. | |
typedef struct vsf_usart_capability_t | vsf_usart_capability_t |
USART capability structure Defines the hardware capabilities and limitations of the USART interface. | |
typedef struct vsf_usart_op_t | vsf_usart_op_t |
USART operation interface structure Contains function pointers for all USART operations. | |
Functions | |
vsf_err_t | vsf_usart_init (vsf_usart_t *usart_ptr, vsf_usart_cfg_t *cfg_ptr) |
Initialize a USART instance. | |
void | vsf_usart_fini (vsf_usart_t *usart_ptr) |
Finalize a USART instance. | |
fsm_rt_t | vsf_usart_enable (vsf_usart_t *usart_ptr) |
Enable a USART instance. | |
fsm_rt_t | vsf_usart_disable (vsf_usart_t *usart_ptr) |
Disable a USART instance. | |
void | vsf_usart_irq_enable (vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask) |
Enable interrupt masks of USART instance. | |
void | vsf_usart_irq_disable (vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask) |
Disable interrupt masks of USART instance. | |
vsf_usart_status_t | vsf_usart_status (vsf_usart_t *usart_ptr) |
Get the status of USART instance. | |
vsf_usart_capability_t | vsf_usart_capability (vsf_usart_t *usart_ptr) |
Get the capability of USART instance. | |
uint_fast32_t | vsf_usart_rxfifo_get_data_count (vsf_usart_t *usart_ptr) |
Get the number of data currently received in the USART receive FIFO. | |
uint_fast32_t | vsf_usart_rxfifo_read (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) |
Try to read the maximum length of data from the USART receive FIFO. | |
uint_fast32_t | vsf_usart_txfifo_get_free_count (vsf_usart_t *usart_ptr) |
Get the maximum number of data that can be sent through the USART send FIFO. | |
uint_fast32_t | vsf_usart_txfifo_write (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) |
Try to write the maximum length of data to the USART send FIFO. | |
vsf_err_t | vsf_usart_request_rx (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) |
Request a DMA receive operation through the USART. | |
vsf_err_t | vsf_usart_request_tx (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) |
Request a DMA transmit operation through the USART. | |
vsf_err_t | vsf_usart_cancel_rx (vsf_usart_t *usart_ptr) |
Cancel an ongoing USART receive operation. | |
vsf_err_t | vsf_usart_cancel_tx (vsf_usart_t *usart_ptr) |
Cancel an ongoing USART transmit operation. | |
int_fast32_t | vsf_usart_get_rx_count (vsf_usart_t *usart_ptr) |
Get the number of bytes received in the current or last USART operation. | |
int_fast32_t | vsf_usart_get_tx_count (vsf_usart_t *usart_ptr) |
Get the number of bytes transmitted in the current or last USART operation. | |
vsf_err_t | vsf_usart_ctrl (vsf_usart_t *usart_ptr, vsf_usart_ctrl_t ctrl, void *param) |
Execute a control command on the USART instance. | |
#define VSF_USART_CFG_MULTI_CLASS ENABLED |
Enable multi-class support by default for maximum availability.
#define VSF_USART_CFG_PREFIX vsf |
Define USART hardware mask if count is defined. If VSF_HW_USART_COUNT is defined, this macro will generate the corresponding mask.
Define USART hardware count if mask is defined. If VSF_HW_USART_MASK is defined, this macro will calculate the corresponding count.
Macro VSF_USART_CFG_PREFIX can be redefined in application code to specify a prefix for directly calling a specific driver. This allows applications to access different USART implementations through unique function names. For example: #define VSF_USART_CFG_PREFIX vsf_hw vsf_usart_init(&vsf_hw_usart0, &cfg); It will be expanded at compile time to vsf_hw_usart_init(&vsf_hw_usart0, &cfg).
#define VSF_USART_CFG_FUNCTION_RENAME ENABLED |
Disable VSF_USART_CFG_FUNCTION_RENAME to use the original function names (e.g., vsf_usart_init()) without prefix.
#define VSF_USART_CFG_REIMPLEMENT_TYPE_MODE DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_MODE to redefine vsf_usart_mode_t as needed.
#define VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK to redefine vsf_usart_irq_mask_t as needed.
#define VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_usart_status_t.
#define VSF_USART_CFG_REIMPLEMENT_TYPE_CTRL DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_CTRL to redefine vsf_usart_ctrl_t as needed.
#define VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS to re-implement the function vsf_usart_mode_to_data_bits().
#define VSF_USART_CFG_REIMPLEMENT_TYPE_CFG DISABLED |
Redefine struct vsf_usart_cfg_t. The vsf_usart_isr_handler_t type also needs to be redefined. For compatibility, members should not be deleted when struct vsf_usart_cfg_t redefining.
#define VSF_USART_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED |
Redefine struct vsf_usart_capability_t. For compatibility, members should not be deleted when struct vsf_usart_capability_t redefining.
#define VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS to redefine struct vsf_usart_status_t.
#define VSF_USART_CFG_INHERIT_HAL_CAPABILITY ENABLED |
In the specific hardware driver, we can enable VSF_USART_CFG_INHERIT_HAL_CAPABILITY to inherit capability from hal.
#define VSF_USART_APIS | ( | __prefix_name | ) |
USART API template, used to generate USART type, specific prefix function declarations, etc.
[in] | __prefix_name | The prefix used for generating USART functions. |
#define VSF_USART_ADDITIONAL_APIS | ( | __prefix_name | ) |
typedef enum vsf_usart_mode_t vsf_usart_mode_t |
Predefined VSF USART modes that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these modes, the following modes must be kept. If the hardware supports more modes, e.g. more parity modes, more databits, more stopbits, more FIFO threshold size, we can implement it in the hardware driver.
If more new modes are added to the driver, then the corresponding MASK macros need to be defined to include the values of the new modes. For example:
typedef enum vsf_usart_irq_mask_t vsf_usart_irq_mask_t |
USART interrupt mask definitions These interrupts provide status and event notifications for USART operations.
typedef struct vsf_usart_t vsf_usart_t |
USART instance structure forward declaration.
typedef void vsf_usart_isr_handler_t(void *target_ptr, vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask) |
USART interrupt handler function type declaration.
[in,out] | target_ptr | User defined target pointer |
[in,out] | usart_ptr | USART instance structure pointer |
[in] | irq_mask | Interrupt mask indicating which events occurred |
Example:
typedef struct vsf_usart_isr_t vsf_usart_isr_t |
USART interrupt configuration structure Contains all necessary information for configuring USART interrupts.
typedef struct vsf_usart_cfg_t vsf_usart_cfg_t |
USART configuration structure Contains all parameters needed to initialize and configure a USART instance.
typedef enum vsf_usart_ctrl_t vsf_usart_ctrl_t |
USART control commands Defines the available control operations for USART instances.
typedef struct vsf_usart_status_t vsf_usart_status_t |
USART status information structure Contains the current status of USART operations and FIFO thresholds.
typedef struct vsf_usart_capability_t vsf_usart_capability_t |
USART capability structure Defines the hardware capabilities and limitations of the USART interface.
typedef struct vsf_usart_op_t vsf_usart_op_t |
USART operation interface structure Contains function pointers for all USART operations.
enum vsf_usart_mode_t |
Predefined VSF USART modes that can be reimplemented in specific HAL drivers. Even if the hardware doesn't support these modes, the following modes must be kept. If the hardware supports more modes, e.g. more parity modes, more databits, more stopbits, more FIFO threshold size, we can implement it in the hardware driver.
If more new modes are added to the driver, then the corresponding MASK macros need to be defined to include the values of the new modes. For example:
anonymous enum |
enum vsf_usart_irq_mask_t |
USART interrupt mask definitions These interrupts provide status and event notifications for USART operations.
anonymous enum |
USART interrupts and control flags.
enum vsf_usart_ctrl_t |
USART control commands Defines the available control operations for USART instances.
|
extern |
Initialize a USART instance.
[in] | usart_ptr | Pointer to USART instance |
[in] | cfg_ptr | Pointer to USART configuration |
calculate baudrate
calculate baudrate
|
extern |
|
extern |
Enable a USART instance.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
don't forget to enable sync clock and peripheral_clk here
|
extern |
Disable a USART instance.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
don't forget to disable sync clock and peripheral_clk here
|
extern |
Enable interrupt masks of USART instance.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
[in] | irq_mask | one or more values of enum vsf_usart_irq_mask_t |
|
extern |
Disable interrupt masks of USART instance.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
[in] | irq_mask | one or more values of enum vsf_usart_irq_mask_t |
|
extern |
Get the status of USART instance.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Get the capability of USART instance.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Get the number of data currently received in the USART receive FIFO.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Try to read the maximum length of data from the USART receive FIFO.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
[in] | buffer_ptr | data buffer |
[in] | count | maximum number of reads |
|
extern |
Get the maximum number of data that can be sent through the USART send FIFO.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Try to write the maximum length of data to the USART send FIFO.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
[in] | buffer_ptr | data buffer |
[in] | count | maximum number of writes |
|
extern |
Request a DMA receive operation through the USART.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
[in] | buffer_ptr | Pointer to the receive buffer |
[in] | count | Number of bytes to receive |
|
extern |
Request a DMA transmit operation through the USART.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
[in] | buffer_ptr | Pointer to the transmit buffer |
[in] | count | Number of bytes to transmit |
|
extern |
Cancel an ongoing USART receive operation.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Cancel an ongoing USART transmit operation.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Get the number of bytes received in the current or last USART operation.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Get the number of bytes transmitted in the current or last USART operation.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
|
extern |
Execute a control command on the USART instance.
[in] | usart_ptr | a pointer to structure vsf_usart_t |
[in] | ctrl | Control command from vsf_usart_ctrl_t enumeration |
[in,out] | param | Command-specific parameter (can be NULL depending on command) |