Zephyr API Documentation  3.0.0
A Scalable Open Source RTOS
3.0.0
All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
uart.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2018-2019 Nordic Semiconductor ASA
3 * Copyright (c) 2015 Wind River Systems, Inc.
4 *
5 * SPDX-License-Identifier: Apache-2.0
6 */
7
13#ifndef ZEPHYR_INCLUDE_DRIVERS_UART_H_
14#define ZEPHYR_INCLUDE_DRIVERS_UART_H_
15
23#include <errno.h>
24#include <stddef.h>
25
26#include <device.h>
27
28#ifdef __cplusplus
29extern "C" {
30#endif
31
39};
40
61 UART_BREAK = (1 << 3),
72};
73
81};
82
89};
90
98};
99
111};
112
128};
129
142typedef void (*uart_irq_callback_user_data_t)(const struct device *dev,
143 void *user_data);
144
150typedef void (*uart_irq_config_func_t)(const struct device *dev);
151
264};
265
269 const uint8_t *buf;
271 size_t len;
272};
273
284 size_t offset;
286 size_t len;
287};
288
291 /* @brief Pointer to buffer that is no longer in use. */
293};
294
301};
302
322};
323
333typedef void (*uart_callback_t)(const struct device *dev,
334 struct uart_event *evt, void *user_data);
335
354struct uart_device_config {
355 union {
356 uint32_t port;
357 uint8_t *base;
358 uint32_t regs;
359 };
360
361 uint32_t sys_clk_freq;
362
363#if defined(CONFIG_UART_INTERRUPT_DRIVEN) || defined(CONFIG_UART_ASYNC_API)
364 uart_irq_config_func_t irq_config_func;
365#endif
366};
367
369__subsystem struct uart_driver_api {
370
371#ifdef CONFIG_UART_ASYNC_API
372
373 int (*callback_set)(const struct device *dev,
374 uart_callback_t callback,
375 void *user_data);
376
377 int (*tx)(const struct device *dev, const uint8_t *buf, size_t len,
379 int (*tx_abort)(const struct device *dev);
380
381 int (*rx_enable)(const struct device *dev, uint8_t *buf, size_t len,
383 int (*rx_buf_rsp)(const struct device *dev, uint8_t *buf, size_t len);
384 int (*rx_disable)(const struct device *dev);
385
386#ifdef CONFIG_UART_WIDE_DATA
387 int (*tx_u16)(const struct device *dev, const uint16_t *buf,
388 size_t len, int32_t timeout);
389 int (*rx_enable_u16)(const struct device *dev, uint16_t *buf,
390 size_t len, int32_t timeout);
391 int (*rx_buf_rsp_u16)(const struct device *dev, uint16_t *buf,
392 size_t len);
393#endif
394
395#endif
396
398 int (*poll_in)(const struct device *dev, unsigned char *p_char);
399 void (*poll_out)(const struct device *dev, unsigned char out_char);
400
401#ifdef CONFIG_UART_WIDE_DATA
402 int (*poll_in_u16)(const struct device *dev, uint16_t *p_u16);
403 void (*poll_out_u16)(const struct device *dev, uint16_t out_u16);
404#endif
405
407 int (*err_check)(const struct device *dev);
408
410 int (*configure)(const struct device *dev,
411 const struct uart_config *cfg);
412 int (*config_get)(const struct device *dev, struct uart_config *cfg);
413
414#ifdef CONFIG_UART_INTERRUPT_DRIVEN
415
417 int (*fifo_fill)(const struct device *dev, const uint8_t *tx_data,
418 int len);
419
420#ifdef CONFIG_UART_WIDE_DATA
421 int (*fifo_fill_u16)(const struct device *dev, const uint16_t *tx_data,
422 int len);
423#endif
424
426 int (*fifo_read)(const struct device *dev, uint8_t *rx_data,
427 const int size);
428
429#ifdef CONFIG_UART_WIDE_DATA
430 int (*fifo_read_u16)(const struct device *dev, uint16_t *rx_data,
431 const int size);
432#endif
433
435 void (*irq_tx_enable)(const struct device *dev);
436
438 void (*irq_tx_disable)(const struct device *dev);
439
441 int (*irq_tx_ready)(const struct device *dev);
442
444 void (*irq_rx_enable)(const struct device *dev);
445
447 void (*irq_rx_disable)(const struct device *dev);
448
450 int (*irq_tx_complete)(const struct device *dev);
451
453 int (*irq_rx_ready)(const struct device *dev);
454
456 void (*irq_err_enable)(const struct device *dev);
457
459 void (*irq_err_disable)(const struct device *dev);
460
462 int (*irq_is_pending)(const struct device *dev);
463
465 int (*irq_update)(const struct device *dev);
466
468 void (*irq_callback_set)(const struct device *dev,
470 void *user_data);
471
472#endif
473
474#ifdef CONFIG_UART_LINE_CTRL
475 int (*line_ctrl_set)(const struct device *dev, uint32_t ctrl,
476 uint32_t val);
477 int (*line_ctrl_get)(const struct device *dev, uint32_t ctrl,
478 uint32_t *val);
479#endif
480
481#ifdef CONFIG_UART_DRV_CMD
482 int (*drv_cmd)(const struct device *dev, uint32_t cmd, uint32_t p);
483#endif
484
485};
486
498__syscall int uart_err_check(const struct device *dev);
499
500static inline int z_impl_uart_err_check(const struct device *dev)
501{
502 const struct uart_driver_api *api =
503 (const struct uart_driver_api *)dev->api;
504
505 if (api->err_check == NULL) {
506 return -ENOSYS;
507 }
508
509 return api->err_check(dev);
510}
511
529__syscall int uart_poll_in(const struct device *dev, unsigned char *p_char);
530
531static inline int z_impl_uart_poll_in(const struct device *dev,
532 unsigned char *p_char)
533{
534 const struct uart_driver_api *api =
535 (const struct uart_driver_api *)dev->api;
536
537 if (api->poll_in == NULL) {
538 return -ENOSYS;
539 }
540
541 return api->poll_in(dev, p_char);
542}
543
557__syscall int uart_poll_in_u16(const struct device *dev, uint16_t *p_u16);
558
559static inline int z_impl_uart_poll_in_u16(const struct device *dev,
560 uint16_t *p_u16)
561{
562#ifdef CONFIG_UART_WIDE_DATA
563 const struct uart_driver_api *api =
564 (const struct uart_driver_api *)dev->api;
565
566 if (api->poll_in_u16 == NULL) {
567 return -ENOSYS;
568 }
569
570 return api->poll_in_u16(dev, p_u16);
571#else
572 return -ENOTSUP;
573#endif
574}
575
589__syscall void uart_poll_out(const struct device *dev,
590 unsigned char out_char);
591
592static inline void z_impl_uart_poll_out(const struct device *dev,
593 unsigned char out_char)
594{
595 const struct uart_driver_api *api =
596 (const struct uart_driver_api *)dev->api;
597
598 api->poll_out(dev, out_char);
599}
600
614__syscall void uart_poll_out_u16(const struct device *dev, uint16_t out_u16);
615
616static inline void z_impl_uart_poll_out_u16(const struct device *dev,
617 uint16_t out_u16)
618{
619#ifdef CONFIG_UART_WIDE_DATA
620 const struct uart_driver_api *api =
621 (const struct uart_driver_api *)dev->api;
622
623 api->poll_out_u16(dev, out_u16);
624#endif
625}
626
644__syscall int uart_configure(const struct device *dev,
645 const struct uart_config *cfg);
646
647static inline int z_impl_uart_configure(const struct device *dev,
648 const struct uart_config *cfg)
649{
650 const struct uart_driver_api *api =
651 (const struct uart_driver_api *)dev->api;
652
653 if (api->configure == NULL) {
654 return -ENOSYS;
655 }
656 return api->configure(dev, cfg);
657}
658
672__syscall int uart_config_get(const struct device *dev,
673 struct uart_config *cfg);
674
675static inline int z_impl_uart_config_get(const struct device *dev,
676 struct uart_config *cfg)
677{
678 const struct uart_driver_api *api =
679 (const struct uart_driver_api *)dev->api;
680
681 if (api->config_get == NULL) {
682 return -ENOSYS;
683 }
684
685 return api->config_get(dev, cfg);
686}
687
713static inline int uart_fifo_fill(const struct device *dev,
714 const uint8_t *tx_data,
715 int size)
716{
717#ifdef CONFIG_UART_INTERRUPT_DRIVEN
718 const struct uart_driver_api *api =
719 (const struct uart_driver_api *)dev->api;
720
721 if (api->fifo_fill == NULL) {
722 return -ENOSYS;
723 }
724
725 return api->fifo_fill(dev, tx_data, size);
726#endif
727
728 return -ENOTSUP;
729}
730
751static inline int uart_fifo_fill_u16(const struct device *dev,
752 const uint16_t *tx_data,
753 int size)
754{
755#if defined(CONFIG_UART_INTERRUPT_DRIVEN) && defined(CONFIG_UART_WIDE_DATA)
756 const struct uart_driver_api *api =
757 (const struct uart_driver_api *)dev->api;
758
759 if (api->fifo_fill_u16 == NULL) {
760 return -ENOSYS;
761 }
762
763 return api->fifo_fill_u16(dev, tx_data, size);
764#else
765 return -ENOTSUP;
766#endif
767}
768
793static inline int uart_fifo_read(const struct device *dev, uint8_t *rx_data,
794 const int size)
795{
796#ifdef CONFIG_UART_INTERRUPT_DRIVEN
797 const struct uart_driver_api *api =
798 (const struct uart_driver_api *)dev->api;
799
800 if (api->fifo_read == NULL) {
801 return -ENOSYS;
802 }
803
804 return api->fifo_read(dev, rx_data, size);
805#endif
806
807 return -ENOTSUP;
808}
809
834static inline int uart_fifo_read_u16(const struct device *dev,
835 uint16_t *rx_data,
836 const int size)
837{
838#if defined(CONFIG_UART_INTERRUPT_DRIVEN) && defined(CONFIG_UART_WIDE_DATA)
839 const struct uart_driver_api *api =
840 (const struct uart_driver_api *)dev->api;
841
842 if (api->fifo_read_u16 == NULL) {
843 return -ENOSYS;
844 }
845
846 return api->fifo_read_u16(dev, rx_data, size);
847#endif
848
849 return -ENOTSUP;
850}
851
857__syscall void uart_irq_tx_enable(const struct device *dev);
858
859static inline void z_impl_uart_irq_tx_enable(const struct device *dev)
860{
861#ifdef CONFIG_UART_INTERRUPT_DRIVEN
862 const struct uart_driver_api *api =
863 (const struct uart_driver_api *)dev->api;
864
865 if (api->irq_tx_enable != NULL) {
866 api->irq_tx_enable(dev);
867 }
868#endif
869}
870
876__syscall void uart_irq_tx_disable(const struct device *dev);
877
878static inline void z_impl_uart_irq_tx_disable(const struct device *dev)
879{
880#ifdef CONFIG_UART_INTERRUPT_DRIVEN
881 const struct uart_driver_api *api =
882 (const struct uart_driver_api *)dev->api;
883
884 if (api->irq_tx_disable != NULL) {
885 api->irq_tx_disable(dev);
886 }
887#endif
888}
889
908static inline int uart_irq_tx_ready(const struct device *dev)
909{
910#ifdef CONFIG_UART_INTERRUPT_DRIVEN
911 const struct uart_driver_api *api =
912 (const struct uart_driver_api *)dev->api;
913
914 if (api->irq_tx_ready == NULL) {
915 return -ENOSYS;
916 }
917
918 return api->irq_tx_ready(dev);
919#endif
920
921 return -ENOTSUP;
922}
923
929__syscall void uart_irq_rx_enable(const struct device *dev);
930
931static inline void z_impl_uart_irq_rx_enable(const struct device *dev)
932{
933#ifdef CONFIG_UART_INTERRUPT_DRIVEN
934 const struct uart_driver_api *api =
935 (const struct uart_driver_api *)dev->api;
936
937 if (api->irq_rx_enable != NULL) {
938 api->irq_rx_enable(dev);
939 }
940#endif
941}
942
948__syscall void uart_irq_rx_disable(const struct device *dev);
949
950static inline void z_impl_uart_irq_rx_disable(const struct device *dev)
951{
952#ifdef CONFIG_UART_INTERRUPT_DRIVEN
953 const struct uart_driver_api *api =
954 (const struct uart_driver_api *)dev->api;
955
956 if (api->irq_rx_disable != NULL) {
957 api->irq_rx_disable(dev);
958 }
959#endif
960}
961
981static inline int uart_irq_tx_complete(const struct device *dev)
982{
983#ifdef CONFIG_UART_INTERRUPT_DRIVEN
984 const struct uart_driver_api *api =
985 (const struct uart_driver_api *)dev->api;
986
987 if (api->irq_tx_complete == NULL) {
988 return -ENOSYS;
989 }
990 return api->irq_tx_complete(dev);
991#endif
992 return -ENOTSUP;
993
994}
995
1016static inline int uart_irq_rx_ready(const struct device *dev)
1017{
1018#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1019 const struct uart_driver_api *api =
1020 (const struct uart_driver_api *)dev->api;
1021
1022 if (api->irq_rx_ready == NULL) {
1023 return -ENOSYS;
1024 }
1025 return api->irq_rx_ready(dev);
1026#endif
1027
1028 return -ENOTSUP;
1029}
1035__syscall void uart_irq_err_enable(const struct device *dev);
1036
1037static inline void z_impl_uart_irq_err_enable(const struct device *dev)
1038{
1039#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1040 const struct uart_driver_api *api =
1041 (const struct uart_driver_api *)dev->api;
1042
1043 if (api->irq_err_enable) {
1044 api->irq_err_enable(dev);
1045 }
1046#endif
1047}
1048
1054__syscall void uart_irq_err_disable(const struct device *dev);
1055
1056static inline void z_impl_uart_irq_err_disable(const struct device *dev)
1057{
1058#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1059 const struct uart_driver_api *api =
1060 (const struct uart_driver_api *)dev->api;
1061
1062 if (api->irq_err_disable) {
1063 api->irq_err_disable(dev);
1064 }
1065#endif
1066}
1067
1078__syscall int uart_irq_is_pending(const struct device *dev);
1079
1080static inline int z_impl_uart_irq_is_pending(const struct device *dev)
1081{
1082#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1083 const struct uart_driver_api *api =
1084 (const struct uart_driver_api *)dev->api;
1085
1086 if (api->irq_is_pending == NULL) {
1087 return -ENOSYS;
1088 }
1089 return api->irq_is_pending(dev);
1090#endif
1091 return -ENOTSUP;
1092}
1093
1119__syscall int uart_irq_update(const struct device *dev);
1120
1121static inline int z_impl_uart_irq_update(const struct device *dev)
1122{
1123#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1124 const struct uart_driver_api *api =
1125 (const struct uart_driver_api *)dev->api;
1126
1127 if (api->irq_update == NULL) {
1128 return -ENOSYS;
1129 }
1130 return api->irq_update(dev);
1131#endif
1132 return -ENOTSUP;
1133}
1134
1146static inline void uart_irq_callback_user_data_set(const struct device *dev,
1148 void *user_data)
1149{
1150#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1151 const struct uart_driver_api *api =
1152 (const struct uart_driver_api *)dev->api;
1153
1154 if ((api != NULL) && (api->irq_callback_set != NULL)) {
1155 api->irq_callback_set(dev, cb, user_data);
1156 }
1157#endif
1158}
1159
1169static inline void uart_irq_callback_set(const struct device *dev,
1171{
1172 uart_irq_callback_user_data_set(dev, cb, NULL);
1173}
1174
1199static inline int uart_callback_set(const struct device *dev,
1200 uart_callback_t callback,
1201 void *user_data)
1202{
1203#ifdef CONFIG_UART_ASYNC_API
1204 const struct uart_driver_api *api =
1205 (const struct uart_driver_api *)dev->api;
1206
1207 if (api->callback_set == NULL) {
1208 return -ENOSYS;
1209 }
1210
1211 return api->callback_set(dev, callback, user_data);
1212#else
1213 return -ENOTSUP;
1214#endif
1215}
1216
1234__syscall int uart_tx(const struct device *dev, const uint8_t *buf,
1235 size_t len,
1237
1238static inline int z_impl_uart_tx(const struct device *dev, const uint8_t *buf,
1239 size_t len, int32_t timeout)
1240
1241{
1242#ifdef CONFIG_UART_ASYNC_API
1243 const struct uart_driver_api *api =
1244 (const struct uart_driver_api *)dev->api;
1245
1246 return api->tx(dev, buf, len, timeout);
1247#else
1248 return -ENOTSUP;
1249#endif
1250}
1251
1269__syscall int uart_tx_u16(const struct device *dev, const uint16_t *buf,
1270 size_t len, int32_t timeout);
1271
1272static inline int z_impl_uart_tx_u16(const struct device *dev,
1273 const uint16_t *buf,
1274 size_t len, int32_t timeout)
1275
1276{
1277#if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
1278 const struct uart_driver_api *api =
1279 (const struct uart_driver_api *)dev->api;
1280
1281 return api->tx_u16(dev, buf, len, timeout);
1282#else
1283 return -ENOTSUP;
1284#endif
1285}
1286
1300__syscall int uart_tx_abort(const struct device *dev);
1301
1302static inline int z_impl_uart_tx_abort(const struct device *dev)
1303{
1304#ifdef CONFIG_UART_ASYNC_API
1305 const struct uart_driver_api *api =
1306 (const struct uart_driver_api *)dev->api;
1307
1308 return api->tx_abort(dev);
1309#else
1310 return -ENOTSUP;
1311#endif
1312}
1313
1336__syscall int uart_rx_enable(const struct device *dev, uint8_t *buf,
1337 size_t len,
1339
1340static inline int z_impl_uart_rx_enable(const struct device *dev,
1341 uint8_t *buf,
1342 size_t len, int32_t timeout)
1343{
1344#ifdef CONFIG_UART_ASYNC_API
1345 const struct uart_driver_api *api =
1346 (const struct uart_driver_api *)dev->api;
1347
1348 return api->rx_enable(dev, buf, len, timeout);
1349#else
1350 return -ENOTSUP;
1351#endif
1352}
1353
1376__syscall int uart_rx_enable_u16(const struct device *dev, uint16_t *buf,
1377 size_t len, int32_t timeout);
1378
1379static inline int z_impl_uart_rx_enable_u16(const struct device *dev,
1380 uint16_t *buf, size_t len,
1382{
1383#if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
1384 const struct uart_driver_api *api =
1385 (const struct uart_driver_api *)dev->api;
1386
1387 return api->rx_enable_u16(dev, buf, len, timeout);
1388#else
1389 return -ENOTSUP;
1390#endif
1391}
1392
1414static inline int uart_rx_buf_rsp(const struct device *dev, uint8_t *buf,
1415 size_t len)
1416{
1417#ifdef CONFIG_UART_ASYNC_API
1418 const struct uart_driver_api *api =
1419 (const struct uart_driver_api *)dev->api;
1420
1421 return api->rx_buf_rsp(dev, buf, len);
1422#else
1423 return -ENOTSUP;
1424#endif
1425}
1426
1448static inline int uart_rx_buf_rsp_u16(const struct device *dev, uint16_t *buf,
1449 size_t len)
1450{
1451#if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
1452 const struct uart_driver_api *api =
1453 (const struct uart_driver_api *)dev->api;
1454
1455 return api->rx_buf_rsp_u16(dev, buf, len);
1456#else
1457 return -ENOTSUP;
1458#endif
1459}
1460
1477__syscall int uart_rx_disable(const struct device *dev);
1478
1479static inline int z_impl_uart_rx_disable(const struct device *dev)
1480{
1481#ifdef CONFIG_UART_ASYNC_API
1482 const struct uart_driver_api *api =
1483 (const struct uart_driver_api *)dev->api;
1484
1485 return api->rx_disable(dev);
1486#else
1487 return -ENOTSUP;
1488#endif
1489}
1490
1507__syscall int uart_line_ctrl_set(const struct device *dev,
1508 uint32_t ctrl, uint32_t val);
1509
1510static inline int z_impl_uart_line_ctrl_set(const struct device *dev,
1511 uint32_t ctrl, uint32_t val)
1512{
1513#ifdef CONFIG_UART_LINE_CTRL
1514 const struct uart_driver_api *api =
1515 (const struct uart_driver_api *)dev->api;
1516
1517 if (api->line_ctrl_set == NULL) {
1518 return -ENOSYS;
1519 }
1520 return api->line_ctrl_set(dev, ctrl, val);
1521#endif
1522
1523 return -ENOTSUP;
1524}
1525
1538__syscall int uart_line_ctrl_get(const struct device *dev, uint32_t ctrl,
1539 uint32_t *val);
1540
1541static inline int z_impl_uart_line_ctrl_get(const struct device *dev,
1542 uint32_t ctrl, uint32_t *val)
1543{
1544#ifdef CONFIG_UART_LINE_CTRL
1545 const struct uart_driver_api *api =
1546 (const struct uart_driver_api *)dev->api;
1547
1548 if (api->line_ctrl_get == NULL) {
1549 return -ENOSYS;
1550 }
1551 return api->line_ctrl_get(dev, ctrl, val);
1552#endif
1553
1554 return -ENOTSUP;
1555}
1556
1572__syscall int uart_drv_cmd(const struct device *dev, uint32_t cmd, uint32_t p);
1573
1574static inline int z_impl_uart_drv_cmd(const struct device *dev, uint32_t cmd,
1575 uint32_t p)
1576{
1577#ifdef CONFIG_UART_DRV_CMD
1578 const struct uart_driver_api *api =
1579 (const struct uart_driver_api *)dev->api;
1580
1581 if (api->drv_cmd == NULL) {
1582 return -ENOSYS;
1583 }
1584 return api->drv_cmd(dev, cmd, p);
1585#endif
1586
1587 return -ENOTSUP;
1588}
1589
1590#ifdef __cplusplus
1591}
1592#endif
1593
1598#include <syscalls/uart.h>
1599
1600#endif /* ZEPHYR_INCLUDE_DRIVERS_UART_H_ */
ZTEST_BMEM int timeout
Definition: main.c:31
System error numbers.
static void cmd(uint32_t command)
Execute a display list command by co-processor engine.
Definition: ft8xx_reference_api.h:153
#define BIT(n)
Unsigned integer with bit position n set (signed in assembly language).
Definition: util_macro.h:44
#define ENOSYS
Definition: errno.h:83
#define ENOTSUP
Definition: errno.h:115
int uart_rx_enable_u16(const struct device *dev, uint16_t *buf, size_t len, int32_t timeout)
Start receiving wide data through UART.
static int uart_rx_buf_rsp(const struct device *dev, uint8_t *buf, size_t len)
Provide receive buffer in response to uart_event_type::UART_RX_BUF_REQUEST event.
Definition: uart.h:1414
static int uart_rx_buf_rsp_u16(const struct device *dev, uint16_t *buf, size_t len)
Provide wide data receive buffer in response to uart_event_type::UART_RX_BUF_REQUEST event.
Definition: uart.h:1448
void(* uart_callback_t)(const struct device *dev, struct uart_event *evt, void *user_data)
Define the application callback function signature for uart_callback_set() function.
Definition: uart.h:333
int uart_rx_enable(const struct device *dev, uint8_t *buf, size_t len, int32_t timeout)
Start receiving data through UART.
int uart_tx_abort(const struct device *dev)
Abort current TX transmission.
int uart_tx_u16(const struct device *dev, const uint16_t *buf, size_t len, int32_t timeout)
Send given number of datum from buffer through UART.
static int uart_callback_set(const struct device *dev, uart_callback_t callback, void *user_data)
Set event handler function.
Definition: uart.h:1199
uart_event_type
Types of events passed to callback in UART_ASYNC_API.
Definition: uart.h:211
int uart_tx(const struct device *dev, const uint8_t *buf, size_t len, int32_t timeout)
Send given number of bytes from buffer through UART.
int uart_rx_disable(const struct device *dev)
Disable RX.
@ UART_RX_STOPPED
RX has stopped due to external event.
Definition: uart.h:263
@ UART_TX_ABORTED
Transmitting aborted due to timeout or uart_tx_abort call.
Definition: uart.h:221
@ UART_RX_BUF_REQUEST
Driver requests next buffer for continuous reception.
Definition: uart.h:245
@ UART_TX_DONE
Whole TX buffer was transmitted.
Definition: uart.h:213
@ UART_RX_RDY
Received data is ready for processing.
Definition: uart.h:233
@ UART_RX_DISABLED
RX has been disabled and can be reenabled.
Definition: uart.h:257
@ UART_RX_BUF_RELEASED
Buffer is no longer used by UART driver.
Definition: uart.h:249
uart_line_ctrl
Line control signals.
Definition: uart.h:33
int uart_err_check(const struct device *dev)
Check whether an error was detected.
int uart_config_get(const struct device *dev, struct uart_config *cfg)
Get UART configuration.
uart_config_flow_control
Hardware flow control options.
Definition: uart.h:107
int uart_configure(const struct device *dev, const struct uart_config *cfg)
Set UART configuration.
int uart_drv_cmd(const struct device *dev, uint32_t cmd, uint32_t p)
Send extra command to driver.
int uart_line_ctrl_set(const struct device *dev, uint32_t ctrl, uint32_t val)
Manipulate line control for UART.
uart_config_parity
Parity modes.
Definition: uart.h:75
uart_config_data_bits
Number of data bits.
Definition: uart.h:92
uart_rx_stop_reason
Reception stop reasons.
Definition: uart.h:47
uart_config_stop_bits
Number of stop bits.
Definition: uart.h:84
int uart_line_ctrl_get(const struct device *dev, uint32_t ctrl, uint32_t *val)
Retrieve line control for UART.
@ UART_LINE_CTRL_DTR
Definition: uart.h:36
@ UART_LINE_CTRL_RTS
Definition: uart.h:35
@ UART_LINE_CTRL_BAUD_RATE
Definition: uart.h:34
@ UART_LINE_CTRL_DCD
Definition: uart.h:37
@ UART_LINE_CTRL_DSR
Definition: uart.h:38
@ UART_CFG_FLOW_CTRL_DTR_DSR
Definition: uart.h:110
@ UART_CFG_FLOW_CTRL_NONE
Definition: uart.h:108
@ UART_CFG_FLOW_CTRL_RTS_CTS
Definition: uart.h:109
@ UART_CFG_PARITY_MARK
Definition: uart.h:79
@ UART_CFG_PARITY_NONE
Definition: uart.h:76
@ UART_CFG_PARITY_ODD
Definition: uart.h:77
@ UART_CFG_PARITY_SPACE
Definition: uart.h:80
@ UART_CFG_PARITY_EVEN
Definition: uart.h:78
@ UART_CFG_DATA_BITS_5
Definition: uart.h:93
@ UART_CFG_DATA_BITS_8
Definition: uart.h:96
@ UART_CFG_DATA_BITS_7
Definition: uart.h:95
@ UART_CFG_DATA_BITS_6
Definition: uart.h:94
@ UART_CFG_DATA_BITS_9
Definition: uart.h:97
@ UART_ERROR_OVERRUN
Overrun error.
Definition: uart.h:49
@ UART_BREAK
Break interrupt.
Definition: uart.h:61
@ UART_ERROR_PARITY
Parity error.
Definition: uart.h:51
@ UART_ERROR_COLLISION
Collision error.
Definition: uart.h:71
@ UART_ERROR_FRAMING
Framing error.
Definition: uart.h:53
@ UART_CFG_STOP_BITS_1_5
Definition: uart.h:87
@ UART_CFG_STOP_BITS_0_5
Definition: uart.h:85
@ UART_CFG_STOP_BITS_1
Definition: uart.h:86
@ UART_CFG_STOP_BITS_2
Definition: uart.h:88
int uart_irq_is_pending(const struct device *dev)
Check if any IRQs is pending.
static int uart_fifo_read_u16(const struct device *dev, uint16_t *rx_data, const int size)
Read wide data from FIFO.
Definition: uart.h:834
void uart_irq_rx_enable(const struct device *dev)
Enable RX interrupt.
static int uart_irq_tx_ready(const struct device *dev)
Check if UART TX buffer can accept a new char.
Definition: uart.h:908
void(* uart_irq_config_func_t)(const struct device *dev)
For configuring IRQ on each individual UART device.
Definition: uart.h:150
void uart_irq_err_enable(const struct device *dev)
Enable error interrupt.
static int uart_irq_tx_complete(const struct device *dev)
Check if UART TX block finished transmission.
Definition: uart.h:981
void uart_irq_tx_enable(const struct device *dev)
Enable TX interrupt in IER.
void uart_irq_rx_disable(const struct device *dev)
Disable RX interrupt.
static int uart_fifo_fill_u16(const struct device *dev, const uint16_t *tx_data, int size)
Fill FIFO with wide data.
Definition: uart.h:751
void uart_irq_err_disable(const struct device *dev)
Disable error interrupt.
static int uart_fifo_read(const struct device *dev, uint8_t *rx_data, const int size)
Read data from FIFO.
Definition: uart.h:793
int uart_irq_update(const struct device *dev)
Start processing interrupts in ISR.
static void uart_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb)
Set the IRQ callback function pointer (legacy).
Definition: uart.h:1169
static int uart_irq_rx_ready(const struct device *dev)
Check if UART RX buffer has a received char.
Definition: uart.h:1016
void(* uart_irq_callback_user_data_t)(const struct device *dev, void *user_data)
Define the application callback function signature for uart_irq_callback_user_data_set() function.
Definition: uart.h:142
static void uart_irq_callback_user_data_set(const struct device *dev, uart_irq_callback_user_data_t cb, void *user_data)
Set the IRQ callback function pointer.
Definition: uart.h:1146
void uart_irq_tx_disable(const struct device *dev)
Disable TX interrupt in IER.
static int uart_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size)
Fill FIFO with data.
Definition: uart.h:713
void uart_poll_out(const struct device *dev, unsigned char out_char)
Output a character in polled mode.
void uart_poll_out_u16(const struct device *dev, uint16_t out_u16)
Output wide data in polled mode.
int uart_poll_in_u16(const struct device *dev, uint16_t *p_u16)
Poll the device for wide data input.
int uart_poll_in(const struct device *dev, unsigned char *p_char)
Poll the device for input.
struct k_pipe p
Definition: kobject.c:1316
__UINT32_TYPE__ uint32_t
Definition: stdint.h:60
__INT32_TYPE__ int32_t
Definition: stdint.h:44
__UINT8_TYPE__ uint8_t
Definition: stdint.h:58
__UINT16_TYPE__ uint16_t
Definition: stdint.h:59
Runtime device structure (in ROM) per driver instance.
Definition: device.h:450
const void * api
Definition: device.h:456
UART controller configuration structure.
Definition: uart.h:122
uint8_t stop_bits
Definition: uart.h:125
uint8_t parity
Definition: uart.h:124
uint8_t data_bits
Definition: uart.h:126
uint32_t baudrate
Definition: uart.h:123
uint8_t flow_ctrl
Definition: uart.h:127
UART RX buffer released event data.
Definition: uart.h:290
uint8_t * buf
Definition: uart.h:292
UART RX stopped data.
Definition: uart.h:296
struct uart_event_rx data
Last received data.
Definition: uart.h:300
enum uart_rx_stop_reason reason
Reason why receiving stopped.
Definition: uart.h:298
UART RX event data.
Definition: uart.h:280
uint8_t * buf
Pointer to current buffer.
Definition: uart.h:282
size_t len
Number of new bytes received.
Definition: uart.h:286
size_t offset
Currently received data offset in bytes.
Definition: uart.h:284
UART TX event data.
Definition: uart.h:267
const uint8_t * buf
Pointer to current buffer.
Definition: uart.h:269
size_t len
Number of bytes sent.
Definition: uart.h:271
Structure containing information about current event.
Definition: uart.h:304
union uart_event::uart_event_data data
enum uart_event_type type
Type of event.
Definition: uart.h:306
static const intptr_t user_data[5]
Definition: main.c:590
Event data.
Definition: uart.h:308
struct uart_event_tx tx
uart_event_type::UART_TX_DONE and uart_event_type::UART_TX_ABORTED events data.
Definition: uart.h:312
struct uart_event_rx_stop rx_stop
uart_event_type::UART_RX_STOPPED event data.
Definition: uart.h:320
struct uart_event_rx_buf rx_buf
uart_event_type::UART_RX_BUF_RELEASED event data.
Definition: uart.h:318
struct uart_event_rx rx
uart_event_type::UART_RX_RDY event data.
Definition: uart.h:314