ChibiOS/HAL 9.0.0
osal.h File Reference

OSAL module header. More...

#include <stddef.h>
#include <stdint.h>
#include <stdbool.h>

Go to the source code of this file.

Data Structures

struct  event_source
 Events source object. More...
struct  threads_queue_t
 Type of a thread queue. More...

Macros

#define OSAL_DBG_ENABLE_ASSERTS   FALSE
 Enables OSAL assertions.
#define OSAL_DBG_ENABLE_CHECKS   FALSE
 Enables OSAL functions parameters checks.
Common constants
#define FALSE   0
#define TRUE   1
#define OSAL_SUCCESS   false
#define OSAL_FAILED   true
Messages
#define MSG_OK   (msg_t)0
#define MSG_TIMEOUT   (msg_t)-1
#define MSG_RESET   (msg_t)-2
Special time constants
#define TIME_IMMEDIATE   ((sysinterval_t)0)
#define TIME_INFINITE   ((sysinterval_t)-1)
Systick modes.
#define OSAL_ST_MODE_NONE   0
#define OSAL_ST_MODE_PERIODIC   1
#define OSAL_ST_MODE_FREERUNNING   2
Systick parameters.
#define OSAL_ST_RESOLUTION   32
 Size in bits of the systick_t type.
#define OSAL_ST_FREQUENCY   1000
 Required systick frequency or resolution.
#define OSAL_ST_MODE   OSAL_ST_MODE_PERIODIC
 Systick mode required by the underlying OS.
IRQ-related constants
#define OSAL_IRQ_PRIORITY_LEVELS   16U
 Total priority levels.
#define OSAL_IRQ_MAXIMUM_PRIORITY   0U
 Highest IRQ priority for HAL drivers.
Debug related macros
#define osalDbgAssert(c, remark)
 Condition assertion.
#define osalDbgCheck(c)
 Function parameters check.
#define osalDbgCheckClassI()
 I-Class state check.
#define osalDbgCheckClassS()
 S-Class state check.
IRQ service routines wrappers
#define OSAL_IRQ_IS_VALID_PRIORITY(n)
 Priority level verification macro.
#define OSAL_IRQ_PROLOGUE()
 IRQ prologue code.
#define OSAL_IRQ_EPILOGUE()
 IRQ epilogue code.
#define OSAL_IRQ_HANDLER(id)
 IRQ handler function declaration.
Time conversion utilities
#define OSAL_S2I(secs)
 Seconds to time interval.
#define OSAL_MS2I(msecs)
 Milliseconds to time interval.
#define OSAL_US2I(usecs)
 Microseconds to time interval.
#define OSAL_I2S(interval)
 Time interval to seconds.
#define OSAL_I2MS(interval)
 Time interval to milliseconds.
#define OSAL_I2US(interval)
 Time interval to microseconds.
Time conversion utilities for the realtime counter
#define OSAL_S2RTC(freq, sec)
 Seconds to realtime counter.
#define OSAL_MS2RTC(freq, msec)
 Milliseconds to realtime counter.
#define OSAL_US2RTC(freq, usec)
 Microseconds to realtime counter.
Sleep macros using absolute time
#define osalThreadSleepSeconds(secs)
 Delays the invoking thread for the specified number of seconds.
#define osalThreadSleepMilliseconds(msecs)
 Delays the invoking thread for the specified number of milliseconds.
#define osalThreadSleepMicroseconds(usecs)
 Delays the invoking thread for the specified number of microseconds.

Typedefs

typedef uint32_t syssts_t
 Type of a system status word.
typedef int32_t msg_t
 Type of a message.
typedef uint32_t systime_t
 Type of system time counter.
typedef uint32_t sysinterval_t
 Type of system time interval.
typedef uint64_t time_conv_t
 Type of time conversion variable.
typedef uint32_t rtcnt_t
 Type of realtime counter.
typedef void * thread_reference_t
 Type of a thread reference.
typedef uint32_t eventflags_t
 Type of an event flags mask.
typedef struct event_source event_source_t
 Type of an event flags object.
typedef void(* eventcallback_t) (event_source_t *esp)
 Type of an event source callback.
typedef uint32_t mutex_t
 Type of a mutex.

Functions

void osalInit (void)
 OSAL module initialization.
void osalSysHalt (const char *reason)
 System halt with error message.
void osalSysPolledDelayX (rtcnt_t cycles)
 Polled delay.
void osalOsTimerHandlerI (void)
 System timer handler.
void osalOsRescheduleS (void)
 Checks if a reschedule is required and performs it.
systime_t osalOsGetSystemTimeX (void)
 Current system time.
void osalThreadSleepS (sysinterval_t time)
 Suspends the invoking thread for the specified time.
void osalThreadSleep (sysinterval_t time)
 Suspends the invoking thread for the specified time.
msg_t osalThreadSuspendS (thread_reference_t *trp)
 Sends the current thread sleeping and sets a reference variable.
msg_t osalThreadSuspendTimeoutS (thread_reference_t *trp, sysinterval_t timeout)
 Sends the current thread sleeping and sets a reference variable.
void osalThreadResumeI (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object.
void osalThreadResumeS (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object.
msg_t osalThreadEnqueueTimeoutS (threads_queue_t *tqp, sysinterval_t timeout)
 Enqueues the caller thread.
void osalThreadDequeueNextI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up one thread from the queue, if any.
void osalThreadDequeueAllI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up all threads from the queue.
void osalEventBroadcastFlagsI (event_source_t *esp, eventflags_t flags)
 Add flags to an event source object.
void osalEventBroadcastFlags (event_source_t *esp, eventflags_t flags)
 Add flags to an event source object.
void osalEventSetCallback (event_source_t *esp, eventcallback_t cb, void *param)
 Event callback setup.
void osalMutexLock (mutex_t *mp)
 Locks the specified mutex.
void osalMutexUnlock (mutex_t *mp)
 Unlocks the specified mutex.
static void osalSysDisable (void)
 Disables interrupts globally.
static void osalSysEnable (void)
 Enables interrupts globally.
static void osalSysLock (void)
 Enters a critical zone from thread context.
static void osalSysUnlock (void)
 Leaves a critical zone from thread context.
static void osalSysLockFromISR (void)
 Enters a critical zone from ISR context.
static void osalSysUnlockFromISR (void)
 Leaves a critical zone from ISR context.
static syssts_t osalSysGetStatusAndLockX (void)
 Returns the execution status and enters a critical zone.
static void osalSysRestoreStatusX (syssts_t sts)
 Restores the specified execution status and leaves a critical zone.
static systime_t osalTimeAddX (systime_t systime, sysinterval_t interval)
 Adds an interval to a system time returning a system time.
static sysinterval_t osalTimeDiffX (systime_t start, systime_t end)
 Subtracts two system times returning an interval.
static bool osalTimeIsInRangeX (systime_t time, systime_t start, systime_t end)
 Checks if the specified time is within the specified time window.
static void osalThreadQueueObjectInit (threads_queue_t *tqp)
 Initializes a threads queue object.
static void osalEventObjectInit (event_source_t *esp)
 Initializes an event source object.
static void osalMutexObjectInit (mutex_t *mp)
 Initializes a mutex_t object.

Variables

const char * osal_halt_msg
 Pointer to a halt error message.

Detailed Description

OSAL module header.

Definition in file osal.h.