VSF Documented
Macros | Functions
usart_common.c File Reference
#include "hal/driver/driver.h"

Macros

#define VSF_USART_CFG_FUNCTION_RENAME   DISABLED
 

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 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.
 

Macro Definition Documentation

◆ VSF_USART_CFG_FUNCTION_RENAME

#define VSF_USART_CFG_FUNCTION_RENAME   DISABLED

Function Documentation

◆ vsf_usart_init()

vsf_err_t vsf_usart_init ( vsf_usart_t usart_ptr,
vsf_usart_cfg_t cfg_ptr 
)

initialize a usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]cfg_ptra pointer to structure vsf_usart_cfg_t
Returns
vsf_err_t: VSF_ERR_NONE if usart was initialized, or a negative error code
Note
It is not necessary to call vsf_usart_fini() to deinitialization. vsf_usart_init() should be called before any other usart API except vsf_usart_capability().

◆ vsf_usart_fini()

void vsf_usart_fini ( vsf_usart_t usart_ptr)

finalize a usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
none

◆ vsf_usart_enable()

fsm_rt_t vsf_usart_enable ( vsf_usart_t usart_ptr)

enable interrupt masks of usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
none.

◆ vsf_usart_disable()

fsm_rt_t vsf_usart_disable ( vsf_usart_t usart_ptr)

disable interrupt masks of usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
none.

◆ vsf_usart_irq_enable()

void vsf_usart_irq_enable ( vsf_usart_t usart_ptr,
vsf_usart_irq_mask_t  irq_mask 
)

enable interrupt masks of usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]irq_maskone or more value of enum vsf_usart_irq_mask_t
Returns
none.
Note
All pending interrupts should be cleared before interrupts are enabled.

◆ vsf_usart_irq_disable()

void vsf_usart_irq_disable ( vsf_usart_t usart_ptr,
vsf_usart_irq_mask_t  irq_mask 
)

disable interrupt masks of usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]irq_maskone or more value of enum vsf_usart_irq_mask_t, vsf_usart_irq_mask_t
Returns
none.

◆ vsf_usart_status()

vsf_usart_status_t vsf_usart_status ( vsf_usart_t usart_ptr)

get the status of usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
vsf_usart_status_t: return all status of current usart

◆ vsf_usart_capability()

vsf_usart_capability_t vsf_usart_capability ( vsf_usart_t usart_ptr)

get the capability of usart instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
vsf_usart_capability_t: return all capability of current usart vsf_usart_capability_t

◆ vsf_usart_rxfifo_get_data_count()

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

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
uint_fast16_t: return the number of data currently in the usart receive queue.

◆ vsf_usart_rxfifo_read()

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

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]buffer_ptrdata buffer
[in]countmaximum number of reads
Returns
uint_fast16_t: return the actual number of reads from the current usart receive fifo

◆ vsf_usart_txfifo_get_free_count()

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

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
uint_fast16_t: return the maximum number of data that can be sent from the current usart send fifo
Note
Some usart has no fifo, or has fifo but can't get the number of fifo, can return 1~2
  1. The data register is empty, but the shift register is not empty
  2. Both data register and shift register are empty

◆ vsf_usart_txfifo_write()

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

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]buffer_ptrdata buffer
[in]countmaximum number of writes
Returns
uint_fast16_t: return the actual number of writes to the current usart send queue

◆ vsf_usart_request_rx()

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

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]buffer_ptrdata buffer
[in]countnumber of requested data
Returns
vsf_err_t: VSF_ERR_NONE if the usart request was successfully, or a negative error code

◆ vsf_usart_request_tx()

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

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]buffer_ptrdata buffer
[in]countnumber of requested data
Returns
vsf_err_t: VSF_ERR_NONE if the usart request was successfully, or a negative error code
Note
: The request interface is usually implemented via DMA.

◆ vsf_usart_cancel_rx()

vsf_err_t vsf_usart_cancel_rx ( vsf_usart_t usart_ptr)

cancel current current receive request

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
vsf_err_t: VSF_ERR_NONE if the usart request was successfully, or a negative error code
Note
: The request interface is usually implemented via DMA.

◆ vsf_usart_cancel_tx()

vsf_err_t vsf_usart_cancel_tx ( vsf_usart_t usart_ptr)

cancel current send request

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
vsf_err_t: VSF_ERR_NONE if the usart request was successfully, or a negative error code

◆ vsf_usart_get_rx_count()

int_fast32_t vsf_usart_get_rx_count ( vsf_usart_t usart_ptr)

get the number of current receive requests that have been received

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
int_fast32_t: number already received
Note
: only valid until the current receive request is completed.

◆ vsf_usart_get_tx_count()

int_fast32_t vsf_usart_get_tx_count ( vsf_usart_t usart_ptr)

get the number of current send requests that have been sended

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
int_fast32_t: number already send
Note
: only valid until the current send request is completed.

◆ vsf_usart_cmd()

vsf_err_t vsf_usart_cmd ( vsf_usart_t usart_ptr,
vsf_usart_cmd_t  cmd,
void *  param 
)

Calls the specified usart command.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]cmdusart command vsf_usart_cmd_t.
[in]paramthe parameter of the command, its use is determined by the command
Returns
vsf_err_t: returns the result of the usart command when it is invoked, success returns VSF_ERR_NONE