nrf_uart.h 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526
  1. /**
  2. * Copyright (c) 2015 - 2019, 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. #define NRF_UART_PSEL_DISCONNECTED 0xFFFFFFFF
  53. /**
  54. * @enum nrf_uart_task_t
  55. * @brief UART tasks.
  56. */
  57. typedef enum
  58. {
  59. /*lint -save -e30 -esym(628,__INTADDR__)*/
  60. NRF_UART_TASK_STARTRX = offsetof(NRF_UART_Type, TASKS_STARTRX), /**< Task for starting reception. */
  61. NRF_UART_TASK_STOPRX = offsetof(NRF_UART_Type, TASKS_STOPRX), /**< Task for stopping reception. */
  62. NRF_UART_TASK_STARTTX = offsetof(NRF_UART_Type, TASKS_STARTTX), /**< Task for starting transmission. */
  63. NRF_UART_TASK_STOPTX = offsetof(NRF_UART_Type, TASKS_STOPTX), /**< Task for stopping transmission. */
  64. NRF_UART_TASK_SUSPEND = offsetof(NRF_UART_Type, TASKS_SUSPEND), /**< Task for suspending UART. */
  65. /*lint -restore*/
  66. } nrf_uart_task_t;
  67. /**
  68. * @enum nrf_uart_event_t
  69. * @brief UART events.
  70. */
  71. typedef enum
  72. {
  73. /*lint -save -e30*/
  74. NRF_UART_EVENT_CTS = offsetof(NRF_UART_Type, EVENTS_CTS), /**< Event from CTS line activation. */
  75. NRF_UART_EVENT_NCTS = offsetof(NRF_UART_Type, EVENTS_NCTS), /**< Event from CTS line deactivation. */
  76. NRF_UART_EVENT_RXDRDY = offsetof(NRF_UART_Type, EVENTS_RXDRDY),/**< Event from data ready in RXD. */
  77. NRF_UART_EVENT_TXDRDY = offsetof(NRF_UART_Type, EVENTS_TXDRDY),/**< Event from data sent from TXD. */
  78. NRF_UART_EVENT_ERROR = offsetof(NRF_UART_Type, EVENTS_ERROR), /**< Event from error detection. */
  79. NRF_UART_EVENT_RXTO = offsetof(NRF_UART_Type, EVENTS_RXTO) /**< Event from receiver timeout. */
  80. /*lint -restore*/
  81. } nrf_uart_event_t;
  82. /**
  83. * @enum nrf_uart_int_mask_t
  84. * @brief UART interrupts.
  85. */
  86. typedef enum
  87. {
  88. /*lint -save -e30*/
  89. NRF_UART_INT_MASK_CTS = UART_INTENCLR_CTS_Msk, /**< CTS line activation interrupt. */
  90. NRF_UART_INT_MASK_NCTS = UART_INTENCLR_NCTS_Msk, /**< CTS line deactivation interrupt. */
  91. NRF_UART_INT_MASK_RXDRDY = UART_INTENCLR_RXDRDY_Msk, /**< Data ready in RXD interrupt. */
  92. NRF_UART_INT_MASK_TXDRDY = UART_INTENCLR_TXDRDY_Msk, /**< Data sent from TXD interrupt. */
  93. NRF_UART_INT_MASK_ERROR = UART_INTENCLR_ERROR_Msk, /**< Error detection interrupt. */
  94. NRF_UART_INT_MASK_RXTO = UART_INTENCLR_RXTO_Msk /**< Receiver timeout interrupt. */
  95. /*lint -restore*/
  96. } nrf_uart_int_mask_t;
  97. /**
  98. * @enum nrf_uart_baudrate_t
  99. * @brief Baudrates supported by UART.
  100. */
  101. typedef enum
  102. {
  103. NRF_UART_BAUDRATE_1200 = UART_BAUDRATE_BAUDRATE_Baud1200, /**< 1200 baud. */
  104. NRF_UART_BAUDRATE_2400 = UART_BAUDRATE_BAUDRATE_Baud2400, /**< 2400 baud. */
  105. NRF_UART_BAUDRATE_4800 = UART_BAUDRATE_BAUDRATE_Baud4800, /**< 4800 baud. */
  106. NRF_UART_BAUDRATE_9600 = UART_BAUDRATE_BAUDRATE_Baud9600, /**< 9600 baud. */
  107. NRF_UART_BAUDRATE_14400 = UART_BAUDRATE_BAUDRATE_Baud14400, /**< 14400 baud. */
  108. NRF_UART_BAUDRATE_19200 = UART_BAUDRATE_BAUDRATE_Baud19200, /**< 19200 baud. */
  109. NRF_UART_BAUDRATE_28800 = UART_BAUDRATE_BAUDRATE_Baud28800, /**< 28800 baud. */
  110. NRF_UART_BAUDRATE_31250 = UART_BAUDRATE_BAUDRATE_Baud31250, /**< 31250 baud. */
  111. NRF_UART_BAUDRATE_38400 = UART_BAUDRATE_BAUDRATE_Baud38400, /**< 38400 baud. */
  112. NRF_UART_BAUDRATE_56000 = UART_BAUDRATE_BAUDRATE_Baud56000, /**< 56000 baud. */
  113. NRF_UART_BAUDRATE_57600 = UART_BAUDRATE_BAUDRATE_Baud57600, /**< 57600 baud. */
  114. NRF_UART_BAUDRATE_76800 = UART_BAUDRATE_BAUDRATE_Baud76800, /**< 76800 baud. */
  115. NRF_UART_BAUDRATE_115200 = UART_BAUDRATE_BAUDRATE_Baud115200, /**< 115200 baud. */
  116. NRF_UART_BAUDRATE_230400 = UART_BAUDRATE_BAUDRATE_Baud230400, /**< 230400 baud. */
  117. NRF_UART_BAUDRATE_250000 = UART_BAUDRATE_BAUDRATE_Baud250000, /**< 250000 baud. */
  118. NRF_UART_BAUDRATE_460800 = UART_BAUDRATE_BAUDRATE_Baud460800, /**< 460800 baud. */
  119. NRF_UART_BAUDRATE_921600 = UART_BAUDRATE_BAUDRATE_Baud921600, /**< 921600 baud. */
  120. NRF_UART_BAUDRATE_1000000 = UART_BAUDRATE_BAUDRATE_Baud1M, /**< 1000000 baud. */
  121. } nrf_uart_baudrate_t;
  122. /**
  123. * @enum nrf_uart_error_mask_t
  124. * @brief Types of UART error masks.
  125. */
  126. typedef enum
  127. {
  128. NRF_UART_ERROR_OVERRUN_MASK = UART_ERRORSRC_OVERRUN_Msk, /**< Overrun error. */
  129. NRF_UART_ERROR_PARITY_MASK = UART_ERRORSRC_PARITY_Msk, /**< Parity error. */
  130. NRF_UART_ERROR_FRAMING_MASK = UART_ERRORSRC_FRAMING_Msk, /**< Framing error. */
  131. NRF_UART_ERROR_BREAK_MASK = UART_ERRORSRC_BREAK_Msk, /**< Break error. */
  132. } nrf_uart_error_mask_t;
  133. /**
  134. * @enum nrf_uart_parity_t
  135. * @brief Types of UART parity modes.
  136. */
  137. typedef enum
  138. {
  139. NRF_UART_PARITY_EXCLUDED = UART_CONFIG_PARITY_Excluded << UART_CONFIG_PARITY_Pos, /**< Parity excluded. */
  140. NRF_UART_PARITY_INCLUDED = UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos, /**< Parity included. */
  141. } nrf_uart_parity_t;
  142. /**
  143. * @enum nrf_uart_hwfc_t
  144. * @brief Types of UART flow control modes.
  145. */
  146. typedef enum
  147. {
  148. NRF_UART_HWFC_DISABLED = UART_CONFIG_HWFC_Disabled, /**< HW flow control disabled. */
  149. NRF_UART_HWFC_ENABLED = UART_CONFIG_HWFC_Enabled, /**< HW flow control enabled. */
  150. } nrf_uart_hwfc_t;
  151. /**
  152. * @brief Function for clearing a specific UART event.
  153. *
  154. * @param[in] p_reg Pointer to the peripheral registers structure.
  155. * @param[in] event Event to clear.
  156. */
  157. __STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event);
  158. /**
  159. * @brief Function for checking the state of a specific UART event.
  160. *
  161. * @param[in] p_reg Pointer to the peripheral registers structure.
  162. * @param[in] event Event to check.
  163. *
  164. * @retval True if event is set, False otherwise.
  165. */
  166. __STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event);
  167. /**
  168. * @brief Function for returning the address of a specific UART event register.
  169. *
  170. * @param[in] p_reg Pointer to the peripheral registers structure.
  171. * @param[in] event Desired event.
  172. *
  173. * @retval Address of specified event register.
  174. */
  175. __STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg,
  176. nrf_uart_event_t event);
  177. /**
  178. * @brief Function for enabling a specific interrupt.
  179. *
  180. * @param p_reg Pointer to the peripheral registers structure.
  181. * @param int_mask Interrupts to enable.
  182. */
  183. __STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t int_mask);
  184. /**
  185. * @brief Function for retrieving the state of a given interrupt.
  186. *
  187. * @param p_reg Pointer to the peripheral registers structure.
  188. * @param int_mask Mask of interrupt to check.
  189. *
  190. * @retval true If the interrupt is enabled.
  191. * @retval false If the interrupt is not enabled.
  192. */
  193. __STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t int_mask);
  194. /**
  195. * @brief Function for disabling specific interrupts.
  196. *
  197. * @param p_reg Pointer to the peripheral registers structure.
  198. * @param int_mask Interrupts to disable.
  199. */
  200. __STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t int_mask);
  201. /**
  202. * @brief Function for getting error source mask. Function is clearing error source flags after reading.
  203. *
  204. * @param p_reg Pointer to the peripheral registers structure.
  205. * @return Mask with error source flags.
  206. */
  207. __STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg);
  208. /**
  209. * @brief Function for enabling UART.
  210. *
  211. * @param p_reg Pointer to the peripheral registers structure.
  212. */
  213. __STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg);
  214. /**
  215. * @brief Function for disabling UART.
  216. *
  217. * @param p_reg Pointer to the peripheral registers structure.
  218. */
  219. __STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg);
  220. /**
  221. * @brief Function for configuring TX/RX pins.
  222. *
  223. * @param p_reg Pointer to the peripheral registers structure.
  224. * @param pseltxd TXD pin number.
  225. * @param pselrxd RXD pin number.
  226. */
  227. __STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd);
  228. /**
  229. * @brief Function for disconnecting TX/RX pins.
  230. *
  231. * @param p_reg Pointer to the peripheral registers structure.
  232. */
  233. __STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg);
  234. /**
  235. * @brief Function for getting TX pin.
  236. *
  237. * @param p_reg Pointer to the peripheral registers structure.
  238. */
  239. __STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg);
  240. /**
  241. * @brief Function for getting RX pin.
  242. *
  243. * @param p_reg Pointer to the peripheral registers structure.
  244. */
  245. __STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg);
  246. /**
  247. * @brief Function for getting RTS pin.
  248. *
  249. * @param p_reg Pointer to the peripheral registers structure.
  250. */
  251. __STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg);
  252. /**
  253. * @brief Function for getting CTS pin.
  254. *
  255. * @param p_reg Pointer to the peripheral registers structure.
  256. */
  257. __STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg);
  258. /**
  259. * @brief Function for configuring flow control pins.
  260. *
  261. * @param p_reg Pointer to the peripheral registers structure.
  262. * @param pselrts RTS pin number.
  263. * @param pselcts CTS pin number.
  264. */
  265. __STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg,
  266. uint32_t pselrts,
  267. uint32_t pselcts);
  268. /**
  269. * @brief Function for disconnecting flow control pins.
  270. *
  271. * @param p_reg Pointer to the peripheral registers structure.
  272. */
  273. __STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg);
  274. /**
  275. * @brief Function for reading RX data.
  276. *
  277. * @param p_reg Pointer to the peripheral registers structure.
  278. * @return Received byte.
  279. */
  280. __STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg);
  281. /**
  282. * @brief Function for setting Tx data.
  283. *
  284. * @param p_reg Pointer to the peripheral registers structure.
  285. * @param txd Byte.
  286. */
  287. __STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd);
  288. /**
  289. * @brief Function for starting an UART task.
  290. *
  291. * @param p_reg Pointer to the peripheral registers structure.
  292. * @param task Task.
  293. */
  294. __STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task);
  295. /**
  296. * @brief Function for returning the address of a specific task register.
  297. *
  298. * @param p_reg Pointer to the peripheral registers structure.
  299. * @param task Task.
  300. *
  301. * @return Task address.
  302. */
  303. __STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task);
  304. /**
  305. * @brief Function for configuring UART.
  306. *
  307. * @param p_reg Pointer to the peripheral registers structure.
  308. * @param hwfc Hardware flow control. Enabled if true.
  309. * @param parity Parity. Included if true.
  310. */
  311. __STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
  312. nrf_uart_parity_t parity,
  313. nrf_uart_hwfc_t hwfc);
  314. /**
  315. * @brief Function for setting UART baudrate.
  316. *
  317. * @param p_reg Pointer to the peripheral registers structure.
  318. * @param baudrate Baudrate.
  319. */
  320. __STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate);
  321. #ifndef SUPPRESS_INLINE_IMPLEMENTATION
  322. __STATIC_INLINE void nrf_uart_event_clear(NRF_UART_Type * p_reg, nrf_uart_event_t event)
  323. {
  324. *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event)) = 0x0UL;
  325. #if __CORTEX_M == 0x04
  326. volatile uint32_t dummy = *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event));
  327. (void)dummy;
  328. #endif
  329. }
  330. __STATIC_INLINE bool nrf_uart_event_check(NRF_UART_Type * p_reg, nrf_uart_event_t event)
  331. {
  332. return (bool)*(volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)event);
  333. }
  334. __STATIC_INLINE uint32_t nrf_uart_event_address_get(NRF_UART_Type * p_reg,
  335. nrf_uart_event_t event)
  336. {
  337. return (uint32_t)((uint8_t *)p_reg + (uint32_t)event);
  338. }
  339. __STATIC_INLINE void nrf_uart_int_enable(NRF_UART_Type * p_reg, uint32_t int_mask)
  340. {
  341. p_reg->INTENSET = int_mask;
  342. }
  343. __STATIC_INLINE bool nrf_uart_int_enable_check(NRF_UART_Type * p_reg, uint32_t int_mask)
  344. {
  345. return (bool)(p_reg->INTENSET & int_mask);
  346. }
  347. __STATIC_INLINE void nrf_uart_int_disable(NRF_UART_Type * p_reg, uint32_t int_mask)
  348. {
  349. p_reg->INTENCLR = int_mask;
  350. }
  351. __STATIC_INLINE uint32_t nrf_uart_errorsrc_get_and_clear(NRF_UART_Type * p_reg)
  352. {
  353. uint32_t errsrc_mask = p_reg->ERRORSRC;
  354. p_reg->ERRORSRC = errsrc_mask;
  355. return errsrc_mask;
  356. }
  357. __STATIC_INLINE void nrf_uart_enable(NRF_UART_Type * p_reg)
  358. {
  359. p_reg->ENABLE = UART_ENABLE_ENABLE_Enabled;
  360. }
  361. __STATIC_INLINE void nrf_uart_disable(NRF_UART_Type * p_reg)
  362. {
  363. p_reg->ENABLE = UART_ENABLE_ENABLE_Disabled;
  364. }
  365. __STATIC_INLINE void nrf_uart_txrx_pins_set(NRF_UART_Type * p_reg, uint32_t pseltxd, uint32_t pselrxd)
  366. {
  367. #if defined(UART_PSEL_RXD_CONNECT_Pos)
  368. p_reg->PSEL.RXD = pselrxd;
  369. #else
  370. p_reg->PSELRXD = pselrxd;
  371. #endif
  372. #if defined(UART_PSEL_TXD_CONNECT_Pos)
  373. p_reg->PSEL.TXD = pseltxd;
  374. #else
  375. p_reg->PSELTXD = pseltxd;
  376. #endif
  377. }
  378. __STATIC_INLINE void nrf_uart_txrx_pins_disconnect(NRF_UART_Type * p_reg)
  379. {
  380. nrf_uart_txrx_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED);
  381. }
  382. __STATIC_INLINE uint32_t nrf_uart_tx_pin_get(NRF_UART_Type * p_reg)
  383. {
  384. #if defined(UART_PSEL_TXD_CONNECT_Pos)
  385. return p_reg->PSEL.TXD;
  386. #else
  387. return p_reg->PSELTXD;
  388. #endif
  389. }
  390. __STATIC_INLINE uint32_t nrf_uart_rx_pin_get(NRF_UART_Type * p_reg)
  391. {
  392. #if defined(UART_PSEL_RXD_CONNECT_Pos)
  393. return p_reg->PSEL.RXD;
  394. #else
  395. return p_reg->PSELRXD;
  396. #endif
  397. }
  398. __STATIC_INLINE uint32_t nrf_uart_rts_pin_get(NRF_UART_Type * p_reg)
  399. {
  400. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  401. return p_reg->PSEL.RTS;
  402. #else
  403. return p_reg->PSELRTS;
  404. #endif
  405. }
  406. __STATIC_INLINE uint32_t nrf_uart_cts_pin_get(NRF_UART_Type * p_reg)
  407. {
  408. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  409. return p_reg->PSEL.CTS;
  410. #else
  411. return p_reg->PSELCTS;
  412. #endif
  413. }
  414. __STATIC_INLINE void nrf_uart_hwfc_pins_set(NRF_UART_Type * p_reg, uint32_t pselrts, uint32_t pselcts)
  415. {
  416. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  417. p_reg->PSEL.RTS = pselrts;
  418. #else
  419. p_reg->PSELRTS = pselrts;
  420. #endif
  421. #if defined(UART_PSEL_RTS_CONNECT_Pos)
  422. p_reg->PSEL.CTS = pselcts;
  423. #else
  424. p_reg->PSELCTS = pselcts;
  425. #endif
  426. }
  427. __STATIC_INLINE void nrf_uart_hwfc_pins_disconnect(NRF_UART_Type * p_reg)
  428. {
  429. nrf_uart_hwfc_pins_set(p_reg, NRF_UART_PSEL_DISCONNECTED, NRF_UART_PSEL_DISCONNECTED);
  430. }
  431. __STATIC_INLINE uint8_t nrf_uart_rxd_get(NRF_UART_Type * p_reg)
  432. {
  433. return p_reg->RXD;
  434. }
  435. __STATIC_INLINE void nrf_uart_txd_set(NRF_UART_Type * p_reg, uint8_t txd)
  436. {
  437. p_reg->TXD = txd;
  438. }
  439. __STATIC_INLINE void nrf_uart_task_trigger(NRF_UART_Type * p_reg, nrf_uart_task_t task)
  440. {
  441. *((volatile uint32_t *)((uint8_t *)p_reg + (uint32_t)task)) = 0x1UL;
  442. }
  443. __STATIC_INLINE uint32_t nrf_uart_task_address_get(NRF_UART_Type * p_reg, nrf_uart_task_t task)
  444. {
  445. return (uint32_t)p_reg + (uint32_t)task;
  446. }
  447. __STATIC_INLINE void nrf_uart_configure(NRF_UART_Type * p_reg,
  448. nrf_uart_parity_t parity,
  449. nrf_uart_hwfc_t hwfc)
  450. {
  451. p_reg->CONFIG = (uint32_t)parity | (uint32_t)hwfc;
  452. }
  453. __STATIC_INLINE void nrf_uart_baudrate_set(NRF_UART_Type * p_reg, nrf_uart_baudrate_t baudrate)
  454. {
  455. p_reg->BAUDRATE = baudrate;
  456. }
  457. #endif //SUPPRESS_INLINE_IMPLEMENTATION
  458. /** @} */
  459. #ifdef __cplusplus
  460. }
  461. #endif
  462. #endif //NRF_UART_H__