VSF Documented
usart.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2022 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*============================ INCLUDES ======================================*/
19
20#ifndef __HAL_DRIVER_NUVOTON_M480_USART_H__
21#define __HAL_DRIVER_NUVOTON_M480_USART_H__
22
23#include "hal/vsf_hal_cfg.h"
24#include "../../__device.h"
25
26#if VSF_HAL_USE_USART == ENABLED
27
28/*============================ MACROS ========================================*/
29
30/* select from { HXT, LXT, PLL, HIRC} */
31#ifndef VSF_CFG_USART_CLOCK_SOURCE
32# define VSF_CFG_USART_CLOCK_SOURCE HXT
33#endif
34
35#define VSF_USART_CFG_REIMPLEMENT_TYPE_MODE ENABLED
36#define VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK ENABLED
37#define VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS ENABLED
38
39/*============================ MACROFIED FUNCTIONS ===========================*/
40/*============================ TYPES =========================================*/
41
42typedef enum vsf_usart_mode_t {
51
53 VSF_USART_1_5_STOPBIT = 0x100ul,
55 VSF_USART_2_STOPBIT = 0x100ul,
60 USART_NONE_PARITY = 0x00000ul,
63 USART_MARK_PARITY = 0x50000ul,
64 USART_SPACE_PARITY = 0x70000ul,
70
71 USART_1_BIT_FIFO = 0x00000000ul,
72 USART_4_BIT_FIFO = 0x01000000ul,
73 USART_8_BIT_FIFO = 0x02000000ul,
74 USART_14_BIT_FIFO = 0x03000000ul,
79
80 USART_TX_INVERTED = 0x04000000ul,
81 USART_RX_INVERTED = 0x08000000ul,
85
91
92 // optional
96
97 //todo: add rx timeout support
99
107
108typedef struct vsf_usart_status_t {
116
117/*============================ INCLUDES ======================================*/
118
119#define VSF_USART_CFG_DEC_PREFIX vsf_hw
120#define VSF_USART_CFG_DEC_UPCASE_PREFIX VSF_HW
122
123/*============================ TYPES =========================================*/
124/*============================ GLOBAL VARIABLES ==============================*/
125/*============================ INCLUDES ======================================*/
126/*============================ PROTOTYPES ====================================*/
127/*============================ IMPLEMENTATION ================================*/
128
129#endif /* VSF_HAL_USE_USART == ENABLED */
130#endif /* __HAL_DRIVER_NUVOTON_M480_USART_H__ */
131/* EOF */
#define VSF_BIT(__N)
Definition __type.h:188
vsf_usart_mode_t
Definition uart.h:32
vsf_usart_irq_mask_t
Definition uart.h:105
vsf_usart_mode_t
Definition usart.h:42
@ USART_FIFO_SIZE
Definition usart.h:75
@ VSF_USART_8_BIT_LENGTH
Definition usart.h:43
@ USART_NONE_PARITY
Definition usart.h:60
@ USART_SPACE_PARITY
Definition usart.h:64
@ VSF_USART_EVEN_PARITY
Definition usart.h:62
@ VSF_USART_ODD_PARITY
Definition usart.h:61
@ USART_TX_INVERTED
Definition usart.h:80
@ USART_8_BIT_FIFO
Definition usart.h:73
@ USART_PARITY
Definition usart.h:65
@ USART_14_BIT_FIFO
Definition usart.h:74
@ USART_RX_INVERTED
Definition usart.h:81
@ USART_MARK_PARITY
Definition usart.h:63
@ VSF_USART_7_BIT_LENGTH
Definition usart.h:44
@ VSF_USART_1_STOPBIT
Definition usart.h:52
@ USART_1_BIT_FIFO
Definition usart.h:71
@ VSF_USART_2_STOPBIT
Definition usart.h:55
@ VSF_USART_5_BIT_LENGTH
Definition usart.h:46
@ USART_BIT_LENGTH
Definition usart.h:47
@ USART_TX_RX_INVERTED
Definition usart.h:82
@ USART_STOPBIT
Definition usart.h:57
@ VSF_USART_6_BIT_LENGTH
Definition usart.h:45
@ USART_4_BIT_FIFO
Definition usart.h:72
@ VSF_USART_1_5_STOPBIT
Definition usart.h:53
vsf_usart_irq_mask_t
Definition usart.h:86
@ VSF_USART_IRQ_MASK_TX_ERROR
Definition usart.h:94
@ VSF_USART_IRQ_MASK_TX_CPL
Definition usart.h:90
@ VSF_USART_IRQ_MASK_TX
Definition usart.h:88
@ VSF_USART_IRQ_MASK_RX
Definition usart.h:87
@ VSF_USART_IRQ_MASK_ERROR
Definition usart.h:95
@ VSF_USART_IRQ_MASK_RX_TIMEOUT
Definition usart.h:98
@ VSF_USART_IRQ_ALL_BITS_MASK
Definition usart.h:100
@ VSF_USART_IRQ_MASK_RX_CPL
Definition usart.h:89
@ VSF_USART_IRQ_MASK_RX_ERROR
Definition usart.h:93
struct vsf_usart_status_t vsf_usart_status_t
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition uart.h:156
uint8_t is_busy
Definition usart.h:109
uint8_t rx_cancel
Definition usart.h:112
uint32_t more_status
Definition usart.h:114
uint8_t tx_cancel
Definition usart.h:113
uint8_t rx_error_detected
Definition usart.h:110
uint8_t tx_error_detected
Definition usart.h:111