LCOV - code coverage report
Current view: top level - zephyr/drivers/uart - uart_internal.h Hit Total Coverage
Test: new.info Lines: 1 1 100.0 %
Date: 2024-12-22 00:14:23

          Line data    Source code
       1           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             : 
       8             : /**
       9             :  * @file
      10             :  * @brief Internal APIs for UART drivers
      11             :  */
      12             : 
      13             : #ifndef ZEPHYR_INCLUDE_DRIVERS_UART_UART_INTERNAL_H_
      14             : #define ZEPHYR_INCLUDE_DRIVERS_UART_UART_INTERNAL_H_
      15             : 
      16             : #include <errno.h>
      17             : #include <stddef.h>
      18             : 
      19             : #include <zephyr/device.h>
      20             : 
      21             : /**
      22             :  * @cond INTERNAL_HIDDEN
      23             :  *
      24             :  * For internal driver use only, skip these in public documentation.
      25             :  */
      26             : 
      27             : #ifdef __cplusplus
      28             : extern "C" {
      29             : #endif
      30             : 
      31             : /**
      32             :  * @brief For configuring IRQ on each individual UART device.
      33             :  *
      34             :  * @param dev UART device instance.
      35             :  */
      36             : typedef void (*uart_irq_config_func_t)(const struct device *dev);
      37             : 
      38             : /** @brief Driver API structure. */
      39             : __subsystem struct uart_driver_api {
      40             : 
      41             : #ifdef CONFIG_UART_ASYNC_API
      42             : 
      43             :         int (*callback_set)(const struct device *dev, uart_callback_t callback, void *user_data);
      44             : 
      45             :         int (*tx)(const struct device *dev, const uint8_t *buf, size_t len, int32_t timeout);
      46             :         int (*tx_abort)(const struct device *dev);
      47             : 
      48             :         int (*rx_enable)(const struct device *dev, uint8_t *buf, size_t len, int32_t timeout);
      49             :         int (*rx_buf_rsp)(const struct device *dev, uint8_t *buf, size_t len);
      50             :         int (*rx_disable)(const struct device *dev);
      51             : 
      52             : #ifdef CONFIG_UART_WIDE_DATA
      53             :         int (*tx_u16)(const struct device *dev, const uint16_t *buf, size_t len, int32_t timeout);
      54             :         int (*rx_enable_u16)(const struct device *dev, uint16_t *buf, size_t len, int32_t timeout);
      55             :         int (*rx_buf_rsp_u16)(const struct device *dev, uint16_t *buf, size_t len);
      56             : #endif
      57             : 
      58             : #endif
      59             : 
      60             :         /** Console I/O function */
      61             :         int (*poll_in)(const struct device *dev, unsigned char *p_char);
      62             :         void (*poll_out)(const struct device *dev, unsigned char out_char);
      63             : 
      64             : #ifdef CONFIG_UART_WIDE_DATA
      65             :         int (*poll_in_u16)(const struct device *dev, uint16_t *p_u16);
      66             :         void (*poll_out_u16)(const struct device *dev, uint16_t out_u16);
      67             : #endif
      68             : 
      69             :         /** Console I/O function */
      70             :         int (*err_check)(const struct device *dev);
      71             : 
      72             : #ifdef CONFIG_UART_USE_RUNTIME_CONFIGURE
      73             :         /** UART configuration functions */
      74             :         int (*configure)(const struct device *dev, const struct uart_config *cfg);
      75             :         int (*config_get)(const struct device *dev, struct uart_config *cfg);
      76             : #endif
      77             : 
      78             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
      79             : 
      80             :         /** Interrupt driven FIFO fill function */
      81             :         int (*fifo_fill)(const struct device *dev, const uint8_t *tx_data, int len);
      82             : 
      83             : #ifdef CONFIG_UART_WIDE_DATA
      84             :         int (*fifo_fill_u16)(const struct device *dev, const uint16_t *tx_data, int len);
      85             : #endif
      86             : 
      87             :         /** Interrupt driven FIFO read function */
      88             :         int (*fifo_read)(const struct device *dev, uint8_t *rx_data, const int size);
      89             : 
      90             : #ifdef CONFIG_UART_WIDE_DATA
      91             :         int (*fifo_read_u16)(const struct device *dev, uint16_t *rx_data, const int size);
      92             : #endif
      93             : 
      94             :         /** Interrupt driven transfer enabling function */
      95             :         void (*irq_tx_enable)(const struct device *dev);
      96             : 
      97             :         /** Interrupt driven transfer disabling function */
      98             :         void (*irq_tx_disable)(const struct device *dev);
      99             : 
     100             :         /** Interrupt driven transfer ready function */
     101             :         int (*irq_tx_ready)(const struct device *dev);
     102             : 
     103             :         /** Interrupt driven receiver enabling function */
     104             :         void (*irq_rx_enable)(const struct device *dev);
     105             : 
     106             :         /** Interrupt driven receiver disabling function */
     107             :         void (*irq_rx_disable)(const struct device *dev);
     108             : 
     109             :         /** Interrupt driven transfer complete function */
     110             :         int (*irq_tx_complete)(const struct device *dev);
     111             : 
     112             :         /** Interrupt driven receiver ready function */
     113             :         int (*irq_rx_ready)(const struct device *dev);
     114             : 
     115             :         /** Interrupt driven error enabling function */
     116             :         void (*irq_err_enable)(const struct device *dev);
     117             : 
     118             :         /** Interrupt driven error disabling function */
     119             :         void (*irq_err_disable)(const struct device *dev);
     120             : 
     121             :         /** Interrupt driven pending status function */
     122             :         int (*irq_is_pending)(const struct device *dev);
     123             : 
     124             :         /** Interrupt driven interrupt update function */
     125             :         int (*irq_update)(const struct device *dev);
     126             : 
     127             :         /** Set the irq callback function */
     128             :         void (*irq_callback_set)(const struct device *dev, uart_irq_callback_user_data_t cb,
     129             :                                  void *user_data);
     130             : 
     131             : #endif
     132             : 
     133             : #ifdef CONFIG_UART_LINE_CTRL
     134             :         int (*line_ctrl_set)(const struct device *dev, uint32_t ctrl, uint32_t val);
     135             :         int (*line_ctrl_get)(const struct device *dev, uint32_t ctrl, uint32_t *val);
     136             : #endif
     137             : 
     138             : #ifdef CONFIG_UART_DRV_CMD
     139             :         int (*drv_cmd)(const struct device *dev, uint32_t cmd, uint32_t p);
     140             : #endif
     141             : };
     142             : 
     143             : static inline int z_impl_uart_err_check(const struct device *dev)
     144             : {
     145             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     146             : 
     147             :         if (api->err_check == NULL) {
     148             :                 return -ENOSYS;
     149             :         }
     150             : 
     151             :         return api->err_check(dev);
     152             : }
     153             : 
     154             : static inline int z_impl_uart_poll_in(const struct device *dev, unsigned char *p_char)
     155             : {
     156             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     157             : 
     158             :         if (api->poll_in == NULL) {
     159             :                 return -ENOSYS;
     160             :         }
     161             : 
     162             :         return api->poll_in(dev, p_char);
     163             : }
     164             : 
     165             : static inline int z_impl_uart_poll_in_u16(const struct device *dev, uint16_t *p_u16)
     166             : {
     167             : #ifdef CONFIG_UART_WIDE_DATA
     168             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     169             : 
     170             :         if (api->poll_in_u16 == NULL) {
     171             :                 return -ENOSYS;
     172             :         }
     173             : 
     174             :         return api->poll_in_u16(dev, p_u16);
     175             : #else
     176             :         ARG_UNUSED(dev);
     177             :         ARG_UNUSED(p_u16);
     178             :         return -ENOTSUP;
     179             : #endif
     180             : }
     181             : 
     182             : static inline void z_impl_uart_poll_out(const struct device *dev, unsigned char out_char)
     183             : {
     184             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     185             : 
     186             :         api->poll_out(dev, out_char);
     187             : }
     188             : 
     189             : static inline void z_impl_uart_poll_out_u16(const struct device *dev, uint16_t out_u16)
     190             : {
     191             : #ifdef CONFIG_UART_WIDE_DATA
     192             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     193             : 
     194             :         api->poll_out_u16(dev, out_u16);
     195             : #else
     196             :         ARG_UNUSED(dev);
     197             :         ARG_UNUSED(out_u16);
     198             : #endif
     199             : }
     200             : 
     201             : static inline int z_impl_uart_configure(const struct device *dev, const struct uart_config *cfg)
     202             : {
     203             : #ifdef CONFIG_UART_USE_RUNTIME_CONFIGURE
     204             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     205             : 
     206             :         if (api->configure == NULL) {
     207             :                 return -ENOSYS;
     208             :         }
     209             :         return api->configure(dev, cfg);
     210             : #else
     211             :         ARG_UNUSED(dev);
     212             :         ARG_UNUSED(cfg);
     213             :         return -ENOTSUP;
     214             : #endif
     215             : }
     216             : 
     217             : static inline int z_impl_uart_config_get(const struct device *dev, struct uart_config *cfg)
     218             : {
     219             : #ifdef CONFIG_UART_USE_RUNTIME_CONFIGURE
     220             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     221             : 
     222             :         if (api->config_get == NULL) {
     223             :                 return -ENOSYS;
     224             :         }
     225             : 
     226             :         return api->config_get(dev, cfg);
     227             : #else
     228             :         ARG_UNUSED(dev);
     229             :         ARG_UNUSED(cfg);
     230             :         return -ENOTSUP;
     231             : #endif
     232             : }
     233             : 
     234             : static inline int uart_fifo_fill(const struct device *dev, const uint8_t *tx_data, int size)
     235             : {
     236             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     237             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     238             : 
     239             :         if (api->fifo_fill == NULL) {
     240             :                 return -ENOSYS;
     241             :         }
     242             : 
     243             :         return api->fifo_fill(dev, tx_data, size);
     244             : #else
     245             :         ARG_UNUSED(dev);
     246             :         ARG_UNUSED(tx_data);
     247             :         ARG_UNUSED(size);
     248             :         return -ENOTSUP;
     249             : #endif
     250             : }
     251             : 
     252             : static inline int uart_fifo_fill_u16(const struct device *dev, const uint16_t *tx_data, int size)
     253             : {
     254             : #if defined(CONFIG_UART_INTERRUPT_DRIVEN) && defined(CONFIG_UART_WIDE_DATA)
     255             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     256             : 
     257             :         if (api->fifo_fill_u16 == NULL) {
     258             :                 return -ENOSYS;
     259             :         }
     260             : 
     261             :         return api->fifo_fill_u16(dev, tx_data, size);
     262             : #else
     263             :         ARG_UNUSED(dev);
     264             :         ARG_UNUSED(tx_data);
     265             :         ARG_UNUSED(size);
     266             :         return -ENOTSUP;
     267             : #endif
     268             : }
     269             : 
     270             : static inline int uart_fifo_read(const struct device *dev, uint8_t *rx_data, const int size)
     271             : {
     272             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     273             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     274             : 
     275             :         if (api->fifo_read == NULL) {
     276             :                 return -ENOSYS;
     277             :         }
     278             : 
     279             :         return api->fifo_read(dev, rx_data, size);
     280             : #else
     281             :         ARG_UNUSED(dev);
     282             :         ARG_UNUSED(rx_data);
     283             :         ARG_UNUSED(size);
     284             :         return -ENOTSUP;
     285             : #endif
     286             : }
     287             : 
     288             : static inline int uart_fifo_read_u16(const struct device *dev, uint16_t *rx_data, const int size)
     289             : {
     290             : #if defined(CONFIG_UART_INTERRUPT_DRIVEN) && defined(CONFIG_UART_WIDE_DATA)
     291             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     292             : 
     293             :         if (api->fifo_read_u16 == NULL) {
     294             :                 return -ENOSYS;
     295             :         }
     296             : 
     297             :         return api->fifo_read_u16(dev, rx_data, size);
     298             : #else
     299             :         ARG_UNUSED(dev);
     300             :         ARG_UNUSED(rx_data);
     301             :         ARG_UNUSED(size);
     302             :         return -ENOTSUP;
     303             : #endif
     304             : }
     305             : 
     306             : static inline void z_impl_uart_irq_tx_enable(const struct device *dev)
     307             : {
     308             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     309             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     310             : 
     311             :         if (api->irq_tx_enable != NULL) {
     312             :                 api->irq_tx_enable(dev);
     313             :         }
     314             : #else
     315             :         ARG_UNUSED(dev);
     316             : #endif
     317             : }
     318             : 
     319             : static inline void z_impl_uart_irq_tx_disable(const struct device *dev)
     320             : {
     321             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     322             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     323             : 
     324             :         if (api->irq_tx_disable != NULL) {
     325             :                 api->irq_tx_disable(dev);
     326             :         }
     327             : #else
     328             :         ARG_UNUSED(dev);
     329             : #endif
     330             : }
     331             : 
     332             : static inline int uart_irq_tx_ready(const struct device *dev)
     333             : {
     334             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     335             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     336             : 
     337             :         if (api->irq_tx_ready == NULL) {
     338             :                 return -ENOSYS;
     339             :         }
     340             : 
     341             :         return api->irq_tx_ready(dev);
     342             : #else
     343             :         ARG_UNUSED(dev);
     344             :         return -ENOTSUP;
     345             : #endif
     346             : }
     347             : 
     348             : static inline void z_impl_uart_irq_rx_enable(const struct device *dev)
     349             : {
     350             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     351             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     352             : 
     353             :         if (api->irq_rx_enable != NULL) {
     354             :                 api->irq_rx_enable(dev);
     355             :         }
     356             : #else
     357             :         ARG_UNUSED(dev);
     358             : #endif
     359             : }
     360             : 
     361             : static inline void z_impl_uart_irq_rx_disable(const struct device *dev)
     362             : {
     363             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     364             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     365             : 
     366             :         if (api->irq_rx_disable != NULL) {
     367             :                 api->irq_rx_disable(dev);
     368             :         }
     369             : #else
     370             :         ARG_UNUSED(dev);
     371             : #endif
     372             : }
     373             : 
     374             : static inline int uart_irq_tx_complete(const struct device *dev)
     375             : {
     376             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     377             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     378             : 
     379             :         if (api->irq_tx_complete == NULL) {
     380             :                 return -ENOSYS;
     381             :         }
     382             :         return api->irq_tx_complete(dev);
     383             : #else
     384             :         ARG_UNUSED(dev);
     385             :         return -ENOTSUP;
     386             : #endif
     387             : }
     388             : 
     389             : static inline int uart_irq_rx_ready(const struct device *dev)
     390             : {
     391             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     392             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     393             : 
     394             :         if (api->irq_rx_ready == NULL) {
     395             :                 return -ENOSYS;
     396             :         }
     397             :         return api->irq_rx_ready(dev);
     398             : #else
     399             :         ARG_UNUSED(dev);
     400             :         return -ENOTSUP;
     401             : #endif
     402             : }
     403             : 
     404             : static inline void z_impl_uart_irq_err_enable(const struct device *dev)
     405             : {
     406             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     407             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     408             : 
     409             :         if (api->irq_err_enable) {
     410             :                 api->irq_err_enable(dev);
     411             :         }
     412             : #else
     413             :         ARG_UNUSED(dev);
     414             : #endif
     415             : }
     416             : 
     417             : static inline void z_impl_uart_irq_err_disable(const struct device *dev)
     418             : {
     419             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     420             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     421             : 
     422             :         if (api->irq_err_disable) {
     423             :                 api->irq_err_disable(dev);
     424             :         }
     425             : #else
     426             :         ARG_UNUSED(dev);
     427             : #endif
     428             : }
     429             : 
     430             : static inline int z_impl_uart_irq_is_pending(const struct device *dev)
     431             : {
     432             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     433             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     434             : 
     435             :         if (api->irq_is_pending == NULL) {
     436             :                 return -ENOSYS;
     437             :         }
     438             :         return api->irq_is_pending(dev);
     439             : #else
     440             :         ARG_UNUSED(dev);
     441             :         return -ENOTSUP;
     442             : #endif
     443             : }
     444             : 
     445             : static inline int z_impl_uart_irq_update(const struct device *dev)
     446             : {
     447             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     448             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     449             : 
     450             :         if (api->irq_update == NULL) {
     451             :                 return -ENOSYS;
     452             :         }
     453             :         return api->irq_update(dev);
     454             : #else
     455             :         ARG_UNUSED(dev);
     456             :         return -ENOTSUP;
     457             : #endif
     458             : }
     459             : 
     460             : static inline int uart_irq_callback_user_data_set(const struct device *dev,
     461             :                                                   uart_irq_callback_user_data_t cb, void *user_data)
     462             : {
     463             : #ifdef CONFIG_UART_INTERRUPT_DRIVEN
     464             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     465             : 
     466             :         if ((api != NULL) && (api->irq_callback_set != NULL)) {
     467             :                 api->irq_callback_set(dev, cb, user_data);
     468             :                 return 0;
     469             :         } else {
     470             :                 return -ENOSYS;
     471             :         }
     472             : #else
     473             :         ARG_UNUSED(dev);
     474             :         ARG_UNUSED(cb);
     475             :         ARG_UNUSED(user_data);
     476             :         return -ENOTSUP;
     477             : #endif
     478             : }
     479             : 
     480             : static inline int uart_irq_callback_set(const struct device *dev, uart_irq_callback_user_data_t cb)
     481             : {
     482             :         return uart_irq_callback_user_data_set(dev, cb, NULL);
     483             : }
     484             : 
     485             : static inline int uart_callback_set(const struct device *dev, uart_callback_t callback,
     486             :                                     void *user_data)
     487             : {
     488             : #ifdef CONFIG_UART_ASYNC_API
     489             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     490             : 
     491             :         if (api->callback_set == NULL) {
     492             :                 return -ENOSYS;
     493             :         }
     494             : 
     495             :         return api->callback_set(dev, callback, user_data);
     496             : #else
     497             :         ARG_UNUSED(dev);
     498             :         ARG_UNUSED(callback);
     499             :         ARG_UNUSED(user_data);
     500             :         return -ENOTSUP;
     501             : #endif
     502             : }
     503             : 
     504             : static inline int z_impl_uart_tx(const struct device *dev, const uint8_t *buf, size_t len,
     505             :                                  int32_t timeout)
     506             : 
     507             : {
     508             : #ifdef CONFIG_UART_ASYNC_API
     509             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     510             : 
     511             :         return api->tx(dev, buf, len, timeout);
     512             : #else
     513             :         ARG_UNUSED(dev);
     514             :         ARG_UNUSED(buf);
     515             :         ARG_UNUSED(len);
     516             :         ARG_UNUSED(timeout);
     517             :         return -ENOTSUP;
     518             : #endif
     519             : }
     520             : 
     521             : static inline int z_impl_uart_tx_u16(const struct device *dev, const uint16_t *buf, size_t len,
     522             :                                      int32_t timeout)
     523             : 
     524             : {
     525             : #if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
     526             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     527             : 
     528             :         return api->tx_u16(dev, buf, len, timeout);
     529             : #else
     530             :         ARG_UNUSED(dev);
     531             :         ARG_UNUSED(buf);
     532             :         ARG_UNUSED(len);
     533             :         ARG_UNUSED(timeout);
     534             :         return -ENOTSUP;
     535             : #endif
     536             : }
     537             : 
     538             : static inline int z_impl_uart_tx_abort(const struct device *dev)
     539             : {
     540             : #ifdef CONFIG_UART_ASYNC_API
     541             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     542             : 
     543             :         return api->tx_abort(dev);
     544             : #else
     545             :         ARG_UNUSED(dev);
     546             :         return -ENOTSUP;
     547             : #endif
     548             : }
     549             : 
     550             : static inline int z_impl_uart_rx_enable(const struct device *dev, uint8_t *buf, size_t len,
     551             :                                         int32_t timeout)
     552             : {
     553             : #ifdef CONFIG_UART_ASYNC_API
     554             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     555             : 
     556             :         return api->rx_enable(dev, buf, len, timeout);
     557             : #else
     558             :         ARG_UNUSED(dev);
     559             :         ARG_UNUSED(buf);
     560             :         ARG_UNUSED(len);
     561             :         ARG_UNUSED(timeout);
     562             :         return -ENOTSUP;
     563             : #endif
     564             : }
     565             : 
     566             : static inline int z_impl_uart_rx_enable_u16(const struct device *dev, uint16_t *buf, size_t len,
     567             :                                             int32_t timeout)
     568             : {
     569             : #if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
     570             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     571             : 
     572             :         return api->rx_enable_u16(dev, buf, len, timeout);
     573             : #else
     574             :         ARG_UNUSED(dev);
     575             :         ARG_UNUSED(buf);
     576             :         ARG_UNUSED(len);
     577             :         ARG_UNUSED(timeout);
     578             :         return -ENOTSUP;
     579             : #endif
     580             : }
     581             : 
     582             : static inline int uart_rx_buf_rsp(const struct device *dev, uint8_t *buf, size_t len)
     583             : {
     584             : #ifdef CONFIG_UART_ASYNC_API
     585             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     586             : 
     587             :         return api->rx_buf_rsp(dev, buf, len);
     588             : #else
     589             :         ARG_UNUSED(dev);
     590             :         ARG_UNUSED(buf);
     591             :         ARG_UNUSED(len);
     592             :         return -ENOTSUP;
     593             : #endif
     594             : }
     595             : 
     596             : static inline int uart_rx_buf_rsp_u16(const struct device *dev, uint16_t *buf, size_t len)
     597             : {
     598             : #if defined(CONFIG_UART_ASYNC_API) && defined(CONFIG_UART_WIDE_DATA)
     599             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     600             : 
     601             :         return api->rx_buf_rsp_u16(dev, buf, len);
     602             : #else
     603             :         ARG_UNUSED(dev);
     604             :         ARG_UNUSED(buf);
     605             :         ARG_UNUSED(len);
     606             :         return -ENOTSUP;
     607             : #endif
     608             : }
     609             : 
     610             : static inline int z_impl_uart_rx_disable(const struct device *dev)
     611             : {
     612             : #ifdef CONFIG_UART_ASYNC_API
     613             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     614             : 
     615             :         return api->rx_disable(dev);
     616             : #else
     617             :         ARG_UNUSED(dev);
     618             :         return -ENOTSUP;
     619             : #endif
     620             : }
     621             : 
     622             : static inline int z_impl_uart_line_ctrl_set(const struct device *dev, uint32_t ctrl, uint32_t val)
     623             : {
     624             : #ifdef CONFIG_UART_LINE_CTRL
     625             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     626             : 
     627             :         if (api->line_ctrl_set == NULL) {
     628             :                 return -ENOSYS;
     629             :         }
     630             :         return api->line_ctrl_set(dev, ctrl, val);
     631             : #else
     632             :         ARG_UNUSED(dev);
     633             :         ARG_UNUSED(ctrl);
     634             :         ARG_UNUSED(val);
     635             :         return -ENOTSUP;
     636             : #endif
     637             : }
     638             : 
     639             : static inline int z_impl_uart_line_ctrl_get(const struct device *dev, uint32_t ctrl, uint32_t *val)
     640             : {
     641             : #ifdef CONFIG_UART_LINE_CTRL
     642             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     643             : 
     644             :         if (api->line_ctrl_get == NULL) {
     645             :                 return -ENOSYS;
     646             :         }
     647             :         return api->line_ctrl_get(dev, ctrl, val);
     648             : #else
     649             :         ARG_UNUSED(dev);
     650             :         ARG_UNUSED(ctrl);
     651             :         ARG_UNUSED(val);
     652             :         return -ENOTSUP;
     653             : #endif
     654             : }
     655             : 
     656             : static inline int z_impl_uart_drv_cmd(const struct device *dev, uint32_t cmd, uint32_t p)
     657             : {
     658             : #ifdef CONFIG_UART_DRV_CMD
     659             :         const struct uart_driver_api *api = (const struct uart_driver_api *)dev->api;
     660             : 
     661             :         if (api->drv_cmd == NULL) {
     662             :                 return -ENOSYS;
     663             :         }
     664             :         return api->drv_cmd(dev, cmd, p);
     665             : #else
     666             :         ARG_UNUSED(dev);
     667             :         ARG_UNUSED(cmd);
     668             :         ARG_UNUSED(p);
     669             :         return -ENOTSUP;
     670             : #endif
     671             : }
     672             : 
     673             : #ifdef __cplusplus
     674             : }
     675             : #endif
     676             : 
     677             : /** @endcond */
     678             : 
     679             : #endif /* ZEPHYR_INCLUDE_DRIVERS_UART_UART_INTERNAL_H_ */

Generated by: LCOV version 1.14