ChibiOS 21.11.5
hal_sio.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006-2026 Giovanni Di Sirio.
3
4 Licensed under the Apache License, Version 2.0 (the "License");
5 you may not use this file except in compliance with the License.
6 You may obtain a copy of the License at
7
8 http://www.apache.org/licenses/LICENSE-2.0
9
10 Unless required by applicable law or agreed to in writing, software
11 distributed under the License is distributed on an "AS IS" BASIS,
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 See the License for the specific language governing permissions and
14 limitations under the License.
15*/
16
17/**
18 * @file hal_sio.c
19 * @brief SIO Driver code.
20 *
21 * @addtogroup SIO
22 * @{
23 */
24
25#include "hal.h"
26
27#if (HAL_USE_SIO == TRUE) || defined(__DOXYGEN__)
28
29/*===========================================================================*/
30/* Driver local definitions. */
31/*===========================================================================*/
32
33/*===========================================================================*/
34/* Driver exported variables. */
35/*===========================================================================*/
36
37/*===========================================================================*/
38/* Driver local variables and types. */
39/*===========================================================================*/
40
41/*===========================================================================*/
42/* Driver local functions. */
43/*===========================================================================*/
44
45#if (SIO_USE_STREAMS_INTERFACE == TRUE) || defined(__DOXYGEN__)
46static size_t sync_write(void *ip, const uint8_t *bp, size_t n,
47 sysinterval_t timeout) {
48 SIODriver *siop = (SIODriver *)ip;
49 size_t i;
50
51 i = 0U;
52 while (i < n) {
53 size_t written;
54 msg_t msg;
55
56 msg = sioSynchronizeTX(siop, timeout);
57 if (msg != MSG_OK) {
58 break;
59 }
60
61 written = sioAsyncWrite(siop, bp, n - i);
62 i += written;
63 bp += written;
64 }
65 return i;
66}
67
68static size_t sync_read(void *ip, uint8_t *bp, size_t n,
69 sysinterval_t timeout) {
70 SIODriver *siop = (SIODriver *)ip;
71 size_t i;
72
73 i = 0U;
74 while (i < n) {
75 size_t read;
76 msg_t msg;
77
78 msg = sioSynchronizeRX(siop, timeout);
79 if (msg == SIO_MSG_ERRORS) {
80 (void) sioGetAndClearErrors(siop);
81 }
82 else if (msg != MSG_OK) {
83 break;
84 }
85
86 read = sioAsyncRead(siop, bp, n - i);
87 i += read;
88 bp += read;
89 }
90 return i;
91}
92
93/*
94 * Interface implementation, the following functions just invoke the equivalent
95 * queue-level function or macro.
96 */
97
98static size_t __write(void *ip, const uint8_t *bp, size_t n) {
99
100 return sync_write(ip, bp, n, TIME_INFINITE);
101}
102
103static size_t __read(void *ip, uint8_t *bp, size_t n) {
104
105 return sync_read(ip, bp, n, TIME_INFINITE);
106}
107
108static msg_t __put(void *ip, uint8_t b) {
109 SIODriver *siop = (SIODriver *)ip;
110 msg_t msg;
111
112 msg = sioSynchronizeTX(siop, TIME_INFINITE);
113 if (msg != MSG_OK) {
114 return msg;
115 }
116
117 sioPutX(siop, b);
118 return MSG_OK;
119}
120
121static msg_t __get(void *ip) {
122 SIODriver *siop = (SIODriver *)ip;
123 msg_t msg;
124
125 while (true) {
126 msg = sioSynchronizeRX(siop, TIME_INFINITE);
127 if (msg == SIO_MSG_ERRORS) {
128 (void)sioGetAndClearErrors(siop);
129 continue;
130 }
131 if (msg != MSG_OK) {
132 return msg;
133 }
134
135 return sioGetX(siop);
136 }
137}
138
139static msg_t __putt(void *ip, uint8_t b, sysinterval_t timeout) {
140 SIODriver *siop = (SIODriver *)ip;
141 msg_t msg;
142
143 msg = sioSynchronizeTX(siop, timeout);
144 if (msg != MSG_OK) {
145 return msg;
146 }
147
148 sioPutX(siop, b);
149 return MSG_OK;
150}
151
152static msg_t __gett(void *ip, sysinterval_t timeout) {
153 SIODriver *siop = (SIODriver *)ip;
154 msg_t msg;
155
156 while (true) {
157 msg = sioSynchronizeRX(siop, timeout);
158 if (msg == SIO_MSG_ERRORS) {
159 (void)sioGetAndClearErrors(siop);
160 continue;
161 }
162 if (msg != MSG_OK) {
163 return msg;
164 }
165
166 return sioGetX(siop);
167 }
168}
169
170static size_t __writet(void *ip, const uint8_t *bp, size_t n,
171 sysinterval_t timeout) {
172
173 return sync_write(ip, bp, n, timeout);
174}
175
176static size_t __readt(void *ip, uint8_t *bp, size_t n,
177 sysinterval_t timeout) {
178
179 return sync_read(ip, bp, n, timeout);
180}
181
182static msg_t __ctl(void *ip, unsigned int operation, void *arg) {
183 SIODriver *siop = (SIODriver *)ip;
184
185 osalDbgCheck(siop != NULL);
186
187 switch (operation) {
188 case CHN_CTL_NOP:
189 osalDbgCheck(arg == NULL);
190 break;
191 case CHN_CTL_INVALID:
192 return HAL_RET_UNKNOWN_CTL;
193 default:
194 /* Delegating to the LLD if supported.*/
195 return sio_lld_control(siop, operation, arg);
196 }
197 return HAL_RET_SUCCESS;
198}
199
200static const struct sio_driver_vmt vmt = {
201 (size_t)0,
204 __ctl
205};
206#endif /* SIO_USE_STREAMS_INTERFACE */
207
208/*===========================================================================*/
209/* Driver exported functions. */
210/*===========================================================================*/
211
212/**
213 * @brief SIO Driver initialization.
214 * @note This function is implicitly invoked by @p halInit(), there is
215 * no need to explicitly initialize the driver.
216 *
217 * @init
218 */
219void sioInit(void) {
220
221 sio_lld_init();
222}
223
224/**
225 * @brief Initializes the standard part of a @p SIODriver structure.
226 *
227 * @param[out] siop pointer to the @p SIODriver object
228 *
229 * @init
230 */
232
233#if SIO_USE_STREAMS_INTERFACE == TRUE
234 siop->vmt = &vmt;
235#endif
236 siop->state = SIO_STOP;
237 siop->config = NULL;
238 siop->enabled = (sioevents_t)0;
239 siop->cb = NULL;
240 siop->arg = NULL;
241#if SIO_USE_SYNCHRONIZATION == TRUE
242 siop->sync_rx = NULL;
243 siop->sync_rxidle = NULL;
244 siop->sync_tx = NULL;
245 siop->sync_txend = NULL;
246#endif
247
248 /* Optional, user-defined initializer.*/
249#if defined(SIO_DRIVER_EXT_INIT_HOOK)
250 SIO_DRIVER_EXT_INIT_HOOK(siop);
251#endif
252}
253
254/**
255 * @brief Configures and activates the SIO peripheral.
256 *
257 * @param[in] siop pointer to the @p SIODriver object
258 * @param[in] config pointer to the @p SIOConfig object, can be @p NULL
259 * if the default configuration is desired
260 * @return The operation status.
261 *
262 * @api
263 */
264msg_t sioStart(SIODriver *siop, const SIOConfig *config) {
265 msg_t msg;
266
267 osalDbgCheck(siop != NULL);
268
269 osalSysLock();
270
271 osalDbgAssert((siop->state == SIO_STOP) || (siop->state == SIO_READY),
272 "invalid state");
273 siop->config = config;
274
275 msg = sio_lld_start(siop);
276 if (msg == HAL_RET_SUCCESS) {
277 siop->state = SIO_READY;
278 }
279 else {
280 siop->state = SIO_STOP;
281 }
282
283 /*lint -save -e9053 [12.2] MISRA seems to assume that the underlying type
284 is 8 bits wide, it is not.*/
285#if SIO_USE_SYNCHRONIZATION == TRUE
286 /* If synchronization is enabled then all events by default.*/
288#else
289 /* If synchronization is disabled then no events by default.*/
292#endif
293 /*lint -restore*/
294
296
297 return msg;
298}
299
300/**
301 * @brief Deactivates the SIO peripheral.
302 *
303 * @param[in] siop pointer to the @p SIODriver object
304 *
305 * @api
306 */
307void sioStop(SIODriver *siop) {
308
309 osalDbgCheck(siop != NULL);
310
311 osalSysLock();
312
313 osalDbgAssert((siop->state == SIO_STOP) || (siop->state == SIO_READY),
314 "invalid state");
315
316 sio_lld_stop(siop);
317 siop->state = SIO_STOP;
318 siop->config = NULL;
319 siop->cb = NULL;
320 siop->arg = NULL;
321
322#if SIO_USE_SYNCHRONIZATION == TRUE
323 /* Informing waiting threads, if any.*/
329#endif
330
332}
333
334/**
335 * @brief Writes the enabled events flags mask.
336 *
337 * @param[in] siop pointer to the @p SIODriver object
338 * @param[in] mask enabled events mask to be written
339 *
340 * @api
341 */
343
344 osalDbgCheck(siop != NULL);
345
346 osalSysLock();
347
348 osalDbgAssert(siop->state == SIO_READY, "invalid state");
349
350 sioWriteEnableFlagsX(siop, mask);
351
353}
354
355/**
356 * @brief Sets flags into the enabled events flags mask.
357 *
358 * @param[in] siop pointer to the @p SIODriver object
359 * @param[in] mask enabled events mask to be set
360 *
361 * @api
362 */
364
365 osalDbgCheck(siop != NULL);
366
367 osalSysLock();
368
369 osalDbgAssert(siop->state == SIO_READY, "invalid state");
370
371 sioSetEnableFlagsX(siop, mask);
372
374}
375
376/**
377 * @brief Clears flags from the enabled events flags mask.
378 *
379 * @param[in] siop pointer to the @p SIODriver object
380 * @param[in] mask enabled events mask to be cleared
381 *
382 * @api
383 */
385
386 osalDbgCheck(siop != NULL);
387
388 osalSysLock();
389
390 osalDbgAssert(siop->state == SIO_READY, "invalid state");
391
392 sioClearEnableFlagsX(siop, mask);
393
395}
396
397/**
398 * @brief Get and clears SIO error event flags.
399 *
400 * @param[in] siop pointer to the @p SIODriver object
401 * @return The pending error event flags.
402 *
403 * @api
404 */
406 sioevents_t errors;
407
408 osalDbgCheck(siop != NULL);
409
410 osalSysLock();
411
412 osalDbgAssert(siop->state == SIO_READY, "invalid state");
413
414 errors = sioGetAndClearErrorsX(siop);
415
417
418 return errors;
419}
420
421/**
422 * @brief Get and clears SIO event flags.
423 *
424 * @param[in] siop pointer to the @p SIODriver object
425 * @return The pending event flags.
426 *
427 * @api
428 */
430 sioevents_t events;
431
432 osalDbgCheck(siop != NULL);
433
434 osalSysLock();
435
436 osalDbgAssert(siop->state == SIO_READY, "invalid state");
437
438 events = sioGetAndClearEventsX(siop);
439
441
442 return events;
443}
444
445/**
446 * @brief Returns the pending SIO event flags.
447 *
448 * @param[in] siop pointer to the @p SIODriver object
449 * @return The pending event flags.
450 *
451 * @api
452 */
454 sioevents_t events;
455
456 osalDbgCheck(siop != NULL);
457
458 osalSysLock();
459
460 osalDbgAssert(siop->state == SIO_READY, "invalid state");
461
462 events = sioGetEventsX(siop);
463
465
466 return events;
467}
468
469/**
470 * @brief Reads data from the RX FIFO.
471 * @details This function is non-blocking, data is read if present and the
472 * effective amount is returned.
473 * @note This function can be called from any context but it is meant to
474 * be called from the @p rxne_cb callback handler.
475 *
476 * @param[in] siop pointer to the @p SIODriver object
477 * @param[in] buffer buffer for the received data
478 * @param[in] n maximum number of frames to read
479 * @return The number of received frames.
480 *
481 * @api
482 */
483size_t sioAsyncRead(SIODriver *siop, uint8_t *buffer, size_t n) {
484
485 osalDbgCheck((siop != NULL) && (buffer != NULL));
486
487 osalSysLock();
488
489 osalDbgAssert(siop->state == SIO_READY, "invalid state");
490
491 n = sioAsyncReadX(siop, buffer, n);
492
494
495 return n;
496}
497
498/**
499 * @brief Writes data into the TX FIFO.
500 * @details This function is non-blocking, data is written if there is space
501 * in the FIFO and the effective amount is returned.
502 * @note This function can be called from any context but it is meant to
503 * be called from the @p txnf_cb callback handler.
504 *
505 * @param[in] siop pointer to the @p SIODriver object
506 * @param[out] buffer buffer containing the data to be transmitted
507 * @param[in] n maximum number of frames to read
508 * @return The number of transmitted frames.
509 *
510 * @api
511 */
512size_t sioAsyncWrite(SIODriver *siop, const uint8_t *buffer, size_t n) {
513
514 osalDbgCheck((siop != NULL) && (buffer != NULL));
515
516 osalSysLock();
517
518 osalDbgAssert(siop->state == SIO_READY, "invalid state");
519
520 n = sioAsyncWriteX(siop, buffer, n);
521
523
524 return n;
525}
526
527#if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__)
528/**
529 * @brief Synchronizes with RX FIFO data availability.
530 * @note The exact behavior depends on low level FIFO settings such
531 * as thresholds, etc.
532 * @note This function can only be called by a single thread at time.
533 *
534 * @param[in] siop pointer to an @p SIODriver structure
535 * @param[in] timeout synchronization timeout
536 * @return The synchronization result.
537 * @retval MSG_OK if there is data in the RX FIFO.
538 * @retval MSG_TIMEOUT if synchronization timed out.
539 * @retval MSG_RESET it the operation has been stopped while waiting.
540 * @retval SIO_MSG_ERRORS if RX errors occurred before or during wait.
541 *
542 * @api
543 */
545 msg_t msg;
546
547 osalDbgCheck(siop != NULL);
548
549 osalSysLock();
550
551 osalDbgAssert(siop->state == SIO_READY, "invalid state");
552
553 /* Checking for errors before going to sleep.*/
554 if (sioHasRXErrorsX(siop)) {
556 return SIO_MSG_ERRORS;
557 }
558
559 msg = MSG_OK;
560 /*lint -save -e506 -e681 [2.1] Silencing this error because it is
561 tested with a template implementation of sio_lld_is_rx_empty() which
562 is constant.*/
563 while (sioIsRXEmptyX(siop)) {
564 /*lint -restore*/
565 msg = osalThreadSuspendTimeoutS(&siop->sync_rx, timeout);
566 if (msg != MSG_OK) {
567 break;
568 }
569 }
570
572
573 return msg;
574}
575/**
576 * @brief Synchronizes with RX going idle.
577 * @note This function can only be called by a single thread at time.
578 *
579 * @param[in] siop pointer to an @p SIODriver structure
580 * @param[in] timeout synchronization timeout
581 * @return The synchronization result.
582 * @retval MSG_OK if RW went idle.
583 * @retval MSG_TIMEOUT if synchronization timed out.
584 * @retval MSG_RESET it the operation has been stopped while waiting.
585 * @retval SIO_MSG_ERRORS if RX errors occurred before or during wait.
586 *
587 * @api
588 */
590 msg_t msg;
591
592 osalDbgCheck(siop != NULL);
593
594 osalSysLock();
595
596 osalDbgAssert(siop->state == SIO_READY, "invalid state");
597
598 /* Checking for errors before going to sleep.*/
599 if (sioHasRXErrorsX(siop)) {
601 return SIO_MSG_ERRORS;
602 }
603
604 msg = MSG_OK;
605 /*lint -save -e506 -e681 [2.1] Silencing this error because it is
606 tested with a template implementation of sio_lld_is_rx_empty() which
607 is constant.*/
608 while (!sioIsRXIdleX(siop)) {
609 /*lint -restore*/
610 msg = osalThreadSuspendTimeoutS(&siop->sync_rxidle, timeout);
611 if (msg != MSG_OK) {
612 break;
613 }
614 }
615
617
618 return msg;
619}
620
621/**
622 * @brief Synchronizes with TX FIFO space availability.
623 * @note The exact behavior depends on low level FIFO settings such
624 * as thresholds, etc.
625 * @note This function can only be called by a single thread at time.
626 *
627 * @param[in] siop pointer to an @p SIODriver structure
628 * @param[in] timeout synchronization timeout
629 * @return The synchronization result.
630 * @retval MSG_OK if there is space in the TX FIFO.
631 * @retval MSG_TIMEOUT if synchronization timed out.
632 * @retval MSG_RESET operation has been stopped while waiting.
633 *
634 * @api
635 */
637 msg_t msg;
638
639 osalDbgCheck(siop != NULL);
640
641 osalSysLock();
642
643 osalDbgAssert(siop->state == SIO_READY, "invalid state");
644
645 msg = MSG_OK;
646 /*lint -save -e506 -e681 [2.1] Silencing this error because it is
647 tested with a template implementation of sio_lld_is_tx_full() which
648 is constant.*/
649 while (sioIsTXFullX(siop)) {
650 /*lint -restore*/
651 msg = osalThreadSuspendTimeoutS(&siop->sync_tx, timeout);
652 if (msg != MSG_OK) {
653 break;
654 }
655 }
656
658
659 return msg;
660}
661
662/**
663 * @brief Synchronizes with TX completion.
664 * @note This function can only be called by a single thread at time.
665 *
666 * @param[in] siop pointer to an @p SIODriver structure
667 * @param[in] timeout synchronization timeout
668 * @return The synchronization result.
669 * @retval MSG_OK if TX operation finished.
670 * @retval MSG_TIMEOUT if synchronization timed out.
671 *
672 * @api
673 */
675 msg_t msg;
676
677 osalDbgCheck(siop != NULL);
678
679 osalSysLock();
680
681 osalDbgAssert(siop->state == SIO_READY, "invalid state");
682
683 /*lint -save -e506 -e774 [2.1, 14.3] Silencing this error because
684 it is tested with a template implementation of sio_lld_is_tx_ongoing()
685 which is constant.*/
686 if (sioIsTXOngoingX(siop)) {
687 /*lint -restore*/
688 msg = osalThreadSuspendTimeoutS(&siop->sync_txend, timeout);
689 }
690 else {
691 msg = MSG_OK;
692 }
693
695
696 return msg;
697}
698#endif /* SIO_USE_SYNCHRONIZATION == TRUE */
699
700#endif /* HAL_USE_SIO == TRUE */
701
702/** @} */
static const struct EFlashDriverVMT vmt
Definition hal_efl.c:71
#define HAL_RET_SUCCESS
Definition hal.h:93
#define HAL_RET_UNKNOWN_CTL
Unknown control code.
Definition hal.h:119
#define CHN_CTL_INVALID
Invalid operation code.
#define CHN_CTL_NOP
Does nothing.
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition osal.h:601
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition osal.h:611
void osalOsRescheduleS(void)
Checks if a reschedule is required and performs it.
Definition osal.c:119
void osalThreadResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Definition osal.c:227
#define osalDbgAssert(c, remark)
Condition assertion.
Definition osal.h:264
msg_t osalThreadSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout)
Sends the current thread sleeping and sets a reference variable.
Definition osal.c:208
#define osalDbgCheck(c)
Function parameters check.
Definition osal.h:284
struct hal_sio_config SIOConfig
Type of structure representing a SIO configuration.
Definition hal_sio.h:143
static size_t sync_write(void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout)
Definition hal_sio.c:46
msg_t sioSynchronizeRX(SIODriver *siop, sysinterval_t timeout)
Synchronizes with RX FIFO data availability.
Definition hal_sio.c:544
#define sioHasRXErrorsX(siop)
Determines if RX has pending errors to be read and cleared.
Definition hal_sio.h:297
msg_t sio_lld_control(SIODriver *siop, unsigned int operation, void *arg)
Control operation on a serial port.
msg_t sioSynchronizeRXIdle(SIODriver *siop, sysinterval_t timeout)
Synchronizes with RX going idle.
Definition hal_sio.c:589
#define sioPutX(siop, data)
Pushes one frame into the TX FIFO.
Definition hal_sio.h:421
static msg_t __put(void *ip, uint8_t b)
Definition hal_sio.c:108
static size_t __writet(void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout)
Definition hal_sio.c:170
msg_t sioSynchronizeTXEnd(SIODriver *siop, sysinterval_t timeout)
Synchronizes with TX completion.
Definition hal_sio.c:674
msg_t sioSynchronizeTX(SIODriver *siop, sysinterval_t timeout)
Synchronizes with TX FIFO space availability.
Definition hal_sio.c:636
static size_t __read(void *ip, uint8_t *bp, size_t n)
Definition hal_sio.c:103
#define sioGetX(siop)
Returns one frame from the RX FIFO.
Definition hal_sio.h:410
void sioWriteEnableFlags(SIODriver *siop, sioevents_t mask)
Writes the enabled events flags mask.
Definition hal_sio.c:342
sioevents_t sioGetAndClearErrors(SIODriver *siop)
Get and clears SIO error event flags.
Definition hal_sio.c:405
struct hal_sio_driver SIODriver
Type of structure representing a SIO driver.
Definition hal_sio.h:138
#define sioIsRXIdleX(siop)
Determines the activity state of the receiver.
Definition hal_sio.h:284
static msg_t __gett(void *ip, sysinterval_t timeout)
Definition hal_sio.c:152
#define sioAsyncWriteX(siop, buffer, n)
Writes data into the TX FIFO.
Definition hal_sio.h:453
static size_t __readt(void *ip, uint8_t *bp, size_t n, sysinterval_t timeout)
Definition hal_sio.c:176
void sioInit(void)
SIO Driver initialization.
Definition hal_sio.c:219
#define sioAsyncReadX(siop, buffer, n)
Reads data from the RX FIFO.
Definition hal_sio.h:437
#define sioSetEnableFlagsX(siop, mask)
Sets flags into the enabled events flags mask.
Definition hal_sio.h:344
#define sioWriteEnableFlagsX(siop, mask)
Writes the enabled events mask.
Definition hal_sio.h:331
size_t sioAsyncRead(SIODriver *siop, uint8_t *buffer, size_t n)
Reads data from the RX FIFO.
Definition hal_sio.c:483
size_t sioAsyncWrite(SIODriver *siop, const uint8_t *buffer, size_t n)
Writes data into the TX FIFO.
Definition hal_sio.c:512
#define sioIsTXFullX(siop)
Determines the state of the TX FIFO.
Definition hal_sio.h:309
#define SIO_EV_NONE
Definition hal_sio.h:56
void sioObjectInit(SIODriver *siop)
Initializes the standard part of a SIODriver structure.
Definition hal_sio.c:231
msg_t sioStart(SIODriver *siop, const SIOConfig *config)
Configures and activates the SIO peripheral.
Definition hal_sio.c:264
void sio_lld_stop(SIODriver *siop)
Deactivates the SIO peripheral.
#define sioGetAndClearEventsX(siop)
Get and clears SIO event flags.
Definition hal_sio.h:389
sioevents_t sioGetAndClearEvents(SIODriver *siop)
Get and clears SIO event flags.
Definition hal_sio.c:429
#define sioGetAndClearErrorsX(siop)
Get and clears SIO error event flags.
Definition hal_sio.h:379
void sioSetEnableFlags(SIODriver *siop, sioevents_t mask)
Sets flags into the enabled events flags mask.
Definition hal_sio.c:363
void sio_lld_init(void)
Low level SIO driver initialization.
Definition hal_sio_lld.c:65
eventflags_t sioevents_t
Type of event flags.
Definition hal_sio.h:133
static msg_t __ctl(void *ip, unsigned int operation, void *arg)
Definition hal_sio.c:182
void sioStop(SIODriver *siop)
Deactivates the SIO peripheral.
Definition hal_sio.c:307
#define SIO_MSG_ERRORS
Definition hal_sio.h:83
static size_t __write(void *ip, const uint8_t *bp, size_t n)
Definition hal_sio.c:98
static msg_t __get(void *ip)
Definition hal_sio.c:121
static size_t sync_read(void *ip, uint8_t *bp, size_t n, sysinterval_t timeout)
Definition hal_sio.c:68
#define sioClearEnableFlagsX(siop, mask)
Clears flags from the enabled events flags mask.
Definition hal_sio.h:357
static msg_t __putt(void *ip, uint8_t b, sysinterval_t timeout)
Definition hal_sio.c:139
#define sioGetEventsX(siop)
Returns the pending SIO event flags.
Definition hal_sio.h:399
sioevents_t sioGetEvents(SIODriver *siop)
Returns the pending SIO event flags.
Definition hal_sio.c:453
void sioClearEnableFlags(SIODriver *siop, sioevents_t mask)
Clears flags from the enabled events flags mask.
Definition hal_sio.c:384
#define sioIsTXOngoingX(siop)
Determines the transmission state.
Definition hal_sio.h:321
msg_t sio_lld_start(SIODriver *siop)
Configures and activates the SIO peripheral.
Definition hal_sio_lld.c:81
#define sioIsRXEmptyX(siop)
Determines the state of the RX FIFO.
Definition hal_sio.h:272
#define SIO_EV_ALL_EVENTS
Definition hal_sio.h:72
@ SIO_READY
Definition hal_sio.h:158
@ SIO_STOP
Definition hal_sio.h:157
int32_t msg_t
Definition chearly.h:87
#define MSG_OK
Normal wakeup message.
Definition chschd.h:38
#define MSG_RESET
Wakeup caused by a reset condition.
Definition chschd.h:41
uint64_t sysinterval_t
Type of time interval.
Definition chtime.h:118
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
Definition chtime.h:54
HAL subsystem header.
thread_reference_t sync_rxidle
Synchronization point for RX idle.
Definition hal_sio.h:233
siostate_t state
Driver state.
Definition hal_sio.h:206
sioevents_t enabled
Enabled event flags.
Definition hal_sio.h:214
siocb_t cb
Events callback.
Definition hal_sio.h:219
thread_reference_t sync_rx
Synchronization point for RX.
Definition hal_sio.h:229
thread_reference_t sync_txend
Synchronization point for TX-end.
Definition hal_sio.h:241
const struct sio_driver_vmt * vmt
Virtual Methods Table.
Definition hal_sio.h:201
thread_reference_t sync_tx
Synchronization point for TX.
Definition hal_sio.h:237
void * arg
User argument.
Definition hal_sio.h:224
const SIOConfig * config
Current configuration data.
Definition hal_sio.h:210
SIODriver virtual methods table.
Definition hal_sio.h:187