LCOV - code coverage report
Current view: top level - home/jason/ncs-2.0.0/modules/hal/nordic/nrfx/hal - nrf_uarte.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 36 48 75.0 %
Date: 2022-08-18 11:36:24 Functions: 11 15 73.3 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2015 - 2022, Nordic Semiconductor ASA
       3                 :            :  * All rights reserved.
       4                 :            :  *
       5                 :            :  * SPDX-License-Identifier: BSD-3-Clause
       6                 :            :  *
       7                 :            :  * Redistribution and use in source and binary forms, with or without
       8                 :            :  * modification, are permitted provided that the following conditions are met:
       9                 :            :  *
      10                 :            :  * 1. Redistributions of source code must retain the above copyright notice, this
      11                 :            :  *    list of conditions and the following disclaimer.
      12                 :            :  *
      13                 :            :  * 2. Redistributions in binary form must reproduce the above copyright
      14                 :            :  *    notice, this list of conditions and the following disclaimer in the
      15                 :            :  *    documentation and/or other materials provided with the distribution.
      16                 :            :  *
      17                 :            :  * 3. Neither the name of the copyright holder nor the names of its
      18                 :            :  *    contributors may be used to endorse or promote products derived from this
      19                 :            :  *    software without specific prior written permission.
      20                 :            :  *
      21                 :            :  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
      22                 :            :  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
      23                 :            :  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
      24                 :            :  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
      25                 :            :  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      26                 :            :  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
      27                 :            :  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
      28                 :            :  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
      29                 :            :  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
      30                 :            :  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      31                 :            :  * POSSIBILITY OF SUCH DAMAGE.
      32                 :            :  */
      33                 :            : 
      34                 :            : #ifndef NRF_UARTE_H__
      35                 :            : #define NRF_UARTE_H__
      36                 :            : 
      37                 :            : #include <nrfx.h>
      38                 :            : 
      39                 :            : #ifdef __cplusplus
      40                 :            : extern "C" {
      41                 :            : #endif
      42                 :            : 
      43                 :            : #define NRF_UARTE_PSEL_DISCONNECTED 0xFFFFFFFF
      44                 :            : 
      45                 :            : /**
      46                 :            :  * @defgroup nrf_uarte_hal UARTE HAL
      47                 :            :  * @{
      48                 :            :  * @ingroup nrf_uarte
      49                 :            :  * @brief   Hardware access layer for managing the UARTE peripheral.
      50                 :            :  */
      51                 :            : 
      52                 :            : /** @brief UARTE tasks. */
      53                 :            : typedef enum
      54                 :            : {
      55                 :            :     NRF_UARTE_TASK_STARTRX   = offsetof(NRF_UARTE_Type, TASKS_STARTRX), ///< Start UART receiver.
      56                 :            :     NRF_UARTE_TASK_STOPRX    = offsetof(NRF_UARTE_Type, TASKS_STOPRX),  ///< Stop UART receiver.
      57                 :            :     NRF_UARTE_TASK_STARTTX   = offsetof(NRF_UARTE_Type, TASKS_STARTTX), ///< Start UART transmitter.
      58                 :            :     NRF_UARTE_TASK_STOPTX    = offsetof(NRF_UARTE_Type, TASKS_STOPTX),  ///< Stop UART transmitter.
      59                 :            :     NRF_UARTE_TASK_FLUSHRX   = offsetof(NRF_UARTE_Type, TASKS_FLUSHRX)  ///< Flush RX FIFO in RX buffer.
      60                 :            : } nrf_uarte_task_t;
      61                 :            : 
      62                 :            : /** @brief UARTE events. */
      63                 :            : typedef enum
      64                 :            : {
      65                 :            :     NRF_UARTE_EVENT_CTS       = offsetof(NRF_UARTE_Type, EVENTS_CTS),       ///< CTS is activated.
      66                 :            :     NRF_UARTE_EVENT_NCTS      = offsetof(NRF_UARTE_Type, EVENTS_NCTS),      ///< CTS is deactivated.
      67                 :            :     NRF_UARTE_EVENT_RXDRDY    = offsetof(NRF_UARTE_Type, EVENTS_RXDRDY),    ///< Data received in RXD (but potentially not yet transferred to Data RAM).
      68                 :            :     NRF_UARTE_EVENT_ENDRX     = offsetof(NRF_UARTE_Type, EVENTS_ENDRX),     ///< Receive buffer is filled up.
      69                 :            :     NRF_UARTE_EVENT_TXDRDY    = offsetof(NRF_UARTE_Type, EVENTS_TXDRDY),    ///< Data sent from TXD.
      70                 :            :     NRF_UARTE_EVENT_ENDTX     = offsetof(NRF_UARTE_Type, EVENTS_ENDTX),     ///< Last TX byte transmitted.
      71                 :            :     NRF_UARTE_EVENT_ERROR     = offsetof(NRF_UARTE_Type, EVENTS_ERROR),     ///< Error detected.
      72                 :            :     NRF_UARTE_EVENT_RXTO      = offsetof(NRF_UARTE_Type, EVENTS_RXTO),      ///< Receiver timeout.
      73                 :            :     NRF_UARTE_EVENT_RXSTARTED = offsetof(NRF_UARTE_Type, EVENTS_RXSTARTED), ///< Receiver has started.
      74                 :            :     NRF_UARTE_EVENT_TXSTARTED = offsetof(NRF_UARTE_Type, EVENTS_TXSTARTED), ///< Transmitter has started.
      75                 :            :     NRF_UARTE_EVENT_TXSTOPPED = offsetof(NRF_UARTE_Type, EVENTS_TXSTOPPED)  ///< Transmitted stopped.
      76                 :            : } nrf_uarte_event_t;
      77                 :            : 
      78                 :            : /** @brief Types of UARTE shortcuts. */
      79                 :            : typedef enum
      80                 :            : {
      81                 :            :     NRF_UARTE_SHORT_ENDRX_STARTRX = UARTE_SHORTS_ENDRX_STARTRX_Msk, ///< Shortcut between ENDRX event and STARTRX task.
      82                 :            :     NRF_UARTE_SHORT_ENDRX_STOPRX  = UARTE_SHORTS_ENDRX_STOPRX_Msk   ///< Shortcut between ENDRX event and STOPRX task.
      83                 :            : } nrf_uarte_short_t;
      84                 :            : 
      85                 :            : 
      86                 :            : /** @brief UARTE interrupts. */
      87                 :            : typedef enum
      88                 :            : {
      89                 :            :     NRF_UARTE_INT_CTS_MASK       = UARTE_INTENSET_CTS_Msk,       ///< Interrupt on CTS event.
      90                 :            :     NRF_UARTE_INT_NCTS_MASK      = UARTE_INTENSET_NCTS_Msk,      ///< Interrupt on NCTS event.
      91                 :            :     NRF_UARTE_INT_RXDRDY_MASK    = UARTE_INTENSET_RXDRDY_Msk,    ///< Interrupt on RXDRDY event.
      92                 :            :     NRF_UARTE_INT_ENDRX_MASK     = UARTE_INTENSET_ENDRX_Msk,     ///< Interrupt on ENDRX event.
      93                 :            :     NRF_UARTE_INT_TXDRDY_MASK    = UARTE_INTENSET_TXDRDY_Msk,    ///< Interrupt on TXDRDY event.
      94                 :            :     NRF_UARTE_INT_ENDTX_MASK     = UARTE_INTENSET_ENDTX_Msk,     ///< Interrupt on ENDTX event.
      95                 :            :     NRF_UARTE_INT_ERROR_MASK     = UARTE_INTENSET_ERROR_Msk,     ///< Interrupt on ERROR event.
      96                 :            :     NRF_UARTE_INT_RXTO_MASK      = UARTE_INTENSET_RXTO_Msk,      ///< Interrupt on RXTO event.
      97                 :            :     NRF_UARTE_INT_RXSTARTED_MASK = UARTE_INTENSET_RXSTARTED_Msk, ///< Interrupt on RXSTARTED event.
      98                 :            :     NRF_UARTE_INT_TXSTARTED_MASK = UARTE_INTENSET_TXSTARTED_Msk, ///< Interrupt on TXSTARTED event.
      99                 :            :     NRF_UARTE_INT_TXSTOPPED_MASK = UARTE_INTENSET_TXSTOPPED_Msk  ///< Interrupt on TXSTOPPED event.
     100                 :            : } nrf_uarte_int_mask_t;
     101                 :            : 
     102                 :            : /** @brief Baudrates supported by UARTE. */
     103                 :            : typedef enum
     104                 :            : {
     105                 :            :     NRF_UARTE_BAUDRATE_1200    = UARTE_BAUDRATE_BAUDRATE_Baud1200,   ///< 1200 baud.
     106                 :            :     NRF_UARTE_BAUDRATE_2400    = UARTE_BAUDRATE_BAUDRATE_Baud2400,   ///< 2400 baud.
     107                 :            :     NRF_UARTE_BAUDRATE_4800    = UARTE_BAUDRATE_BAUDRATE_Baud4800,   ///< 4800 baud.
     108                 :            :     NRF_UARTE_BAUDRATE_9600    = UARTE_BAUDRATE_BAUDRATE_Baud9600,   ///< 9600 baud.
     109                 :            :     NRF_UARTE_BAUDRATE_14400   = UARTE_BAUDRATE_BAUDRATE_Baud14400,  ///< 14400 baud.
     110                 :            :     NRF_UARTE_BAUDRATE_19200   = UARTE_BAUDRATE_BAUDRATE_Baud19200,  ///< 19200 baud.
     111                 :            :     NRF_UARTE_BAUDRATE_28800   = UARTE_BAUDRATE_BAUDRATE_Baud28800,  ///< 28800 baud.
     112                 :            :     NRF_UARTE_BAUDRATE_31250   = UARTE_BAUDRATE_BAUDRATE_Baud31250,  ///< 31250 baud.
     113                 :            :     NRF_UARTE_BAUDRATE_38400   = UARTE_BAUDRATE_BAUDRATE_Baud38400,  ///< 38400 baud.
     114                 :            :     NRF_UARTE_BAUDRATE_56000   = UARTE_BAUDRATE_BAUDRATE_Baud56000,  ///< 56000 baud.
     115                 :            :     NRF_UARTE_BAUDRATE_57600   = UARTE_BAUDRATE_BAUDRATE_Baud57600,  ///< 57600 baud.
     116                 :            :     NRF_UARTE_BAUDRATE_76800   = UARTE_BAUDRATE_BAUDRATE_Baud76800,  ///< 76800 baud.
     117                 :            :     NRF_UARTE_BAUDRATE_115200  = UARTE_BAUDRATE_BAUDRATE_Baud115200, ///< 115200 baud.
     118                 :            :     NRF_UARTE_BAUDRATE_230400  = UARTE_BAUDRATE_BAUDRATE_Baud230400, ///< 230400 baud.
     119                 :            :     NRF_UARTE_BAUDRATE_250000  = UARTE_BAUDRATE_BAUDRATE_Baud250000, ///< 250000 baud.
     120                 :            :     NRF_UARTE_BAUDRATE_460800  = UARTE_BAUDRATE_BAUDRATE_Baud460800, ///< 460800 baud.
     121                 :            :     NRF_UARTE_BAUDRATE_921600  = UARTE_BAUDRATE_BAUDRATE_Baud921600, ///< 921600 baud.
     122                 :            :     NRF_UARTE_BAUDRATE_1000000 = UARTE_BAUDRATE_BAUDRATE_Baud1M      ///< 1000000 baud.
     123                 :            : } nrf_uarte_baudrate_t;
     124                 :            : 
     125                 :            : /** @brief Types of UARTE error masks. */
     126                 :            : typedef enum
     127                 :            : {
     128                 :            :     NRF_UARTE_ERROR_OVERRUN_MASK = UARTE_ERRORSRC_OVERRUN_Msk, ///< Overrun error.
     129                 :            :     NRF_UARTE_ERROR_PARITY_MASK  = UARTE_ERRORSRC_PARITY_Msk,  ///< Parity error.
     130                 :            :     NRF_UARTE_ERROR_FRAMING_MASK = UARTE_ERRORSRC_FRAMING_Msk, ///< Framing error.
     131                 :            :     NRF_UARTE_ERROR_BREAK_MASK   = UARTE_ERRORSRC_BREAK_Msk    ///< Break error.
     132                 :            : } nrf_uarte_error_mask_t;
     133                 :            : 
     134                 :            : /** @brief Types of UARTE parity modes. */
     135                 :            : typedef enum
     136                 :            : {
     137                 :            :     NRF_UARTE_PARITY_EXCLUDED = UARTE_CONFIG_PARITY_Excluded << UARTE_CONFIG_PARITY_Pos, ///< Parity excluded.
     138                 :            :     NRF_UARTE_PARITY_INCLUDED = UARTE_CONFIG_PARITY_Included << UARTE_CONFIG_PARITY_Pos  ///< Parity included.
     139                 :            : } nrf_uarte_parity_t;
     140                 :            : 
     141                 :            : /** @brief Types of UARTE flow control modes. */
     142                 :            : typedef enum
     143                 :            : {
     144                 :            :     NRF_UARTE_HWFC_DISABLED = UARTE_CONFIG_HWFC_Disabled << UARTE_CONFIG_HWFC_Pos, ///< Hardware flow control disabled.
     145                 :            :     NRF_UARTE_HWFC_ENABLED  = UARTE_CONFIG_HWFC_Enabled  << UARTE_CONFIG_HWFC_Pos  ///< Hardware flow control enabled.
     146                 :            : } nrf_uarte_hwfc_t;
     147                 :            : 
     148                 :            : #if defined(UARTE_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
     149                 :            : /** @brief Types of UARTE stop bit modes. */
     150                 :            : typedef enum
     151                 :            : {
     152                 :            :     NRF_UARTE_STOP_ONE = UARTE_CONFIG_STOP_One << UARTE_CONFIG_STOP_Pos, ///< One stop bit.
     153                 :            :     NRF_UARTE_STOP_TWO = UARTE_CONFIG_STOP_Two << UARTE_CONFIG_STOP_Pos  ///< Two stop bits.
     154                 :            : } nrf_uarte_stop_t;
     155                 :            : #endif
     156                 :            : 
     157                 :            : #if defined(UARTE_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
     158                 :            : /** @brief Types of UARTE parity types. */
     159                 :            : typedef enum
     160                 :            : {
     161                 :            :     NRF_UARTE_PARITYTYPE_EVEN = UARTE_CONFIG_PARITYTYPE_Even << UARTE_CONFIG_PARITYTYPE_Pos, ///< Parity even.
     162                 :            :     NRF_UARTE_PARITYTYPE_ODD  = UARTE_CONFIG_PARITYTYPE_Odd << UARTE_CONFIG_PARITYTYPE_Pos,  ///< Parity odd.
     163                 :            : } nrf_uarte_paritytype_t;
     164                 :            : #endif
     165                 :            : 
     166                 :            : /** @brief Structure for UARTE transmission configuration. */
     167                 :            : typedef struct
     168                 :            : {
     169                 :            :     nrf_uarte_hwfc_t       hwfc;       ///< Flow control configuration.
     170                 :            :     nrf_uarte_parity_t     parity;     ///< Parity configuration.
     171                 :            : #if defined(UARTE_CONFIG_STOP_Msk) || defined(__NRFX_DOXYGEN__)
     172                 :            :     nrf_uarte_stop_t       stop;       ///< Stop bits.
     173                 :            : #endif
     174                 :            : #if defined(UARTE_CONFIG_PARITYTYPE_Msk) || defined(__NRFX_DOXYGEN__)
     175                 :            :     nrf_uarte_paritytype_t paritytype; ///< Parity type.
     176                 :            : #endif
     177                 :            : } nrf_uarte_config_t;
     178                 :            : 
     179                 :            : /**
     180                 :            :  * @brief Function for clearing a specific UARTE event.
     181                 :            :  *
     182                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     183                 :            :  * @param[in] event Event to clear.
     184                 :            :  */
     185                 :            : NRF_STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event);
     186                 :            : 
     187                 :            : /**
     188                 :            :  * @brief Function for retrieving the state of the UARTE event.
     189                 :            :  *
     190                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     191                 :            :  * @param[in] event Event to be checked.
     192                 :            :  *
     193                 :            :  * @retval true  The event has been generated.
     194                 :            :  * @retval false The event has not been generated.
     195                 :            :  */
     196                 :            : NRF_STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type const * p_reg,
     197                 :            :                                              nrf_uarte_event_t      event);
     198                 :            : 
     199                 :            : /**
     200                 :            :  * @brief Function for returning the address of the specified UARTE event register.
     201                 :            :  *
     202                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     203                 :            :  * @param[in] event The specified event.
     204                 :            :  *
     205                 :            :  * @return Address of specified event register.
     206                 :            :  */
     207                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type const * p_reg,
     208                 :            :                                                        nrf_uarte_event_t      event);
     209                 :            : 
     210                 :            : /**
     211                 :            :  * @brief Function for enabling UARTE shortcuts.
     212                 :            :  *
     213                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     214                 :            :  * @param[in] mask  Shortcuts to be enabled.
     215                 :            :  */
     216                 :            : NRF_STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t mask);
     217                 :            : 
     218                 :            : /**
     219                 :            :  * @brief Function for disabling UARTE shortcuts.
     220                 :            :  *
     221                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     222                 :            :  * @param[in] mask  Shortcuts to be disabled.
     223                 :            :  */
     224                 :            : NRF_STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t mask);
     225                 :            : 
     226                 :            : /**
     227                 :            :  * @brief Function for enabling UARTE interrupts.
     228                 :            :  *
     229                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     230                 :            :  * @param[in] mask  Mask of interrupts to be enabled.
     231                 :            :  */
     232                 :            : NRF_STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t mask);
     233                 :            : 
     234                 :            : /**
     235                 :            :  * @brief Function for checking if the specified interrupts are enabled.
     236                 :            :  *
     237                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     238                 :            :  * @param[in] mask  Mask of interrupts to be checked.
     239                 :            :  *
     240                 :            :  * @return Mask of enabled interrupts.
     241                 :            :  */
     242                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_int_enable_check(NRF_UARTE_Type const * p_reg, uint32_t mask);
     243                 :            : 
     244                 :            : /**
     245                 :            :  * @brief Function for disabling the specified interrupts.
     246                 :            :  *
     247                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     248                 :            :  * @param[in] mask  Mask of interrupts to be disabled.
     249                 :            :  */
     250                 :            : NRF_STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t mask);
     251                 :            : 
     252                 :            : #if defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
     253                 :            : /**
     254                 :            :  * @brief Function for setting the subscribe configuration for a given
     255                 :            :  *        UARTE task.
     256                 :            :  *
     257                 :            :  * @param[in] p_reg   Pointer to the structure of registers of the peripheral.
     258                 :            :  * @param[in] task    Task for which to set the configuration.
     259                 :            :  * @param[in] channel Channel through which to subscribe events.
     260                 :            :  */
     261                 :            : NRF_STATIC_INLINE void nrf_uarte_subscribe_set(NRF_UARTE_Type * p_reg,
     262                 :            :                                                nrf_uarte_task_t task,
     263                 :            :                                                uint8_t          channel);
     264                 :            : 
     265                 :            : /**
     266                 :            :  * @brief Function for clearing the subscribe configuration for a given
     267                 :            :  *        UARTE task.
     268                 :            :  *
     269                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     270                 :            :  * @param[in] task  Task for which to clear the configuration.
     271                 :            :  */
     272                 :            : NRF_STATIC_INLINE void nrf_uarte_subscribe_clear(NRF_UARTE_Type * p_reg,
     273                 :            :                                                  nrf_uarte_task_t task);
     274                 :            : 
     275                 :            : /**
     276                 :            :  * @brief Function for setting the publish configuration for a given
     277                 :            :  *        UARTE event.
     278                 :            :  *
     279                 :            :  * @param[in] p_reg   Pointer to the structure of registers of the peripheral.
     280                 :            :  * @param[in] event   Event for which to set the configuration.
     281                 :            :  * @param[in] channel Channel through which to publish the event.
     282                 :            :  */
     283                 :            : NRF_STATIC_INLINE void nrf_uarte_publish_set(NRF_UARTE_Type *  p_reg,
     284                 :            :                                              nrf_uarte_event_t event,
     285                 :            :                                              uint8_t           channel);
     286                 :            : 
     287                 :            : /**
     288                 :            :  * @brief Function for clearing the publish configuration for a given
     289                 :            :  *        UARTE event.
     290                 :            :  *
     291                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     292                 :            :  * @param[in] event Event for which to clear the configuration.
     293                 :            :  */
     294                 :            : NRF_STATIC_INLINE void nrf_uarte_publish_clear(NRF_UARTE_Type *  p_reg,
     295                 :            :                                                nrf_uarte_event_t event);
     296                 :            : #endif // defined(DPPI_PRESENT) || defined(__NRFX_DOXYGEN__)
     297                 :            : 
     298                 :            : /**
     299                 :            :  * @brief Function for getting error source mask. Function is clearing error source flags after reading.
     300                 :            :  *
     301                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     302                 :            :  *
     303                 :            :  * @return Mask with error source flags.
     304                 :            :  */
     305                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg);
     306                 :            : 
     307                 :            : /**
     308                 :            :  * @brief Function for enabling UARTE.
     309                 :            :  *
     310                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     311                 :            :  */
     312                 :            : NRF_STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg);
     313                 :            : 
     314                 :            : /**
     315                 :            :  * @brief Function for disabling UARTE.
     316                 :            :  *
     317                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     318                 :            :  */
     319                 :            : NRF_STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg);
     320                 :            : 
     321                 :            : /**
     322                 :            :  * @brief Function for configuring TX/RX pins.
     323                 :            :  *
     324                 :            :  * @param[in] p_reg   Pointer to the structure of registers of the peripheral.
     325                 :            :  * @param[in] pseltxd TXD pin number.
     326                 :            :  * @param[in] pselrxd RXD pin number.
     327                 :            :  */
     328                 :            : NRF_STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg,
     329                 :            :                                                uint32_t         pseltxd,
     330                 :            :                                                uint32_t         pselrxd);
     331                 :            : 
     332                 :            : /**
     333                 :            :  * @brief Function for disconnecting TX/RX pins.
     334                 :            :  *
     335                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     336                 :            :  */
     337                 :            : NRF_STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg);
     338                 :            : 
     339                 :            : /**
     340                 :            :  * @brief Function for getting TX pin selection.
     341                 :            :  *
     342                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     343                 :            :  *
     344                 :            :  * @return TX pin selection.
     345                 :            :  */
     346                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type const * p_reg);
     347                 :            : 
     348                 :            : /**
     349                 :            :  * @brief Function for getting RX pin selection.
     350                 :            :  *
     351                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     352                 :            :  *
     353                 :            :  * @return RX pin selection.
     354                 :            :  */
     355                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type const * p_reg);
     356                 :            : 
     357                 :            : /**
     358                 :            :  * @brief Function for getting RTS pin selection.
     359                 :            :  *
     360                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     361                 :            :  *
     362                 :            :  * @return RTS pin selection.
     363                 :            :  */
     364                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type const * p_reg);
     365                 :            : 
     366                 :            : /**
     367                 :            :  * @brief Function for getting CTS pin selection.
     368                 :            :  *
     369                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     370                 :            :  *
     371                 :            :  * @return CTS pin selection.
     372                 :            :  */
     373                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type const * p_reg);
     374                 :            : 
     375                 :            : /**
     376                 :            :  * @brief Function for configuring flow control pins.
     377                 :            :  *
     378                 :            :  * @param[in] p_reg   Pointer to the structure of registers of the peripheral.
     379                 :            :  * @param[in] pselrts RTS pin number.
     380                 :            :  * @param[in] pselcts CTS pin number.
     381                 :            :  */
     382                 :            : NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg,
     383                 :            :                                                uint32_t         pselrts,
     384                 :            :                                                uint32_t         pselcts);
     385                 :            : 
     386                 :            : /**
     387                 :            :  * @brief Function for disconnecting flow control pins.
     388                 :            :  *
     389                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     390                 :            :  */
     391                 :            : NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg);
     392                 :            : 
     393                 :            : /**
     394                 :            :  * @brief Function for starting an UARTE task.
     395                 :            :  *
     396                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     397                 :            :  * @param[in] task  Task.
     398                 :            :  */
     399                 :            : NRF_STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task);
     400                 :            : 
     401                 :            : /**
     402                 :            :  * @brief Function for returning the address of the specified task register.
     403                 :            :  *
     404                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     405                 :            :  * @param[in] task  Task.
     406                 :            :  *
     407                 :            :  * @return Task address.
     408                 :            :  */
     409                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type const * p_reg,
     410                 :            :                                                       nrf_uarte_task_t       task);
     411                 :            : 
     412                 :            : /**
     413                 :            :  * @brief Function for configuring UARTE.
     414                 :            :  *
     415                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     416                 :            :  * @param[in] p_cfg Pointer to UARTE settings structure.
     417                 :            :  */
     418                 :            : NRF_STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type           * p_reg,
     419                 :            :                                            nrf_uarte_config_t const * p_cfg);
     420                 :            : 
     421                 :            : /**
     422                 :            :  * @brief Function for setting UARTE baud rate.
     423                 :            :  *
     424                 :            :  * @param[in] p_reg    Pointer to the structure of registers of the peripheral.
     425                 :            :  * @param[in] baudrate Baud rate.
     426                 :            :  */
     427                 :            : NRF_STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type *     p_reg,
     428                 :            :                                               nrf_uarte_baudrate_t baudrate);
     429                 :            : 
     430                 :            : /**
     431                 :            :  * @brief Function for setting the transmit buffer.
     432                 :            :  *
     433                 :            :  * @param[in] p_reg    Pointer to the structure of registers of the peripheral.
     434                 :            :  * @param[in] p_buffer Pointer to the buffer with data to send.
     435                 :            :  * @param[in] length   Maximum number of data bytes to transmit.
     436                 :            :  */
     437                 :            : NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
     438                 :            :                                                uint8_t  const * p_buffer,
     439                 :            :                                                size_t           length);
     440                 :            : 
     441                 :            : /**
     442                 :            :  * @brief Function for getting number of bytes transmitted in the last transaction.
     443                 :            :  *
     444                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     445                 :            :  *
     446                 :            :  * @retval Amount of bytes transmitted.
     447                 :            :  */
     448                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type const * p_reg);
     449                 :            : 
     450                 :            : /**
     451                 :            :  * @brief Function for setting the receive buffer.
     452                 :            :  *
     453                 :            :  * @param[in] p_reg    Pointer to the structure of registers of the peripheral.
     454                 :            :  * @param[in] p_buffer Pointer to the buffer for received data.
     455                 :            :  * @param[in] length   Maximum number of data bytes to receive.
     456                 :            :  */
     457                 :            : NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
     458                 :            :                                                uint8_t *        p_buffer,
     459                 :            :                                                size_t           length);
     460                 :            : 
     461                 :            : /**
     462                 :            :  * @brief Function for getting number of bytes received in the last transaction.
     463                 :            :  *
     464                 :            :  * @param[in] p_reg Pointer to the structure of registers of the peripheral.
     465                 :            :  *
     466                 :            :  * @retval Amount of bytes received.
     467                 :            :  */
     468                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type const * p_reg);
     469                 :            : 
     470                 :            : #ifndef NRF_DECLARE_ONLY
     471                 :     382313 : NRF_STATIC_INLINE void nrf_uarte_event_clear(NRF_UARTE_Type * p_reg, nrf_uarte_event_t event)
     472                 :            : {
     473                 :     382313 :     *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
     474                 :     382313 :     nrf_event_readback((uint8_t *)p_reg + (uint32_t)event);
     475                 :     382313 : }
     476                 :            : 
     477                 :    1522480 : NRF_STATIC_INLINE bool nrf_uarte_event_check(NRF_UARTE_Type const * p_reg,
     478                 :            :                                              nrf_uarte_event_t      event)
     479                 :            : {
     480                 :    1522480 :     return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
     481                 :            : }
     482                 :            : 
     483                 :          1 : NRF_STATIC_INLINE uint32_t nrf_uarte_event_address_get(NRF_UARTE_Type const * p_reg,
     484                 :            :                                                        nrf_uarte_event_t      event)
     485                 :            : {
     486                 :          1 :     return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
     487                 :            : }
     488                 :            : 
     489                 :            : NRF_STATIC_INLINE void nrf_uarte_shorts_enable(NRF_UARTE_Type * p_reg, uint32_t mask)
     490                 :            : {
     491                 :            :     p_reg->SHORTS |= mask;
     492                 :            : }
     493                 :            : 
     494                 :            : NRF_STATIC_INLINE void nrf_uarte_shorts_disable(NRF_UARTE_Type * p_reg, uint32_t mask)
     495                 :            : {
     496                 :            :     p_reg->SHORTS &= ~(mask);
     497                 :            : }
     498                 :            : 
     499                 :          0 : NRF_STATIC_INLINE void nrf_uarte_int_enable(NRF_UARTE_Type * p_reg, uint32_t mask)
     500                 :            : {
     501                 :          0 :     p_reg->INTENSET = mask;
     502                 :          0 : }
     503                 :            : 
     504                 :          0 : NRF_STATIC_INLINE uint32_t nrf_uarte_int_enable_check(NRF_UARTE_Type const * p_reg, uint32_t mask)
     505                 :            : {
     506                 :          0 :     return p_reg->INTENSET & mask;
     507                 :            : }
     508                 :            : 
     509                 :          0 : NRF_STATIC_INLINE void nrf_uarte_int_disable(NRF_UARTE_Type * p_reg, uint32_t mask)
     510                 :            : {
     511                 :          0 :     p_reg->INTENCLR = mask;
     512                 :          0 : }
     513                 :            : 
     514                 :            : #if defined(DPPI_PRESENT)
     515                 :            : NRF_STATIC_INLINE void nrf_uarte_subscribe_set(NRF_UARTE_Type * p_reg,
     516                 :            :                                                nrf_uarte_task_t task,
     517                 :            :                                                uint8_t          channel)
     518                 :            : {
     519                 :            :     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) =
     520                 :            :             ((uint32_t)channel | UARTE_SUBSCRIBE_STARTRX_EN_Msk);
     521                 :            : }
     522                 :            : 
     523                 :            : NRF_STATIC_INLINE void nrf_uarte_subscribe_clear(NRF_UARTE_Type * p_reg,
     524                 :            :                                                  nrf_uarte_task_t task)
     525                 :            : {
     526                 :            :     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) task + 0x80uL)) = 0;
     527                 :            : }
     528                 :            : 
     529                 :            : NRF_STATIC_INLINE void nrf_uarte_publish_set(NRF_UARTE_Type *  p_reg,
     530                 :            :                                              nrf_uarte_event_t event,
     531                 :            :                                              uint8_t           channel)
     532                 :            : {
     533                 :            :     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) =
     534                 :            :             ((uint32_t)channel | UARTE_PUBLISH_CTS_EN_Msk);
     535                 :            : }
     536                 :            : 
     537                 :            : NRF_STATIC_INLINE void nrf_uarte_publish_clear(NRF_UARTE_Type *  p_reg,
     538                 :            :                                                nrf_uarte_event_t event)
     539                 :            : {
     540                 :            :     *((volatile uint32_t *) ((uint8_t *) p_reg + (uint32_t) event + 0x80uL)) = 0;
     541                 :            : }
     542                 :            : #endif // defined(DPPI_PRESENT)
     543                 :            : 
     544                 :          0 : NRF_STATIC_INLINE uint32_t nrf_uarte_errorsrc_get_and_clear(NRF_UARTE_Type * p_reg)
     545                 :            : {
     546                 :          0 :     uint32_t errsrc_mask = p_reg->ERRORSRC;
     547                 :          0 :     p_reg->ERRORSRC = errsrc_mask;
     548                 :          0 :     return errsrc_mask;
     549                 :            : }
     550                 :            : 
     551                 :          1 : NRF_STATIC_INLINE void nrf_uarte_enable(NRF_UARTE_Type * p_reg)
     552                 :            : {
     553                 :          1 :     p_reg->ENABLE = UARTE_ENABLE_ENABLE_Enabled;
     554                 :          1 : }
     555                 :            : 
     556                 :          1 : NRF_STATIC_INLINE void nrf_uarte_disable(NRF_UARTE_Type * p_reg)
     557                 :            : {
     558                 :          1 :     p_reg->ENABLE = UARTE_ENABLE_ENABLE_Disabled;
     559                 :          1 : }
     560                 :            : 
     561                 :            : NRF_STATIC_INLINE void nrf_uarte_txrx_pins_set(NRF_UARTE_Type * p_reg,
     562                 :            :                                                uint32_t         pseltxd,
     563                 :            :                                                uint32_t         pselrxd)
     564                 :            : {
     565                 :            :     p_reg->PSEL.TXD = pseltxd;
     566                 :            :     p_reg->PSEL.RXD = pselrxd;
     567                 :            : }
     568                 :            : 
     569                 :            : NRF_STATIC_INLINE void nrf_uarte_txrx_pins_disconnect(NRF_UARTE_Type * p_reg)
     570                 :            : {
     571                 :            :     nrf_uarte_txrx_pins_set(p_reg, NRF_UARTE_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED);
     572                 :            : }
     573                 :            : 
     574                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_tx_pin_get(NRF_UARTE_Type const * p_reg)
     575                 :            : {
     576                 :            :     return p_reg->PSEL.TXD;
     577                 :            : }
     578                 :            : 
     579                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_rx_pin_get(NRF_UARTE_Type const * p_reg)
     580                 :            : {
     581                 :            :     return p_reg->PSEL.RXD;
     582                 :            : }
     583                 :            : 
     584                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_rts_pin_get(NRF_UARTE_Type const * p_reg)
     585                 :            : {
     586                 :            :     return p_reg->PSEL.RTS;
     587                 :            : }
     588                 :            : 
     589                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_cts_pin_get(NRF_UARTE_Type const * p_reg)
     590                 :            : {
     591                 :            :     return p_reg->PSEL.CTS;
     592                 :            : }
     593                 :            : 
     594                 :            : NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_set(NRF_UARTE_Type * p_reg,
     595                 :            :                                                uint32_t         pselrts,
     596                 :            :                                                uint32_t         pselcts)
     597                 :            : {
     598                 :            :     p_reg->PSEL.RTS = pselrts;
     599                 :            :     p_reg->PSEL.CTS = pselcts;
     600                 :            : }
     601                 :            : 
     602                 :            : NRF_STATIC_INLINE void nrf_uarte_hwfc_pins_disconnect(NRF_UARTE_Type * p_reg)
     603                 :            : {
     604                 :            :     nrf_uarte_hwfc_pins_set(p_reg, NRF_UARTE_PSEL_DISCONNECTED, NRF_UARTE_PSEL_DISCONNECTED);
     605                 :            : }
     606                 :            : 
     607                 :     191159 : NRF_STATIC_INLINE void nrf_uarte_task_trigger(NRF_UARTE_Type * p_reg, nrf_uarte_task_t task)
     608                 :            : {
     609                 :     191159 :     *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
     610                 :     191159 : }
     611                 :            : 
     612                 :          1 : NRF_STATIC_INLINE uint32_t nrf_uarte_task_address_get(NRF_UARTE_Type const * p_reg,
     613                 :            :                                                       nrf_uarte_task_t       task)
     614                 :            : {
     615                 :          1 :     return (uint32_t)p_reg + (uint32_t)task;
     616                 :            : }
     617                 :            : 
     618                 :          1 : NRF_STATIC_INLINE void nrf_uarte_configure(NRF_UARTE_Type           * p_reg,
     619                 :            :                                            nrf_uarte_config_t const * p_cfg)
     620                 :            : {
     621                 :          1 :     p_reg->CONFIG = (uint32_t)p_cfg->parity
     622                 :            : #if defined(UARTE_CONFIG_STOP_Msk)
     623                 :          1 :                     | (uint32_t)p_cfg->stop
     624                 :            : #endif
     625                 :            : #if defined(UARTE_CONFIG_PARITYTYPE_Msk)
     626                 :          1 :                     | (uint32_t)p_cfg->paritytype
     627                 :            : #endif
     628                 :          1 :                     | (uint32_t)p_cfg->hwfc;
     629                 :          1 : }
     630                 :            : 
     631                 :          1 : NRF_STATIC_INLINE void nrf_uarte_baudrate_set(NRF_UARTE_Type * p_reg, nrf_uarte_baudrate_t baudrate)
     632                 :            : {
     633                 :          1 :     p_reg->BAUDRATE = baudrate;
     634                 :          1 : }
     635                 :            : 
     636                 :     191157 : NRF_STATIC_INLINE void nrf_uarte_tx_buffer_set(NRF_UARTE_Type * p_reg,
     637                 :            :                                                uint8_t  const * p_buffer,
     638                 :            :                                                size_t           length)
     639                 :            : {
     640                 :     191157 :     p_reg->TXD.PTR    = (uint32_t)p_buffer;
     641                 :     191157 :     p_reg->TXD.MAXCNT = length;
     642                 :     191157 : }
     643                 :            : 
     644                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_tx_amount_get(NRF_UARTE_Type const * p_reg)
     645                 :            : {
     646                 :            :     return p_reg->TXD.AMOUNT;
     647                 :            : }
     648                 :            : 
     649                 :          1 : NRF_STATIC_INLINE void nrf_uarte_rx_buffer_set(NRF_UARTE_Type * p_reg,
     650                 :            :                                                uint8_t *        p_buffer,
     651                 :            :                                                size_t           length)
     652                 :            : {
     653                 :          1 :     p_reg->RXD.PTR    = (uint32_t)p_buffer;
     654                 :          1 :     p_reg->RXD.MAXCNT = length;
     655                 :          1 : }
     656                 :            : 
     657                 :            : NRF_STATIC_INLINE uint32_t nrf_uarte_rx_amount_get(NRF_UARTE_Type const * p_reg)
     658                 :            : {
     659                 :            :     return p_reg->RXD.AMOUNT;
     660                 :            : }
     661                 :            : #endif // NRF_DECLARE_ONLY
     662                 :            : 
     663                 :            : /** @} */
     664                 :            : 
     665                 :            : #ifdef __cplusplus
     666                 :            : }
     667                 :            : #endif
     668                 :            : 
     669                 :            : #endif // NRF_UARTE_H__

Generated by: LCOV version 1.14