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
 USART instance structure Used for USART Multi Class support. More...
 

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 a USART instance.
 
fsm_rt_t vsf_usart_disable (vsf_usart_t *usart)
 Disable a 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)
 
uint_fast16_t vsf_usart_txfifo_write (vsf_usart_t *usart, void *buffer, uint_fast16_t count)
 
vsf_err_t vsf_usart_request_rx (vsf_usart_t *usart, void *buffer, uint_fast32_t count)
 Request a DMA receive operation through the USART.
 
vsf_err_t vsf_usart_request_tx (vsf_usart_t *usart, void *buffer, uint_fast32_t count)
 Request a DMA transmit operation through the USART.
 
vsf_err_t vsf_usart_cancel_rx (vsf_usart_t *usart)
 Cancel an ongoing USART receive operation.
 
vsf_err_t vsf_usart_cancel_tx (vsf_usart_t *usart)
 Cancel an ongoing USART transmit operation.
 
int_fast32_t vsf_usart_get_rx_count (vsf_usart_t *usart)
 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)
 Get the number of bytes transmitted in the current or last USART operation.
 

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
USART instance structure Used for USART Multi Class support.
Definition vsf_template_usart.h:775
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_ptrPointer to USART instance
[in]cfg_ptrPointer to USART configuration
Returns
vsf_err_t VSF_ERR_NONE if successful, otherwise an error code
Note
This function must be called before using any other USART functions

calculate baudrate

◆ vsf_usart_enable()

fsm_rt_t vsf_usart_enable ( vsf_usart_t usart_ptr)

Enable a USART instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
fsm_rt_t: fsm_rt_cpl if USART was enabled, fsm_rt_on_going if USART is still enabling

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 a USART instance.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
fsm_rt_t: fsm_rt_cpl if USART was disabled, fsm_rt_on_going if USART is still disabling

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 values 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 values of enum 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,
void *  buffer,
uint_fast16_t  count 
)

◆ vsf_usart_txfifo_write()

uint_fast16_t vsf_usart_txfifo_write ( vsf_usart_t usart,
void *  buffer,
uint_fast16_t  count 
)

◆ vsf_usart_request_rx()

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.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]buffer_ptrPointer to the receive buffer
[in]countNumber of bytes to receive
Returns
vsf_err_t: VSF_ERR_NONE if the receive request was successfully started, otherwise returns error code
Note
This is an asynchronous operation

◆ vsf_usart_request_tx()

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.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
[in]buffer_ptrPointer to the transmit buffer
[in]countNumber of bytes to transmit
Returns
vsf_err_t: VSF_ERR_NONE if the transmit request was successfully started, otherwise returns error code
Note
This is an asynchronous operation

◆ vsf_usart_cancel_rx()

vsf_err_t vsf_usart_cancel_rx ( vsf_usart_t usart_ptr)

Cancel an ongoing USART receive operation.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
vsf_err_t: VSF_ERR_NONE if the receive operation was successfully cancelled, otherwise returns error code

◆ vsf_usart_cancel_tx()

vsf_err_t vsf_usart_cancel_tx ( vsf_usart_t usart_ptr)

Cancel an ongoing USART transmit operation.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
vsf_err_t: VSF_ERR_NONE if the transmit operation was successfully cancelled, otherwise returns error code

◆ vsf_usart_get_rx_count()

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.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
int_fast32_t: Number of received bytes, negative value for error

◆ vsf_usart_get_tx_count()

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.

Parameters
[in]usart_ptra pointer to structure vsf_usart_t
Returns
int_fast32_t: Number of transmitted bytes, negative value for error
Generated from commit: vsfteam/vsf@2b286be