ChibiOS/HAL 9.0.0
osal.h
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 osal.h
19 * @brief OSAL module header.
20 *
21 * @addtogroup OSAL
22 * @{
23 */
24
25#ifndef OSAL_H
26#define OSAL_H
27
28#include <stddef.h>
29#include <stdint.h>
30#include <stdbool.h>
31
32/*===========================================================================*/
33/* Module constants. */
34/*===========================================================================*/
35
36/**
37 * @name Common constants
38 * @{
39 */
40#if !defined(FALSE) || defined(__DOXYGEN__)
41#define FALSE 0
42#endif
43
44#if !defined(TRUE) || defined(__DOXYGEN__)
45#define TRUE 1
46#endif
47
48#define OSAL_SUCCESS false
49#define OSAL_FAILED true
50/** @} */
51
52/**
53 * @name Messages
54 * @{
55 */
56#define MSG_OK (msg_t)0
57#define MSG_TIMEOUT (msg_t)-1
58#define MSG_RESET (msg_t)-2
59/** @} */
60
61/**
62 * @name Special time constants
63 * @{
64 */
65#define TIME_IMMEDIATE ((sysinterval_t)0)
66#define TIME_INFINITE ((sysinterval_t)-1)
67/** @} */
68
69/**
70 * @name Systick modes.
71 * @{
72 */
73#define OSAL_ST_MODE_NONE 0
74#define OSAL_ST_MODE_PERIODIC 1
75#define OSAL_ST_MODE_FREERUNNING 2
76/** @} */
77
78/**
79 * @name Systick parameters.
80 * @{
81 */
82/**
83 * @brief Size in bits of the @p systick_t type.
84 */
85#define OSAL_ST_RESOLUTION 32
86
87/**
88 * @brief Required systick frequency or resolution.
89 */
90#define OSAL_ST_FREQUENCY 1000
91
92/**
93 * @brief Systick mode required by the underlying OS.
94 */
95#define OSAL_ST_MODE OSAL_ST_MODE_PERIODIC
96/** @} */
97
98/**
99 * @name IRQ-related constants
100 * @{
101 */
102/**
103 * @brief Total priority levels.
104 * @brief Implementation not mandatory.
105 */
106#define OSAL_IRQ_PRIORITY_LEVELS 16U
107
108/**
109 * @brief Highest IRQ priority for HAL drivers.
110 * @brief Implementation not mandatory.
111 */
112#define OSAL_IRQ_MAXIMUM_PRIORITY 0U
113/** @} */
114
115/*===========================================================================*/
116/* Module pre-compile time settings. */
117/*===========================================================================*/
118
119/**
120 * @brief Enables OSAL assertions.
121 */
122#if !defined(OSAL_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
123#define OSAL_DBG_ENABLE_ASSERTS FALSE
124#endif
125
126/**
127 * @brief Enables OSAL functions parameters checks.
128 */
129#if !defined(OSAL_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
130#define OSAL_DBG_ENABLE_CHECKS FALSE
131#endif
132
133/*===========================================================================*/
134/* Derived constants and error checks. */
135/*===========================================================================*/
136
137#if !(OSAL_ST_MODE == OSAL_ST_MODE_NONE) && \
138 !(OSAL_ST_MODE == OSAL_ST_MODE_PERIODIC) && \
139 !(OSAL_ST_MODE == OSAL_ST_MODE_FREERUNNING)
140#error "invalid OSAL_ST_MODE setting in osal.h"
141#endif
142
143#if (OSAL_ST_RESOLUTION != 16) && (OSAL_ST_RESOLUTION != 32)
144#error "invalid OSAL_ST_RESOLUTION, must be 16 or 32"
145#endif
146
147/*===========================================================================*/
148/* Module data structures and types. */
149/*===========================================================================*/
150
151/**
152 * @brief Type of a system status word.
153 */
154typedef uint32_t syssts_t;
155
156/**
157 * @brief Type of a message.
158 */
159typedef int32_t msg_t;
160
161/**
162 * @brief Type of system time counter.
163 */
164typedef uint32_t systime_t;
165
166/**
167 * @brief Type of system time interval.
168 */
169typedef uint32_t sysinterval_t;
170
171/**
172 * @brief Type of time conversion variable.
173 * @note This type must have double width than other time types, it is
174 * only used internally for conversions.
175 */
176typedef uint64_t time_conv_t;
177
178/**
179 * @brief Type of realtime counter.
180 */
181typedef uint32_t rtcnt_t;
182
183/**
184 * @brief Type of a thread reference.
185 */
186typedef void * thread_reference_t;
187
188/**
189 * @brief Type of an event flags mask.
190 */
191typedef uint32_t eventflags_t;
192
193/**
194 * @brief Type of an event flags object.
195 * @note The content of this structure is not part of the API and should
196 * not be relied upon. Implementers may define this structure in
197 * an entirely different way.
198 * @note Retrieval and clearing of the flags are not defined in this
199 * API and are implementation-dependent.
200 */
202
203/**
204 * @brief Type of an event source callback.
205 * @note This type is not part of the OSAL API and is provided
206 * exclusively as an example and for convenience.
207 */
208typedef void (*eventcallback_t)(event_source_t *esp);
209
210/**
211 * @brief Events source object.
212 * @note The content of this structure is not part of the API and should
213 * not be relied upon. Implementers may define this structure in
214 * an entirely different way.
215 * @note Retrieval and clearing of the flags are not defined in this
216 * API and are implementation-dependent.
217 */
219 volatile eventflags_t flags; /**< @brief Stored event flags. */
220 eventcallback_t cb; /**< @brief Event source callback. */
221 void *param; /**< @brief User defined field. */
222};
223
224/**
225 * @brief Type of a mutex.
226 * @note If the OS does not support mutexes or there is no OS then them
227 * mechanism can be simulated.
228 */
229typedef uint32_t mutex_t;
230
231/**
232 * @brief Type of a thread queue.
233 * @details A thread queue is a queue of sleeping threads, queued threads
234 * can be dequeued one at time or all together.
235 * @note If the OSAL is implemented on a bare metal machine without RTOS
236 * then the queue can be implemented as a single thread reference.
237 */
241
242/*===========================================================================*/
243/* Module macros. */
244/*===========================================================================*/
245
246/**
247 * @name Debug related macros
248 * @{
249 */
250/**
251 * @brief Condition assertion.
252 * @details If the condition check fails then the OSAL panics with a
253 * message and halts.
254 * @note The condition is tested only if the @p OSAL_ENABLE_ASSERTIONS
255 * switch is enabled.
256 * @note The remark string is not currently used except for putting a
257 * comment in the code about the assertion.
258 *
259 * @param[in] c the condition to be verified to be true
260 * @param[in] remark a remark string
261 *
262 * @api
263 */
264#define osalDbgAssert(c, remark) do { \
265 /*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
266 if (OSAL_DBG_ENABLE_ASSERTS != FALSE) { \
267 if (!(c)) { \
268 /*lint -restore*/ \
269 osalSysHalt(__func__); \
270 } \
271 } \
272} while (false)
273
274/**
275 * @brief Function parameters check.
276 * @details If the condition check fails then the OSAL panics and halts.
277 * @note The condition is tested only if the @p OSAL_ENABLE_CHECKS switch
278 * is enabled.
279 *
280 * @param[in] c the condition to be verified to be true
281 *
282 * @api
283 */
284#define osalDbgCheck(c) do { \
285 /*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
286 if (OSAL_DBG_ENABLE_CHECKS != FALSE) { \
287 if (!(c)) { \
288 /*lint -restore*/ \
289 osalSysHalt(__func__); \
290 } \
291 } \
292} while (false)
293
294/**
295 * @brief I-Class state check.
296 * @note Implementation is optional.
297 */
298#define osalDbgCheckClassI()
299
300/**
301 * @brief S-Class state check.
302 * @note Implementation is optional.
303 */
304#define osalDbgCheckClassS()
305/** @} */
306
307/**
308 * @name IRQ service routines wrappers
309 * @{
310 */
311/**
312 * @brief Priority level verification macro.
313 */
314#define OSAL_IRQ_IS_VALID_PRIORITY(n) \
315 (((n) >= OSAL_IRQ_MAXIMUM_PRIORITY) && ((n) < OSAL_IRQ_PRIORITY_LEVELS))
316
317/**
318 * @brief IRQ prologue code.
319 * @details This macro must be inserted at the start of all IRQ handlers.
320 */
321#define OSAL_IRQ_PROLOGUE()
322
323/**
324 * @brief IRQ epilogue code.
325 * @details This macro must be inserted at the end of all IRQ handlers.
326 */
327#define OSAL_IRQ_EPILOGUE()
328
329/**
330 * @brief IRQ handler function declaration.
331 * @details This macro hides the details of an ISR function declaration.
332 *
333 * @param[in] id a vector name as defined in @p vectors.s
334 */
335#define OSAL_IRQ_HANDLER(id) void id(void)
336/** @} */
337
338/**
339 * @name Time conversion utilities
340 * @{
341 */
342/**
343 * @brief Seconds to time interval.
344 * @details Converts from seconds to system ticks number.
345 * @note The result is rounded upward to the next tick boundary.
346 * @note Use of this macro for large values is not secure because
347 * integer overflows, make sure your value can be correctly
348 * converted.
349 *
350 * @param[in] secs number of seconds
351 * @return The number of ticks.
352 *
353 * @api
354 */
355#define OSAL_S2I(secs) \
356 ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)OSAL_ST_FREQUENCY))
357
358/**
359 * @brief Milliseconds to time interval.
360 * @details Converts from milliseconds to system ticks number.
361 * @note The result is rounded upward to the next tick boundary.
362 * @note Use of this macro for large values is not secure because
363 * integer overflows, make sure your value can be correctly
364 * converted.
365 *
366 * @param[in] msecs number of milliseconds
367 * @return The number of ticks.
368 *
369 * @api
370 */
371#define OSAL_MS2I(msecs) \
372 ((sysinterval_t)((((time_conv_t)(msecs) * \
373 (time_conv_t)OSAL_ST_FREQUENCY) + \
374 (time_conv_t)999) / (time_conv_t)1000))
375
376/**
377 * @brief Microseconds to time interval.
378 * @details Converts from microseconds to system ticks number.
379 * @note The result is rounded upward to the next tick boundary.
380 * @note Use of this macro for large values is not secure because
381 * integer overflows, make sure your value can be correctly
382 * converted.
383 *
384 * @param[in] usecs number of microseconds
385 * @return The number of ticks.
386 *
387 * @api
388 */
389#define OSAL_US2I(usecs) \
390 ((sysinterval_t)((((time_conv_t)(usecs) * \
391 (time_conv_t)OSAL_ST_FREQUENCY) + \
392 (time_conv_t)999999) / (time_conv_t)1000000))
393
394/**
395 * @brief Time interval to seconds.
396 * @details Converts from system ticks number to seconds.
397 * @note The result is rounded up to the next second boundary.
398 * @note Use of this macro for large values is not secure because
399 * integer overflows, make sure your value can be correctly
400 * converted.
401 *
402 * @param[in] interval interval in ticks
403 * @return The number of seconds.
404 *
405 * @api
406 */
407#define OSAL_I2S(interval) \
408 (time_secs_t)(((time_conv_t)(interval) + \
409 (time_conv_t)OSAL_ST_FREQUENCY - \
410 (time_conv_t)1) / (time_conv_t)OSAL_ST_FREQUENCY)
411
412/**
413 * @brief Time interval to milliseconds.
414 * @details Converts from system ticks number to milliseconds.
415 * @note The result is rounded up to the next millisecond boundary.
416 * @note Use of this macro for large values is not secure because
417 * integer overflows, make sure your value can be correctly
418 * converted.
419 *
420 * @param[in] interval interval in ticks
421 * @return The number of milliseconds.
422 *
423 * @api
424 */
425#define OSAL_I2MS(interval) \
426 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \
427 (time_conv_t)OSAL_ST_FREQUENCY - (time_conv_t)1) / \
428 (time_conv_t)OSAL_ST_FREQUENCY)
429
430/**
431 * @brief Time interval to microseconds.
432 * @details Converts from system ticks number to microseconds.
433 * @note The result is rounded up to the next microsecond boundary.
434 * @note Use of this macro for large values is not secure because
435 * integer overflows, make sure your value can be correctly
436 * converted.
437 *
438 * @param[in] interval interval in ticks
439 * @return The number of microseconds.
440 *
441 * @api
442 */
443#define OSAL_I2US(interval) \
444 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \
445 (time_conv_t)OSAL_ST_FREQUENCY - (time_conv_t)1) / \
446 (time_conv_t)OSAL_ST_FREQUENCY)
447/** @} */
448
449/**
450 * @name Time conversion utilities for the realtime counter
451 * @{
452 */
453/**
454 * @brief Seconds to realtime counter.
455 * @details Converts from seconds to realtime counter cycles.
456 * @note The macro assumes that @p freq >= @p 1.
457 *
458 * @param[in] freq clock frequency, in Hz, of the realtime counter
459 * @param[in] sec number of seconds
460 * @return The number of cycles.
461 *
462 * @api
463 */
464#define OSAL_S2RTC(freq, sec) ((freq) * (sec))
465
466/**
467 * @brief Milliseconds to realtime counter.
468 * @details Converts from milliseconds to realtime counter cycles.
469 * @note The result is rounded upward to the next millisecond boundary.
470 * @note The macro assumes that @p freq >= @p 1000.
471 *
472 * @param[in] freq clock frequency, in Hz, of the realtime counter
473 * @param[in] msec number of milliseconds
474 * @return The number of cycles.
475 *
476 * @api
477 */
478#define OSAL_MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec))
479
480/**
481 * @brief Microseconds to realtime counter.
482 * @details Converts from microseconds to realtime counter cycles.
483 * @note The result is rounded upward to the next microsecond boundary.
484 * @note The macro assumes that @p freq >= @p 1000000.
485 *
486 * @param[in] freq clock frequency, in Hz, of the realtime counter
487 * @param[in] usec number of microseconds
488 * @return The number of cycles.
489 *
490 * @api
491 */
492#define OSAL_US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec))
493/** @} */
494
495/**
496 * @name Sleep macros using absolute time
497 * @{
498 */
499/**
500 * @brief Delays the invoking thread for the specified number of seconds.
501 * @note The specified time is rounded up to a value allowed by the real
502 * system tick clock.
503 * @note The maximum specifiable value is implementation dependent.
504 *
505 * @param[in] secs time in seconds, must be different from zero
506 *
507 * @api
508 */
509#define osalThreadSleepSeconds(secs) osalThreadSleep(OSAL_S2I(secs))
510
511/**
512 * @brief Delays the invoking thread for the specified number of
513 * milliseconds.
514 * @note The specified time is rounded up to a value allowed by the real
515 * system tick clock.
516 * @note The maximum specifiable value is implementation dependent.
517 *
518 * @param[in] msecs time in milliseconds, must be different from zero
519 *
520 * @api
521 */
522#define osalThreadSleepMilliseconds(msecs) osalThreadSleep(OSAL_MS2I(msecs))
523
524/**
525 * @brief Delays the invoking thread for the specified number of
526 * microseconds.
527 * @note The specified time is rounded up to a value allowed by the real
528 * system tick clock.
529 * @note The maximum specifiable value is implementation dependent.
530 *
531 * @param[in] usecs time in microseconds, must be different from zero
532 *
533 * @api
534 */
535#define osalThreadSleepMicroseconds(usecs) osalThreadSleep(OSAL_US2I(usecs))
536/** @} */
537
538/*===========================================================================*/
539/* External declarations. */
540/*===========================================================================*/
541
542extern const char *osal_halt_msg;
543
544#ifdef __cplusplus
545extern "C" {
546#endif
547 void osalInit(void);
548 void osalSysHalt(const char *reason);
549 void osalSysPolledDelayX(rtcnt_t cycles);
550 void osalOsTimerHandlerI(void);
551 void osalOsRescheduleS(void);
566 void *param);
567 void osalMutexLock(mutex_t *mp);
568 void osalMutexUnlock(mutex_t *mp);
569#ifdef __cplusplus
570}
571#endif
572
573/*===========================================================================*/
574/* Module inline functions. */
575/*===========================================================================*/
576
577/**
578 * @brief Disables interrupts globally.
579 *
580 * @special
581 */
582static inline void osalSysDisable(void) {
583
584}
585
586/**
587 * @brief Enables interrupts globally.
588 *
589 * @special
590 */
591static inline void osalSysEnable(void) {
592
593}
594
595/**
596 * @brief Enters a critical zone from thread context.
597 * @note This function cannot be used for reentrant critical zones.
598 *
599 * @special
600 */
601static inline void osalSysLock(void) {
602
603}
604
605/**
606 * @brief Leaves a critical zone from thread context.
607 * @note This function cannot be used for reentrant critical zones.
608 *
609 * @special
610 */
611static inline void osalSysUnlock(void) {
612
613}
614
615/**
616 * @brief Enters a critical zone from ISR context.
617 * @note This function cannot be used for reentrant critical zones.
618 *
619 * @special
620 */
621static inline void osalSysLockFromISR(void) {
622
623}
624
625/**
626 * @brief Leaves a critical zone from ISR context.
627 * @note This function cannot be used for reentrant critical zones.
628 *
629 * @special
630 */
631static inline void osalSysUnlockFromISR(void) {
632
633}
634
635/**
636 * @brief Returns the execution status and enters a critical zone.
637 * @details This functions enters into a critical zone and can be called
638 * from any context. Because its flexibility it is less efficient
639 * than @p chSysLock() which is preferable when the calling context
640 * is known.
641 * @post The system is in a critical zone.
642 *
643 * @return The previous system status, the encoding of this
644 * status word is architecture-dependent and opaque.
645 *
646 * @xclass
647 */
649
650 return (syssts_t)0;
651}
652
653/**
654 * @brief Restores the specified execution status and leaves a critical zone.
655 * @note A call to @p chSchRescheduleS() is automatically performed
656 * if exiting the critical zone and if not in ISR context.
657 *
658 * @param[in] sts the system status to be restored.
659 *
660 * @xclass
661 */
662static inline void osalSysRestoreStatusX(syssts_t sts) {
663
664 (void)sts;
665}
666
667/**
668 * @brief Adds an interval to a system time returning a system time.
669 *
670 * @param[in] systime base system time
671 * @param[in] interval interval to be added
672 * @return The new system time.
673 *
674 * @xclass
675 */
676static inline systime_t osalTimeAddX(systime_t systime,
677 sysinterval_t interval) {
678
679 return systime + (systime_t)interval;
680}
681
682/**
683 * @brief Subtracts two system times returning an interval.
684 *
685 * @param[in] start first system time
686 * @param[in] end second system time
687 * @return The interval representing the time difference.
688 *
689 * @xclass
690 */
692
693 return (sysinterval_t)((systime_t)(end - start));
694}
695
696/**
697 * @brief Checks if the specified time is within the specified time window.
698 * @note When start==end then the function returns always false because the
699 * time window has zero size.
700 * @note This function can be called from any context.
701 *
702 * @param[in] time the time to be verified
703 * @param[in] start the start of the time window (inclusive)
704 * @param[in] end the end of the time window (non inclusive)
705 * @retval true current time within the specified time window.
706 * @retval false current time not within the specified time window.
707 *
708 * @xclass
709 */
710static inline bool osalTimeIsInRangeX(systime_t time,
711 systime_t start,
712 systime_t end) {
713
714 return (bool)((systime_t)((systime_t)time - (systime_t)start) <
715 (systime_t)((systime_t)end - (systime_t)start));
716}
717
718/**
719 * @brief Initializes a threads queue object.
720 *
721 * @param[out] tqp pointer to the threads queue object
722 *
723 * @init
724 */
726
727 osalDbgCheck(tqp != NULL);
728}
729
730/**
731 * @brief Initializes an event source object.
732 *
733 * @param[out] esp pointer to the event source object
734 *
735 * @init
736 */
737static inline void osalEventObjectInit(event_source_t *esp) {
738
739 osalDbgCheck(esp != NULL);
740
741 esp->flags = (eventflags_t)0;
742 esp->cb = NULL;
743 esp->param = NULL;
744}
745
746/**
747 * @brief Initializes a @p mutex_t object.
748 *
749 * @param[out] mp pointer to the @p mutex_t object
750 *
751 * @init
752 */
753static inline void osalMutexObjectInit(mutex_t *mp) {
754
755 osalDbgCheck(mp != NULL);
756
757 *mp = 0;
758}
759
760#endif /* OSAL_H */
761
762/** @} */
msg_t osalThreadEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread.
Definition osal.c:273
void osalSysHalt(const char *reason)
System halt with error message.
Definition osal.c:77
static void osalSysLock(void)
Enters a critical zone from thread context.
Definition osal.h:601
void osalEventSetCallback(event_source_t *esp, eventcallback_t cb, void *param)
Event callback setup.
Definition osal.c:361
uint32_t eventflags_t
Type of an event flags mask.
Definition osal.h:191
static void osalMutexObjectInit(mutex_t *mp)
Initializes a mutex_t object.
Definition osal.h:753
static void osalSysUnlock(void)
Leaves a critical zone from thread context.
Definition osal.h:611
static systime_t osalTimeAddX(systime_t systime, sysinterval_t interval)
Adds an interval to a system time returning a system time.
Definition osal.h:676
static void osalSysEnable(void)
Enables interrupts globally.
Definition osal.h:591
const char * osal_halt_msg
Pointer to a halt error message.
Definition osal.c:40
void osalThreadDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the queue.
Definition osal.c:305
struct event_source event_source_t
Type of an event flags object.
Definition osal.h:201
uint32_t rtcnt_t
Type of realtime counter.
Definition osal.h:181
static void osalSysLockFromISR(void)
Enters a critical zone from ISR context.
Definition osal.h:621
static void osalThreadQueueObjectInit(threads_queue_t *tqp)
Initializes a threads queue object.
Definition osal.h:725
int32_t msg_t
Type of a message.
Definition osal.h:159
uint32_t sysinterval_t
Type of system time interval.
Definition osal.h:169
msg_t osalThreadSuspendS(thread_reference_t *trp)
Sends the current thread sleeping and sets a reference variable.
Definition osal.c:183
void(* eventcallback_t)(event_source_t *esp)
Type of an event source callback.
Definition osal.h:208
void osalThreadResumeS(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Definition osal.c:244
void * thread_reference_t
Type of a thread reference.
Definition osal.h:186
void osalOsRescheduleS(void)
Checks if a reschedule is required and performs it.
Definition osal.c:119
void osalThreadSleep(sysinterval_t time)
Suspends the invoking thread for the specified time.
Definition osal.c:168
static void osalSysDisable(void)
Disables interrupts globally.
Definition osal.h:582
void osalMutexLock(mutex_t *mp)
Locks the specified mutex.
Definition osal.c:380
void osalOsTimerHandlerI(void)
System timer handler.
Definition osal.c:105
void osalThreadResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Definition osal.c:227
static bool osalTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time window.
Definition osal.h:710
uint32_t mutex_t
Type of a mutex.
Definition osal.h:229
void osalInit(void)
OSAL module initialization.
Definition osal.c:63
static sysinterval_t osalTimeDiffX(systime_t start, systime_t end)
Subtracts two system times returning an interval.
Definition osal.h:691
void osalThreadSleepS(sysinterval_t time)
Suspends the invoking thread for the specified time.
Definition osal.c:152
void osalEventBroadcastFlags(event_source_t *esp, eventflags_t flags)
Add flags to an event source object.
Definition osal.c:337
uint64_t time_conv_t
Type of time conversion variable.
Definition osal.h:176
static syssts_t osalSysGetStatusAndLockX(void)
Returns the execution status and enters a critical zone.
Definition osal.h:648
static void osalSysUnlockFromISR(void)
Leaves a critical zone from ISR context.
Definition osal.h:631
systime_t osalOsGetSystemTimeX(void)
Current system time.
Definition osal.c:136
static void osalEventObjectInit(event_source_t *esp)
Initializes an event source object.
Definition osal.h:737
static void osalSysRestoreStatusX(syssts_t sts)
Restores the specified execution status and leaves a critical zone.
Definition osal.h:662
uint32_t syssts_t
Type of a system status word.
Definition osal.h:154
void osalMutexUnlock(mutex_t *mp)
Unlocks the specified mutex.
Definition osal.c:400
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
uint32_t systime_t
Type of system time counter.
Definition osal.h:164
void osalSysPolledDelayX(rtcnt_t cycles)
Polled delay.
Definition osal.c:94
void osalThreadDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the queue, if any.
Definition osal.c:290
void osalEventBroadcastFlagsI(event_source_t *esp, eventflags_t flags)
Add flags to an event source object.
Definition osal.c:319
Events source object.
Definition osal.h:218
void * param
User defined field.
Definition osal.h:221
eventcallback_t cb
Event source callback.
Definition osal.h:220
volatile eventflags_t flags
Stored event flags.
Definition osal.h:219
Type of a thread queue.
Definition osal.h:238
thread_reference_t tr
Definition osal.h:239