VSF Documented
vsf_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#ifndef __VSF_USART_H__
19#define __VSF_USART_H__
20
21#include "hal/vsf_hal_cfg.h"
22
23#if VSF_HAL_USE_USART == ENABLED
24#include "../../__device.h"
26
28 USART1_CLK_EN = 0x04000U,
29 USART2_CLK_EN = 0x20000U,
30 USART3_CLK_EN = 0x40000U,
31
32 GPIOA_CLK_EN = 0X00004U,
33 GPIOB_CLK_EN = 0X00008U,
34};
35
38 USART1_GPIO_MODE = 0x000008B0U,
39
41 USART2_GPIO_MODE = 0x00008B00U,
42
44 USART3_GPIO_MODE = 0x00008B00U,
45};
46
48
51
54
58
63
64 USART_RX_MODE = 0x0004U,
65 USART_TX_MODE = 0x0008U,
66 USART_TX_RX_MODE = 0x000CU
67};
68
70 USART_EN = 0x2000U,
71 USART_DISEN = 0xDFFFU,
72
77
82};
83
84struct vsf_usart_status_t {
85 union {
87 struct {
88 uint32_t ip_is_busy : 1;
89 uint32_t bw_is_busy : 1;
90 uint32_t br_is_busy : 1;
91 uint32_t event_status : 8;
92 uint32_t : 21;
93 };
94 };
95};
96
97struct vsf_usart_t {
98 USART_TypeDef *reg_ptr;
100 //pm_periph_async_clk_no_t pclk_idx;
101 //pm_sync_clk_no_t sync_clk_idx;
110 vsf_usart_event_t event_rx;
111 vsf_usart_event_t event_tx;
112 vsf_usart_event_t event_rcv;
113 vsf_usart_event_t event_send;
115 usart_event_status_t event_mask;
116};
117
118#endif
119
120#endif
vsf_usart_mode_t
Definition uart.h:32
em_gpio_reg_rw_t
Definition uart.c:60
em_clk_reg_rw_t
Definition uart.c:51
enum IRQn IRQn_Type
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_hal_driver.h:196
Definition uart.h:156
Definition vsf_template_usart.h:661
uint32_t read_sizecounter
Definition vsf_usart.h:107
uint32_t write_sizecounter
Definition vsf_usart.h:106
vsf_usart_event_t event_tx
Definition vsf_usart.h:111
uint32_t read_size
Definition vsf_usart.h:105
bool is_loading
Definition vsf_usart.h:109
uint32_t write_size
Definition vsf_usart.h:104
bool is_writing
Definition vsf_usart.h:108
vsf_usart_event_t event_send
Definition vsf_usart.h:113
usart_event_status_t event_mask
Definition vsf_usart.h:115
uint8_t * read_buffer_ptr
Definition vsf_usart.h:103
vsf_usart_event_t event_rcv
Definition vsf_usart.h:112
uint8_t * write_buffer_ptr
Definition vsf_usart.h:102
USART_TypeDef * reg_ptr
Definition vsf_usart.h:98
vsf_usart_status_t event_status
Definition vsf_usart.h:114
IRQn_Type USART_IRQn
Definition vsf_usart.h:99
vsf_usart_event_t event_rx
Definition vsf_usart.h:110
@ VSF_USART_8_BIT_LENGTH
Definition vsf_usart.h:49
@ VSF_USART_EVEN_PARITY
Definition vsf_usart.h:56
@ VSF_USART_ODD_PARITY
Definition vsf_usart.h:57
@ VSF_USART_NO_PARITY
Definition vsf_usart.h:55
@ VSF_USART_RTS_HWCONTROL
Definition vsf_usart.h:60
@ USART_TX_RX_MODE
Definition vsf_usart.h:66
@ VSF_USART_9_BIT_LENGTH
Definition vsf_usart.h:50
@ VSF_USART_1_STOPBIT
Definition vsf_usart.h:52
@ USART_TX_MODE
Definition vsf_usart.h:65
@ VSF_USART_2_STOPBIT
Definition vsf_usart.h:53
@ VSF_USART_CTS_HWCONTROL
Definition vsf_usart.h:61
@ USART_RX_MODE
Definition vsf_usart.h:64
@ VSF_USART_RTS_CTS_HWCONTROL
Definition vsf_usart.h:62
@ VSF_USART_NO_HWCONTROL
Definition vsf_usart.h:59
@ USART1_GPIO_MODE_CLEAR
Definition vsf_usart.h:37
@ USART2_GPIO_MODE
Definition vsf_usart.h:41
@ USART1_GPIO_MODE
Definition vsf_usart.h:38
@ USART3_GPIO_MODE
Definition vsf_usart.h:44
@ USART3_GPIO_MODE_CLEAR
Definition vsf_usart.h:43
@ USART2_GPIO_MODE_CLEAR
Definition vsf_usart.h:40
@ GPIOA_CLK_EN
Definition vsf_usart.h:32
@ USART2_CLK_EN
Definition vsf_usart.h:29
@ USART1_CLK_EN
Definition vsf_usart.h:28
@ GPIOB_CLK_EN
Definition vsf_usart.h:33
@ USART3_CLK_EN
Definition vsf_usart.h:30
em_usart_reg_rw_t
Definition vsf_usart.h:69
@ USART_SR_RXNE_FULL
Definition vsf_usart.h:74
@ USART_EN
Definition vsf_usart.h:70
@ USART_CR1_RXNEIE_DISEN
Definition vsf_usart.h:81
@ USART_DISEN
Definition vsf_usart.h:71
@ USART_SR_TXE_TRUE
Definition vsf_usart.h:76
@ USART_CR1_RXNEIE_EN
Definition vsf_usart.h:80
@ USART_CR1_TXEIE_EN
Definition vsf_usart.h:78
@ USART_SR_IDLE_FREE
Definition vsf_usart.h:73
@ USART_CR1_TXEIE_DISEN
Definition vsf_usart.h:79
@ USART_SR_TC_TRUE
Definition vsf_usart.h:75