18#if VSF_HAL_USE_USART == ENABLED
23#ifndef VSF_USART_CFG_REIMPLEMENT_API_REQUEST
24# define VSF_USART_CFG_REIMPLEMENT_API_REQUEST DISABLED
27#ifndef VSF_USART_CFG_REIMPLEMENT_API_CAPABILITY
28# define VSF_USART_CFG_REIMPLEMENT_API_CAPABILITY DISABLED
31#ifndef VSF_USART_CFG_REIMPLEMENT_API_CMD
32# define VSF_USART_CFG_REIMPLEMENT_API_CMD DISABLED
35#ifdef VSF_USART_CFG_IMP_REMAP_PREFIX
36# undef VSF_USART_CFG_REIMPLEMENT_API_REQUEST
37# undef VSF_USART_CFG_REIMPLEMENT_API_CAPABILITY
38# undef VSF_USART_CFG_REIMPLEMENT_API_CMD
39# define VSF_USART_CFG_REIMPLEMENT_API_REQUEST ENABLED
40# define VSF_USART_CFG_REIMPLEMENT_API_CAPABILITY ENABLED
41# define VSF_USART_CFG_REIMPLEMENT_API_CMD ENABLED
44#if VSF_USART_CFG_REIMPLEMENT_API_CAPABILITY == DISABLED
45# ifndef VSF_USART_CFG_CAPABILITY_IRQ_MASK
46# define VSF_USART_CFG_CAPABILITY_IRQ_MASK VSF_USART_IRQ_ALL_BITS_MASK
48# ifndef VSF_USART_CFG_CAPABILITY_MAX_BAUDRATE
49# define VSF_USART_CFG_CAPABILITY_MAX_BAUDRATE 921600
51# ifndef VSF_USART_CFG_CAPABILITY_MIN_BAUDRATE
52# define VSF_USART_CFG_CAPABILITY_MIN_BAUDRATE 4800
54# ifndef VSF_USART_CFG_CAPABILITY_TXFIFO_DEPTH
55# define VSF_USART_CFG_CAPABILITY_TXFIFO_DEPTH 64
57# ifndef VSF_USART_CFG_CAPABILITY_RXFIFO_DEPTH
58# define VSF_USART_CFG_CAPABILITY_RXFIFO_DEPTH 64
60# ifndef VSF_USART_CFG_CAPABILITY_MAX_DATA_BITS
61# define VSF_USART_CFG_CAPABILITY_MAX_DATA_BITS 9
63# ifndef VSF_USART_CFG_CAPABILITY_MIN_DATA_BITS
64# define VSF_USART_CFG_CAPABILITY_MIN_DATA_BITS 8
66# ifndef VSF_USART_CFG_CAPABILITY_SUPPORT_RX_TIMEOUT
67# define VSF_USART_CFG_CAPABILITY_SUPPORT_RX_TIMEOUT 1
69# ifndef VSF_USART_CFG_CAPABILITY_SUPPORT_SEND_BREAK
70# define VSF_USART_CFG_CAPABILITY_SUPPORT_SEND_BREAK 1
72# ifndef VSF_USART_CFG_CAPABILITY_SUPPORT_SET_AND_CLEAR_BREAK
73# define VSF_USART_CFG_CAPABILITY_SUPPORT_SET_AND_CLEAR_BREAK 0
77#define vsf_real_usart_t VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_t)
78#define vsf_real_usart_request_rx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_request_rx)
79#define vsf_real_usart_cancel_rx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_cancel_rx)
80#define vsf_real_usart_get_rx_count VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_get_rx_count)
81#define vsf_real_usart_request_tx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_request_tx)
82#define vsf_real_usart_cancel_tx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_cancel_tx)
83#define vsf_real_usart_get_tx_count VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_get_tx_count)
84#define vsf_real_usart_capability VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_capability)
85#define vsf_real_usart_cmd VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_cmd)
86#define vsf_real_usart_tx_send_break VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_tx_send_break)
90#if VSF_USART_CFG_REIMPLEMENT_API_REQUEST == DISABLED
98vsf_err_t vsf_real_usart_cancel_rx(vsf_real_usart_t *usart_ptr)
104int_fast32_t vsf_real_usart_get_rx_count(vsf_real_usart_t *usart_ptr)
116vsf_err_t vsf_real_usart_cancel_tx(vsf_real_usart_t *usart_ptr)
122int_fast32_t vsf_real_usart_get_tx_count(vsf_real_usart_t *usart_ptr)
130#if VSF_USART_CFG_REIMPLEMENT_API_CAPABILITY == DISABLED
134 .irq_mask = VSF_USART_CFG_CAPABILITY_IRQ_MASK,
136 .min_baudrate = VSF_USART_CFG_CAPABILITY_MIN_BAUDRATE,
137 .txfifo_depth = VSF_USART_CFG_CAPABILITY_TXFIFO_DEPTH,
138 .rxfifo_depth = VSF_USART_CFG_CAPABILITY_RXFIFO_DEPTH,
139 .max_data_bits = VSF_USART_CFG_CAPABILITY_MAX_DATA_BITS,
140 .min_data_bits = VSF_USART_CFG_CAPABILITY_MIN_DATA_BITS,
141 .support_rx_timeout = VSF_USART_CFG_CAPABILITY_SUPPORT_RX_TIMEOUT,
142 .support_send_break = VSF_USART_CFG_CAPABILITY_SUPPORT_SEND_BREAK,
143 .support_set_and_clear_break = VSF_USART_CFG_CAPABILITY_SUPPORT_SET_AND_CLEAR_BREAK,
146 return usart_capability;
150#if VSF_USART_CFG_REIMPLEMENT_API_CMD == DISABLED
161#undef VSF_USART_CFG_REIMPLEMENT_API_CAPABILITY
162#undef VSF_USART_CFG_CAPABILITY_IRQ_MASK
163#undef VSF_USART_CFG_CAPABILITY_MAX_BAUDRATE
164#undef VSF_USART_CFG_CAPABILITY_MIN_BAUDRATE
165#undef VSF_USART_CFG_CAPABILITY_TXFIFO_DEPTH
166#undef VSF_USART_CFG_CAPABILITY_RXFIFO_DEPTH
167#undef VSF_USART_CFG_CAPABILITY_MAX_DATA_BITS
168#undef VSF_USART_CFG_CAPABILITY_MIN_DATA_BITS
169#undef VSF_USART_CFG_CAPABILITY_SUPPORT_RX_TIMEOUT
170#undef VSF_USART_CFG_REIMPLEMENT_API_REQUEST
171#undef VSF_USART_CFG_REIMPLEMENT_API_CMD
172#undef vsf_real_usart_t
173#undef vsf_real_usart_init
174#undef vsf_real_usart_fini
175#undef vsf_real_usart_rxfifo_read
176#undef vsf_real_usart_txfifo_write
177#undef vsf_real_usart_irq_enable
178#undef vsf_real_usart_irq_disable
179#undef vsf_real_usart_request_rx
180#undef vsf_real_usart_cancel_rx
181#undef vsf_real_usart_get_rx_count
182#undef vsf_real_usart_request_tx
183#undef vsf_real_usart_cancel_tx
184#undef vsf_real_usart_get_tx_count
185#undef vsf_real_usart_capability
186#undef vsf_real_usart_cmd
187#undef vsf_real_usart_tx_send_break
192#ifdef VSF_USART_CFG_IMP_REMAP_PREFIX
193# define vsf_imp_usart_t VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_t)
194# define vsf_imp_usart_init VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_init)
195# define vsf_imp_usart_fini VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_fini)
196# define vsf_imp_usart_capability VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_capability)
197# define vsf_imp_usart_enable VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_enable)
198# define vsf_imp_usart_disable VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_disable)
199# define vsf_imp_usart_irq_enable VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_irq_enable)
200# define vsf_imp_usart_irq_disable VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_irq_disable)
201# define vsf_imp_usart_status VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_status)
202# define vsf_imp_usart_rxfifo_get_data_count VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_rxfifo_get_data_count)
203# define vsf_imp_usart_rxfifo_read VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_rxfifo_read)
204# define vsf_imp_usart_txfifo_get_free_count VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_txfifo_get_free_count)
205# define vsf_imp_usart_txfifo_write VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_txfifo_write)
206# define vsf_imp_usart_request_rx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_request_rx)
207# define vsf_imp_usart_request_tx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_request_tx)
208# define vsf_imp_usart_cancel_rx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_cancel_rx)
209# define vsf_imp_usart_cancel_tx VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_cancel_tx)
210# define vsf_imp_usart_get_rx_count VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_get_rx_count)
211# define vsf_imp_usart_get_tx_count VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_get_tx_count)
212# define vsf_imp_usart_cmd VSF_MCONNECT(VSF_USART_CFG_IMP_PREFIX, _usart_cmd)
214# define vsf_remap_usart_t VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_t)
215# define vsf_remap_usart_init VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_init)
216# define vsf_remap_usart_fini VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_fini)
217# define vsf_remap_usart_capability VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_capability)
218# define vsf_remap_usart_enable VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_enable)
219# define vsf_remap_usart_disable VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_disable)
220# define vsf_remap_usart_irq_enable VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_irq_enable)
221# define vsf_remap_usart_irq_disable VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_irq_disable)
222# define vsf_remap_usart_status VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_status)
223# define vsf_remap_usart_rxfifo_get_data_count VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_rxfifo_get_data_count)
224# define vsf_remap_usart_rxfifo_read VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_rxfifo_read)
225# define vsf_remap_usart_txfifo_get_free_count VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_txfifo_get_free_count)
226# define vsf_remap_usart_txfifo_write VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_txfifo_write)
227# define vsf_remap_usart_request_rx VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_request_rx)
228# define vsf_remap_usart_request_tx VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_request_tx)
229# define vsf_remap_usart_cancel_rx VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_cancel_rx)
230# define vsf_remap_usart_cancel_tx VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_cancel_tx)
231# define vsf_remap_usart_get_rx_count VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_get_rx_count)
232# define vsf_remap_usart_get_tx_count VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_get_tx_count)
233# define vsf_remap_usart_cmd VSF_MCONNECT(VSF_USART_CFG_IMP_REMAP_PREFIX, _usart_cmd)
234# define VSF_USART_CFG_IMP_REMAP_FUNCTIONS \
235 vsf_err_t vsf_imp_usart_init(vsf_imp_usart_t *usart_ptr, vsf_usart_cfg_t *cfg_ptr) \
237 VSF_HAL_ASSERT(usart_ptr != NULL); \
238 return vsf_remap_usart_init(usart_ptr, cfg_ptr); \
240 void vsf_imp_usart_fini(vsf_imp_usart_t *usart_ptr) \
242 VSF_HAL_ASSERT(usart_ptr != NULL); \
243 vsf_remap_usart_fini(usart_ptr); \
245 fsm_rt_t vsf_imp_usart_enable(vsf_imp_usart_t *usart_ptr) \
247 VSF_HAL_ASSERT(usart_ptr != NULL); \
248 return vsf_remap_usart_enable(usart_ptr); \
250 fsm_rt_t vsf_imp_usart_disable(vsf_imp_usart_t *usart_ptr) \
252 VSF_HAL_ASSERT(usart_ptr != NULL); \
253 return vsf_remap_usart_disable(usart_ptr); \
255 void vsf_imp_usart_irq_enable(vsf_imp_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask) \
257 VSF_HAL_ASSERT(usart_ptr != NULL); \
258 vsf_remap_usart_irq_enable(usart_ptr, irq_mask); \
260 void vsf_imp_usart_irq_disable(vsf_imp_usart_t *usart_ptr, vsf_usart_irq_mask_t irq_mask) \
262 VSF_HAL_ASSERT(usart_ptr != NULL); \
263 vsf_remap_usart_irq_disable(usart_ptr, irq_mask); \
265 vsf_usart_status_t vsf_imp_usart_status(vsf_imp_usart_t *usart_ptr) \
267 VSF_HAL_ASSERT(usart_ptr != NULL); \
268 return vsf_remap_usart_status(usart_ptr); \
270 vsf_usart_capability_t vsf_imp_usart_capability(vsf_imp_usart_t *usart_ptr) \
272 VSF_HAL_ASSERT(usart_ptr != NULL); \
273 return vsf_remap_usart_capability(usart_ptr); \
275 uint_fast16_t vsf_imp_usart_rxfifo_get_data_count(vsf_imp_usart_t *usart_ptr) \
277 VSF_HAL_ASSERT(usart_ptr != NULL); \
278 return vsf_remap_usart_rxfifo_get_data_count(usart_ptr); \
280 uint_fast16_t vsf_imp_usart_rxfifo_read(vsf_imp_usart_t *usart_ptr, void *buffer_ptr, uint_fast16_t count) \
282 VSF_HAL_ASSERT(usart_ptr != NULL); \
283 return vsf_remap_usart_rxfifo_read(usart_ptr, buffer_ptr, count); \
285 uint_fast16_t vsf_imp_usart_txfifo_get_free_count(vsf_imp_usart_t *usart_ptr) \
287 VSF_HAL_ASSERT(usart_ptr != NULL); \
288 return vsf_remap_usart_txfifo_get_free_count(usart_ptr); \
290 uint_fast16_t vsf_imp_usart_txfifo_write(vsf_imp_usart_t *usart_ptr, void *buffer_ptr, uint_fast16_t count) \
292 VSF_HAL_ASSERT(usart_ptr != NULL); \
293 return vsf_remap_usart_txfifo_write(usart_ptr, buffer_ptr, count); \
295 vsf_err_t vsf_imp_usart_request_rx(vsf_imp_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) \
297 VSF_HAL_ASSERT(usart_ptr != NULL); \
298 return vsf_remap_usart_request_rx(usart_ptr, buffer_ptr, count); \
300 vsf_err_t vsf_imp_usart_request_tx(vsf_imp_usart_t *usart_ptr, void *buffer_ptr, uint_fast32_t count) \
302 VSF_HAL_ASSERT(usart_ptr != NULL); \
303 return vsf_remap_usart_request_tx(usart_ptr, buffer_ptr, count); \
305 vsf_err_t vsf_imp_usart_cancel_rx(vsf_imp_usart_t *usart_ptr) \
307 VSF_HAL_ASSERT(usart_ptr != NULL); \
308 return vsf_remap_usart_cancel_rx(usart_ptr); \
310 vsf_err_t vsf_imp_usart_cancel_tx(vsf_imp_usart_t *usart_ptr) \
312 VSF_HAL_ASSERT(usart_ptr != NULL); \
313 return vsf_remap_usart_cancel_tx(usart_ptr); \
315 int_fast32_t vsf_imp_usart_get_rx_count(vsf_imp_usart_t *usart_ptr) \
317 VSF_HAL_ASSERT(usart_ptr != NULL); \
318 return vsf_remap_usart_get_rx_count(usart_ptr); \
320 int_fast32_t vsf_imp_usart_get_tx_count(vsf_imp_usart_t *usart_ptr) \
322 VSF_HAL_ASSERT(usart_ptr != NULL); \
323 return vsf_remap_usart_get_tx_count(usart_ptr); \
325 vsf_err_t vsf_imp_usart_cmd(vsf_imp_usart_t *usart_ptr, vsf_usart_cmd_t cmd, void *param) \
327 VSF_HAL_ASSERT(usart_ptr != NULL); \
328 return vsf_remap_usart_cmd(usart_ptr, cmd, param); \
334#define VSF_HAL_TEMPLATE_IMP_NAME _usart
335#define VSF_HAL_TEMPLATE_IMP_UPCASE_NAME _USART
337#ifndef VSF_USART_CFG_IMP_PREFIX
338# error "Please define VSF_USART_CFG_IMP_PREFIX in usart driver"
341#ifndef VSF_USART_CFG_IMP_UPCASE_PREFIX
342# error "Please define VSF_USART_CFG_IMP_UPCASE_PREFIX in usart driver"
345#ifndef VSF_USART_CFG_IMP_COUNT_MASK_PREFIX
346# define VSF_USART_CFG_IMP_COUNT_MASK_PREFIX VSF_USART_CFG_IMP_UPCASE_PREFIX
349#ifdef VSF_USART_CFG_IMP_REMAP_FUNCTIONS
350# define VSF_HAL_CFG_IMP_REMAP_FUNCTIONS VSF_USART_CFG_IMP_REMAP_FUNCTIONS
355#undef VSF_USART_CFG_IMP_PREFIX
356#undef VSF_USART_CFG_IMP_COUNT_MASK_PREFIX
357#undef VSF_USART_CFG_IMP_UPCASE_PREFIX
358#undef VSF_USART_CFG_IMP_REMAP_PREFIX
359#undef VSF_USART_CFG_IMP_LV0
360#undef VSF_USART_CFG_IMP_REMAP_FUNCTIONS
361#undef VSF_USART_CFG_IMP_HAS_OP
362#undef VSF_USART_CFG_IMP_EXTERN_OP
364#undef vsf_imp_usart_t
365#undef vsf_imp_usart_init
366#undef vsf_imp_usart_fini
367#undef vsf_imp_usart_capability
368#undef vsf_imp_usart_enable
369#undef vsf_imp_usart_disable
370#undef vsf_imp_usart_irq_enable
371#undef vsf_imp_usart_irq_disable
372#undef vsf_imp_usart_status
373#undef vsf_imp_usart_rxfifo_get_data_count
374#undef vsf_imp_usart_rxfifo_read
375#undef vsf_imp_usart_txfifo_get_free_count
376#undef vsf_imp_usart_txfifo_write
377#undef vsf_imp_usart_request_rx
378#undef vsf_imp_usart_request_tx
379#undef vsf_imp_usart_cancel_rx
380#undef vsf_imp_usart_cancel_tx
381#undef vsf_imp_usart_get_rx_count
382#undef vsf_imp_usart_get_tx_count
383#undef vsf_imp_usart_cmd
384#undef vsf_imp_usart_tx_send_break
386#undef vsf_remap_usart_t
387#undef vsf_remap_usart_init
388#undef vsf_remap_usart_fini
389#undef vsf_remap_usart_capability
390#undef vsf_remap_usart_enable
391#undef vsf_remap_usart_disable
392#undef vsf_remap_usart_irq_enable
393#undef vsf_remap_usart_irq_disable
394#undef vsf_remap_usart_status
395#undef vsf_remap_usart_rxfifo_get_data_count
396#undef vsf_remap_usart_rxfifo_read
397#undef vsf_remap_usart_txfifo_get_free_count
398#undef vsf_remap_usart_txfifo_write
399#undef vsf_remap_usart_request_rx
400#undef vsf_remap_usart_request_tx
401#undef vsf_remap_usart_cancel_rx
402#undef vsf_remap_usart_cancel_tx
403#undef vsf_remap_usart_get_rx_count
404#undef vsf_remap_usart_get_tx_count
405#undef vsf_remap_usart_cmd
406#undef vsf_remap_usart_tx_send_break
vsf_err_t
Definition __type.h:42
@ VSF_ERR_NOT_SUPPORT
function not supported
Definition __type.h:46
@ VSF_ERR_FAIL
failed
Definition __type.h:51
unsigned int uint_fast32_t
Definition stdint.h:27
int int_fast32_t
Definition stdint.h:26
Definition vsf_template_usart.h:695
uint32_t max_baudrate
Definition vsf_template_usart.h:702
#define VSF_HAL_ASSERT(__CON)
all hal modules use this configuration file
Definition vsf_hal_cfg.h:36
vsf_usart_cmd_t
Predefined VSF USART command that can be reimplemented in specific hal drivers.
Definition vsf_template_usart.h:647