ChibiOS/HAL
6.1.0
|
Operating System Abstraction Layer. More...
Operating System Abstraction Layer.
The OSAL is the link between ChibiOS/HAL and services provided by operating systems like:
ChibiOS/HAL is designed to tightly integrate with the underlying RTOS in order to provide the best experience to developers and minimize integration issues.
This section describes the API that OSALs are expected to expose to the HAL.
The OSAL API closely resembles the ChibiOS/RT API, for obvious reasons, however an OSAL module can be implemented for any reasonably complete RTOS or even a RTOS-less bare metal machine, if required.
In order to be able to support an HAL an RTOS should support the following minimal set of features:
All the above requirements can be satisfied even on naked HW with a very think SW layer. In case that the HAL is required to work without an RTOS.
The RTOSes supported out of the box are:
Implementations have also been successfully created on RTOSes not belonging to the ChibiOS products family but are not supported as a core feature of ChibiOS/HAL.
Macros | |
#define | OSAL_DBG_ENABLE_ASSERTS FALSE |
Enables OSAL assertions. More... | |
#define | OSAL_DBG_ENABLE_CHECKS FALSE |
Enables OSAL functions parameters checks. More... | |
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. More... | |
#define | OSAL_ST_FREQUENCY 1000 |
Required systick frequency or resolution. More... | |
#define | OSAL_ST_MODE OSAL_ST_MODE_PERIODIC |
Systick mode required by the underlying OS. More... | |
IRQ-related constants | |
#define | OSAL_IRQ_PRIORITY_LEVELS 16U |
Total priority levels. More... | |
#define | OSAL_IRQ_MAXIMUM_PRIORITY 0U |
Highest IRQ priority for HAL drivers. More... | |
Debug related macros | |
#define | osalDbgAssert(c, remark) |
Condition assertion. More... | |
#define | osalDbgCheck(c) |
Function parameters check. More... | |
#define | osalDbgCheckClassI() |
I-Class state check. More... | |
#define | osalDbgCheckClassS() |
S-Class state check. More... | |
IRQ service routines wrappers | |
#define | OSAL_IRQ_IS_VALID_PRIORITY(n) (((n) >= OSAL_IRQ_MAXIMUM_PRIORITY) && ((n) < OSAL_IRQ_PRIORITY_LEVELS)) |
Priority level verification macro. More... | |
#define | OSAL_IRQ_PROLOGUE() |
IRQ prologue code. More... | |
#define | OSAL_IRQ_EPILOGUE() |
IRQ epilogue code. More... | |
#define | OSAL_IRQ_HANDLER(id) void id(void) |
IRQ handler function declaration. More... | |
Time conversion utilities | |
#define | OSAL_S2I(secs) ((sysinterval_t)((uint32_t)(secs) * (uint32_t)OSAL_ST_FREQUENCY)) |
Seconds to system ticks. More... | |
#define | OSAL_MS2I(msecs) |
Milliseconds to system ticks. More... | |
#define | OSAL_US2I(usecs) |
Microseconds to system ticks. More... | |
Time conversion utilities for the realtime counter | |
#define | OSAL_S2RTC(freq, sec) ((freq) * (sec)) |
Seconds to realtime counter. More... | |
#define | OSAL_MS2RTC(freq, msec) (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec)) |
Milliseconds to realtime counter. More... | |
#define | OSAL_US2RTC(freq, usec) (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec)) |
Microseconds to realtime counter. More... | |
Sleep macros using absolute time | |
#define | osalThreadSleepSeconds(secs) osalThreadSleep(OSAL_S2I(secs)) |
Delays the invoking thread for the specified number of seconds. More... | |
#define | osalThreadSleepMilliseconds(msecs) osalThreadSleep(OSAL_MS2I(msecs)) |
Delays the invoking thread for the specified number of milliseconds. More... | |
#define | osalThreadSleepMicroseconds(usecs) osalThreadSleep(OSAL_US2I(usecs)) |
Delays the invoking thread for the specified number of microseconds. More... | |
Typedefs | |
typedef uint32_t | syssts_t |
Type of a system status word. More... | |
typedef int32_t | msg_t |
Type of a message. More... | |
typedef uint32_t | systime_t |
Type of system time counter. More... | |
typedef uint32_t | sysinterval_t |
Type of system time interval. More... | |
typedef uint32_t | rtcnt_t |
Type of realtime counter. More... | |
typedef void * | thread_reference_t |
Type of a thread reference. More... | |
typedef uint32_t | eventflags_t |
Type of an event flags mask. More... | |
typedef struct event_source | event_source_t |
Type of an event flags object. More... | |
typedef void(* | eventcallback_t) (event_source_t *esp) |
Type of an event source callback. More... | |
typedef uint32_t | mutex_t |
Type of a mutex. More... | |
Data Structures | |
struct | event_source |
Events source object. More... | |
struct | threads_queue_t |
Type of a thread queue. More... | |
Functions | |
void | osalInit (void) |
OSAL module initialization. More... | |
void | osalSysHalt (const char *reason) |
System halt with error message. More... | |
void | osalSysPolledDelayX (rtcnt_t cycles) |
Polled delay. More... | |
void | osalOsTimerHandlerI (void) |
System timer handler. More... | |
void | osalOsRescheduleS (void) |
Checks if a reschedule is required and performs it. More... | |
systime_t | osalOsGetSystemTimeX (void) |
Current system time. More... | |
void | osalThreadSleepS (sysinterval_t time) |
Suspends the invoking thread for the specified time. More... | |
void | osalThreadSleep (sysinterval_t time) |
Suspends the invoking thread for the specified time. More... | |
msg_t | osalThreadSuspendS (thread_reference_t *trp) |
Sends the current thread sleeping and sets a reference variable. More... | |
msg_t | osalThreadSuspendTimeoutS (thread_reference_t *trp, sysinterval_t timeout) |
Sends the current thread sleeping and sets a reference variable. More... | |
void | osalThreadResumeI (thread_reference_t *trp, msg_t msg) |
Wakes up a thread waiting on a thread reference object. More... | |
void | osalThreadResumeS (thread_reference_t *trp, msg_t msg) |
Wakes up a thread waiting on a thread reference object. More... | |
msg_t | osalThreadEnqueueTimeoutS (threads_queue_t *tqp, sysinterval_t timeout) |
Enqueues the caller thread. More... | |
void | osalThreadDequeueNextI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up one thread from the queue, if any. More... | |
void | osalThreadDequeueAllI (threads_queue_t *tqp, msg_t msg) |
Dequeues and wakes up all threads from the queue. More... | |
void | osalEventBroadcastFlagsI (event_source_t *esp, eventflags_t flags) |
Add flags to an event source object. More... | |
void | osalEventBroadcastFlags (event_source_t *esp, eventflags_t flags) |
Add flags to an event source object. More... | |
void | osalEventSetCallback (event_source_t *esp, eventcallback_t cb, void *param) |
Event callback setup. More... | |
void | osalMutexLock (mutex_t *mp) |
Locks the specified mutex. More... | |
void | osalMutexUnlock (mutex_t *mp) |
Unlocks the specified mutex. More... | |
static void | osalSysDisable (void) |
Disables interrupts globally. More... | |
static void | osalSysEnable (void) |
Enables interrupts globally. More... | |
static void | osalSysLock (void) |
Enters a critical zone from thread context. More... | |
static void | osalSysUnlock (void) |
Leaves a critical zone from thread context. More... | |
static void | osalSysLockFromISR (void) |
Enters a critical zone from ISR context. More... | |
static void | osalSysUnlockFromISR (void) |
Leaves a critical zone from ISR context. More... | |
static syssts_t | osalSysGetStatusAndLockX (void) |
Returns the execution status and enters a critical zone. More... | |
static void | osalSysRestoreStatusX (syssts_t sts) |
Restores the specified execution status and leaves a critical zone. More... | |
static systime_t | osalTimeAddX (systime_t systime, sysinterval_t interval) |
Adds an interval to a system time returning a system time. More... | |
static sysinterval_t | osalTimeDiffX (systime_t start, systime_t end) |
Subtracts two system times returning an interval. More... | |
static bool | osalTimeIsInRangeX (systime_t time, systime_t start, systime_t end) |
Checks if the specified time is within the specified time window. More... | |
static void | osalThreadQueueObjectInit (threads_queue_t *tqp) |
Initializes a threads queue object. More... | |
static void | osalEventObjectInit (event_source_t *esp) |
Initializes an event source object. More... | |
static void | osalMutexObjectInit (mutex_t *mp) |
Initializes s mutex_t object. More... | |
Variables | |
const char * | osal_halt_msg |
Pointer to a halt error message. More... | |
const char * | osal_halt_msg |
Pointer to a halt error message. More... | |
#define OSAL_ST_RESOLUTION 32 |
#define OSAL_ST_FREQUENCY 1000 |
#define OSAL_ST_MODE OSAL_ST_MODE_PERIODIC |
#define OSAL_IRQ_PRIORITY_LEVELS 16U |
#define OSAL_IRQ_MAXIMUM_PRIORITY 0U |
#define OSAL_DBG_ENABLE_ASSERTS FALSE |
#define OSAL_DBG_ENABLE_CHECKS FALSE |
#define osalDbgAssert | ( | c, | |
remark | |||
) |
Condition assertion.
If the condition check fails then the OSAL panics with a message and halts.
OSAL_ENABLE_ASSERTIONS
switch is enabled. [in] | c | the condition to be verified to be true |
[in] | remark | a remark string |
Definition at line 258 of file osal.h.
Referenced by _usb_ep0in(), _usb_ep0out(), adcConvert(), adcStart(), adcStartConversionI(), adcStop(), adcStopConversion(), adcStopConversionI(), canReceiveTimeout(), canSleep(), canStart(), canStop(), canTransmitTimeout(), canTryReceiveI(), canTryTransmitI(), canWakeup(), cryDecryptAES(), cryDecryptAES_CBC(), cryDecryptAES_CFB(), cryDecryptAES_CTR(), cryDecryptAES_ECB(), cryDecryptAES_GCM(), cryDecryptDES(), cryDecryptDES_CBC(), cryDecryptDES_ECB(), cryEncryptAES(), cryEncryptAES_CBC(), cryEncryptAES_CFB(), cryEncryptAES_CTR(), cryEncryptAES_ECB(), cryEncryptAES_GCM(), cryEncryptDES(), cryEncryptDES_CBC(), cryEncryptDES_ECB(), crySHA1Final(), crySHA1Init(), crySHA1Update(), crySHA256Final(), crySHA256Init(), crySHA256Update(), crySHA512Final(), crySHA512Init(), crySHA512Update(), cryStart(), cryStop(), cryTRNG(), dacPutChannelX(), dacStart(), dacStartConversionI(), dacStop(), dacStopConversion(), dacStopConversionI(), extChannelDisable(), extChannelEnable(), extSetChannelModeI(), extStart(), extStop(), flashGetSectorOffset(), flashGetSectorSize(), gptChangeInterval(), gptPolledDelay(), gptStart(), gptStartContinuousI(), gptStartOneShotI(), gptStop(), gptStopTimerI(), i2cMasterReceiveTimeout(), i2cMasterTransmitTimeout(), i2cStart(), i2cStop(), i2sStart(), i2sStartExchange(), i2sStop(), i2sStopExchange(), ibqGetFullBufferTimeoutS(), ibqPostFullBufferI(), ibqReleaseEmptyBufferS(), icuDisableNotifications(), icuEnableNotifications(), icuStart(), icuStartCapture(), icuStop(), icuStopCapture(), icuWaitCapture(), macPollLinkStatus(), macStart(), macStop(), macWaitReceiveDescriptor(), macWaitTransmitDescriptor(), mfsStart(), mfsStop(), mmc_cmd6_construct(), mmc_set_bus_width(), mmcConnect(), mmcDisconnect(), mmcStart(), mmcStartSequentialRead(), mmcStartSequentialWrite(), mmcStop(), obqGetEmptyBufferTimeoutS(), obqPostFullBufferS(), obqReleaseEmptyBufferI(), pwmChangePeriod(), pwmDisableChannel(), pwmDisableChannelNotification(), pwmDisablePeriodicNotification(), pwmEnableChannel(), pwmEnableChannelNotification(), pwmEnablePeriodicNotification(), pwmStart(), pwmStop(), qspiCommand(), qspiMapFlash(), qspiReceive(), qspiSend(), qspiStart(), qspiStartCommand(), qspiStartReceive(), qspiStartSend(), qspiStop(), qspiUnmapFlash(), sdc_cmd6_construct(), sdc_lld_set_bus_mode(), sdcConnect(), sdcDisconnect(), sdcErase(), sdcGetAndClearErrors(), sdcRead(), sdcStart(), sdcStop(), sdcWrite(), sdStart(), sdStop(), sduSOFHookI(), sduStart(), sduStop(), spiAbort(), spiAbortI(), spiExchange(), spiIgnore(), spiReceive(), spiSelect(), spiSend(), spiStart(), spiStartExchange(), spiStartIgnore(), spiStartReceive(), spiStartSend(), spiStop(), spiUnselect(), stGetAlarm(), stSetAlarm(), stStartAlarm(), uartReceiveTimeout(), uartSendFullTimeout(), uartSendTimeout(), uartStart(), uartStartReceive(), uartStartReceiveI(), uartStartSend(), uartStartSendI(), uartStop(), uartStopReceive(), uartStopReceiveI(), uartStopSend(), uartStopSendI(), usbDisableEndpointsI(), usbInitEndpointI(), usbStart(), usbStartReceiveI(), usbStartTransmitI(), usbStop(), wdgReset(), wdgStart(), and wdgStop().
#define osalDbgCheck | ( | c | ) |
Function parameters check.
If the condition check fails then the OSAL panics and halts.
OSAL_ENABLE_CHECKS
switch is enabled.[in] | c | the condition to be verified to be true |
Definition at line 278 of file osal.h.
Referenced by _mmcsd_get_capacity(), _mmcsd_get_capacity_ext(), _mmcsd_get_slice(), _mmcsd_unpack_csd_mmc(), _mmcsd_unpack_csd_v10(), _mmcsd_unpack_csd_v20(), _mmcsd_unpack_mmc_cid(), _mmcsd_unpack_sdc_cid(), adcAcquireBus(), adcReleaseBus(), adcStart(), adcStartConversionI(), adcStop(), adcStopConversion(), adcStopConversionI(), canReceiveTimeout(), canSleep(), canStart(), canStop(), canTransmitTimeout(), canTryReceiveI(), canTryTransmitI(), canWakeup(), cryDecryptAES(), cryDecryptAES_CBC(), cryDecryptAES_CFB(), cryDecryptAES_CTR(), cryDecryptAES_ECB(), cryDecryptAES_GCM(), cryDecryptDES(), cryDecryptDES_CBC(), cryDecryptDES_ECB(), cryEncryptAES(), cryEncryptAES_CBC(), cryEncryptAES_CFB(), cryEncryptAES_CTR(), cryEncryptAES_ECB(), cryEncryptAES_GCM(), cryEncryptDES(), cryEncryptDES_CBC(), cryEncryptDES_ECB(), cryLoadTransientKey(), crySHA1Final(), crySHA1Init(), crySHA1Update(), crySHA256Final(), crySHA256Init(), crySHA256Update(), crySHA512Final(), crySHA512Init(), crySHA512Update(), cryStart(), cryStop(), cryTRNG(), dacAcquireBus(), dacPutChannelX(), dacReleaseBus(), dacStart(), dacStartConversionI(), dacStop(), dacStopConversion(), dacStopConversionI(), extChannelDisable(), extChannelEnable(), extSetChannelModeI(), extStart(), extStop(), gptChangeInterval(), gptStart(), gptStartContinuousI(), gptStartOneShotI(), gptStop(), gptStopTimerI(), i2cAcquireBus(), i2cGetErrors(), i2cMasterReceiveTimeout(), i2cMasterTransmitTimeout(), i2cReleaseBus(), i2cStart(), i2cStop(), i2sStart(), i2sStartExchange(), i2sStop(), i2sStopExchange(), ibqObjectInit(), ibqPostFullBufferI(), ibqReadTimeout(), icuDisableNotifications(), icuEnableNotifications(), icuStart(), icuStartCapture(), icuStop(), icuStopCapture(), icuWaitCapture(), iq_read(), iqReadTimeout(), macPollLinkStatus(), macReleaseReceiveDescriptor(), macReleaseTransmitDescriptor(), macStart(), macStop(), macWaitReceiveDescriptor(), macWaitTransmitDescriptor(), mfsErase(), mfsEraseRecord(), mfsObjectInit(), mfsPerformGarbageCollection(), mfsReadRecord(), mfsStart(), mfsStop(), mfsWriteRecord(), mmcConnect(), mmcDisconnect(), mmcErase(), mmcGetInfo(), mmcSequentialRead(), mmcSequentialWrite(), mmcStart(), mmcStartSequentialRead(), mmcStartSequentialWrite(), mmcStop(), mmcStopSequentialRead(), mmcStopSequentialWrite(), mmcSync(), obqObjectInit(), obqPostFullBufferS(), obqWriteTimeout(), oq_write(), oqWriteTimeout(), osalEventBroadcastFlags(), osalEventBroadcastFlagsI(), osalEventObjectInit(), osalEventSetCallback(), osalMutexLock(), osalMutexObjectInit(), osalMutexUnlock(), osalThreadDequeueNextI(), osalThreadEnqueueTimeoutS(), osalThreadQueueObjectInit(), osalThreadResumeI(), osalThreadResumeS(), osalThreadSuspendS(), osalThreadSuspendTimeoutS(), palReadBus(), palSetBusMode(), palWriteBus(), pwmChangePeriod(), pwmDisableChannel(), pwmDisableChannelNotification(), pwmDisablePeriodicNotification(), pwmEnableChannel(), pwmEnableChannelNotification(), pwmEnablePeriodicNotification(), pwmStart(), pwmStop(), qspiAcquireBus(), qspiCommand(), qspiMapFlash(), qspiReceive(), qspiReleaseBus(), qspiSend(), qspiStart(), qspiStartCommand(), qspiStartReceive(), qspiStartSend(), qspiStop(), qspiUnmapFlash(), rtcGetAlarm(), rtcGetTime(), rtcSetAlarm(), rtcSetCallback(), rtcSetTime(), sdcConnect(), sdcDisconnect(), sdcErase(), sdcGetAndClearErrors(), sdcGetInfo(), sdcRead(), sdcStart(), sdcStop(), sdcSync(), sdcWrite(), sdIncomingDataI(), sdRequestDataI(), sdStart(), sdStop(), sduStart(), sduStop(), spiAbortI(), spiAcquireBus(), spiExchange(), spiIgnore(), spiReceive(), spiReleaseBus(), spiSelect(), spiSend(), spiStart(), spiStartExchange(), spiStartIgnore(), spiStartReceive(), spiStartSend(), spiStop(), spiUnselect(), uartAcquireBus(), uartReceiveTimeout(), uartReleaseBus(), uartSendFullTimeout(), uartSendTimeout(), uartStart(), uartStartReceive(), uartStartReceiveI(), uartStartSend(), uartStartSendI(), uartStop(), uartStopReceive(), uartStopReceiveI(), uartStopSend(), uartStopSendI(), usbDisableEndpointsI(), usbInitEndpointI(), usbStallReceiveI(), usbStallTransmitI(), usbStart(), usbStartReceiveI(), usbStartTransmitI(), usbStop(), wdgReset(), wdgStart(), and wdgStop().
#define osalDbgCheckClassI | ( | ) |
I-Class state check.
Definition at line 292 of file osal.h.
Referenced by adcStartConversionI(), adcStopConversionI(), canTryReceiveI(), canTryTransmitI(), dacStartConversionI(), dacStopConversionI(), gptStartContinuousI(), gptStartOneShotI(), gptStopTimerI(), ibqGetEmptyBufferI(), ibqPostFullBufferI(), ibqResetI(), iqGetI(), iqPutI(), iqReadI(), iqResetI(), obqGetFullBufferI(), obqReleaseEmptyBufferI(), obqResetI(), obqTryFlushI(), oqGetI(), oqPutI(), oqResetI(), oqWriteI(), osalOsTimerHandlerI(), sdIncomingDataI(), sdRequestDataI(), spiAbortI(), uartStartReceiveI(), uartStartSendI(), uartStopReceiveI(), uartStopSendI(), usbDisableEndpointsI(), usbInitEndpointI(), usbStallReceiveI(), usbStallTransmitI(), usbStartReceiveI(), and usbStartTransmitI().
#define osalDbgCheckClassS | ( | ) |
S-Class state check.
Definition at line 298 of file osal.h.
Referenced by ibqGetFullBufferTimeoutS(), ibqReleaseEmptyBufferS(), obqGetEmptyBufferTimeoutS(), and obqPostFullBufferS().
#define OSAL_IRQ_IS_VALID_PRIORITY | ( | n | ) | (((n) >= OSAL_IRQ_MAXIMUM_PRIORITY) && ((n) < OSAL_IRQ_PRIORITY_LEVELS)) |
#define OSAL_IRQ_PROLOGUE | ( | ) |
#define OSAL_IRQ_EPILOGUE | ( | ) |
#define OSAL_IRQ_HANDLER | ( | id | ) | void id(void) |
#define OSAL_S2I | ( | secs | ) | ((sysinterval_t)((uint32_t)(secs) * (uint32_t)OSAL_ST_FREQUENCY)) |
Seconds to system ticks.
Converts from seconds to system ticks number.
[in] | secs | number of seconds |
#define OSAL_MS2I | ( | msecs | ) |
Milliseconds to system ticks.
Converts from milliseconds to system ticks number.
[in] | msecs | number of milliseconds |
#define OSAL_US2I | ( | usecs | ) |
Microseconds to system ticks.
Converts from microseconds to system ticks number.
[in] | usecs | number of microseconds |
#define OSAL_S2RTC | ( | freq, | |
sec | |||
) | ((freq) * (sec)) |
Seconds to realtime counter.
Converts from seconds to realtime counter cycles.
freq
>= 1
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | sec | number of seconds |
#define OSAL_MS2RTC | ( | freq, | |
msec | |||
) | (rtcnt_t)((((freq) + 999UL) / 1000UL) * (msec)) |
Milliseconds to realtime counter.
Converts from milliseconds to realtime counter cycles.
freq
>= 1000
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | msec | number of milliseconds |
#define OSAL_US2RTC | ( | freq, | |
usec | |||
) | (rtcnt_t)((((freq) + 999999UL) / 1000000UL) * (usec)) |
Microseconds to realtime counter.
Converts from microseconds to realtime counter cycles.
freq
>= 1000000
.[in] | freq | clock frequency, in Hz, of the realtime counter |
[in] | usec | number of microseconds |
#define osalThreadSleepSeconds | ( | secs | ) | osalThreadSleep(OSAL_S2I(secs)) |
Delays the invoking thread for the specified number of seconds.
[in] | secs | time in seconds, must be different from zero |
#define osalThreadSleepMilliseconds | ( | msecs | ) | osalThreadSleep(OSAL_MS2I(msecs)) |
Delays the invoking thread for the specified number of milliseconds.
[in] | msecs | time in milliseconds, must be different from zero |
Definition at line 451 of file osal.h.
Referenced by _sdc_wait_for_transfer_state(), flashWaitErase(), mmc_init(), mmcConnect(), sdc_init(), sync(), and wait().
#define osalThreadSleepMicroseconds | ( | usecs | ) | osalThreadSleep(OSAL_US2I(usecs)) |
Delays the invoking thread for the specified number of microseconds.
[in] | usecs | time in microseconds, must be different from zero |
typedef uint32_t sysinterval_t |
typedef void* thread_reference_t |
typedef uint32_t eventflags_t |
typedef struct event_source event_source_t |
Type of an event flags object.
typedef void(* eventcallback_t) (event_source_t *esp) |
typedef uint32_t mutex_t |
void osalInit | ( | void | ) |
void osalSysHalt | ( | const char * | reason | ) |
System halt with error message.
[in] | reason | the halt message pointer |
Definition at line 77 of file osal.c.
References osal_halt_msg, and osalSysDisable().
void osalSysPolledDelayX | ( | rtcnt_t | cycles | ) |
void osalOsTimerHandlerI | ( | void | ) |
System timer handler.
The handler is used for scheduling and Virtual Timers management.
Definition at line 105 of file osal.c.
References osalDbgCheckClassI.
void osalOsRescheduleS | ( | void | ) |
Checks if a reschedule is required and performs it.
Definition at line 119 of file osal.c.
Referenced by canSleep(), canStop(), canWakeup(), sdStop(), sduStop(), spiAbort(), and usbStop().
systime_t osalOsGetSystemTimeX | ( | void | ) |
Current system time.
Returns the number of system ticks since the osalInit()
invocation.
systime_t
size.void osalThreadSleepS | ( | sysinterval_t | time | ) |
Suspends the invoking thread for the specified time.
[in] | time | the delay in system ticks, the special values are handled as follow:
|
void osalThreadSleep | ( | sysinterval_t | time | ) |
Suspends the invoking thread for the specified time.
[in] | time | the delay in system ticks, the special values are handled as follow:
|
msg_t osalThreadSuspendS | ( | thread_reference_t * | trp | ) |
Sends the current thread sleeping and sets a reference variable.
[in] | trp | a pointer to a thread reference object |
Definition at line 185 of file osal.c.
References osalDbgCheck.
Referenced by adcConvert(), dacConvert(), qspiCommand(), qspiReceive(), qspiSend(), spiExchange(), spiIgnore(), spiReceive(), spiSend(), usbReceive(), and usbTransmit().
msg_t osalThreadSuspendTimeoutS | ( | thread_reference_t * | trp, |
sysinterval_t | timeout | ||
) |
Sends the current thread sleeping and sets a reference variable.
[in] | trp | a pointer to a thread reference object |
[in] | timeout | the timeout in system ticks, the special values are handled as follow:
|
MSG_TIMEOUT | if the operation timed out. |
Definition at line 211 of file osal.c.
References osalDbgCheck.
Referenced by uartReceiveTimeout(), uartSendFullTimeout(), and uartSendTimeout().
void osalThreadResumeI | ( | thread_reference_t * | trp, |
msg_t | msg | ||
) |
Wakes up a thread waiting on a thread reference object.
[in] | trp | a pointer to a thread reference object |
[in] | msg | the message code |
Definition at line 230 of file osal.c.
References osalDbgCheck.
Referenced by _usb_reset(), _usb_suspend(), spiAbortI(), usbDisableEndpointsI(), and usbStop().
void osalThreadResumeS | ( | thread_reference_t * | trp, |
msg_t | msg | ||
) |
Wakes up a thread waiting on a thread reference object.
[in] | trp | a pointer to a thread reference object |
[in] | msg | the message code |
Definition at line 247 of file osal.c.
References osalDbgCheck.
msg_t osalThreadEnqueueTimeoutS | ( | threads_queue_t * | tqp, |
sysinterval_t | timeout | ||
) |
Enqueues the caller thread.
The caller thread is enqueued and put to sleep until it is dequeued or the specified timeouts expires.
[in] | tqp | pointer to the threads queue object |
[in] | timeout | the timeout in system ticks, the special values are handled as follow:
|
osalQueueWakeupOneI()
or osalQueueWakeupAllI()
functions. MSG_TIMEOUT | if the thread has not been dequeued within the specified timeout or if the function has been invoked with TIME_IMMEDIATE as timeout specification. |
Definition at line 277 of file osal.c.
References osalDbgCheck.
Referenced by canReceiveTimeout(), canTransmitTimeout(), ibqGetFullBufferTimeoutS(), iqGetTimeout(), iqReadTimeout(), macWaitReceiveDescriptor(), macWaitTransmitDescriptor(), obqGetEmptyBufferTimeoutS(), oqPutTimeout(), oqWriteTimeout(), palWaitLineTimeoutS(), and palWaitPadTimeoutS().
void osalThreadDequeueNextI | ( | threads_queue_t * | tqp, |
msg_t | msg | ||
) |
Dequeues and wakes up one thread from the queue, if any.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 294 of file osal.c.
References osalDbgCheck.
Referenced by ibqPostFullBufferI(), iqPutI(), obqReleaseEmptyBufferI(), and oqGetI().
void osalThreadDequeueAllI | ( | threads_queue_t * | tqp, |
msg_t | msg | ||
) |
Dequeues and wakes up all threads from the queue.
[in] | tqp | pointer to the threads queue object |
[in] | msg | the message code |
Definition at line 309 of file osal.c.
Referenced by canStop(), ibqResetI(), iqResetI(), obqResetI(), and oqResetI().
void osalEventBroadcastFlagsI | ( | event_source_t * | esp, |
eventflags_t | flags | ||
) |
Add flags to an event source object.
[in] | esp | pointer to the event flags object |
[in] | flags | flags to be ORed to the flags mask |
Definition at line 323 of file osal.c.
References event_source::cb, event_source::flags, and osalDbgCheck.
Referenced by canSleep(), canWakeup(), and osalEventBroadcastFlags().
void osalEventBroadcastFlags | ( | event_source_t * | esp, |
eventflags_t | flags | ||
) |
Add flags to an event source object.
[in] | esp | pointer to the event flags object |
[in] | flags | flags to be ORed to the flags mask |
Definition at line 341 of file osal.c.
References osalDbgCheck, osalEventBroadcastFlagsI(), osalSysLock(), and osalSysUnlock().
void osalEventSetCallback | ( | event_source_t * | esp, |
eventcallback_t | cb, | ||
void * | param | ||
) |
Event callback setup.
osalEventGetAndClearFlagsI()
. [in] | esp | pointer to the event flags object |
[in] | cb | pointer to the callback function |
[in] | param | parameter to be passed to the callback function |
Definition at line 365 of file osal.c.
References event_source::cb, osalDbgCheck, and event_source::param.
void osalMutexLock | ( | mutex_t * | mp | ) |
Locks the specified mutex.
[in,out] | mp | pointer to the mutex_t object |
Definition at line 384 of file osal.c.
References osalDbgCheck.
Referenced by adcAcquireBus(), dacAcquireBus(), i2cAcquireBus(), qspiAcquireBus(), spiAcquireBus(), and uartAcquireBus().
void osalMutexUnlock | ( | mutex_t * | mp | ) |
Unlocks the specified mutex.
mp
parameter which is supplied in order to support those OSes not supporting a stack of the owned mutexes.[in,out] | mp | pointer to the mutex_t object |
Definition at line 404 of file osal.c.
References osalDbgCheck.
Referenced by adcReleaseBus(), dacReleaseBus(), i2cReleaseBus(), qspiReleaseBus(), spiReleaseBus(), and uartReleaseBus().
|
inlinestatic |
Disables interrupts globally.
Definition at line 511 of file osal.h.
Referenced by osalSysHalt().
|
inlinestatic |
|
inlinestatic |
Enters a critical zone from thread context.
Definition at line 530 of file osal.h.
Referenced by adcConvert(), adcStart(), adcStartConversion(), adcStop(), adcStopConversion(), canReceiveTimeout(), canSleep(), canStart(), canStop(), canTransmitTimeout(), canWakeup(), cryStart(), cryStop(), dacConvert(), dacStart(), dacStartConversion(), dacStop(), dacStopConversion(), extChannelDisable(), extChannelEnable(), extStart(), extStop(), gptChangeInterval(), gptStart(), gptStartContinuous(), gptStartOneShot(), gptStop(), gptStopTimer(), i2cMasterReceiveTimeout(), i2cMasterTransmitTimeout(), i2cStart(), i2cStop(), i2sStart(), i2sStartExchange(), i2sStop(), i2sStopExchange(), ibqGetFullBufferTimeout(), ibqGetTimeout(), ibqReadTimeout(), ibqReleaseEmptyBuffer(), icuDisableNotifications(), icuEnableNotifications(), icuStart(), icuStartCapture(), icuStop(), icuStopCapture(), icuWaitCapture(), iqGetTimeout(), iqReadTimeout(), macStart(), macStop(), macWaitReceiveDescriptor(), macWaitTransmitDescriptor(), mmcDisconnect(), obqFlush(), obqGetEmptyBufferTimeout(), obqPostFullBuffer(), obqPutTimeout(), obqWriteTimeout(), oqPutTimeout(), oqWriteTimeout(), osalEventBroadcastFlags(), palWaitLineTimeout(), palWaitPadTimeout(), pwmChangePeriod(), pwmDisableChannel(), pwmDisableChannelNotification(), pwmDisablePeriodicNotification(), pwmEnableChannel(), pwmEnableChannelNotification(), pwmEnablePeriodicNotification(), pwmStart(), pwmStop(), qspiCommand(), qspiMapFlash(), qspiReceive(), qspiSend(), qspiStart(), qspiStartCommand(), qspiStartReceive(), qspiStartSend(), qspiStop(), qspiUnmapFlash(), sdcDisconnect(), sdcGetAndClearErrors(), sdcStart(), sdcStop(), sdGetWouldBlock(), sdPutWouldBlock(), sdStart(), sdStop(), sduStart(), sduStop(), spiAbort(), spiExchange(), spiIgnore(), spiReceive(), spiSelect(), spiSend(), spiStart(), spiStartExchange(), spiStartIgnore(), spiStartReceive(), spiStartSend(), spiStop(), spiUnselect(), uartReceiveTimeout(), uartSendFullTimeout(), uartSendTimeout(), uartStart(), uartStartReceive(), uartStartSend(), uartStop(), uartStopReceive(), uartStopSend(), usbReceive(), usbStart(), usbStop(), usbTransmit(), wdgReset(), wdgStart(), and wdgStop().
|
inlinestatic |
Leaves a critical zone from thread context.
Definition at line 540 of file osal.h.
Referenced by adcConvert(), adcStart(), adcStartConversion(), adcStop(), adcStopConversion(), canReceiveTimeout(), canSleep(), canStart(), canStop(), canTransmitTimeout(), canWakeup(), cryStart(), cryStop(), dacConvert(), dacStart(), dacStartConversion(), dacStop(), dacStopConversion(), extChannelDisable(), extChannelEnable(), extStart(), extStop(), gptChangeInterval(), gptStart(), gptStartContinuous(), gptStartOneShot(), gptStop(), gptStopTimer(), i2cMasterReceiveTimeout(), i2cMasterTransmitTimeout(), i2cStart(), i2cStop(), i2sStart(), i2sStartExchange(), i2sStop(), i2sStopExchange(), ibqGetFullBufferTimeout(), ibqGetTimeout(), ibqReadTimeout(), ibqReleaseEmptyBuffer(), icuDisableNotifications(), icuEnableNotifications(), icuStart(), icuStartCapture(), icuStop(), icuStopCapture(), icuWaitCapture(), iqGetTimeout(), iqReadTimeout(), macStart(), macStop(), macWaitReceiveDescriptor(), macWaitTransmitDescriptor(), mmcDisconnect(), obqFlush(), obqGetEmptyBufferTimeout(), obqPostFullBuffer(), obqPutTimeout(), obqWriteTimeout(), oqPutTimeout(), oqWriteTimeout(), osalEventBroadcastFlags(), palWaitLineTimeout(), palWaitPadTimeout(), pwmChangePeriod(), pwmDisableChannel(), pwmDisableChannelNotification(), pwmDisablePeriodicNotification(), pwmEnableChannel(), pwmEnableChannelNotification(), pwmEnablePeriodicNotification(), pwmStart(), pwmStop(), qspiCommand(), qspiMapFlash(), qspiReceive(), qspiSend(), qspiStart(), qspiStartCommand(), qspiStartReceive(), qspiStartSend(), qspiStop(), qspiUnmapFlash(), sdcDisconnect(), sdcGetAndClearErrors(), sdcStart(), sdcStop(), sdGetWouldBlock(), sdPutWouldBlock(), sdStart(), sdStop(), sduStart(), sduStop(), spiAbort(), spiExchange(), spiIgnore(), spiReceive(), spiSelect(), spiSend(), spiStart(), spiStartExchange(), spiStartIgnore(), spiStartReceive(), spiStartSend(), spiStop(), spiUnselect(), uartReceiveTimeout(), uartSendFullTimeout(), uartSendTimeout(), uartStart(), uartStartReceive(), uartStartSend(), uartStop(), uartStopReceive(), uartStopSend(), usbReceive(), usbStart(), usbStop(), usbTransmit(), wdgReset(), wdgStart(), and wdgStop().
|
inlinestatic |
Enters a critical zone from ISR context.
Definition at line 550 of file osal.h.
Referenced by _usb_ep0in(), _usb_ep0out(), _usb_ep0setup(), _usb_reset(), _usb_suspend(), default_handler(), sduDataReceived(), and sduDataTransmitted().
|
inlinestatic |
Leaves a critical zone from ISR context.
Definition at line 560 of file osal.h.
Referenced by _usb_ep0in(), _usb_ep0out(), _usb_ep0setup(), _usb_reset(), _usb_suspend(), default_handler(), sduDataReceived(), and sduDataTransmitted().
|
inlinestatic |
Returns the execution status and enters a critical zone.
This functions enters into a critical zone and can be called from any context. Because its flexibility it is less efficient than chSysLock()
which is preferable when the calling context is known.
|
inlinestatic |
Restores the specified execution status and leaves a critical zone.
chSchRescheduleS()
is automatically performed if exiting the critical zone and if not in ISR context.[in] | sts | the system status to be restored. |
|
inlinestatic |
|
inlinestatic |
Checks if the specified time is within the specified time window.
[in] | time | the time to be verified |
[in] | start | the start of the time window (inclusive) |
[in] | end | the end of the time window (non inclusive) |
true | current time within the specified time window. |
false | current time not within the specified time window. |
|
inlinestatic |
Initializes a threads queue object.
[out] | tqp | pointer to the threads queue object |
Definition at line 653 of file osal.h.
References osalDbgCheck.
Referenced by canObjectInit(), ibqObjectInit(), iqObjectInit(), macObjectInit(), obqObjectInit(), and oqObjectInit().
|
inlinestatic |
Initializes an event source object.
[out] | esp | pointer to the event source object |
Definition at line 665 of file osal.h.
References event_source::cb, event_source::flags, osalDbgCheck, and event_source::param.
Referenced by canObjectInit(), macObjectInit(), sdObjectInit(), and sduObjectInit().
|
inlinestatic |
Initializes s mutex_t
object.
[out] | mp | pointer to the mutex_t object |
Definition at line 681 of file osal.h.
References osalDbgCheck.
Referenced by adcObjectInit(), dacObjectInit(), i2cObjectInit(), qspiObjectInit(), spiObjectInit(), and uartObjectInit().
const char* osal_halt_msg |
Pointer to a halt error message.
Definition at line 40 of file osal.c.
Referenced by osalSysHalt().
const char* osal_halt_msg |
Pointer to a halt error message.
Definition at line 40 of file osal.c.
Referenced by osalSysHalt().