|
#define | VSF_USART_CFG_MULTI_CLASS ENABLED |
|
#define | VSF_USART_CFG_PREFIX vsf |
|
#define | VSF_USART_CFG_FUNCTION_RENAME ENABLED |
|
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_MODE DISABLED |
|
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED |
|
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS DISABLED |
|
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_CMD DISABLED |
|
#define | VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS DISABLED |
|
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_CFG DISABLED |
|
#define | VSF_USART_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED |
|
#define | VSF_USART_CFG_INHERT_HAL_CAPABILITY ENABLED |
|
#define | VSF_USART_CFG_REQUEST_API ENABLED |
|
#define | VSF_USART_CFG_FIFO_API ENABLED |
|
#define | __VSF_USART_BASE_APIS(__prefix_name) |
|
#define | __VSF_USART_FIFO_APIS(__prefix_name) |
|
#define | __VSF_USART_REQUEST_APIS(__prefix_name) |
|
#define | __VSF_USART_REQUEST_EXTRA_APIS(__prefix_name) __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, usart, cmd, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, vsf_usart_cmd_t cmd, void* param) |
|
#define | VSF_USART_ADDITIONAL_APIS(__prefix_name) |
|
#define | VSF_USART_APIS(__prefix_name) |
|
#define | __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP |
|
#define | __vsf_usart_t VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_t) |
|
#define | vsf_usart_init(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_init) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_fini(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_fini) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_capability(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_capability) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_enable(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_enable) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_disable(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_disable) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_irq_enable(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_irq_enable) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_irq_disable(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_irq_disable) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_status(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_status) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_rxfifo_get_data_count(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_rxfifo_get_data_count) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_rxfifo_read(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_rxfifo_read) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_txfifo_get_free_count(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_txfifo_get_free_count) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_txfifo_write(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_txfifo_write) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_request_rx(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_request_rx) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_request_tx(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_request_tx) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
#define | vsf_usart_cancel_rx(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_cancel_rx) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_cancel_tx(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_cancel_tx) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_get_rx_count(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_get_rx_count) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_get_tx_count(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_get_tx_count) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_send_break(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_send_break) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_set_break(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_send_break) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_clear_break(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_send_break) ((__vsf_usart_t *)(__USART)) |
|
#define | vsf_usart_cmd(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_cmd) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__) |
|
|
enum | vsf_usart_mode_t {
VSF_USART_NO_PARITY = (0x0ul << 0)
,
VSF_USART_EVEN_PARITY = (0x1ul << 0)
,
VSF_USART_ODD_PARITY = (0x2ul << 0)
,
VSF_USART_FORCE_0_PARITY = (0x3ul << 0)
,
VSF_USART_FORCE_1_PARITY = (0x4ul << 0)
,
VSF_USART_1_STOPBIT = (0x0ul << 3)
,
VSF_USART_1_5_STOPBIT = (0x1ul << 3)
,
VSF_USART_0_5_STOPBIT = (0x2ul << 3)
,
VSF_USART_2_STOPBIT = (0x3ul << 3)
,
VSF_USART_5_BIT_LENGTH = (0x0ul << 5)
,
VSF_USART_6_BIT_LENGTH = (0x1ul << 5)
,
VSF_USART_7_BIT_LENGTH = (0x2ul << 5)
,
VSF_USART_8_BIT_LENGTH = (0x3ul << 5)
,
VSF_USART_9_BIT_LENGTH = (0x4ul << 5)
,
VSF_USART_10_BIT_LENGTH = (0x5ul << 5)
,
VSF_USART_NO_HWCONTROL = (0x0ul << 8)
,
VSF_USART_RTS_HWCONTROL = (0x1ul << 8)
,
VSF_USART_CTS_HWCONTROL = (0x2ul << 8)
,
VSF_USART_RTS_CTS_HWCONTROL = (0x3ul << 8)
,
VSF_USART_TX_ENABLE = (0x0ul << 9)
,
VSF_USART_TX_DISABLE = (0x1ul << 9)
,
VSF_USART_RX_ENABLE = (0x0ul << 10)
,
VSF_USART_RX_DISABLE = (0x1ul << 10)
,
VSF_USART_SYNC_CLOCK_ENABLE = (0x0ul << 11)
,
VSF_USART_SYNC_CLOCK_DISABLE = (0x1ul << 11)
,
VSF_USART_SYNC_CLOCK_POLARITY_LOW = (0x0ul << 12)
,
VSF_USART_SYNC_CLOCK_POLARITY_HIGH = (0x1ul << 12)
,
VSF_USART_SYNC_CLOCK_PHASE_1_EDGE = (0x0ul << 13)
,
VSF_USART_SYNC_CLOCK_PHASE_2_EDGE = (0x1ul << 13)
,
VSF_USART_HALF_DUPLEX_DISABLE = (0x0ul << 14)
,
VSF_USART_HALF_DUPLEX_ENABLE = (0x1ul << 14)
,
VSF_USART_TX_FIFO_THRESHOLD_EMPTY = (0x0ul << 15)
,
VSF_USART_TX_FIFO_THRESHOLD_HALF_EMPTY = (0x1ul << 15)
,
VSF_USART_TX_FIFO_THRESHOLD_NOT_FULL = (0x2ul << 15)
,
VSF_USART_RX_FIFO_THRESHOLD_NOT_EMPTY = (0x0ul << 17)
,
VSF_USART_RX_FIFO_THRESHOLD_HALF_FULL = (0x1ul << 17)
,
VSF_USART_RX_FIFO_THRESHOLD_FULL = (0x2ul << 17)
} |
| Predefined VSF USART modes that can be reimplemented in specific hal drivers. More...
|
|
enum | {
VSF_USART_PARITY_MASK
,
VSF_USART_STOPBIT_MASK
,
VSF_USART_BIT_LENGTH_MASK
,
VSF_USART_TX_FIFO_THRESHOLD_MASK
,
VSF_USART_RX_FIFO_THRESHOLD_MASK
,
VSF_USART_HWCONTROL_MASK
,
VSF_USART_TX_MASK
,
VSF_USART_RX_MASK
,
VSF_USART_SYNC_CLOCK_MASK
,
VSF_USART_HALF_DUPLEX_MASK
,
VSF_USART_SYNC_CLOCK_POLARITY_MASK
,
VSF_USART_SYNC_CLOCK_PHASE_MASK
,
VSF_USART_MODE_ALL_BITS_MASK
} |
|
enum | vsf_usart_irq_mask_t {
VSF_USART_IRQ_MASK_TX_CPL = (0x1ul << 0)
,
VSF_USART_IRQ_MASK_RX_CPL = (0x1ul << 1)
,
VSF_USART_IRQ_MASK_TX = (0x1ul << 2)
,
VSF_USART_IRQ_MASK_RX = (0x1ul << 3)
,
VSF_USART_IRQ_MASK_RX_TIMEOUT = (0x1ul << 4)
,
VSF_USART_IRQ_MASK_CTS = (0x1ul << 5)
,
VSF_USART_IRQ_MASK_FRAME_ERR = (0x1ul << 6)
,
VSF_USART_IRQ_MASK_PARITY_ERR = (0x1ul << 7)
,
VSF_USART_IRQ_MASK_BREAK_ERR = (0x1ul << 8)
,
VSF_USART_IRQ_MASK_OVERFLOW_ERR = (0x1ul << 9)
} |
| Predefined VSF USART interrupt that can be reimplemented in specific hal drivers. More...
|
|
enum | {
VSF_USART_IRQ_MASK_RX_IDLE = VSF_USART_IRQ_MASK_RX_TIMEOUT
,
VSF_USART_IRQ_MASK_TX_FIFO_THRESHOLD = VSF_USART_IRQ_MASK_TX
,
VSF_USART_IRQ_MASK_RX_FIFO_THRESHOLD = VSF_USART_IRQ_MASK_RX
,
VSF_USART_IRQ_MASK_ERR
,
VSF_USART_IRQ_ALL_BITS_MASK
} |
|
enum | vsf_usart_cmd_t {
VSF_USART_CMD_SEND_BREAK = (0x01ul << 0)
,
VSF_USART_CMD_SET_BREAK = (0x01ul << 1)
,
VSF_USART_CMD_CLEAR_BREAK = (0x01ul << 2)
} |
| Predefined VSF USART command that can be reimplemented in specific hal drivers. More...
|
|
|
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 interrupt masks of usart instance.
|
|
fsm_rt_t | vsf_usart_disable (vsf_usart_t *usart_ptr) |
| disable interrupt masks of 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_fast16_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_fast16_t | vsf_usart_rxfifo_read (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast16_t count) |
| try to read the maximum length of data from the usart receive fifo
|
|
uint_fast16_t | vsf_usart_txfifo_get_free_count (vsf_usart_t *usart_ptr) |
| try to get the maximum number of data that can be sent from the usart send fifo
|
|
uint_fast16_t | vsf_usart_txfifo_write (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast16_t count) |
| try to write the maximum length of data from the usart send fifo
|
|
vsf_err_t | vsf_usart_request_rx (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) |
| usart request to receive data of specified length
|
|
vsf_err_t | vsf_usart_request_tx (vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) |
| usart request to send data of specified length
|
|
vsf_err_t | vsf_usart_cancel_rx (vsf_usart_t *usart_ptr) |
| cancel current current receive request
|
|
vsf_err_t | vsf_usart_cancel_tx (vsf_usart_t *usart_ptr) |
| cancel current send request
|
|
int_fast32_t | vsf_usart_get_rx_count (vsf_usart_t *usart_ptr) |
| get the number of current receive requests that have been received
|
|
int_fast32_t | vsf_usart_get_tx_count (vsf_usart_t *usart_ptr) |
| get the number of current send requests that have been sended
|
|
vsf_err_t | vsf_usart_cmd (vsf_usart_t *usart_ptr, vsf_usart_cmd_t cmd, void *param) |
| Calls the specified usart command.
|
|
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, Adding the new TX FIFO Threshold option requires that the macro VSF_USART_TX_FIFO_THRESHOLD_MASK be defined. Adding the new parity check option requires the macro VSF_USART_PARITY_MASK be defined. Adding the new stop bit option requires the macro of VSF_USART_BIT_LENGTH_MASK be defined.
Optional features 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 switch to different modes at compile-time.
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, Adding the new TX FIFO Threshold option requires that the macro VSF_USART_TX_FIFO_THRESHOLD_MASK be defined. Adding the new parity check option requires the macro VSF_USART_PARITY_MASK be defined. Adding the new stop bit option requires the macro of VSF_USART_BIT_LENGTH_MASK be defined.
Optional features 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 switch to different modes at compile-time.
Enumerator |
---|
VSF_USART_NO_PARITY | USART Parity.
|
VSF_USART_EVEN_PARITY | |
VSF_USART_ODD_PARITY | |
VSF_USART_FORCE_0_PARITY | |
VSF_USART_FORCE_1_PARITY | |
VSF_USART_1_STOPBIT | USART Stopbit.
stopbit: 1 bit
|
VSF_USART_1_5_STOPBIT | stopbit: 1.5 bit
|
VSF_USART_0_5_STOPBIT | stopbit: 0.5 bit
|
VSF_USART_2_STOPBIT | stopbit: 2 bit
|
VSF_USART_5_BIT_LENGTH | USART Databit Lenght.
data bits : 5,
|
VSF_USART_6_BIT_LENGTH | data bits : 6,
|
VSF_USART_7_BIT_LENGTH | data bits : 7,
|
VSF_USART_8_BIT_LENGTH | data bits : 8,
|
VSF_USART_9_BIT_LENGTH | data bits : 9,
|
VSF_USART_10_BIT_LENGTH | data bits : 10,
|
VSF_USART_NO_HWCONTROL | USART Hardware Control.
|
VSF_USART_RTS_HWCONTROL | |
VSF_USART_CTS_HWCONTROL | |
VSF_USART_RTS_CTS_HWCONTROL | |
VSF_USART_TX_ENABLE | |
VSF_USART_TX_DISABLE | |
VSF_USART_RX_ENABLE | |
VSF_USART_RX_DISABLE | |
VSF_USART_SYNC_CLOCK_ENABLE | |
VSF_USART_SYNC_CLOCK_DISABLE | |
VSF_USART_SYNC_CLOCK_POLARITY_LOW | USART SYNC Mode Clock.
|
VSF_USART_SYNC_CLOCK_POLARITY_HIGH | |
VSF_USART_SYNC_CLOCK_PHASE_1_EDGE | |
VSF_USART_SYNC_CLOCK_PHASE_2_EDGE | |
VSF_USART_HALF_DUPLEX_DISABLE | |
VSF_USART_HALF_DUPLEX_ENABLE | |
VSF_USART_TX_FIFO_THRESHOLD_EMPTY | TX FIFO becomes emtpy.
As generic options for tx/RX FIFO threshold, only three modes are defined here. More options for thresholds can be defined in the specific driver.
|
VSF_USART_TX_FIFO_THRESHOLD_HALF_EMPTY | TX FIFO becomes half emtpy
|
VSF_USART_TX_FIFO_THRESHOLD_NOT_FULL | TX FIFO maximum non-full threshold value, it can send at least one data. If the TX FIFO threshold cannot be set to the fifo maximum minus 1, then we can use the tx not full interrupt to accomplish this.
|
VSF_USART_RX_FIFO_THRESHOLD_NOT_EMPTY | RX FIFO Minimum non-empty threshold, which should contain at least one data. If the threshold value of RX FIFO cannot be set to 1, then we can use the RX FIFO not empty interrupt to accomplish this.
|
VSF_USART_RX_FIFO_THRESHOLD_HALF_FULL | Half of the threshold for RX FIFO.
|
VSF_USART_RX_FIFO_THRESHOLD_FULL | Full of the threshold for RX FIFO.
|