Lines Matching +full:uart +full:- +full:dev

2  * Copyright (c) 2018-2019 Nordic Semiconductor ASA
5 * SPDX-License-Identifier: Apache-2.0
10 * @brief Public APIs for UART drivers
17 * @brief UART Interface
18 * @defgroup uart_interface UART Interface
69 * RS-485 half-duplex. This error is only valid on UARTs that
118 * @brief UART controller configuration structure
129 * @defgroup uart_interrupt Interrupt-driven UART API
137 * @param dev UART device instance.
140 typedef void (*uart_irq_callback_user_data_t)(const struct device *dev,
146 * @defgroup uart_async Async UART API
161 * - Provide second buffer using uart_rx_buf_rsp, when first buffer is
163 * - Ignore the event, this way when current buffer is filled
214 * - When RX timeout occurred, and data was stored in provided buffer.
216 * - When provided buffer is full.
217 * - After uart_rx_disable().
218 * - After stopping due to external event (#UART_RX_STOPPED).
234 * @brief Buffer is no longer used by UART driver.
253 /** @brief UART TX event data. */
262 * @brief UART RX event data.
276 /** @brief UART RX buffer released event data. */
282 /** @brief UART RX stopped data. */
312 * @param dev UART device instance.
316 typedef void (*uart_callback_t)(const struct device *dev,
326 * @param dev UART device instance.
330 * @retval -ENOSYS If not implemented.
332 __syscall int uart_err_check(const struct device *dev);
335 * @defgroup uart_polling Polling UART API
345 * calling thread. It returns -1, otherwise. This function is a
346 * non-blocking call.
348 * @param dev UART device instance.
352 * @retval -1 If no character was available to read (i.e. the UART
354 * @retval -ENOSYS If the operation is not implemented.
355 * @retval -EBUSY If async reception was enabled using @ref uart_rx_enable
357 __syscall int uart_poll_in(const struct device *dev, unsigned char *p_char);
360 * @brief Read a 16-bit datum from the device for input.
363 * receiver has valid data, it reads a 16-bit datum from the device,
365 * calling thread. It returns -1, otherwise. This function is a
366 * non-blocking call.
368 * @param dev UART device instance.
369 * @param p_u16 Pointer to 16-bit data.
372 * @retval -1 If no data was available to read (i.e., the UART
374 * @retval -ENOTSUP If API is not enabled.
375 * @retval -ENOSYS If the function is not implemented.
376 * @retval -EBUSY If async reception was enabled using @ref uart_rx_enable
378 __syscall int uart_poll_in_u16(const struct device *dev, uint16_t *p_u16);
392 * @param dev UART device instance.
395 __syscall void uart_poll_out(const struct device *dev,
399 * @brief Write a 16-bit datum to the device for output.
402 * transmitter is not full, it writes a 16-bit datum to the data
409 * @param dev UART device instance.
412 __syscall void uart_poll_out_u16(const struct device *dev, uint16_t out_u16);
419 * @brief Set UART configuration.
421 * Sets UART configuration using data from *cfg.
423 * @param dev UART device instance.
424 * @param cfg UART configuration structure.
427 * @retval -errno Negative errno code in case of failure.
428 * @retval -ENOSYS If configuration is not supported by device
430 * @retval -ENOTSUP If API is not enabled.
432 __syscall int uart_configure(const struct device *dev,
436 * @brief Get UART configuration.
438 * Stores current UART configuration to *cfg, can be used to retrieve initial
441 * @param dev UART device instance.
442 * @param cfg UART configuration structure.
445 * @retval -errno Negative errno code in case of failure.
446 * @retval -ENOSYS If driver does not support getting current configuration.
447 * @retval -ENOTSUP If API is not enabled.
449 __syscall int uart_config_get(const struct device *dev,
460 * @details This function is expected to be called from UART
463 * (hardware-dependent). Likewise, *not* calling this function
469 * @param dev UART device instance.
474 * @retval -ENOSYS if this function is not supported
475 * @retval -ENOTSUP If API is not enabled.
477 static inline int uart_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size);
482 * @details This function is expected to be called from UART
485 * (hardware-dependent). Likewise, *not* calling this function
491 * @param dev UART device instance.
496 * @retval -ENOSYS If this function is not implemented
497 * @retval -ENOTSUP If API is not enabled.
499 static inline int uart_fifo_fill_u16(const struct device *dev, const uint16_t *tx_data, int size);
504 * @details This function is expected to be called from UART
507 * (hardware-dependent). It's unspecified whether "RX ready"
508 * condition as returned by uart_irq_rx_ready() is level- or
509 * edge- triggered. That means that once uart_irq_rx_ready() is
514 * @param dev UART device instance.
519 * @retval -ENOSYS If this function is not implemented.
520 * @retval -ENOTSUP If API is not enabled.
522 static inline int uart_fifo_read(const struct device *dev, uint8_t *rx_data, const int size);
527 * @details This function is expected to be called from UART
530 * (hardware-dependent). It's unspecified whether "RX ready"
531 * condition as returned by uart_irq_rx_ready() is level- or
532 * edge- triggered. That means that once uart_irq_rx_ready() is
537 * @param dev UART device instance.
542 * @retval -ENOSYS If this function is not implemented.
543 * @retval -ENOTSUP If API is not enabled.
545 static inline int uart_fifo_read_u16(const struct device *dev, uint16_t *rx_data, const int size);
550 * @param dev UART device instance.
552 __syscall void uart_irq_tx_enable(const struct device *dev);
557 * @param dev UART device instance.
559 __syscall void uart_irq_tx_disable(const struct device *dev);
562 * @brief Check if UART TX buffer can accept bytes
564 * @details Check if UART TX buffer can accept more bytes
566 * non-zero). This function must be called in a UART interrupt
571 * @param dev UART device instance.
578 * @retval -ENOSYS If this function is not implemented.
579 * @retval -ENOTSUP If API is not enabled.
581 static inline int uart_irq_tx_ready(const struct device *dev);
586 * @param dev UART device instance.
588 __syscall void uart_irq_rx_enable(const struct device *dev);
593 * @param dev UART device instance.
595 __syscall void uart_irq_rx_disable(const struct device *dev);
598 * @brief Check if UART TX block finished transmission
600 * @details Check if any outgoing data buffered in UART TX block was
602 * true, UART device (or whole system) can be power off. Note that
603 * this function is *not* useful to check if UART TX can accept more
605 * in a UART interrupt handler, or its result is undefined. Before
609 * @param dev UART device instance.
613 * @retval -ENOSYS If this function is not implemented.
614 * @retval -ENOTSUP If API is not enabled.
616 static inline int uart_irq_tx_complete(const struct device *dev);
619 * @brief Check if UART RX buffer has a received char
621 * @details Check if UART RX buffer has at least one pending character
622 * (i.e. uart_fifo_read() will succeed and return non-zero). This function
623 * must be called in a UART interrupt handler, or its result is undefined.
626 * condition as returned by this function is level- or edge- triggered (i.e.
627 * if this function returns true when RX FIFO is non-empty, or when a new
631 * @param dev UART device instance.
635 * @retval -ENOSYS If this function is not implemented.
636 * @retval -ENOTSUP If API is not enabled.
638 static inline int uart_irq_rx_ready(const struct device *dev);
643 * @param dev UART device instance.
645 __syscall void uart_irq_err_enable(const struct device *dev);
650 * @param dev UART device instance.
652 __syscall void uart_irq_err_disable(const struct device *dev);
657 * @param dev UART device instance.
661 * @retval -ENOSYS If this function is not implemented.
662 * @retval -ENOTSUP If API is not enabled.
664 __syscall int uart_irq_is_pending(const struct device *dev);
675 * * For devices with auto-acknowledge of interrupt status on register
685 * @param dev UART device instance.
688 * @retval -ENOSYS If this function is not implemented.
689 * @retval -ENOTSUP If API is not enabled.
691 __syscall int uart_irq_update(const struct device *dev);
700 * @param dev UART device instance.
705 * @retval -ENOSYS If this function is not implemented.
706 * @retval -ENOTSUP If API is not enabled.
708 static inline int uart_irq_callback_user_data_set(const struct device *dev,
718 * @param dev UART device instance.
722 * @retval -ENOSYS If this function is not implemented.
723 * @retval -ENOTSUP If API is not enabled.
725 static inline int uart_irq_callback_set(const struct device *dev,
744 * @param dev UART device instance.
749 * @retval -ENOSYS If not supported by the device.
750 * @retval -ENOTSUP If API not enabled.
752 static inline int uart_callback_set(const struct device *dev,
757 * @brief Send given number of bytes from buffer through UART.
762 * @param dev UART device instance.
769 * @retval -ENOTSUP If API is not enabled.
770 * @retval -EBUSY If There is already an ongoing transfer.
771 * @retval -errno Other negative errno value in case of failure.
773 __syscall int uart_tx(const struct device *dev, const uint8_t *buf,
778 * @brief Send given number of datum from buffer through UART.
783 * @param dev UART device instance.
790 * @retval -ENOTSUP If API is not enabled.
791 * @retval -EBUSY If there is already an ongoing transfer.
792 * @retval -errno Other negative errno value in case of failure.
794 __syscall int uart_tx_u16(const struct device *dev, const uint16_t *buf,
802 * @param dev UART device instance.
805 * @retval -ENOTSUP If API is not enabled.
806 * @retval -EFAULT There is no active transmission.
807 * @retval -errno Other negative errno value in case of failure.
809 __syscall int uart_tx_abort(const struct device *dev);
812 * @brief Start receiving data through UART.
818 * @param dev UART device instance.
827 * @retval -ENOTSUP If API is not enabled.
828 * @retval -EBUSY RX already in progress.
829 * @retval -errno Other negative errno value in case of failure.
832 __syscall int uart_rx_enable(const struct device *dev, uint8_t *buf,
837 * @brief Start receiving wide data through UART.
843 * @param dev UART device instance.
852 * @retval -ENOTSUP If API is not enabled.
853 * @retval -EBUSY RX already in progress.
854 * @retval -errno Other negative errno value in case of failure.
857 __syscall int uart_rx_enable_u16(const struct device *dev, uint16_t *buf,
870 * @param dev UART device instance.
875 * @retval -ENOTSUP If API is not enabled.
876 * @retval -EBUSY Next buffer already set.
877 * @retval -EACCES Receiver is already disabled (function called too late?).
878 * @retval -errno Other negative errno value in case of failure.
880 static inline int uart_rx_buf_rsp(const struct device *dev, uint8_t *buf,
894 * @param dev UART device instance.
899 * @retval -ENOTSUP If API is not enabled
900 * @retval -EBUSY Next buffer already set.
901 * @retval -EACCES Receiver is already disabled (function called too late?).
902 * @retval -errno Other negative errno value in case of failure.
904 static inline int uart_rx_buf_rsp_u16(const struct device *dev, uint16_t *buf,
915 * @param dev UART device instance.
918 * @retval -ENOTSUP If API is not enabled.
919 * @retval -EFAULT There is no active reception.
920 * @retval -errno Other negative errno value in case of failure.
922 __syscall int uart_rx_disable(const struct device *dev);
929 * @brief Manipulate line control for UART.
931 * @param dev UART device instance.
936 * @retval -ENOSYS If this function is not implemented.
937 * @retval -ENOTSUP If API is not enabled.
938 * @retval -errno Other negative errno value in case of failure.
940 __syscall int uart_line_ctrl_set(const struct device *dev,
944 * @brief Retrieve line control for UART.
946 * @param dev UART device instance.
951 * @retval -ENOSYS If this function is not implemented.
952 * @retval -ENOTSUP If API is not enabled.
953 * @retval -errno Other negative errno value in case of failure.
955 __syscall int uart_line_ctrl_get(const struct device *dev, uint32_t ctrl,
964 * @param dev UART device instance.
969 * @retval -ENOSYS If this function is not implemented.
970 * @retval -ENOTSUP If API is not enabled.
971 * @retval -errno Other negative errno value in case of failure.
973 __syscall int uart_drv_cmd(const struct device *dev, uint32_t cmd, uint32_t p);
983 #include <zephyr/drivers/uart/uart_internal.h>
984 #include <zephyr/syscalls/uart.h>