Zephyr Project API  3.2.0
A Scalable Open Source RTOS
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 <zephyr/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
347__subsystem struct uart_driver_api {
348
349#ifdef CONFIG_UART_ASYNC_API
350
351 int (*callback_set)(const struct device *dev,
352 uart_callback_t callback,
353 void *user_data);
354
355 int (*tx)(const struct device *dev, const uint8_t *buf, size_t len,
357 int (*tx_abort)(const struct device *dev);
358
359 int (*rx_enable)(const struct device *dev, uint8_t *buf, size_t len,
361 int (*rx_buf_rsp)(const struct device *dev, uint8_t *buf, size_t len);
362 int (*rx_disable)(const struct device *dev);
363
364#ifdef CONFIG_UART_WIDE_DATA
365 int (*tx_u16)(const struct device *dev, const uint16_t *buf,
366 size_t len, int32_t timeout);
367 int (*rx_enable_u16)(const struct device *dev, uint16_t *buf,
368 size_t len, int32_t timeout);
369 int (*rx_buf_rsp_u16)(const struct device *dev, uint16_t *buf,
370 size_t len);
371#endif
372
373#endif
374
376 int (*poll_in)(const struct device *dev, unsigned char *p_char);
377 void (*poll_out)(const struct device *dev, unsigned char out_char);
378
379#ifdef CONFIG_UART_WIDE_DATA
380 int (*poll_in_u16)(const struct device *dev, uint16_t *p_u16);
381 void (*poll_out_u16)(const struct device *dev, uint16_t out_u16);
382#endif
383
385 int (*err_check)(const struct device *dev);
386
388 int (*configure)(const struct device *dev,
389 const struct uart_config *cfg);
390 int (*config_get)(const struct device *dev, struct uart_config *cfg);
391
392#ifdef CONFIG_UART_INTERRUPT_DRIVEN
393
395 int (*fifo_fill)(const struct device *dev, const uint8_t *tx_data,
396 int len);
397
398#ifdef CONFIG_UART_WIDE_DATA
399 int (*fifo_fill_u16)(const struct device *dev, const uint16_t *tx_data,
400 int len);
401#endif
402
404 int (*fifo_read)(const struct device *dev, uint8_t *rx_data,
405 const int size);
406
407#ifdef CONFIG_UART_WIDE_DATA
408 int (*fifo_read_u16)(const struct device *dev, uint16_t *rx_data,
409 const int size);
410#endif
411
413 void (*irq_tx_enable)(const struct device *dev);
414
416 void (*irq_tx_disable)(const struct device *dev);
417
419 int (*irq_tx_ready)(const struct device *dev);
420
422 void (*irq_rx_enable)(const struct device *dev);
423
425 void (*irq_rx_disable)(const struct device *dev);
426
428 int (*irq_tx_complete)(const struct device *dev);
429
431 int (*irq_rx_ready)(const struct device *dev);
432
434 void (*irq_err_enable)(const struct device *dev);
435
437 void (*irq_err_disable)(const struct device *dev);
438
440 int (*irq_is_pending)(const struct device *dev);
441
443 int (*irq_update)(const struct device *dev);
444
446 void (*irq_callback_set)(const struct device *dev,
448 void *user_data);
449
450#endif
451
452#ifdef CONFIG_UART_LINE_CTRL
453 int (*line_ctrl_set)(const struct device *dev, uint32_t ctrl,
454 uint32_t val);
455 int (*line_ctrl_get)(const struct device *dev, uint32_t ctrl,
456 uint32_t *val);
457#endif
458
459#ifdef CONFIG_UART_DRV_CMD
460 int (*drv_cmd)(const struct device *dev, uint32_t cmd, uint32_t p);
461#endif
462
463};
464
476__syscall int uart_err_check(const struct device *dev);
477
478static inline int z_impl_uart_err_check(const struct device *dev)
479{
480 const struct uart_driver_api *api =
481 (const struct uart_driver_api *)dev->api;
482
483 if (api->err_check == NULL) {
484 return -ENOSYS;
485 }
486
487 return api->err_check(dev);
488}
489
513__syscall int uart_poll_in(const struct device *dev, unsigned char *p_char);
514
515static inline int z_impl_uart_poll_in(const struct device *dev,
516 unsigned char *p_char)
517{
518 const struct uart_driver_api *api =
519 (const struct uart_driver_api *)dev->api;
520
521 if (api->poll_in == NULL) {
522 return -ENOSYS;
523 }
524
525 return api->poll_in(dev, p_char);
526}
527
547__syscall int uart_poll_in_u16(const struct device *dev, uint16_t *p_u16);
548
549static inline int z_impl_uart_poll_in_u16(const struct device *dev,
550 uint16_t *p_u16)
551{
552#ifdef CONFIG_UART_WIDE_DATA
553 const struct uart_driver_api *api =
554 (const struct uart_driver_api *)dev->api;
555
556 if (api->poll_in_u16 == NULL) {
557 return -ENOSYS;
558 }
559
560 return api->poll_in_u16(dev, p_u16);
561#else
562 ARG_UNUSED(dev);
563 ARG_UNUSED(p_u16);
564 return -ENOTSUP;
565#endif
566}
567
582__syscall void uart_poll_out(const struct device *dev,
583 unsigned char out_char);
584
585static inline void z_impl_uart_poll_out(const struct device *dev,
586 unsigned char out_char)
587{
588 const struct uart_driver_api *api =
589 (const struct uart_driver_api *)dev->api;
590
591 api->poll_out(dev, out_char);
592}
593
608__syscall void uart_poll_out_u16(const struct device *dev, uint16_t out_u16);
609
610static inline void z_impl_uart_poll_out_u16(const struct device *dev,
611 uint16_t out_u16)
612{
613#ifdef CONFIG_UART_WIDE_DATA
614 const struct uart_driver_api *api =
615 (const struct uart_driver_api *)dev->api;
616
617 api->poll_out_u16(dev, out_u16);
618#else
619 ARG_UNUSED(dev);
620 ARG_UNUSED(out_u16);
621#endif
622}
623
641__syscall int uart_configure(const struct device *dev,
642 const struct uart_config *cfg);
643
644static inline int z_impl_uart_configure(const struct device *dev,
645 const struct uart_config *cfg)
646{
647 const struct uart_driver_api *api =
648 (const struct uart_driver_api *)dev->api;
649
650 if (api->configure == NULL) {
651 return -ENOSYS;
652 }
653 return api->configure(dev, cfg);
654}
655
669__syscall int uart_config_get(const struct device *dev,
670 struct uart_config *cfg);
671
672static inline int z_impl_uart_config_get(const struct device *dev,
673 struct uart_config *cfg)
674{
675 const struct uart_driver_api *api =
676 (const struct uart_driver_api *)dev->api;
677
678 if (api->config_get == NULL) {
679 return -ENOSYS;
680 }
681
682 return api->config_get(dev, cfg);
683}
684
710static inline int uart_fifo_fill(const struct device *dev,
711 const uint8_t *tx_data,
712 int size)
713{
714#ifdef CONFIG_UART_INTERRUPT_DRIVEN
715 const struct uart_driver_api *api =
716 (const struct uart_driver_api *)dev->api;
717
718 if (api->fifo_fill == NULL) {
719 return -ENOSYS;
720 }
721
722 return api->fifo_fill(dev, tx_data, size);
723#else
724 ARG_UNUSED(dev);
725 ARG_UNUSED(tx_data);
726 ARG_UNUSED(size);
727 return -ENOTSUP;
728#endif
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 ARG_UNUSED(dev);
766 ARG_UNUSED(tx_data);
767 ARG_UNUSED(size);
768 return -ENOTSUP;
769#endif
770}
771
796static inline int uart_fifo_read(const struct device *dev, uint8_t *rx_data,
797 const int size)
798{
799#ifdef CONFIG_UART_INTERRUPT_DRIVEN
800 const struct uart_driver_api *api =
801 (const struct uart_driver_api *)dev->api;
802
803 if (api->fifo_read == NULL) {
804 return -ENOSYS;
805 }
806
807 return api->fifo_read(dev, rx_data, size);
808#else
809 ARG_UNUSED(dev);
810 ARG_UNUSED(rx_data);
811 ARG_UNUSED(size);
812 return -ENOTSUP;
813#endif
814}
815
840static inline int uart_fifo_read_u16(const struct device *dev,
841 uint16_t *rx_data,
842 const int size)
843{
844#if defined(CONFIG_UART_INTERRUPT_DRIVEN) && defined(CONFIG_UART_WIDE_DATA)
845 const struct uart_driver_api *api =
846 (const struct uart_driver_api *)dev->api;
847
848 if (api->fifo_read_u16 == NULL) {
849 return -ENOSYS;
850 }
851
852 return api->fifo_read_u16(dev, rx_data, size);
853#else
854 ARG_UNUSED(dev);
855 ARG_UNUSED(rx_data);
856 ARG_UNUSED(size);
857 return -ENOTSUP;
858#endif
859}
860
866__syscall void uart_irq_tx_enable(const struct device *dev);
867
868static inline void z_impl_uart_irq_tx_enable(const struct device *dev)
869{
870#ifdef CONFIG_UART_INTERRUPT_DRIVEN
871 const struct uart_driver_api *api =
872 (const struct uart_driver_api *)dev->api;
873
874 if (api->irq_tx_enable != NULL) {
875 api->irq_tx_enable(dev);
876 }
877#else
878 ARG_UNUSED(dev);
879#endif
880}
881
887__syscall void uart_irq_tx_disable(const struct device *dev);
888
889static inline void z_impl_uart_irq_tx_disable(const struct device *dev)
890{
891#ifdef CONFIG_UART_INTERRUPT_DRIVEN
892 const struct uart_driver_api *api =
893 (const struct uart_driver_api *)dev->api;
894
895 if (api->irq_tx_disable != NULL) {
896 api->irq_tx_disable(dev);
897 }
898#else
899 ARG_UNUSED(dev);
900#endif
901}
902
921static inline int uart_irq_tx_ready(const struct device *dev)
922{
923#ifdef CONFIG_UART_INTERRUPT_DRIVEN
924 const struct uart_driver_api *api =
925 (const struct uart_driver_api *)dev->api;
926
927 if (api->irq_tx_ready == NULL) {
928 return -ENOSYS;
929 }
930
931 return api->irq_tx_ready(dev);
932#else
933 ARG_UNUSED(dev);
934 return -ENOTSUP;
935#endif
936}
937
943__syscall void uart_irq_rx_enable(const struct device *dev);
944
945static inline void z_impl_uart_irq_rx_enable(const struct device *dev)
946{
947#ifdef CONFIG_UART_INTERRUPT_DRIVEN
948 const struct uart_driver_api *api =
949 (const struct uart_driver_api *)dev->api;
950
951 if (api->irq_rx_enable != NULL) {
952 api->irq_rx_enable(dev);
953 }
954#else
955 ARG_UNUSED(dev);
956#endif
957}
958
964__syscall void uart_irq_rx_disable(const struct device *dev);
965
966static inline void z_impl_uart_irq_rx_disable(const struct device *dev)
967{
968#ifdef CONFIG_UART_INTERRUPT_DRIVEN
969 const struct uart_driver_api *api =
970 (const struct uart_driver_api *)dev->api;
971
972 if (api->irq_rx_disable != NULL) {
973 api->irq_rx_disable(dev);
974 }
975#else
976 ARG_UNUSED(dev);
977#endif
978}
979
999static inline int uart_irq_tx_complete(const struct device *dev)
1000{
1001#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1002 const struct uart_driver_api *api =
1003 (const struct uart_driver_api *)dev->api;
1004
1005 if (api->irq_tx_complete == NULL) {
1006 return -ENOSYS;
1007 }
1008 return api->irq_tx_complete(dev);
1009#else
1010 ARG_UNUSED(dev);
1011 return -ENOTSUP;
1012#endif
1013}
1014
1035static inline int uart_irq_rx_ready(const struct device *dev)
1036{
1037#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1038 const struct uart_driver_api *api =
1039 (const struct uart_driver_api *)dev->api;
1040
1041 if (api->irq_rx_ready == NULL) {
1042 return -ENOSYS;
1043 }
1044 return api->irq_rx_ready(dev);
1045#else
1046 ARG_UNUSED(dev);
1047 return -ENOTSUP;
1048#endif
1049}
1055__syscall void uart_irq_err_enable(const struct device *dev);
1056
1057static inline void z_impl_uart_irq_err_enable(const struct device *dev)
1058{
1059#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1060 const struct uart_driver_api *api =
1061 (const struct uart_driver_api *)dev->api;
1062
1063 if (api->irq_err_enable) {
1064 api->irq_err_enable(dev);
1065 }
1066#else
1067 ARG_UNUSED(dev);
1068#endif
1069}
1070
1076__syscall void uart_irq_err_disable(const struct device *dev);
1077
1078static inline void z_impl_uart_irq_err_disable(const struct device *dev)
1079{
1080#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1081 const struct uart_driver_api *api =
1082 (const struct uart_driver_api *)dev->api;
1083
1084 if (api->irq_err_disable) {
1085 api->irq_err_disable(dev);
1086 }
1087#else
1088 ARG_UNUSED(dev);
1089#endif
1090}
1091
1102__syscall int uart_irq_is_pending(const struct device *dev);
1103
1104static inline int z_impl_uart_irq_is_pending(const struct device *dev)
1105{
1106#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1107 const struct uart_driver_api *api =
1108 (const struct uart_driver_api *)dev->api;
1109
1110 if (api->irq_is_pending == NULL) {
1111 return -ENOSYS;
1112 }
1113 return api->irq_is_pending(dev);
1114#else
1115 ARG_UNUSED(dev);
1116 return -ENOTSUP;
1117#endif
1118}
1119
1145__syscall int uart_irq_update(const struct device *dev);
1146
1147static inline int z_impl_uart_irq_update(const struct device *dev)
1148{
1149#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1150 const struct uart_driver_api *api =
1151 (const struct uart_driver_api *)dev->api;
1152
1153 if (api->irq_update == NULL) {
1154 return -ENOSYS;
1155 }
1156 return api->irq_update(dev);
1157#else
1158 ARG_UNUSED(dev);
1159 return -ENOTSUP;
1160#endif
1161}
1162
1174static inline void uart_irq_callback_user_data_set(const struct device *dev,
1176 void *user_data)
1177{
1178#ifdef CONFIG_UART_INTERRUPT_DRIVEN
1179 const struct uart_driver_api *api =
1180 (const struct uart_driver_api *)dev->api;
1181
1182 if ((api != NULL) && (api->irq_callback_set != NULL)) {
1183 api->irq_callback_set(dev, cb, user_data);
1184 }
1185#else
1186 ARG_UNUSED(dev);
1187 ARG_UNUSED(cb);
1188 ARG_UNUSED(user_data);
1189#endif
1190}
1191
1201static inline void uart_irq_callback_set(const struct device *dev,
1203{
1204 uart_irq_callback_user_data_set(dev, cb, NULL);
1205}
1206
1231static inline int uart_callback_set(const struct device *dev,
1232 uart_callback_t callback,
1233 void *user_data)
1234{
1235#ifdef CONFIG_UART_ASYNC_API
1236 const struct uart_driver_api *api =
1237 (const struct uart_driver_api *)dev->api;
1238
1239 if (api->callback_set == NULL) {
1240 return -ENOSYS;
1241 }
1242
1243 return api->callback_set(dev, callback, user_data);
1244#else
1245 ARG_UNUSED(dev);
1246 ARG_UNUSED(callback);
1247 ARG_UNUSED(user_data);
1248 return -ENOTSUP;
1249#endif
1250}
1251
1269__syscall int uart_tx(const struct device *dev, const uint8_t *buf,
1270 size_t len,
1272
1273static inline int z_impl_uart_tx(const struct device *dev, const uint8_t *buf,
1274 size_t len, int32_t timeout)
1275
1276{
1277#ifdef CONFIG_UART_ASYNC_API
1278 const struct uart_driver_api *api =
1279 (const struct uart_driver_api *)dev->api;
1280
1281 return api->tx(dev, buf, len, timeout);
1282#else
1283 ARG_UNUSED(dev);
1284 ARG_UNUSED(buf);
1285 ARG_UNUSED(len);
1286 ARG_UNUSED(timeout);
1287 return -ENOTSUP;
1288#endif
1289}
1290
1308__syscall int uart_tx_u16(const struct device *dev, const uint16_t *buf,
1309 size_t len, int32_t timeout);
1310
1311static inline int z_impl_uart_tx_u16(const struct device *dev,
1312 const uint16_t *buf,
1313 size_t len, int32_t timeout)
1314
1315{
1316#if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
1317 const struct uart_driver_api *api =
1318 (const struct uart_driver_api *)dev->api;
1319
1320 return api->tx_u16(dev, buf, len, timeout);
1321#else
1322 ARG_UNUSED(dev);
1323 ARG_UNUSED(buf);
1324 ARG_UNUSED(len);
1325 ARG_UNUSED(timeout);
1326 return -ENOTSUP;
1327#endif
1328}
1329
1343__syscall int uart_tx_abort(const struct device *dev);
1344
1345static inline int z_impl_uart_tx_abort(const struct device *dev)
1346{
1347#ifdef CONFIG_UART_ASYNC_API
1348 const struct uart_driver_api *api =
1349 (const struct uart_driver_api *)dev->api;
1350
1351 return api->tx_abort(dev);
1352#else
1353 ARG_UNUSED(dev);
1354 return -ENOTSUP;
1355#endif
1356}
1357
1380__syscall int uart_rx_enable(const struct device *dev, uint8_t *buf,
1381 size_t len,
1383
1384static inline int z_impl_uart_rx_enable(const struct device *dev,
1385 uint8_t *buf,
1386 size_t len, int32_t timeout)
1387{
1388#ifdef CONFIG_UART_ASYNC_API
1389 const struct uart_driver_api *api =
1390 (const struct uart_driver_api *)dev->api;
1391
1392 return api->rx_enable(dev, buf, len, timeout);
1393#else
1394 ARG_UNUSED(dev);
1395 ARG_UNUSED(buf);
1396 ARG_UNUSED(len);
1397 ARG_UNUSED(timeout);
1398 return -ENOTSUP;
1399#endif
1400}
1401
1424__syscall int uart_rx_enable_u16(const struct device *dev, uint16_t *buf,
1425 size_t len, int32_t timeout);
1426
1427static inline int z_impl_uart_rx_enable_u16(const struct device *dev,
1428 uint16_t *buf, size_t len,
1430{
1431#if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
1432 const struct uart_driver_api *api =
1433 (const struct uart_driver_api *)dev->api;
1434
1435 return api->rx_enable_u16(dev, buf, len, timeout);
1436#else
1437 ARG_UNUSED(dev);
1438 ARG_UNUSED(buf);
1439 ARG_UNUSED(len);
1440 ARG_UNUSED(timeout);
1441 return -ENOTSUP;
1442#endif
1443}
1444
1466static inline int uart_rx_buf_rsp(const struct device *dev, uint8_t *buf,
1467 size_t len)
1468{
1469#ifdef CONFIG_UART_ASYNC_API
1470 const struct uart_driver_api *api =
1471 (const struct uart_driver_api *)dev->api;
1472
1473 return api->rx_buf_rsp(dev, buf, len);
1474#else
1475 ARG_UNUSED(dev);
1476 ARG_UNUSED(buf);
1477 ARG_UNUSED(len);
1478 return -ENOTSUP;
1479#endif
1480}
1481
1503static inline int uart_rx_buf_rsp_u16(const struct device *dev, uint16_t *buf,
1504 size_t len)
1505{
1506#if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
1507 const struct uart_driver_api *api =
1508 (const struct uart_driver_api *)dev->api;
1509
1510 return api->rx_buf_rsp_u16(dev, buf, len);
1511#else
1512 ARG_UNUSED(dev);
1513 ARG_UNUSED(buf);
1514 ARG_UNUSED(len);
1515 return -ENOTSUP;
1516#endif
1517}
1518
1535__syscall int uart_rx_disable(const struct device *dev);
1536
1537static inline int z_impl_uart_rx_disable(const struct device *dev)
1538{
1539#ifdef CONFIG_UART_ASYNC_API
1540 const struct uart_driver_api *api =
1541 (const struct uart_driver_api *)dev->api;
1542
1543 return api->rx_disable(dev);
1544#else
1545 ARG_UNUSED(dev);
1546 return -ENOTSUP;
1547#endif
1548}
1549
1566__syscall int uart_line_ctrl_set(const struct device *dev,
1567 uint32_t ctrl, uint32_t val);
1568
1569static inline int z_impl_uart_line_ctrl_set(const struct device *dev,
1570 uint32_t ctrl, uint32_t val)
1571{
1572#ifdef CONFIG_UART_LINE_CTRL
1573 const struct uart_driver_api *api =
1574 (const struct uart_driver_api *)dev->api;
1575
1576 if (api->line_ctrl_set == NULL) {
1577 return -ENOSYS;
1578 }
1579 return api->line_ctrl_set(dev, ctrl, val);
1580#else
1581 ARG_UNUSED(dev);
1582 ARG_UNUSED(ctrl);
1583 ARG_UNUSED(val);
1584 return -ENOTSUP;
1585#endif
1586}
1587
1600__syscall int uart_line_ctrl_get(const struct device *dev, uint32_t ctrl,
1601 uint32_t *val);
1602
1603static inline int z_impl_uart_line_ctrl_get(const struct device *dev,
1604 uint32_t ctrl, uint32_t *val)
1605{
1606#ifdef CONFIG_UART_LINE_CTRL
1607 const struct uart_driver_api *api =
1608 (const struct uart_driver_api *)dev->api;
1609
1610 if (api->line_ctrl_get == NULL) {
1611 return -ENOSYS;
1612 }
1613 return api->line_ctrl_get(dev, ctrl, val);
1614#else
1615 ARG_UNUSED(dev);
1616 ARG_UNUSED(ctrl);
1617 ARG_UNUSED(val);
1618 return -ENOTSUP;
1619#endif
1620}
1621
1637__syscall int uart_drv_cmd(const struct device *dev, uint32_t cmd, uint32_t p);
1638
1639static inline int z_impl_uart_drv_cmd(const struct device *dev, uint32_t cmd,
1640 uint32_t p)
1641{
1642#ifdef CONFIG_UART_DRV_CMD
1643 const struct uart_driver_api *api =
1644 (const struct uart_driver_api *)dev->api;
1645
1646 if (api->drv_cmd == NULL) {
1647 return -ENOSYS;
1648 }
1649 return api->drv_cmd(dev, cmd, p);
1650#else
1651 ARG_UNUSED(dev);
1652 ARG_UNUSED(cmd);
1653 ARG_UNUSED(p);
1654 return -ENOTSUP;
1655#endif
1656}
1657
1658#ifdef __cplusplus
1659}
1660#endif
1661
1666#include <syscalls/uart.h>
1667
1668#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:1466
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:1503
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:1231
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:840
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:921
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:999
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:796
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:1201
static int uart_irq_rx_ready(const struct device *dev)
Check if UART RX buffer has a received char.
Definition: uart.h:1035
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:1174
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:710
void uart_poll_out(const struct device *dev, unsigned char out_char)
Write a character to the device for output.
void uart_poll_out_u16(const struct device *dev, uint16_t out_u16)
Write a 16-bit datum to the device for output.
int uart_poll_in_u16(const struct device *dev, uint16_t *p_u16)
Read a 16-bit datum from the device for input.
int uart_poll_in(const struct device *dev, unsigned char *p_char)
Read a character from the device for input.
struct k_pipe p
Definition: kobject.c:1322
__UINT32_TYPE__ uint32_t
Definition: stdint.h:90
__INT32_TYPE__ int32_t
Definition: stdint.h:74
__UINT8_TYPE__ uint8_t
Definition: stdint.h:88
__UINT16_TYPE__ uint16_t
Definition: stdint.h:89
Runtime device structure (in ROM) per driver instance.
Definition: device.h:435
const void * api
Definition: device.h:441
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:588
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