VSF Documented
Data Structures | Macros | Typedefs | Functions
usart.c File Reference
#include "utilities/vsf_utilities.h"
#include "./usart.h"

Data Structures

struct  vsf_usart_ip_t
 
struct  vsf_usart_t
 

Macros

#define __VSF_USART_CLASS_IMPLEMENT
 
#define ____USART_LV0_IMPL(__N, __DONT_CARE)
 
#define __USART_LV0_IMPL(__N, __DONT_CARE)    ____USART_LV0_IMPL(__N, __DONT_CARE)
 

Typedefs

typedef struct vsf_usart_ip_t vsf_usart_ip_t
 

Functions

vsf_err_t vsf_usart_init (vsf_usart_t *usart, vsf_usart_cfg_t *cfg)
 initialize a usart instance.
 
fsm_rt_t vsf_usart_enable (vsf_usart_t *usart)
 enable interrupt masks of usart instance.
 
fsm_rt_t vsf_usart_disable (vsf_usart_t *usart)
 disable interrupt masks of usart instance.
 
void vsf_usart_irq_enable (vsf_usart_t *usart, vsf_usart_irq_mask_t irq_mask)
 enable interrupt masks of usart instance.
 
void vsf_usart_irq_disable (vsf_usart_t *usart, vsf_usart_irq_mask_t irq_mask)
 disable interrupt masks of usart instance.
 
vsf_usart_status_t vsf_usart_status (vsf_usart_t *usart)
 get the status of usart instance.
 
uint_fast16_t vsf_usart_rxfifo_read (vsf_usart_t *usart, void *buffer, uint_fast16_t count)
 try to read the maximum length of data from the usart receive fifo
 
uint_fast16_t vsf_usart_txfifo_write (vsf_usart_t *usart, void *buffer, 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, void *buffer, uint_fast32_t count)
 usart request to receive data of specified length
 
vsf_err_t vsf_usart_request_tx (vsf_usart_t *usart, void *buffer, uint_fast32_t count)
 usart request to send data of specified length
 
vsf_err_t vsf_usart_cancel_rx (vsf_usart_t *usart)
 cancel current current receive request
 
vsf_err_t vsf_usart_cancel_tx (vsf_usart_t *usart)
 cancel current send request
 
int_fast32_t vsf_usart_get_rx_count (vsf_usart_t *usart)
 get the number of current receive requests that have been received
 
int_fast32_t vsf_usart_get_tx_count (vsf_usart_t *usart)
 get the number of current send requests that have been sended
 

Macro Definition Documentation

◆ __VSF_USART_CLASS_IMPLEMENT

#define __VSF_USART_CLASS_IMPLEMENT

◆ ____USART_LV0_IMPL

#define ____USART_LV0_IMPL (   __N,
  __DONT_CARE 
)
Value:
vsf_usart_t vsf_usart##__N = { \
.ip = { \
.reg = USART##__N, \
.irq = USART##__N##_IRQn, \
.pclk_idx = PCLK_USART##__N##_IDX, \
.sclk_idx = SCLK_USART##__N##_IDX, \
.tx_dma = USART##__N##_TX_DMA, \
.rx_dma = USART##__N##_RX_DMA, \
}, \
}; \
VSF_CAL_ROOT void USART##__N##_IRQHandler(void) \
{ \
__vsf_usart_irqhandler(&vsf_usart##__N); \
}
USART_TypeDef * reg
Definition usart.c:53
Definition vsf_template_usart.h:661
const vsf_usart_ip_t ip
Definition usart.c:64

◆ __USART_LV0_IMPL

#define __USART_LV0_IMPL (   __N,
  __DONT_CARE 
)     ____USART_LV0_IMPL(__N, __DONT_CARE)

Typedef Documentation

◆ vsf_usart_ip_t

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

calculate baudrate

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

don't forget to enable sync clock and peripheral_clk here

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

don't forget to disable sync clock and peripheral_clk here

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