ChibiOS 21.11.4
hal_sio.c
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2018 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 != MSG_OK) {
80 break;
81 }
82
83 read = sioAsyncRead(siop, bp, n - i);
84 i += read;
85 bp += read;
86 }
87 return i;
88}
89
90/*
91 * Interface implementation, the following functions just invoke the equivalent
92 * queue-level function or macro.
93 */
94
95static size_t __write(void *ip, const uint8_t *bp, size_t n) {
96
97 return sync_write(ip, bp, n, TIME_INFINITE);
98}
99
100static size_t __read(void *ip, uint8_t *bp, size_t n) {
101
102 return sync_read(ip, bp, n, TIME_INFINITE);
103}
104
105static msg_t __put(void *ip, uint8_t b) {
106 SIODriver *siop = (SIODriver *)ip;
107 msg_t msg;
108
109 msg = sioSynchronizeTX(siop, TIME_INFINITE);
110 if (msg != MSG_OK) {
111 return msg;
112 }
113
114 sioPutX(siop, b);
115 return MSG_OK;
116}
117
118static msg_t __get(void *ip) {
119 SIODriver *siop = (SIODriver *)ip;
120 msg_t msg;
121
122 msg = sioSynchronizeRX(siop, TIME_INFINITE);
123 if (msg != MSG_OK) {
124 return msg;
125 }
126
127 return sioGetX(siop);
128}
129
130static msg_t __putt(void *ip, uint8_t b, sysinterval_t timeout) {
131 SIODriver *siop = (SIODriver *)ip;
132 msg_t msg;
133
134 msg = sioSynchronizeTX(siop, timeout);
135 if (msg != MSG_OK) {
136 return msg;
137 }
138
139 sioPutX(siop, b);
140 return MSG_OK;
141}
142
143static msg_t __gett(void *ip, sysinterval_t timeout) {
144 SIODriver *siop = (SIODriver *)ip;
145 msg_t msg;
146
147 msg = sioSynchronizeRX(siop, timeout);
148 if (msg != MSG_OK) {
149 return msg;
150 }
151
152 return sioGetX(siop);
153}
154
155static size_t __writet(void *ip, const uint8_t *bp, size_t n,
156 sysinterval_t timeout) {
157
158 return sync_write(ip, bp, n, timeout);
159}
160
161static size_t __readt(void *ip, uint8_t *bp, size_t n,
162 sysinterval_t timeout) {
163
164 return sync_read(ip, bp, n, timeout);
165}
166
167static msg_t __ctl(void *ip, unsigned int operation, void *arg) {
168 SIODriver *siop = (SIODriver *)ip;
169
170 osalDbgCheck(siop != NULL);
171
172 switch (operation) {
173 case CHN_CTL_NOP:
174 osalDbgCheck(arg == NULL);
175 break;
176 case CHN_CTL_INVALID:
177 return HAL_RET_UNKNOWN_CTL;
178 default:
179 /* Delegating to the LLD if supported.*/
180 return sio_lld_control(siop, operation, arg);
181 }
182 return HAL_RET_SUCCESS;
183}
184
185static const struct sio_driver_vmt vmt = {
186 (size_t)0,
189 __ctl
190};
191#endif /* SIO_USE_STREAMS_INTERFACE */
192
193/*===========================================================================*/
194/* Driver exported functions. */
195/*===========================================================================*/
196
197/**
198 * @brief SIO Driver initialization.
199 * @note This function is implicitly invoked by @p halInit(), there is
200 * no need to explicitly initialize the driver.
201 *
202 * @init
203 */
204void sioInit(void) {
205
206 sio_lld_init();
207}
208
209/**
210 * @brief Initializes the standard part of a @p SIODriver structure.
211 *
212 * @param[out] siop pointer to the @p SIODriver object
213 *
214 * @init
215 */
217
218#if SIO_USE_STREAMS_INTERFACE == TRUE
219 siop->vmt = &vmt;
220#endif
221 siop->state = SIO_STOP;
222 siop->config = NULL;
223 siop->enabled = (sioevents_t)0;
224 siop->cb = NULL;
225 siop->arg = NULL;
226#if SIO_USE_SYNCHRONIZATION == TRUE
227 siop->sync_rx = NULL;
228 siop->sync_rxidle = NULL;
229 siop->sync_tx = NULL;
230 siop->sync_txend = NULL;
231#endif
232
233 /* Optional, user-defined initializer.*/
234#if defined(SIO_DRIVER_EXT_INIT_HOOK)
235 SIO_DRIVER_EXT_INIT_HOOK(siop);
236#endif
237}
238
239/**
240 * @brief Configures and activates the SIO peripheral.
241 *
242 * @param[in] siop pointer to the @p SIODriver object
243 * @param[in] config pointer to the @p SIOConfig object, can be @p NULL
244 * if the default configuration is desired
245 * @return The operation status.
246 *
247 * @api
248 */
249msg_t sioStart(SIODriver *siop, const SIOConfig *config) {
250 msg_t msg;
251
252 osalDbgCheck(siop != NULL);
253
254 osalSysLock();
255
256 osalDbgAssert((siop->state == SIO_STOP) || (siop->state == SIO_READY),
257 "invalid state");
258 siop->config = config;
259
260 msg = sio_lld_start(siop);
261 if (msg == HAL_RET_SUCCESS) {
262 siop->state = SIO_READY;
263 }
264 else {
265 siop->state = SIO_STOP;
266 }
267
268 /*lint -save -e9053 [12.2] MISRA seems to assume that the underlying type
269 is 8 bits wide, it is not.*/
270#if SIO_USE_SYNCHRONIZATION == TRUE
271 /* If synchronization is enabled then all events by default.*/
273#else
274 /* If synchronization is disabled then no events by default.*/
277#endif
278 /*lint -restore*/
279
281
282 return msg;
283}
284
285/**
286 * @brief Deactivates the SIO peripheral.
287 *
288 * @param[in] siop pointer to the @p SIODriver object
289 *
290 * @api
291 */
292void sioStop(SIODriver *siop) {
293
294 osalDbgCheck(siop != NULL);
295
296 osalSysLock();
297
298 osalDbgAssert((siop->state == SIO_STOP) || (siop->state == SIO_READY),
299 "invalid state");
300
301 sio_lld_stop(siop);
302 siop->state = SIO_STOP;
303 siop->config = NULL;
304 siop->cb = NULL;
305 siop->arg = NULL;
306
307#if SIO_USE_SYNCHRONIZATION == TRUE
308 /* Informing waiting threads, if any.*/
314#endif
315
317}
318
319/**
320 * @brief Writes the enabled events flags mask.
321 *
322 * @param[in] siop pointer to the @p SIODriver object
323 * @param[in] mask enabled events mask to be written
324 *
325 * @api
326 */
328
329 osalDbgCheck(siop != NULL);
330
331 osalSysLock();
332
333 osalDbgAssert(siop->state == SIO_READY, "invalid state");
334
335 sioWriteEnableFlagsX(siop, mask);
336
338}
339
340/**
341 * @brief Sets flags into the enabled events flags mask.
342 *
343 * @param[in] siop pointer to the @p SIODriver object
344 * @param[in] mask enabled events mask to be set
345 *
346 * @api
347 */
349
350 osalDbgCheck(siop != NULL);
351
352 osalSysLock();
353
354 osalDbgAssert(siop->state == SIO_READY, "invalid state");
355
356 sioSetEnableFlagsX(siop, mask);
357
359}
360
361/**
362 * @brief Clears flags from the enabled events flags mask.
363 *
364 * @param[in] siop pointer to the @p SIODriver object
365 * @param[in] mask enabled events mask to be cleared
366 *
367 * @api
368 */
370
371 osalDbgCheck(siop != NULL);
372
373 osalSysLock();
374
375 osalDbgAssert(siop->state == SIO_READY, "invalid state");
376
377 sioClearEnableFlagsX(siop, mask);
378
380}
381
382/**
383 * @brief Get and clears SIO error event flags.
384 *
385 * @param[in] siop pointer to the @p SIODriver object
386 * @return The pending error event flags.
387 *
388 * @api
389 */
391 sioevents_t errors;
392
393 osalDbgCheck(siop != NULL);
394
395 osalSysLock();
396
397 osalDbgAssert(siop->state == SIO_READY, "invalid state");
398
399 errors = sioGetAndClearErrorsX(siop);
400
402
403 return errors;
404}
405
406/**
407 * @brief Get and clears SIO event flags.
408 *
409 * @param[in] siop pointer to the @p SIODriver object
410 * @return The pending event flags.
411 *
412 * @api
413 */
415 sioevents_t events;
416
417 osalDbgCheck(siop != NULL);
418
419 osalSysLock();
420
421 osalDbgAssert(siop->state == SIO_READY, "invalid state");
422
423 events = sioGetAndClearEventsX(siop);
424
426
427 return events;
428}
429
430/**
431 * @brief Returns the pending SIO event flags.
432 *
433 * @param[in] siop pointer to the @p SIODriver object
434 * @return The pending event flags.
435 *
436 * @api
437 */
439 sioevents_t events;
440
441 osalDbgCheck(siop != NULL);
442
443 osalSysLock();
444
445 osalDbgAssert(siop->state == SIO_READY, "invalid state");
446
447 events = sioGetEventsX(siop);
448
450
451 return events;
452}
453
454/**
455 * @brief Reads data from the RX FIFO.
456 * @details This function is non-blocking, data is read if present and the
457 * effective amount is returned.
458 * @note This function can be called from any context but it is meant to
459 * be called from the @p rxne_cb callback handler.
460 *
461 * @param[in] siop pointer to the @p SIODriver object
462 * @param[in] buffer buffer for the received data
463 * @param[in] n maximum number of frames to read
464 * @return The number of received frames.
465 *
466 * @api
467 */
468size_t sioAsyncRead(SIODriver *siop, uint8_t *buffer, size_t n) {
469
470 osalDbgCheck((siop != NULL) && (buffer != NULL));
471
472 osalSysLock();
473
474 osalDbgAssert(siop->state == SIO_READY, "invalid state");
475
476 n = sioAsyncReadX(siop, buffer, n);
477
479
480 return n;
481}
482
483/**
484 * @brief Writes data into the TX FIFO.
485 * @details This function is non-blocking, data is written if there is space
486 * in the FIFO and the effective amount is returned.
487 * @note This function can be called from any context but it is meant to
488 * be called from the @p txnf_cb callback handler.
489 *
490 * @param[in] siop pointer to the @p SIODriver object
491 * @param[out] buffer buffer containing the data to be transmitted
492 * @param[in] n maximum number of frames to read
493 * @return The number of transmitted frames.
494 *
495 * @api
496 */
497size_t sioAsyncWrite(SIODriver *siop, const uint8_t *buffer, size_t n) {
498
499 osalDbgCheck((siop != NULL) && (buffer != NULL));
500
501 osalSysLock();
502
503 osalDbgAssert(siop->state == SIO_READY, "invalid state");
504
505 n = sioAsyncWriteX(siop, buffer, n);
506
508
509 return n;
510}
511
512#if (SIO_USE_SYNCHRONIZATION == TRUE) || defined(__DOXYGEN__)
513/**
514 * @brief Synchronizes with RX FIFO data availability.
515 * @note The exact behavior depends on low level FIFO settings such
516 * as thresholds, etc.
517 * @note This function can only be called by a single thread at time.
518 *
519 * @param[in] siop pointer to an @p SIODriver structure
520 * @param[in] timeout synchronization timeout
521 * @return The synchronization result.
522 * @retval MSG_OK if there is data in the RX FIFO.
523 * @retval MSG_TIMEOUT if synchronization timed out.
524 * @retval MSG_RESET it the operation has been stopped while waiting.
525 * @retval SIO_MSG_ERRORS if RX errors occurred before or during wait.
526 *
527 * @api
528 */
530 msg_t msg;
531
532 osalDbgCheck(siop != NULL);
533
534 osalSysLock();
535
536 osalDbgAssert(siop->state == SIO_READY, "invalid state");
537
538 /* Checking for errors before going to sleep.*/
539 if (sioHasRXErrorsX(siop)) {
541 return SIO_MSG_ERRORS;
542 }
543
544 msg = MSG_OK;
545 /*lint -save -e506 -e681 [2.1] Silencing this error because it is
546 tested with a template implementation of sio_lld_is_rx_empty() which
547 is constant.*/
548 while (sioIsRXEmptyX(siop)) {
549 /*lint -restore*/
550 msg = osalThreadSuspendTimeoutS(&siop->sync_rx, timeout);
551 if (msg != MSG_OK) {
552 break;
553 }
554 }
555
557
558 return msg;
559}
560/**
561 * @brief Synchronizes with RX going idle.
562 * @note This function can only be called by a single thread at time.
563 *
564 * @param[in] siop pointer to an @p SIODriver structure
565 * @param[in] timeout synchronization timeout
566 * @return The synchronization result.
567 * @retval MSG_OK if RW went idle.
568 * @retval MSG_TIMEOUT if synchronization timed out.
569 * @retval MSG_RESET it the operation has been stopped while waiting.
570 * @retval SIO_MSG_ERRORS if RX errors occurred before or during wait.
571 *
572 * @api
573 */
575 msg_t msg;
576
577 osalDbgCheck(siop != NULL);
578
579 osalSysLock();
580
581 osalDbgAssert(siop->state == SIO_READY, "invalid state");
582
583 /* Checking for errors before going to sleep.*/
584 if (sioHasRXErrorsX(siop)) {
586 return SIO_MSG_ERRORS;
587 }
588
589 msg = MSG_OK;
590 /*lint -save -e506 -e681 [2.1] Silencing this error because it is
591 tested with a template implementation of sio_lld_is_rx_empty() which
592 is constant.*/
593 while (!sioIsRXIdleX(siop)) {
594 /*lint -restore*/
595 msg = osalThreadSuspendTimeoutS(&siop->sync_rxidle, timeout);
596 if (msg != MSG_OK) {
597 break;
598 }
599 }
600
602
603 return msg;
604}
605
606/**
607 * @brief Synchronizes with TX FIFO space availability.
608 * @note The exact behavior depends on low level FIFO settings such
609 * as thresholds, etc.
610 * @note This function can only be called by a single thread at time.
611 *
612 * @param[in] siop pointer to an @p SIODriver structure
613 * @param[in] timeout synchronization timeout
614 * @return The synchronization result.
615 * @retval MSG_OK if there is space in the TX FIFO.
616 * @retval MSG_TIMEOUT if synchronization timed out.
617 * @retval MSG_RESET operation has been stopped while waiting.
618 *
619 * @api
620 */
622 msg_t msg;
623
624 osalDbgCheck(siop != NULL);
625
626 osalSysLock();
627
628 osalDbgAssert(siop->state == SIO_READY, "invalid state");
629
630 msg = MSG_OK;
631 /*lint -save -e506 -e681 [2.1] Silencing this error because it is
632 tested with a template implementation of sio_lld_is_tx_full() which
633 is constant.*/
634 while (sioIsTXFullX(siop)) {
635 /*lint -restore*/
636 msg = osalThreadSuspendTimeoutS(&siop->sync_tx, timeout);
637 if (msg != MSG_OK) {
638 break;
639 }
640 }
641
643
644 return msg;
645}
646
647/**
648 * @brief Synchronizes with TX completion.
649 * @note This function can only be called by a single thread at time.
650 *
651 * @param[in] siop pointer to an @p SIODriver structure
652 * @param[in] timeout synchronization timeout
653 * @return The synchronization result.
654 * @retval MSG_OK if TX operation finished.
655 * @retval MSG_TIMEOUT if synchronization timed out.
656 *
657 * @api
658 */
660 msg_t msg;
661
662 osalDbgCheck(siop != NULL);
663
664 osalSysLock();
665
666 osalDbgAssert(siop->state == SIO_READY, "invalid state");
667
668 /*lint -save -e506 -e774 [2.1, 14.3] Silencing this error because
669 it is tested with a template implementation of sio_lld_is_tx_ongoing()
670 which is constant.*/
671 if (sioIsTXOngoingX(siop)) {
672 /*lint -restore*/
673 msg = osalThreadSuspendTimeoutS(&siop->sync_txend, timeout);
674 }
675 else {
676 msg = MSG_OK;
677 }
678
680
681 return msg;
682}
683#endif /* SIO_USE_SYNCHRONIZATION == TRUE */
684
685#endif /* HAL_USE_SIO == TRUE */
686
687/** @} */
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:529
#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:574
#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:105
static size_t __writet(void *ip, const uint8_t *bp, size_t n, sysinterval_t timeout)
Definition hal_sio.c:155
msg_t sioSynchronizeTXEnd(SIODriver *siop, sysinterval_t timeout)
Synchronizes with TX completion.
Definition hal_sio.c:659
msg_t sioSynchronizeTX(SIODriver *siop, sysinterval_t timeout)
Synchronizes with TX FIFO space availability.
Definition hal_sio.c:621
static size_t __read(void *ip, uint8_t *bp, size_t n)
Definition hal_sio.c:100
#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:327
sioevents_t sioGetAndClearErrors(SIODriver *siop)
Get and clears SIO error event flags.
Definition hal_sio.c:390
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:143
static size_t __readt(void *ip, uint8_t *bp, size_t n, sysinterval_t timeout)
Definition hal_sio.c:161
void sioInit(void)
SIO Driver initialization.
Definition hal_sio.c:204
#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:468
size_t sioAsyncWrite(SIODriver *siop, const uint8_t *buffer, size_t n)
Writes data into the TX FIFO.
Definition hal_sio.c:497
#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:216
msg_t sioStart(SIODriver *siop, const SIOConfig *config)
Configures and activates the SIO peripheral.
Definition hal_sio.c:249
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:414
#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:348
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:167
void sioStop(SIODriver *siop)
Deactivates the SIO peripheral.
Definition hal_sio.c:292
#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:95
static msg_t __get(void *ip)
Definition hal_sio.c:118
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:130
#define sioGetEventsX(siop)
Returns the pending SIO event flags.
Definition hal_sio.h:399
#define sioAsyncReadX(siop, size, buffer)
Reads data from the RX FIFO.
Definition hal_sio.h:437
#define sioAsyncWriteX(siop, size, buffer)
Writes data into the TX FIFO.
Definition hal_sio.h:453
sioevents_t sioGetEvents(SIODriver *siop)
Returns the pending SIO event flags.
Definition hal_sio.c:438
void sioClearEnableFlags(SIODriver *siop, sioevents_t mask)
Clears flags from the enabled events flags mask.
Definition hal_sio.c:369
#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:88
#define MSG_OK
Normal wakeup message.
Definition chschd.h:39
#define MSG_RESET
Wakeup caused by a reset condition.
Definition chschd.h:42
uint64_t sysinterval_t
Type of time interval.
Definition chtime.h:119
#define TIME_INFINITE
Infinite interval specification for all functions with a timeout specification.
Definition chtime.h:55
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