nrf_serial.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675
  1. /**
  2. * Copyright (c) 2016 - 2018, 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. #include "sdk_common.h"
  41. #if NRF_MODULE_ENABLED(NRF_SERIAL)
  42. #include "nrf_serial.h"
  43. #if defined (UART_PRESENT)
  44. static void event_handler(nrf_serial_t const * p_serial,
  45. nrf_serial_event_t event)
  46. {
  47. if (p_serial->p_ctx->p_config->ev_handler)
  48. {
  49. p_serial->p_ctx->p_config->ev_handler(p_serial, event);
  50. }
  51. }
  52. static void sleep_handler(nrf_serial_t const * p_serial)
  53. {
  54. if (p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_POLLING)
  55. {
  56. return;
  57. }
  58. if (p_serial->p_ctx->p_config->sleep_handler)
  59. {
  60. p_serial->p_ctx->p_config->sleep_handler();
  61. }
  62. }
  63. static size_t serial_rx(nrf_serial_t const * p_serial,
  64. uint8_t * p_buff,
  65. size_t length)
  66. {
  67. if (p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_POLLING)
  68. {
  69. size_t rx_len = MIN(length, UINT8_MAX);
  70. size_t len = rx_len;
  71. while (nrf_drv_uart_rx_ready(&p_serial->instance) && len)
  72. {
  73. ret_code_t ret = nrf_drv_uart_rx(&p_serial->instance, p_buff, 1);
  74. if (ret != NRF_SUCCESS)
  75. {
  76. break;
  77. }
  78. p_buff++;
  79. len--;
  80. }
  81. return rx_len - len;
  82. }
  83. nrf_queue_t const * p_rxq = p_serial->p_ctx->p_config->p_queues->p_rxq;
  84. return nrf_queue_out(p_rxq, p_buff, length);
  85. }
  86. static size_t serial_tx(nrf_serial_t const * p_serial,
  87. uint8_t const * p_buff,
  88. size_t length)
  89. {
  90. size_t tx_len = 0;
  91. if (p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_POLLING)
  92. {
  93. tx_len = MIN(length, UINT8_MAX);
  94. ret_code_t ret = nrf_drv_uart_tx(&p_serial->instance, p_buff, tx_len);
  95. ASSERT(ret == NRF_SUCCESS)
  96. return tx_len;
  97. }
  98. nrf_queue_t const * p_txq = p_serial->p_ctx->p_config->p_queues->p_txq;
  99. nrf_serial_buffers_t const * p_buffs = p_serial->p_ctx->p_config->p_buffers;
  100. /* Try to enqueue data. */
  101. size_t queue_in_len = nrf_queue_in(p_txq, p_buff, length);
  102. if (nrf_drv_uart_tx_in_progress(&p_serial->instance))
  103. {
  104. return queue_in_len;
  105. }
  106. size_t len = nrf_queue_out(p_txq, p_buffs->p_txb, p_buffs->tx_size);
  107. ASSERT(len > 0);
  108. ret_code_t ret = nrf_drv_uart_tx(&p_serial->instance, p_buffs->p_txb, len);
  109. ASSERT(ret == NRF_SUCCESS);
  110. return queue_in_len;
  111. }
  112. static void uart_event_handler(nrf_drv_uart_event_t * p_event, void * p_context)
  113. {
  114. uint32_t ret;
  115. nrf_serial_t const * p_serial = p_context;
  116. switch (p_event->type)
  117. {
  118. case NRF_DRV_UART_EVT_RX_DONE:
  119. {
  120. nrf_queue_t const * p_rxq =
  121. p_serial->p_ctx->p_config->p_queues->p_rxq;
  122. size_t len = nrf_queue_in(p_rxq,
  123. p_event->data.rxtx.p_data,
  124. p_event->data.rxtx.bytes);
  125. if (len < p_event->data.rxtx.bytes)
  126. {
  127. event_handler(p_serial, NRF_SERIAL_EVENT_FIFO_ERR);
  128. break;
  129. }
  130. event_handler(p_serial, NRF_SERIAL_EVENT_RX_DATA);
  131. nrf_serial_buffers_t const * p_buffs =
  132. p_serial->p_ctx->p_config->p_buffers;
  133. ret = nrf_drv_uart_rx(&p_serial->instance,
  134. p_buffs->p_rxb,
  135. p_buffs->rx_size);
  136. ASSERT(ret == NRF_SUCCESS);
  137. break;
  138. }
  139. case NRF_DRV_UART_EVT_ERROR:
  140. {
  141. event_handler(p_serial, NRF_SERIAL_EVENT_DRV_ERR);
  142. break;
  143. }
  144. case NRF_DRV_UART_EVT_TX_DONE:
  145. {
  146. nrf_queue_t const * p_txq =
  147. p_serial->p_ctx->p_config->p_queues->p_txq;
  148. nrf_serial_buffers_t const * p_buffs =
  149. p_serial->p_ctx->p_config->p_buffers;
  150. event_handler(p_serial, NRF_SERIAL_EVENT_TX_DONE);
  151. size_t len = nrf_queue_out(p_txq, p_buffs->p_txb, p_buffs->tx_size);
  152. if (len == 0)
  153. {
  154. break;
  155. }
  156. ret = nrf_drv_uart_tx(&p_serial->instance, p_buffs->p_txb, len);
  157. ASSERT(ret == NRF_SUCCESS);
  158. break;
  159. }
  160. default:
  161. break;
  162. }
  163. }
  164. ret_code_t nrf_serial_init(nrf_serial_t const * p_serial,
  165. nrf_drv_uart_config_t const * p_drv_uart_config,
  166. nrf_serial_config_t const * p_config)
  167. {
  168. ret_code_t ret;
  169. ASSERT(p_serial && p_drv_uart_config && p_config);
  170. if (p_serial->p_ctx->p_config)
  171. {
  172. /*Already initialized.*/
  173. return NRF_ERROR_MODULE_ALREADY_INITIALIZED;
  174. }
  175. if (p_config->mode != NRF_SERIAL_MODE_POLLING)
  176. {
  177. ASSERT(p_config->p_queues && p_config->p_buffers);
  178. }
  179. nrf_drv_uart_config_t drv_config;
  180. memcpy(&drv_config, p_drv_uart_config, sizeof(nrf_drv_uart_config_t));
  181. drv_config.p_context = (void *)p_serial;
  182. #if defined(UARTE_PRESENT) && defined(UART_PRESENT)
  183. drv_config.use_easy_dma = (p_config->mode == NRF_SERIAL_MODE_DMA);
  184. #endif
  185. ret = nrf_drv_uart_init(&p_serial->instance,
  186. &drv_config,
  187. p_config->mode == NRF_SERIAL_MODE_POLLING ?
  188. NULL : uart_event_handler);
  189. if (ret != NRF_SUCCESS)
  190. {
  191. return ret;
  192. }
  193. p_serial->p_ctx->p_config = p_config;
  194. if (p_serial->p_ctx->p_config->p_queues)
  195. {
  196. nrf_queue_reset(p_serial->p_ctx->p_config->p_queues->p_txq);
  197. nrf_queue_reset(p_serial->p_ctx->p_config->p_queues->p_rxq);
  198. }
  199. nrf_mtx_init(&p_serial->p_ctx->read_lock);
  200. nrf_mtx_init(&p_serial->p_ctx->write_lock);
  201. p_serial->p_ctx->flags = NRF_SERIAL_RX_ENABLED_FLAG |
  202. NRF_SERIAL_TX_ENABLED_FLAG;
  203. if (drv_config.pseltxd == NRF_UART_PSEL_DISCONNECTED)
  204. {
  205. p_serial->p_ctx->flags &= ~NRF_SERIAL_TX_ENABLED_FLAG;
  206. }
  207. if (drv_config.pselrxd == NRF_UART_PSEL_DISCONNECTED)
  208. {
  209. p_serial->p_ctx->flags &= ~NRF_SERIAL_RX_ENABLED_FLAG;
  210. return NRF_SUCCESS;
  211. }
  212. if (p_serial->p_ctx->p_config->mode != NRF_SERIAL_MODE_DMA)
  213. {
  214. nrf_drv_uart_rx_enable(&p_serial->instance);
  215. if (p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_POLLING)
  216. {
  217. return NRF_SUCCESS;
  218. }
  219. }
  220. return nrf_drv_uart_rx(&p_serial->instance,
  221. p_serial->p_ctx->p_config->p_buffers->p_rxb,
  222. p_serial->p_ctx->p_config->p_buffers->rx_size);
  223. }
  224. ret_code_t nrf_serial_uninit(nrf_serial_t const * p_serial)
  225. {
  226. ASSERT(p_serial);
  227. if (!p_serial->p_ctx->p_config)
  228. {
  229. /*Already uninitialized.*/
  230. return NRF_ERROR_MODULE_NOT_INITIALIZED;
  231. }
  232. if (!nrf_mtx_trylock(&p_serial->p_ctx->write_lock))
  233. {
  234. return NRF_ERROR_BUSY;
  235. }
  236. if (!nrf_mtx_trylock(&p_serial->p_ctx->read_lock))
  237. {
  238. nrf_mtx_unlock(&p_serial->p_ctx->write_lock);
  239. return NRF_ERROR_BUSY;
  240. }
  241. nrf_drv_uart_uninit(&p_serial->instance);
  242. if (p_serial->p_ctx->p_config->p_queues)
  243. {
  244. nrf_queue_reset(p_serial->p_ctx->p_config->p_queues->p_txq);
  245. nrf_queue_reset(p_serial->p_ctx->p_config->p_queues->p_rxq);
  246. }
  247. memset(p_serial->p_ctx, 0, sizeof(nrf_serial_ctx_t));
  248. return NRF_SUCCESS;
  249. }
  250. typedef struct {
  251. volatile bool expired;
  252. } nrf_serial_timeout_ctx_t;
  253. static void serial_timeout_handler(void * p_context)
  254. {
  255. nrf_serial_timeout_ctx_t * p_tout_ctx = p_context;
  256. p_tout_ctx->expired = true;
  257. }
  258. static ret_code_t timeout_setup(nrf_serial_t const * p_serial,
  259. app_timer_id_t const * p_timer_id,
  260. uint32_t timeout_ms,
  261. nrf_serial_timeout_ctx_t * p_tout_ctx)
  262. {
  263. uint32_t ticks = APP_TIMER_TICKS(timeout_ms);
  264. if (ticks < APP_TIMER_MIN_TIMEOUT_TICKS)
  265. {
  266. p_tout_ctx->expired = true;
  267. return NRF_SUCCESS;
  268. }
  269. ret_code_t ret = app_timer_create(p_timer_id,
  270. APP_TIMER_MODE_SINGLE_SHOT,
  271. serial_timeout_handler);
  272. if (ret != NRF_SUCCESS)
  273. {
  274. return ret;
  275. }
  276. return app_timer_start(*p_timer_id, ticks, p_tout_ctx);
  277. }
  278. ret_code_t nrf_serial_write(nrf_serial_t const * p_serial,
  279. void const * p_data,
  280. size_t size,
  281. size_t * p_written,
  282. uint32_t timeout_ms)
  283. {
  284. ret_code_t ret;
  285. ASSERT(p_serial);
  286. if (!p_serial->p_ctx->p_config)
  287. {
  288. return NRF_ERROR_MODULE_NOT_INITIALIZED;
  289. }
  290. if (!(p_serial->p_ctx->flags & NRF_SERIAL_TX_ENABLED_FLAG))
  291. {
  292. return NRF_ERROR_INVALID_STATE;
  293. }
  294. if (size == 0)
  295. {
  296. return NRF_SUCCESS;
  297. }
  298. if (!nrfx_is_in_ram(p_data) &&
  299. p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_DMA)
  300. {
  301. return NRF_ERROR_INVALID_ADDR;
  302. }
  303. if (!nrf_mtx_trylock(&p_serial->p_ctx->write_lock))
  304. {
  305. return NRF_ERROR_BUSY;
  306. }
  307. nrf_serial_timeout_ctx_t tout_ctx = {
  308. .expired = false,
  309. };
  310. if (timeout_ms != NRF_SERIAL_MAX_TIMEOUT)
  311. {
  312. ret = timeout_setup(p_serial,
  313. p_serial->p_tx_timer,
  314. timeout_ms,
  315. &tout_ctx);
  316. if (ret != NRF_SUCCESS)
  317. {
  318. nrf_mtx_unlock(&p_serial->p_ctx->write_lock);
  319. return ret;
  320. }
  321. }
  322. size_t left = size;
  323. uint8_t const * p_buff = p_data;
  324. do
  325. {
  326. size_t wcnt = serial_tx(p_serial, p_buff, left);
  327. left -= wcnt;
  328. p_buff += wcnt;
  329. if (!left)
  330. {
  331. break;
  332. }
  333. sleep_handler(p_serial);
  334. } while (!tout_ctx.expired);
  335. if (p_written)
  336. {
  337. *p_written = size - left;
  338. }
  339. if (!tout_ctx.expired && (timeout_ms != NRF_SERIAL_MAX_TIMEOUT))
  340. {
  341. (void)app_timer_stop(*p_serial->p_tx_timer);
  342. }
  343. nrf_mtx_unlock(&p_serial->p_ctx->write_lock);
  344. if (left && tout_ctx.expired)
  345. {
  346. return NRF_ERROR_TIMEOUT;
  347. }
  348. return NRF_SUCCESS;
  349. }
  350. ret_code_t nrf_serial_read(nrf_serial_t const * p_serial,
  351. void * p_data,
  352. size_t size,
  353. size_t * p_read,
  354. uint32_t timeout_ms)
  355. {
  356. ret_code_t ret;
  357. ASSERT(p_serial);
  358. if (!p_serial->p_ctx->p_config)
  359. {
  360. return NRF_ERROR_MODULE_NOT_INITIALIZED;
  361. }
  362. if (!(p_serial->p_ctx->flags & NRF_SERIAL_RX_ENABLED_FLAG))
  363. {
  364. return NRF_ERROR_INVALID_STATE;
  365. }
  366. if (size == 0)
  367. {
  368. return NRF_SUCCESS;
  369. }
  370. if (!nrf_mtx_trylock(&p_serial->p_ctx->read_lock))
  371. {
  372. return NRF_ERROR_BUSY;
  373. }
  374. nrf_serial_timeout_ctx_t tout_ctx = {
  375. .expired = false,
  376. };
  377. if (timeout_ms != NRF_SERIAL_MAX_TIMEOUT)
  378. {
  379. ret = timeout_setup(p_serial,
  380. p_serial->p_rx_timer,
  381. timeout_ms,
  382. &tout_ctx);
  383. if (ret != NRF_SUCCESS)
  384. {
  385. nrf_mtx_unlock(&p_serial->p_ctx->read_lock);
  386. return ret;
  387. }
  388. }
  389. size_t left = size;
  390. uint8_t * p_buff = p_data;
  391. do
  392. {
  393. size_t rcnt = serial_rx(p_serial, p_buff, left);
  394. left -= rcnt;
  395. p_buff += rcnt;
  396. if (!left)
  397. {
  398. break;
  399. }
  400. if (tout_ctx.expired)
  401. {
  402. if (p_serial->p_ctx->p_config->mode != NRF_SERIAL_MODE_POLLING)
  403. {
  404. nrf_drv_uart_rx_abort(&p_serial->instance);
  405. }
  406. break;
  407. }
  408. sleep_handler(p_serial);
  409. } while (1);
  410. if (p_read)
  411. {
  412. *p_read = size - left;
  413. }
  414. if (!tout_ctx.expired && (timeout_ms != NRF_SERIAL_MAX_TIMEOUT))
  415. {
  416. (void)app_timer_stop(*p_serial->p_rx_timer);
  417. }
  418. nrf_mtx_unlock(&p_serial->p_ctx->read_lock);
  419. if (left && tout_ctx.expired)
  420. {
  421. return NRF_ERROR_TIMEOUT;
  422. }
  423. return NRF_SUCCESS;
  424. }
  425. ret_code_t nrf_serial_flush(nrf_serial_t const * p_serial, uint32_t timeout_ms)
  426. {
  427. ret_code_t ret;
  428. ASSERT(p_serial);
  429. if (!p_serial->p_ctx->p_config)
  430. {
  431. return NRF_ERROR_MODULE_NOT_INITIALIZED;
  432. }
  433. if (!(p_serial->p_ctx->flags & NRF_SERIAL_TX_ENABLED_FLAG))
  434. {
  435. return NRF_ERROR_INVALID_STATE;
  436. }
  437. if (p_serial->p_ctx->p_config->mode == NRF_SERIAL_MODE_POLLING)
  438. {
  439. return NRF_SUCCESS;
  440. }
  441. if (!nrf_mtx_trylock(&p_serial->p_ctx->write_lock))
  442. {
  443. return NRF_ERROR_BUSY;
  444. }
  445. nrf_serial_timeout_ctx_t tout_ctx = {
  446. .expired = false,
  447. };
  448. if (timeout_ms != NRF_SERIAL_MAX_TIMEOUT)
  449. {
  450. ret = timeout_setup(p_serial,
  451. p_serial->p_tx_timer,
  452. timeout_ms,
  453. &tout_ctx);
  454. if (ret != NRF_SUCCESS)
  455. {
  456. nrf_mtx_unlock(&p_serial->p_ctx->write_lock);
  457. return ret;
  458. }
  459. }
  460. bool empty;
  461. do
  462. {
  463. empty = nrf_queue_is_empty(p_serial->p_ctx->p_config->p_queues->p_txq)
  464. && !nrf_drv_uart_tx_in_progress(&p_serial->instance);
  465. if (empty)
  466. {
  467. break;
  468. }
  469. sleep_handler(p_serial);
  470. } while (!tout_ctx.expired);
  471. if (!tout_ctx.expired && (timeout_ms != NRF_SERIAL_MAX_TIMEOUT))
  472. {
  473. (void)app_timer_stop(*p_serial->p_tx_timer);
  474. }
  475. nrf_mtx_unlock(&p_serial->p_ctx->write_lock);
  476. if (!empty && tout_ctx.expired)
  477. {
  478. return NRF_ERROR_TIMEOUT;
  479. }
  480. return NRF_SUCCESS;
  481. }
  482. ret_code_t nrf_serial_tx_abort(nrf_serial_t const * p_serial)
  483. {
  484. ASSERT(p_serial);
  485. if (!p_serial->p_ctx->p_config)
  486. {
  487. return NRF_ERROR_MODULE_NOT_INITIALIZED;
  488. }
  489. if (!(p_serial->p_ctx->flags & NRF_SERIAL_TX_ENABLED_FLAG))
  490. {
  491. return NRF_ERROR_INVALID_STATE;
  492. }
  493. if (!nrf_mtx_trylock(&p_serial->p_ctx->write_lock))
  494. {
  495. return NRF_ERROR_BUSY;
  496. }
  497. nrf_drv_uart_tx_abort(&p_serial->instance);
  498. if (p_serial->p_ctx->p_config->p_queues->p_txq)
  499. {
  500. nrf_queue_reset(p_serial->p_ctx->p_config->p_queues->p_txq);
  501. }
  502. nrf_mtx_unlock(&p_serial->p_ctx->write_lock);
  503. return NRF_SUCCESS;
  504. }
  505. ret_code_t nrf_serial_rx_drain(nrf_serial_t const * p_serial)
  506. {
  507. ASSERT(p_serial);
  508. if (!p_serial->p_ctx->p_config)
  509. {
  510. return NRF_ERROR_MODULE_NOT_INITIALIZED;
  511. }
  512. if (!(p_serial->p_ctx->flags & NRF_SERIAL_RX_ENABLED_FLAG))
  513. {
  514. return NRF_ERROR_INVALID_STATE;
  515. }
  516. if (!nrf_mtx_trylock(&p_serial->p_ctx->read_lock))
  517. {
  518. return NRF_ERROR_BUSY;
  519. }
  520. uint8_t c;
  521. /*Drain HW FIFO*/
  522. while (serial_rx(p_serial, &c, sizeof(c)))
  523. {
  524. }
  525. /*Drain SW FIFO*/
  526. if (p_serial->p_ctx->p_config->p_queues->p_rxq)
  527. {
  528. nrf_queue_reset(p_serial->p_ctx->p_config->p_queues->p_rxq);
  529. }
  530. nrf_mtx_unlock(&p_serial->p_ctx->read_lock);
  531. return NRF_SUCCESS;
  532. }
  533. #else
  534. ret_code_t nrf_serial_init(nrf_serial_t const * p_serial,
  535. nrf_drv_uart_config_t const * p_drv_uart_config,
  536. nrf_serial_config_t const * p_config)
  537. {
  538. return NRF_ERROR_NOT_SUPPORTED;
  539. }
  540. ret_code_t nrf_serial_uninit(nrf_serial_t const * p_serial)
  541. {
  542. return NRF_ERROR_NOT_SUPPORTED;
  543. }
  544. ret_code_t nrf_serial_write(nrf_serial_t const * p_serial,
  545. void const * p_data,
  546. size_t size,
  547. size_t * p_written,
  548. uint32_t timeout_ms)
  549. {
  550. return NRF_ERROR_NOT_SUPPORTED;
  551. }
  552. ret_code_t nrf_serial_read(nrf_serial_t const * p_serial,
  553. void * p_data,
  554. size_t size,
  555. size_t * p_read,
  556. uint32_t timeout_ms)
  557. {
  558. return NRF_ERROR_NOT_SUPPORTED;
  559. }
  560. ret_code_t nrf_serial_flush(nrf_serial_t const * p_serial, uint32_t timeout_ms)
  561. {
  562. return NRF_ERROR_NOT_SUPPORTED;
  563. }
  564. ret_code_t nrf_serial_tx_abort(nrf_serial_t const * p_serial)
  565. {
  566. return NRF_ERROR_NOT_SUPPORTED;
  567. }
  568. ret_code_t nrf_serial_rx_drain(nrf_serial_t const * p_serial)
  569. {
  570. return NRF_ERROR_NOT_SUPPORTED;
  571. }
  572. #endif // UART_PRESENT
  573. #endif //NRF_MODULE_ENABLED(NRF_SERIAL)