nrf_uart.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511
  1. /**
  2. * Copyright (c) 2015 - 2020, Nordic Semiconductor ASA
  3. *
  4. * All rights reserved.
  5. *
  6. * Redistribution and use in source and binary forms, with or without modification,
  7. * are permitted provided that the following conditions are met:
  8. *
  9. * 1. Redistributions of source code must retain the above copyright notice, this
  10. * list of conditions and the following disclaimer.
  11. *
  12. * 2. Redistributions in binary form, except as embedded into a Nordic
  13. * Semiconductor ASA integrated circuit in a product or a software update for
  14. * such product, must reproduce the above copyright notice, this list of
  15. * conditions and the following disclaimer in the documentation and/or other
  16. * materials provided with the distribution.
  17. *
  18. * 3. Neither the name of Nordic Semiconductor ASA nor the names of its
  19. * contributors may be used to endorse or promote products derived from this
  20. * software without specific prior written permission.
  21. *
  22. * 4. This software, with or without modification, must only be used with a
  23. * Nordic Semiconductor ASA integrated circuit.
  24. *
  25. * 5. Any software provided in binary form under this license must not be reverse
  26. * engineered, decompiled, modified and/or disassembled.
  27. *
  28. * THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY EXPRESS
  29. * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  30. * OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A PARTICULAR PURPOSE ARE
  31. * DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR ASA OR CONTRIBUTORS BE
  32. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  33. * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
  34. * GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  35. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  36. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  37. * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. *
  39. */
  40. #ifndef NRF_UART_H__
  41. #define NRF_UART_H__
  42. #include <nrfx.h>
  43. #ifdef __cplusplus
  44. extern "C" {
  45. #endif
  46. /**
  47. * @defgroup nrf_uart_hal UART HAL
  48. * @{
  49. * @ingroup nrf_uart
  50. * @brief Hardware access layer for managing the UART peripheral.
  51. */
  52. /** @brief Pin disconnected value. */
  53. #define NRF_UART_PSEL_DISCONNECTED 0xFFFFFFFF
  54. /** @brief UART tasks. */
  55. typedef enum
  56. {
  57. NRF_UART_TASK_STARTRX = offsetof(NRF_UART_Type, TASKS_STARTRX), /**< Task for starting reception. */
  58. NRF_UART_TASK_STOPRX = offsetof(NRF_UART_Type, TASKS_STOPRX), /**< Task for stopping reception. */
  59. NRF_UART_TASK_STARTTX = offsetof(NRF_UART_Type, TASKS_STARTTX), /**< Task for starting transmission. */
  60. NRF_UART_TASK_STOPTX = offsetof(NRF_UART_Type, TASKS_STOPTX), /**< Task for stopping transmission. */
  61. NRF_UART_TASK_SUSPEND = offsetof(NRF_UART_Type, TASKS_SUSPEND), /**< Task for suspending UART. */
  62. } nrf_uart_task_t;
  63. /** @brief UART events. */
  64. typedef enum
  65. {
  66. NRF_UART_EVENT_CTS = offsetof(NRF_UART_Type, EVENTS_CTS), /**< Event from CTS line activation. */
  67. NRF_UART_EVENT_NCTS = offsetof(NRF_UART_Type, EVENTS_NCTS), /**< Event from CTS line deactivation. */
  68. NRF_UART_EVENT_RXDRDY = offsetof(NRF_UART_Type, EVENTS_RXDRDY),/**< Event from data ready in RXD. */
  69. NRF_UART_EVENT_TXDRDY = offsetof(NRF_UART_Type, EVENTS_TXDRDY),/**< Event from data sent from TXD. */
  70. NRF_UART_EVENT_ERROR = offsetof(NRF_UART_Type, EVENTS_ERROR), /**< Event from error detection. */
  71. NRF_UART_EVENT_RXTO = offsetof(NRF_UART_Type, EVENTS_RXTO) /**< Event from receiver timeout. */
  72. } nrf_uart_event_t;
  73. /** @brief UART interrupts. */
  74. typedef enum
  75. {
  76. NRF_UART_INT_MASK_CTS = UART_INTENCLR_CTS_Msk, /**< CTS line activation interrupt. */
  77. NRF_UART_INT_MASK_NCTS = UART_INTENCLR_NCTS_Msk, /**< CTS line deactivation interrupt. */
  78. NRF_UART_INT_MASK_RXDRDY = UART_INTENCLR_RXDRDY_Msk, /**< Data ready in RXD interrupt. */
  79. NRF_UART_INT_MASK_TXDRDY = UART_INTENCLR_TXDRDY_Msk, /**< Data sent from TXD interrupt. */
  80. NRF_UART_INT_MASK_ERROR = UART_INTENCLR_ERROR_Msk, /**< Error detection interrupt. */
  81. NRF_UART_INT_MASK_RXTO = UART_INTENCLR_RXTO_Msk /**< Receiver timeout interrupt. */
  82. } nrf_uart_int_mask_t;
  83. /** @brief Baudrates supported by UART. */
  84. typedef enum
  85. {
  86. NRF_UART_BAUDRATE_1200 = UART_BAUDRATE_BAUDRATE_Baud1200, /**< 1200 baud. */
  87. NRF_UART_BAUDRATE_2400 = UART_BAUDRATE_BAUDRATE_Baud2400, /**< 2400 baud. */
  88. NRF_UART_BAUDRATE_4800 = UART_BAUDRATE_BAUDRATE_Baud4800, /**< 4800 baud. */
  89. NRF_UART_BAUDRATE_9600 = UART_BAUDRATE_BAUDRATE_Baud9600, /**< 9600 baud. */
  90. NRF_UART_BAUDRATE_14400 = UART_BAUDRATE_BAUDRATE_Baud14400, /**< 14400 baud. */
  91. NRF_UART_BAUDRATE_19200 = UART_BAUDRATE_BAUDRATE_Baud19200, /**< 19200 baud. */
  92. NRF_UART_BAUDRATE_28800 = UART_BAUDRATE_BAUDRATE_Baud28800, /**< 28800 baud. */
  93. NRF_UART_BAUDRATE_31250 = UART_BAUDRATE_BAUDRATE_Baud31250, /**< 31250 baud. */
  94. NRF_UART_BAUDRATE_38400 = UART_BAUDRATE_BAUDRATE_Baud38400, /**< 38400 baud. */
  95. NRF_UART_BAUDRATE_56000 = UART_BAUDRATE_BAUDRATE_Baud56000, /**< 56000 baud. */
  96. NRF_UART_BAUDRATE_57600 = UART_BAUDRATE_BAUDRATE_Baud57600, /**< 57600 baud. */
  97. NRF_UART_BAUDRATE_76800 = UART_BAUDRATE_BAUDRATE_Baud76800, /**< 76800 baud. */
  98. NRF_UART_BAUDRATE_115200 = UART_BAUDRATE_BAUDRATE_Baud115200, /**< 115200 baud. */
  99. NRF_UART_BAUDRATE_230400 = UART_BAUDRATE_BAUDRATE_Baud230400, /**< 230400 baud. */
  100. NRF_UART_BAUDRATE_250000 = UART_BAUDRATE_BAUDRATE_Baud250000, /**< 250000 baud. */
  101. NRF_UART_BAUDRATE_460800 = UART_BAUDRATE_BAUDRATE_Baud460800, /**< 460800 baud. */
  102. NRF_UART_BAUDRATE_921600 = UART_BAUDRATE_BAUDRATE_Baud921600, /**< 921600 baud. */
  103. NRF_UART_BAUDRATE_1000000 = UART_BAUDRATE_BAUDRATE_Baud1M, /**< 1000000 baud. */
  104. } nrf_uart_baudrate_t;
  105. /** @brief Types of UART error masks. */
  106. typedef enum
  107. {
  108. NRF_UART_ERROR_OVERRUN_MASK = UART_ERRORSRC_OVERRUN_Msk, /**< Overrun error. */
  109. NRF_UART_ERROR_PARITY_MASK = UART_ERRORSRC_PARITY_Msk, /**< Parity error. */
  110. NRF_UART_ERROR_FRAMING_MASK = UART_ERRORSRC_FRAMING_Msk, /**< Framing error. */
  111. NRF_UART_ERROR_BREAK_MASK = UART_ERRORSRC_BREAK_Msk, /**< Break error. */
  112. } nrf_uart_error_mask_t;
  113. /** @brief Types of UART parity modes. */
  114. typedef enum
  115. {
  116. NRF_UART_PARITY_EXCLUDED = UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos, /**< Parity excluded. */
  117. NRF_UART_PARITY_INCLUDED = UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos, /**< Parity included. */
  118. } nrf_uart_parity_t;
  119. /** @brief Types of UART flow control modes. */
  120. typedef enum
  121. {
  122. NRF_UART_HWFC_DISABLED = UART_CONFIG_HWFC_Disabled, /**< Hardware flow control disabled. */
  123. NRF_UART_HWFC_ENABLED = UART_CONFIG_HWFC_Enabled, /**< Hardware flow control enabled. */
  124. } nrf_uart_hwfc_t;
  125. /**
  126. * @brief Function for clearing the specified UART event.
  127. *
  128. * @param[in] p_reg Pointer to the structure of registers of the peripheral.
  129. * @param[in] event Event to clear.
  130. */
  131. __STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event);
  132. /**
  133. * @brief Function for retrieving the state of the UART event.
  134. *
  135. * @param[in] p_reg Pointer to the structure of registers of the peripheral.
  136. * @param[in] event Event to be checked.
  137. *
  138. * @retval true The event has been generated.
  139. * @retval false The event has not been generated.
  140. */
  141. __STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event);
  142. /**
  143. * @brief Function for returning the address of the specified UART event register.
  144. *
  145. * @param[in] p_reg Pointer to the structure of registers of the peripheral.
  146. * @param[in] event Desired event.
  147. *
  148. * @return Address of the specified event register.
  149. */
  150. __STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg,
  151. nrf_uart_event_t event);
  152. /**
  153. * @brief Function for enabling the specified interrupt.
  154. *
  155. * @param p_reg Pointer to the structure of registers of the peripheral.
  156. * @param mask Mask of interrupts to be enabled.
  157. */
  158. __STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t mask);
  159. /**
  160. * @brief Function for retrieving the state of a given interrupt.
  161. *
  162. * @param p_reg Pointer to the structure of registers of the peripheral.
  163. * @param mask Mask of interrupts to be checked.
  164. *
  165. * @retval true The interrupt is enabled.
  166. * @retval false The interrupt is not enabled.
  167. */
  168. __STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t mask);
  169. /**
  170. * @brief Function for disabling the specified interrupts.
  171. *
  172. * @param p_reg Pointer to the structure of registers of the peripheral.
  173. * @param mask Mask of interrupts to be disabled.
  174. */
  175. __STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t mask);
  176. /**
  177. * @brief Function for getting error source mask. Function is clearing error source flags after reading.
  178. *
  179. * @param p_reg Pointer to the structure of registers of the peripheral.
  180. *
  181. * @return Mask with error source flags.
  182. */
  183. __STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg);
  184. /**
  185. * @brief Function for enabling UART.
  186. *
  187. * @param p_reg Pointer to the structure of registers of the peripheral.
  188. */
  189. __STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg);
  190. /**
  191. * @brief Function for disabling UART.
  192. *
  193. * @param p_reg Pointer to the structure of registers of the peripheral.
  194. */
  195. __STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg);
  196. /**
  197. * @brief Function for configuring TX/RX pins.
  198. *
  199. * @param p_reg Pointer to the structure of registers of the peripheral.
  200. * @param pseltxd TXD pin number.
  201. * @param pselrxd RXD pin number.
  202. */
  203. __STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd);
  204. /**
  205. * @brief Function for disconnecting TX/RX pins.
  206. *
  207. * @param p_reg Pointer to the structure of registers of the peripheral.
  208. */
  209. __STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg);
  210. /**
  211. * @brief Function for getting TX pin.
  212. *
  213. * @param p_reg Pointer to the structure of registers of the peripheral.
  214. *
  215. * @return TX pin number.
  216. */
  217. __STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg);
  218. /**
  219. * @brief Function for getting RX pin.
  220. *
  221. * @param p_reg Pointer to the structure of registers of the peripheral.
  222. *
  223. * @return RX pin number.
  224. */
  225. __STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg);
  226. /**
  227. * @brief Function for getting RTS pin.
  228. *
  229. * @param p_reg Pointer to the structure of registers of the peripheral.
  230. *
  231. * @return RTS pin number.
  232. */
  233. __STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg);
  234. /**
  235. * @brief Function for getting CTS pin.
  236. *
  237. * @param p_reg Pointer to the structure of registers of the peripheral.
  238. *
  239. * @return CTS pin number.
  240. */
  241. __STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg);
  242. /**
  243. * @brief Function for configuring flow control pins.
  244. *
  245. * @param p_reg Pointer to the structure of registers of the peripheral.
  246. * @param pselrts RTS pin number.
  247. * @param pselcts CTS pin number.
  248. */
  249. __STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg,
  250. uint32_t pselrts,
  251. uint32_t pselcts);
  252. /**
  253. * @brief Function for disconnecting flow control pins.
  254. *
  255. * @param p_reg Pointer to the structure of registers of the peripheral.
  256. */
  257. __STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg);
  258. /**
  259. * @brief Function for reading RX data.
  260. *
  261. * @param p_reg Pointer to the structure of registers of the peripheral.
  262. *
  263. * @return Received byte.
  264. */
  265. __STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg);
  266. /**
  267. * @brief Function for setting Tx data.
  268. *
  269. * @param p_reg Pointer to the structure of registers of the peripheral.
  270. * @param txd Byte.
  271. */
  272. __STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd);
  273. /**
  274. * @brief Function for starting an UART task.
  275. *
  276. * @param p_reg Pointer to the structure of registers of the peripheral.
  277. * @param task Task.
  278. */
  279. __STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task);
  280. /**
  281. * @brief Function for returning the address of the specified task register.
  282. *
  283. * @param p_reg Pointer to the structure of registers of the peripheral.
  284. * @param task Task.
  285. *
  286. * @return Task address.
  287. */
  288. __STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task);
  289. /**
  290. * @brief Function for configuring UART.
  291. *
  292. * @param p_reg Pointer to the structure of registers of the peripheral.
  293. * @param hwfc Hardware flow control. Enabled if true.
  294. * @param parity Parity. Included if true.
  295. */
  296. __STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
  297. nrf_uart_parity_t parity,
  298. nrf_uart_hwfc_t hwfc);
  299. /**
  300. * @brief Function for setting UART baud rate.
  301. *
  302. * @param p_reg Pointer to the structure of registers of the peripheral.
  303. * @param baudrate Baud rate.
  304. */
  305. __STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate);
  306. #ifndef SUPPRESS_INLINE_IMPLEMENTATION
  307. __STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event)
  308. {
  309. *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
  310. #if __CORTEX_M == 0x04
  311. volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
  312. (void)dummy;
  313. #endif
  314. }
  315. __STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event)
  316. {
  317. return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
  318. }
  319. __STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg,
  320. nrf_uart_event_t event)
  321. {
  322. return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
  323. }
  324. __STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t mask)
  325. {
  326. p_reg->INTENSET = mask;
  327. }
  328. __STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t mask)
  329. {
  330. return (bool)(p_reg->INTENSET & mask);
  331. }
  332. __STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t mask)
  333. {
  334. p_reg->INTENCLR = mask;
  335. }
  336. __STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg)
  337. {
  338. uint32_t errsrc_mask = p_reg->ERRORSRC;
  339. p_reg->ERRORSRC = errsrc_mask;
  340. return errsrc_mask;
  341. }
  342. __STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg)
  343. {
  344. p_reg->ENABLE = UART_ENABLE_ENABLE_Enabled;
  345. }
  346. __STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg)
  347. {
  348. p_reg->ENABLE = UART_ENABLE_ENABLE_Disabled;
  349. }
  350. __STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd)
  351. {
  352. #if defined(UART_PSEL_RXD_CONNECT_Pos)
  353. p_reg->PSEL.RXD = pselrxd;
  354. #else
  355. p_reg->PSELRXD = pselrxd;
  356. #endif
  357. #if defined(UART_PSEL_TXD_CONNECT_Pos)
  358. p_reg->PSEL.TXD = pseltxd;
  359. #else
  360. p_reg->PSELTXD = pseltxd;
  361. #endif
  362. }
  363. __STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg)
  364. {
  365. nrf_uart_txrx_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED);
  366. }
  367. __STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg)
  368. {
  369. #if defined(UART_PSEL_TXD_CONNECT_Pos)
  370. return p_reg->PSEL.TXD;
  371. #else
  372. return p_reg->PSELTXD;
  373. #endif
  374. }
  375. __STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg)
  376. {
  377. #if defined(UART_PSEL_RXD_CONNECT_Pos)
  378. return p_reg->PSEL.RXD;
  379. #else
  380. return p_reg->PSELRXD;
  381. #endif
  382. }
  383. __STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg)
  384. {
  385. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  386. return p_reg->PSEL.RTS;
  387. #else
  388. return p_reg->PSELRTS;
  389. #endif
  390. }
  391. __STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg)
  392. {
  393. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  394. return p_reg->PSEL.CTS;
  395. #else
  396. return p_reg->PSELCTS;
  397. #endif
  398. }
  399. __STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg, uint32_t pselrts, uint32_t pselcts)
  400. {
  401. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  402. p_reg->PSEL.RTS = pselrts;
  403. #else
  404. p_reg->PSELRTS = pselrts;
  405. #endif
  406. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  407. p_reg->PSEL.CTS = pselcts;
  408. #else
  409. p_reg->PSELCTS = pselcts;
  410. #endif
  411. }
  412. __STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg)
  413. {
  414. nrf_uart_hwfc_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED);
  415. }
  416. __STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg)
  417. {
  418. return p_reg->RXD;
  419. }
  420. __STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd)
  421. {
  422. p_reg->TXD = txd;
  423. }
  424. __STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task)
  425. {
  426. *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
  427. }
  428. __STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task)
  429. {
  430. return (uint32_t)p_reg + (uint32_t)task;
  431. }
  432. __STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
  433. nrf_uart_parity_t parity,
  434. nrf_uart_hwfc_t hwfc)
  435. {
  436. p_reg->CONFIG = (uint32_t)parity | (uint32_t)hwfc;
  437. }
  438. __STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate)
  439. {
  440. p_reg->BAUDRATE = baudrate;
  441. }
  442. #endif //SUPPRESS_INLINE_IMPLEMENTATION
  443. /** @} */
  444. #ifdef __cplusplus
  445. }
  446. #endif
  447. #endif //NRF_UART_H__