VSF Documented
vsf_template_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_TEMPLATE_USART_H__
19#define __VSF_TEMPLATE_USART_H__
20
21/*============================ INCLUDES ======================================*/
22
24#include "hal/arch/vsf_arch.h"
25
26#ifdef __cplusplus
27extern "C" {
28#endif
29
30/*============================ MACROS ========================================*/
31
38#ifndef VSF_USART_CFG_MULTI_CLASS
39# define VSF_USART_CFG_MULTI_CLASS ENABLED
40#endif
41
50#if defined(VSF_HW_USART_COUNT) && !defined(VSF_HW_USART_MASK)
51# define VSF_HW_USART_MASK VSF_HAL_COUNT_TO_MASK(VSF_HW_USART_COUNT)
52#endif
53
62#if defined(VSF_HW_USART_MASK) && !defined(VSF_HW_USART_COUNT)
63# define VSF_HW_USART_COUNT VSF_HAL_MASK_TO_COUNT(VSF_HW_USART_MASK)
64#endif
65
83#ifndef VSF_USART_CFG_PREFIX
84# if VSF_USART_CFG_MULTI_CLASS == ENABLED
85# define VSF_USART_CFG_PREFIX vsf
86# elif defined(VSF_HW_USART_COUNT) && (VSF_HW_USART_COUNT != 0)
87# define VSF_USART_CFG_PREFIX vsf_hw
88# else
89# define VSF_USART_CFG_PREFIX vsf
90# endif
91#endif
92
101#ifndef VSF_USART_CFG_FUNCTION_RENAME
102# define VSF_USART_CFG_FUNCTION_RENAME ENABLED
103#endif
104
113#ifndef VSF_USART_CFG_REIMPLEMENT_TYPE_MODE
114# define VSF_USART_CFG_REIMPLEMENT_TYPE_MODE DISABLED
115#endif
116
125#ifndef VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK
126# define VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK DISABLED
127#endif
128
137#ifndef VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS
138# define VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS DISABLED
139#endif
140
149#ifndef VSF_USART_CFG_REIMPLEMENT_TYPE_CTRL
150# define VSF_USART_CFG_REIMPLEMENT_TYPE_CTRL DISABLED
151#endif
152
162#ifndef VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS
163# define VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS \
164 DISABLED
165#endif
166
176#if VSF_USART_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
177# define VSF_USART_CFG_REIMPLEMENT_TYPE_CFG DISABLED
178#endif
179
190#if VSF_USART_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
191# define VSF_USART_CFG_REIMPLEMENT_TYPE_CAPABILITY DISABLED
192#endif
193
202#if VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
203# define VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS DISABLED
204#endif
205
214#ifndef VSF_USART_CFG_INHERIT_HAL_CAPABILITY
215# define VSF_USART_CFG_INHERIT_HAL_CAPABILITY ENABLED
216#endif
217
218/*============================ MACROFIED FUNCTIONS ===========================*/
219
228#define VSF_USART_APIS(__prefix_name) \
229 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, usart, init, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, vsf_usart_cfg_t *cfg_ptr) \
230 __VSF_HAL_TEMPLATE_API(__prefix_name, void, usart, fini, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
231 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, usart, enable, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
232 __VSF_HAL_TEMPLATE_API(__prefix_name, fsm_rt_t, usart, disable, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
233 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_usart_capability_t, usart, capability, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
234 __VSF_HAL_TEMPLATE_API(__prefix_name, void, usart, irq_enable, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, vsf_usart_irq_mask_t irq_mask) \
235 __VSF_HAL_TEMPLATE_API(__prefix_name, void, usart, irq_disable, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, vsf_usart_irq_mask_t irq_mask) \
236 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_usart_status_t, usart, status, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
237 __VSF_HAL_TEMPLATE_API(__prefix_name, uint_fast32_t, usart, rxfifo_get_data_count, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
238 __VSF_HAL_TEMPLATE_API(__prefix_name, uint_fast32_t, usart, rxfifo_read, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, void *buffer_ptr, uint_fast32_t count) \
239 __VSF_HAL_TEMPLATE_API(__prefix_name, uint_fast32_t, usart, txfifo_get_free_count, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
240 __VSF_HAL_TEMPLATE_API(__prefix_name, uint_fast32_t, usart, txfifo_write, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, void *buffer_ptr, uint_fast32_t count) \
241 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, usart, request_rx, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, void *buffer_ptr, uint_fast32_t count) \
242 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, usart, request_tx, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, void *buffer_ptr, uint_fast32_t count) \
243 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, usart, cancel_rx, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
244 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, usart, cancel_tx, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
245 __VSF_HAL_TEMPLATE_API(__prefix_name, int_fast32_t, usart, get_rx_count, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
246 __VSF_HAL_TEMPLATE_API(__prefix_name, int_fast32_t, usart, get_tx_count, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
247 __VSF_HAL_TEMPLATE_API(__prefix_name, vsf_err_t, usart, ctrl, VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr, vsf_usart_ctrl_t ctrl, void* param)
248
249#define VSF_USART_ADDITIONAL_APIS(__prefix_name) \
250 static inline vsf_err_t VSF_MCONNECT(__prefix_name, _usart_send_break) \
251 (VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
252 { \
253 return VSF_MCONNECT(__prefix_name, _usart_ctrl)(usart_ptr, \
254 VSF_USART_CTRL_SEND_BREAK, NULL); \
255 } \
256 static inline vsf_err_t VSF_MCONNECT(__prefix_name, _usart_set_break) \
257 (VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
258 { \
259 vsf_usart_capability_t cap = \
260 VSF_MCONNECT(__prefix_name, _usart_capability)(usart_ptr); \
261 VSF_HAL_ASSERT(cap.support_set_and_clear_break); \
262 return VSF_MCONNECT(__prefix_name, _usart_ctrl)(usart_ptr, \
263 VSF_USART_CTRL_SET_BREAK, NULL); \
264 } \
265 static inline vsf_err_t VSF_MCONNECT(__prefix_name, _usart_clear_break) \
266 (VSF_MCONNECT(__prefix_name, _usart_t) *usart_ptr) \
267 { \
268 vsf_usart_capability_t cap = \
269 VSF_MCONNECT(__prefix_name, _usart_capability)(usart_ptr); \
270 VSF_HAL_ASSERT(cap.support_set_and_clear_break); \
271 return VSF_MCONNECT(__prefix_name, _usart_ctrl)(usart_ptr, \
272 VSF_USART_CTRL_CLEAR_BREAK, NULL); \
273 }
274
275/*============================ TYPES =========================================*/
276
277#if VSF_USART_CFG_REIMPLEMENT_TYPE_MODE == DISABLED
301typedef enum vsf_usart_mode_t {
308 VSF_USART_NO_PARITY = (0x0ul << 0),
309 VSF_USART_EVEN_PARITY = (0x1ul << 0),
310 VSF_USART_ODD_PARITY = (0x2ul << 0),
313
320 VSF_USART_1_STOPBIT = (0x0ul << 3),
321 VSF_USART_1_5_STOPBIT = (0x1ul << 3),
322 VSF_USART_0_5_STOPBIT = (0x2ul << 3),
323 VSF_USART_2_STOPBIT = (0x3ul << 3),
324
331 VSF_USART_5_BIT_LENGTH = (0x0ul << 5),
332 VSF_USART_6_BIT_LENGTH = (0x1ul << 5),
333 VSF_USART_7_BIT_LENGTH = (0x2ul << 5),
334 VSF_USART_8_BIT_LENGTH = (0x3ul << 5),
335 VSF_USART_9_BIT_LENGTH = (0x4ul << 5),
336 VSF_USART_10_BIT_LENGTH = (0x5ul << 5),
337
344 VSF_USART_NO_HWCONTROL = (0x0ul << 8),
345 VSF_USART_RTS_HWCONTROL = (0x1ul << 8),
346 VSF_USART_CTS_HWCONTROL = (0x2ul << 8),
348
355 VSF_USART_TX_ENABLE = (0x0ul << 9),
356 VSF_USART_TX_DISABLE = (0x1ul << 9),
357 VSF_USART_RX_ENABLE = (0x0ul << 10),
358 VSF_USART_RX_DISABLE = (0x1ul << 10),
359
368
377
389
402#endif
403
404enum {
405#ifndef VSF_USART_PARITY_MASK
411#endif
412
413#ifndef VSF_USART_STOPBIT_MASK
418#endif
419
420#ifndef VSF_USART_BIT_LENGTH_MASK
427#endif
428
429#ifndef VSF_USART_TX_FIFO_THRESHOLD_MASK
433#endif
434
435#ifndef VSF_USART_RX_FIFO_THRESHOLD_MASK
439#endif
440
441#ifndef VSF_USART_HWCONTROL_MASK
446#endif
447
450
453
456
459
470#ifdef VSF_USART_SYNC_CLOCK_LAST_BIT_MASK
472#endif
473
474#ifdef VSF_USART_IRDA_PRESCALER_MASK
475 | VSF_USART_IRDA_PRESCALER_MASK
476#endif
477#ifdef VSF_USART_IRDA_MASK
478 | VSF_USART_IRDA_MASK
479#endif
480
481#ifdef VSF_USART_SMARTCARD_MASK
482 | VSF_USART_SMARTCARD_MASK
483#endif
485
486#if VSF_USART_CFG_REIMPLEMENT_TYPE_IRQ_MASK == DISABLED
498 VSF_USART_IRQ_MASK_TX = (0x1ul << 2),
499 VSF_USART_IRQ_MASK_RX = (0x1ul << 3),
501 VSF_USART_IRQ_MASK_CTS = (0x1ul << 5),
507#endif
508
515enum {
519
520#ifndef VSF_USART_IRQ_MASK_ERR
525#endif
526
527#ifndef VSF_USART_IRQ_ALL_BITS_MASK
535# ifdef VSF_USART_IRQ_MASK_TX_HALF_CPL
536 | VSF_USART_IRQ_MASK_TX_HALF_CPL
537# endif
538# ifdef VSF_USART_IRQ_MASK_RX_HALF_CPL
539 | VSF_USART_IRQ_MASK_RX_HALF_CPL
540# endif
541# ifdef VSF_USART_IRQ_MASK_CANCEL_TX_CPL
542 | VSF_USART_IRQ_MASK_CANCEL_TX_CPL
543# endif
544# ifdef VSF_USART_IRQ_MASK_CANCEL_RX_CPL
545 | VSF_USART_IRQ_MASK_CANCEL_RX_CPL
546# endif
547#endif
548};
549
550#if VSF_USART_CFG_REIMPLEMENT_TYPE_CFG == DISABLED
558
602typedef void vsf_usart_isr_handler_t(void *target_ptr,
603 vsf_usart_t *usart_ptr,
605
614typedef struct vsf_usart_isr_t {
619
628typedef struct vsf_usart_cfg_t {
634#endif
635
636#if VSF_USART_CFG_REIMPLEMENT_TYPE_CTRL == DISABLED
645typedef enum vsf_usart_ctrl_t {
655
665
675
676 /*
677 VSF_USART_CTRL_REQUEST_RX_RESUME = (0x1ul << 3),
678 #define VSF_USART_CTRL_REQUEST_RX_RESUME VSF_USART_CTRL_REQUEST_RX_RESUME
679 VSF_USART_CTRL_REQUEST_TX_RESUME = (0x1ul << 4),
680 #define VSF_USART_CTRL_REQUEST_TX_RESUME VSF_USART_CTRL_REQUEST_TX_RESUME
681
682 VSF_USART_CTRL_REQUEST_RX_PAUSE = (0x1ul << 5),
683 #define VSF_USART_CTRL_REQUEST_RX_PAUSE VSF_USART_CTRL_REQUEST_RX_PAUSE
684 VSF_USART_CTRL_REQUEST_TX_PAUSE = (0x1ul << 6),
685 #define VSF_USART_CTRL_REQUEST_TX_PAUSE VSF_USART_CTRL_REQUEST_TX_PAUSE
686
687 VSF_USART_CTRL_HALF_DUPLEX_ENABLE_TRANSMITTER = (0x1ul << 7),
688 #define VSF_USART_CTRL_HALF_DUPLEX_ENABLE_TRANSMITTER VSF_USART_CTRL_HALF_DUPLEX_ENABLE_TRANSMITTER
689
690 VSF_USART_CTRL_HALF_DUPLEX_ENABLE_RECEIVER = (0x1ul << 8),
691 #define VSF_USART_CTRL_HALF_DUPLEX_ENABLE_RECEIVER VSF_USART_CTRL_HALF_DUPLEX_ENABLE_RECEIVER
692 */
694#endif
695
704#if VSF_USART_CFG_REIMPLEMENT_TYPE_STATUS == DISABLED
705typedef struct vsf_usart_status_t {
706 union {
709 struct {
715 };
716 };
718#endif
719
728#if VSF_USART_CFG_REIMPLEMENT_TYPE_CAPABILITY == DISABLED
730#if VSF_USART_CFG_INHERIT_HAL_CAPABILITY == ENABLED
732#endif
734
737
740
743
748#endif
757typedef struct vsf_usart_op_t {
759#undef __VSF_HAL_TEMPLATE_API
760#define __VSF_HAL_TEMPLATE_API VSF_HAL_TEMPLATE_API_FP
762
763 VSF_USART_APIS(vsf)
765
766#if VSF_USART_CFG_MULTI_CLASS == ENABLED
777};
778#endif
779
780/*============================ PROTOTYPES ====================================*/
781
799extern vsf_err_t vsf_usart_init(vsf_usart_t *usart_ptr, vsf_usart_cfg_t *cfg_ptr);
800
812extern void vsf_usart_fini(vsf_usart_t *usart_ptr);
813
825extern fsm_rt_t vsf_usart_enable(vsf_usart_t *usart_ptr);
826
838extern fsm_rt_t vsf_usart_disable(vsf_usart_t *usart_ptr);
839
856
871
884
897
910
926extern uint_fast32_t vsf_usart_rxfifo_read(vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count);
927
940
956extern uint_fast32_t vsf_usart_txfifo_write(vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count);
957
975extern vsf_err_t vsf_usart_request_rx(vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count);
976
994extern vsf_err_t vsf_usart_request_tx(vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count);
995
1007extern vsf_err_t vsf_usart_cancel_rx(vsf_usart_t *usart_ptr);
1008
1020extern vsf_err_t vsf_usart_cancel_tx(vsf_usart_t *usart_ptr);
1021
1034
1047
1065extern vsf_err_t vsf_usart_ctrl(vsf_usart_t *usart_ptr, vsf_usart_ctrl_t ctrl, void *param);
1066
1067/*============================ INLINE FUNCTIONS ==============================*/
1068
1069#if VSF_USART_CFG_REIMPLEMENT_MODE_TO_DATA_BITS == DISABLED
1080static inline uint8_t vsf_usart_mode_to_data_bits(vsf_usart_mode_t mode)
1081{
1082 switch (mode & VSF_USART_BIT_LENGTH_MASK) {
1084 return 5;
1086 return 6;
1088 return 7;
1090 return 8;
1092 return 9;
1094 return 10;
1095 default:
1096 return 0;
1097 }
1098}
1099#endif
1100
1113static inline vsf_err_t vsf_usart_send_break(vsf_usart_t *usart_ptr)
1114{
1117
1118 return vsf_usart_ctrl(usart_ptr, VSF_USART_CTRL_SEND_BREAK, NULL);
1119}
1120
1132static inline vsf_err_t vsf_usart_set_break(vsf_usart_t *usart_ptr)
1133{
1136
1137 return vsf_usart_ctrl(usart_ptr, VSF_USART_CTRL_SET_BREAK, NULL);
1138}
1139
1151static inline vsf_err_t vsf_usart_clear_break(vsf_usart_t *usart_ptr)
1152{
1155
1157}
1158
1159/*============================ MACROFIED FUNCTIONS ===========================*/
1160
1162#if VSF_USART_CFG_FUNCTION_RENAME == ENABLED
1163# define __vsf_usart_t VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_t)
1164# define vsf_usart_init(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_init) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1165# define vsf_usart_fini(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_fini) ((__vsf_usart_t *)(__USART))
1166# define vsf_usart_capability(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_capability) ((__vsf_usart_t *)(__USART))
1167# define vsf_usart_enable(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_enable) ((__vsf_usart_t *)(__USART))
1168# define vsf_usart_disable(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_disable) ((__vsf_usart_t *)(__USART))
1169# define vsf_usart_irq_enable(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_irq_enable) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1170# define vsf_usart_irq_disable(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_irq_disable) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1171# define vsf_usart_status(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_status) ((__vsf_usart_t *)(__USART))
1172# define vsf_usart_rxfifo_get_data_count(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_rxfifo_get_data_count) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1173# define vsf_usart_rxfifo_read(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_rxfifo_read) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1174# define vsf_usart_txfifo_get_free_count(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_txfifo_get_free_count) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1175# define vsf_usart_txfifo_write(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_txfifo_write) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1176# define vsf_usart_request_rx(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_request_rx) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1177# define vsf_usart_request_tx(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_request_tx) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1178# define vsf_usart_cancel_rx(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_cancel_rx) ((__vsf_usart_t *)(__USART))
1179# define vsf_usart_cancel_tx(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_cancel_tx) ((__vsf_usart_t *)(__USART))
1180# define vsf_usart_get_rx_count(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_get_rx_count) ((__vsf_usart_t *)(__USART))
1181# define vsf_usart_get_tx_count(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_get_tx_count) ((__vsf_usart_t *)(__USART))
1182# define vsf_usart_send_break(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_send_break) ((__vsf_usart_t *)(__USART))
1183# define vsf_usart_set_break(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_set_break) ((__vsf_usart_t *)(__USART))
1184# define vsf_usart_clear_break(__USART) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_clear_break) ((__vsf_usart_t *)(__USART))
1185# define vsf_usart_ctrl(__USART, ...) VSF_MCONNECT(VSF_USART_CFG_PREFIX, _usart_ctrl) ((__vsf_usart_t *)(__USART), ##__VA_ARGS__)
1186#endif
1188
1189/*============================ INCLUDES ======================================*/
1190
1191#ifdef __cplusplus
1192}
1193#endif
1194
1195#endif
vsf_err_t
Definition __type.h:42
vsf_usart_mode_t
Definition uart.h:32
vsf_usart_irq_mask_t
Definition uart.h:106
#define VSF_USART_SYNC_CLOCK_LAST_BIT_MASK
Definition usart.h:129
vsf_arch_prio_t
Definition cortex_a_generic.h:88
#define NULL
Definition lvgl.h:26
const i_spi_t vsf_spi_irq_mask_t irq_mask
Definition spi_interface.h:38
unsigned uint32_t
Definition stdint.h:9
unsigned int uint_fast32_t
Definition stdint.h:27
int int_fast32_t
Definition stdint.h:26
unsigned char uint8_t
Definition stdint.h:5
Definition vsf_template_hal_driver.h:203
Definition vsf_template_hal_driver.h:196
USART capability structure Defines the hardware capabilities and limitations of the USART interface.
Definition vsf_template_usart.h:729
uint8_t max_data_bits
Maximum data bits per frame.
Definition vsf_template_usart.h:741
uint8_t support_set_and_clear_break
Support set and clear break.
Definition vsf_template_usart.h:746
inherit(vsf_peripheral_capability_t) vsf_usart_irq_mask_t irq_mask
Supported interrupt mask bits.
vsf_usart_irq_mask_t irq_mask
Definition usart.h:256
uint8_t support_rx_timeout
Support receive timeout.
Definition vsf_template_usart.h:744
uint8_t rxfifo_depth
RX FIFO depth in data frames (0 means no FIFO)
Definition vsf_template_usart.h:739
uint8_t support_send_break
Support send break.
Definition vsf_template_usart.h:745
uint8_t txfifo_depth
TX FIFO depth in data frames (0 means no FIFO)
Definition vsf_template_usart.h:738
uint8_t min_data_bits
Minimum data bits per frame.
Definition vsf_template_usart.h:742
uint32_t min_baudrate
Minimum supported baudrate (bps)
Definition vsf_template_usart.h:736
uint32_t max_baudrate
Maximum supported baudrate (bps)
Definition vsf_template_usart.h:735
USART configuration structure Contains all parameters needed to initialize and configure a USART inst...
Definition vsf_template_usart.h:628
uint32_t mode
USART working mode.
Definition vsf_template_usart.h:629
uint32_t baudrate
Baudrate in Hz.
Definition vsf_template_usart.h:630
uint32_t rx_timeout
RX timeout in microseconds.
Definition vsf_template_usart.h:631
vsf_usart_isr_t isr
Interrupt configuration.
Definition vsf_template_usart.h:632
USART interrupt configuration structure Contains all necessary information for configuring USART inte...
Definition vsf_template_usart.h:614
vsf_usart_isr_handler_t * handler_fn
Interrupt handler function pointer.
Definition vsf_template_usart.h:615
vsf_arch_prio_t prio
Interrupt priority.
Definition vsf_template_usart.h:617
void * target_ptr
User target pointer.
Definition vsf_template_usart.h:616
USART operation interface structure Contains function pointers for all USART operations.
Definition vsf_template_usart.h:757
USART status information structure Contains the current status of USART operations and FIFO threshold...
Definition uart.h:156
uint32_t is_busy
USART is busy with any operation.
Definition vsf_template_usart.h:710
uint32_t is_tx_busy
TX is busy transmitting data.
Definition vsf_template_usart.h:711
uint32_t value
Definition usart.h:284
uint32_t tx_fifo_thresh
TX FIFO threshold level (0-255)
Definition vsf_template_usart.h:713
uint32_t rx_fifo_thresh
RX FIFO threshold level (0-255)
Definition vsf_template_usart.h:714
uint32_t is_rx_busy
RX is busy receiving data.
Definition vsf_template_usart.h:712
USART instance structure Used for USART Multi Class support.
Definition vsf_template_usart.h:775
const vsf_usart_op_t * op
Operation functions.
Definition vsf_template_usart.h:776
vsf_usart_irq_mask_t
Definition usart.h:176
void vsf_usart_isr_handler_t(void *target_ptr, vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask)
Definition usart.h:236
fsm_rt_t
Definition vsf_fsm.h:315
#define VSF_HAL_ASSERT(__CON)
all hal modules use this configuration file
Definition vsf_hal_cfg.h:36
fsm_rt_t vsf_usart_disable(vsf_usart_t *usart_ptr)
Disable a USART instance.
Definition usart_common.c:65
vsf_usart_status_t vsf_usart_status(vsf_usart_t *usart_ptr)
Get the status of USART instance.
Definition usart_common.c:92
struct vsf_usart_cfg_t vsf_usart_cfg_t
USART configuration structure Contains all parameters needed to initialize and configure a USART inst...
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.
Definition usart_common.c:146
struct vsf_usart_capability_t vsf_usart_capability_t
USART capability structure Defines the hardware capabilities and limitations of the USART interface.
vsf_err_t vsf_usart_cancel_rx(vsf_usart_t *usart_ptr)
Cancel an ongoing USART receive operation.
Definition usart_common.c:164
vsf_usart_mode_t
Predefined VSF USART modes that can be reimplemented in specific HAL drivers. Even if the hardware do...
Definition vsf_template_usart.h:301
@ VSF_USART_TX_FIFO_THRESHOLD_EMPTY
USART TX FIFO threshold configuration options Note: Some devices may support additional threshold lev...
Definition vsf_template_usart.h:386
@ VSF_USART_HALF_DUPLEX_DISABLE
USART Half-duplex configuration options.
Definition vsf_template_usart.h:375
@ VSF_USART_8_BIT_LENGTH
8-bit data length
Definition vsf_template_usart.h:334
@ VSF_USART_SYNC_CLOCK_ENABLE
USART Synchronous clock configuration options.
Definition vsf_template_usart.h:366
@ VSF_USART_EVEN_PARITY
Even parity.
Definition vsf_template_usart.h:309
@ VSF_USART_RX_FIFO_THRESHOLD_NOT_EMPTY
USART RX FIFO threshold configuration options Note: Some devices may support additional threshold lev...
Definition vsf_template_usart.h:398
@ VSF_USART_ODD_PARITY
Odd parity.
Definition vsf_template_usart.h:310
@ VSF_USART_NO_PARITY
USART Parity configuration options.
Definition vsf_template_usart.h:308
@ VSF_USART_10_BIT_LENGTH
10-bit data length
Definition vsf_template_usart.h:336
@ VSF_USART_RTS_HWCONTROL
RTS hardware flow control.
Definition vsf_template_usart.h:345
@ VSF_USART_RX_FIFO_THRESHOLD_HALF_FULL
RX FIFO half full.
Definition vsf_template_usart.h:399
@ VSF_USART_RX_ENABLE
RX enabled.
Definition vsf_template_usart.h:357
@ VSF_USART_FORCE_0_PARITY
Force 0 parity.
Definition vsf_template_usart.h:311
@ VSF_USART_TX_FIFO_THRESHOLD_NOT_FULL
TX FIFO not full.
Definition vsf_template_usart.h:388
@ VSF_USART_TX_ENABLE
USART TX/RX enable/disable options.
Definition vsf_template_usart.h:355
@ VSF_USART_9_BIT_LENGTH
9-bit data length
Definition vsf_template_usart.h:335
@ VSF_USART_7_BIT_LENGTH
7-bit data length
Definition vsf_template_usart.h:333
@ VSF_USART_1_STOPBIT
USART Stop bit configuration options.
Definition vsf_template_usart.h:320
@ VSF_USART_FORCE_1_PARITY
Force 1 parity.
Definition vsf_template_usart.h:312
@ VSF_USART_RX_DISABLE
RX disabled.
Definition vsf_template_usart.h:358
@ VSF_USART_2_STOPBIT
2 stop bits
Definition vsf_template_usart.h:323
@ VSF_USART_CTS_HWCONTROL
CTS hardware flow control.
Definition vsf_template_usart.h:346
@ VSF_USART_5_BIT_LENGTH
USART Data bit length configuration options.
Definition vsf_template_usart.h:331
@ VSF_USART_SYNC_CLOCK_DISABLE
Sync clock disabled.
Definition vsf_template_usart.h:367
@ VSF_USART_RTS_CTS_HWCONTROL
RTS/CTS hardware flow control.
Definition vsf_template_usart.h:347
@ VSF_USART_HALF_DUPLEX_ENABLE
Half-duplex enabled.
Definition vsf_template_usart.h:376
@ VSF_USART_TX_DISABLE
TX disabled.
Definition vsf_template_usart.h:356
@ VSF_USART_RX_FIFO_THRESHOLD_FULL
RX FIFO full.
Definition vsf_template_usart.h:400
@ VSF_USART_6_BIT_LENGTH
6-bit data length
Definition vsf_template_usart.h:332
@ VSF_USART_0_5_STOPBIT
0.5 stop bit
Definition vsf_template_usart.h:322
@ VSF_USART_TX_FIFO_THRESHOLD_HALF_EMPTY
TX FIFO half empty.
Definition vsf_template_usart.h:387
@ VSF_USART_NO_HWCONTROL
USART Hardware flow control configuration options.
Definition vsf_template_usart.h:344
@ VSF_USART_1_5_STOPBIT
1.5 stop bits
Definition vsf_template_usart.h:321
uint_fast32_t vsf_usart_rxfifo_get_data_count(vsf_usart_t *usart_ptr)
Get the number of data currently received in the USART receive FIFO.
Definition usart_common.c:110
uint_fast32_t vsf_usart_rxfifo_read(vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count)
Try to read the maximum length of data from the USART receive FIFO.
fsm_rt_t vsf_usart_enable(vsf_usart_t *usart_ptr)
Enable a USART instance.
Definition usart_common.c:56
@ VSF_USART_IRQ_MASK_ERR
Combined error interrupt mask.
Definition vsf_template_usart.h:521
@ VSF_USART_IRQ_MASK_TX_FIFO_THRESHOLD
TX FIFO threshold interrupt mask.
Definition vsf_template_usart.h:517
@ VSF_USART_IRQ_ALL_BITS_MASK
All supported interrupt mask bits.
Definition vsf_template_usart.h:528
@ VSF_USART_IRQ_MASK_RX_IDLE
RX idle timeout interrupt mask.
Definition vsf_template_usart.h:516
@ VSF_USART_IRQ_MASK_RX_FIFO_THRESHOLD
RX FIFO threshold interrupt mask.
Definition vsf_template_usart.h:518
struct vsf_usart_isr_t vsf_usart_isr_t
USART interrupt configuration structure Contains all necessary information for configuring USART inte...
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.
Definition usart_common.c:155
uint_fast32_t vsf_usart_txfifo_get_free_count(vsf_usart_t *usart_ptr)
Get the maximum number of data that can be sent through the USART send FIFO.
Definition usart_common.c:128
vsf_err_t vsf_usart_cancel_tx(vsf_usart_t *usart_ptr)
Cancel an ongoing USART transmit operation.
Definition usart_common.c:173
vsf_usart_irq_mask_t
USART interrupt mask definitions These interrupts provide status and event notifications for USART op...
Definition vsf_template_usart.h:495
@ VSF_USART_IRQ_MASK_TX_CPL
TX complete interrupt.
Definition vsf_template_usart.h:496
@ VSF_USART_IRQ_MASK_OVERFLOW_ERR
Overflow error interrupt.
Definition vsf_template_usart.h:505
@ VSF_USART_IRQ_MASK_CTS
CTS change interrupt.
Definition vsf_template_usart.h:501
@ VSF_USART_IRQ_MASK_TX
TX FIFO threshold interrupt.
Definition vsf_template_usart.h:498
@ VSF_USART_IRQ_MASK_BREAK_ERR
Break error interrupt.
Definition vsf_template_usart.h:504
@ VSF_USART_IRQ_MASK_RX
RX FIFO threshold interrupt.
Definition vsf_template_usart.h:499
@ VSF_USART_IRQ_MASK_RX_TIMEOUT
RX timeout interrupt.
Definition vsf_template_usart.h:500
@ VSF_USART_IRQ_MASK_RX_CPL
RX complete interrupt.
Definition vsf_template_usart.h:497
@ VSF_USART_IRQ_MASK_PARITY_ERR
Parity error interrupt.
Definition vsf_template_usart.h:503
@ VSF_USART_IRQ_MASK_FRAME_ERR
Frame error interrupt.
Definition vsf_template_usart.h:502
void vsf_usart_fini(vsf_usart_t *usart_ptr)
Finalize a USART instance.
Definition usart_common.c:47
#define VSF_USART_APIS(__prefix_name)
USART API template, used to generate USART type, specific prefix function declarations,...
Definition vsf_template_usart.h:228
void vsf_usart_irq_enable(vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask)
Enable interrupt masks of USART instance.
Definition usart_common.c:74
void vsf_usart_irq_disable(vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask)
Disable interrupt masks of USART instance.
Definition usart_common.c:83
struct vsf_usart_status_t vsf_usart_status_t
USART status information structure Contains the current status of USART operations and FIFO threshold...
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.
Definition usart_common.c:182
vsf_err_t vsf_usart_init(vsf_usart_t *usart_ptr, vsf_usart_cfg_t *cfg_ptr)
Initialize a USART instance.
Definition usart_common.c:38
vsf_usart_capability_t vsf_usart_capability(vsf_usart_t *usart_ptr)
Get the capability of USART instance.
Definition usart_common.c:101
vsf_usart_ctrl_t
USART control commands Defines the available control operations for USART instances.
Definition vsf_template_usart.h:645
@ VSF_USART_CTRL_CLEAR_BREAK
Clear BREAK signal Clears a previously set BREAK signal.
Definition vsf_template_usart.h:674
@ VSF_USART_CTRL_SEND_BREAK
Send BREAK signal The BREAK signal will be automatically cleared after a number of bit times.
Definition vsf_template_usart.h:654
@ VSF_USART_CTRL_SET_BREAK
Set BREAK signal The BREAK signal will remain until explicitly cleared.
Definition vsf_template_usart.h:664
vsf_err_t vsf_usart_ctrl(vsf_usart_t *usart_ptr, vsf_usart_ctrl_t ctrl, void *param)
Execute a control command on the USART instance.
Definition usart_common.c:200
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.
Definition usart_common.c:191
void vsf_usart_isr_handler_t(void *target_ptr, vsf_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask)
USART interrupt handler function type declaration.
Definition vsf_template_usart.h:602
@ VSF_USART_BIT_LENGTH_MASK
Definition vsf_template_usart.h:421
@ VSF_USART_TX_FIFO_THRESHOLD_MASK
Definition vsf_template_usart.h:430
@ VSF_USART_PARITY_MASK
Definition vsf_template_usart.h:406
@ VSF_USART_MODE_ALL_BITS_MASK
Definition vsf_template_usart.h:460
@ VSF_USART_HALF_DUPLEX_MASK
Definition vsf_template_usart.h:457
@ VSF_USART_HWCONTROL_MASK
Definition vsf_template_usart.h:442
@ VSF_USART_RX_MASK
Definition vsf_template_usart.h:451
@ VSF_USART_STOPBIT_MASK
Definition vsf_template_usart.h:414
@ VSF_USART_RX_FIFO_THRESHOLD_MASK
Definition vsf_template_usart.h:436
@ VSF_USART_SYNC_CLOCK_MASK
Definition vsf_template_usart.h:454
@ VSF_USART_TX_MASK
Definition vsf_template_usart.h:448
uint_fast32_t vsf_usart_txfifo_write(vsf_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count)
Try to write the maximum length of data to the USART send FIFO.
Generated from commit: vsfteam/vsf@2b286be