ChibiOS  0.0.0
Collaboration diagram for API:

Detailed Description

Macros

#define _CHIBIOS_NIL_
 ChibiOS/NIL identification macro. More...
 
#define CH_KERNEL_STABLE   0
 Stable release flag. More...
 
#define CH_CFG_USE_FACTORY   TRUE
 Objects Factory APIs. More...
 
#define CH_CFG_FACTORY_MAX_NAMES_LENGTH   8
 Maximum length for object names. More...
 
#define CH_CFG_FACTORY_OBJECTS_REGISTRY   TRUE
 Enables the registry of generic objects. More...
 
#define CH_CFG_FACTORY_GENERIC_BUFFERS   TRUE
 Enables factory for generic buffers. More...
 
#define CH_CFG_FACTORY_SEMAPHORES   TRUE
 Enables factory for semaphores. More...
 
#define CH_CFG_FACTORY_MAILBOXES   TRUE
 Enables factory for mailboxes. More...
 
#define CH_CFG_FACTORY_OBJ_FIFOS   TRUE
 Enables factory for objects FIFOs. More...
 
#define THD_IDLE_BASE   (&__main_thread_stack_base__)
 
#define __CH_STRINGIFY(a)   #a
 Utility to make the parameter a quoted string. More...
 

ChibiOS/NIL version identification

#define CH_KERNEL_VERSION   "3.0.0"
 Kernel version string. More...
 
#define CH_KERNEL_MAJOR   3
 Kernel version major number. More...
 
#define CH_KERNEL_MINOR   0
 Kernel version minor number. More...
 
#define CH_KERNEL_PATCH   0
 Kernel version patch number. More...
 

Constants for configuration options

#define FALSE   0
 Generic 'false' preprocessor boolean constant. More...
 
#define TRUE   1
 Generic 'true' preprocessor boolean constant. More...
 

Wakeup messages

#define MSG_OK   (msg_t)0
 OK wakeup message. More...
 
#define MSG_TIMEOUT   (msg_t)-1
 Wake-up caused by a timeout condition. More...
 
#define MSG_RESET   (msg_t)-2
 Wake-up caused by a reset condition. More...
 

Special time constants

#define TIME_IMMEDIATE   ((sysinterval_t)-1)
 Zero time specification for some functions with a timeout specification. More...
 
#define TIME_INFINITE   ((sysinterval_t)0)
 Infinite time specification for all functions with a timeout specification. More...
 
#define TIME_MAX_INTERVAL   ((sysinterval_t)-2)
 Maximum interval constant usable as timeout. More...
 
#define TIME_MAX_SYSTIME   ((systime_t)-1)
 Maximum system of system time before it wraps. More...
 

Thread state related macros

#define NIL_STATE_READY   (tstate_t)0
 Thread ready or executing. More...
 
#define NIL_STATE_SLEEPING   (tstate_t)1
 Thread sleeping. More...
 
#define NIL_STATE_SUSP   (tstate_t)2
 Thread suspended. More...
 
#define NIL_STATE_WTQUEUE   (tstate_t)3
 On queue or semaph. More...
 
#define NIL_STATE_WTOREVT   (tstate_t)4
 Waiting for events. More...
 
#define NIL_THD_IS_READY(tr)   ((tr)->state == NIL_STATE_READY)
 
#define NIL_THD_IS_SLEEPING(tr)   ((tr)->state == NIL_STATE_SLEEPING)
 
#define NIL_THD_IS_SUSP(tr)   ((tr)->state == NIL_STATE_SUSP)
 
#define NIL_THD_IS_WTQUEUE(tr)   ((tr)->state == NIL_STATE_WTQUEUE)
 
#define NIL_THD_IS_WTOREVT(tr)   ((tr)->state == NIL_STATE_WTOREVT)
 

Events related macros

#define ALL_EVENTS   ((eventmask_t)-1)
 All events allowed mask. More...
 
#define EVENT_MASK(eid)   ((eventmask_t)(1 << (eid)))
 Returns an event mask from an event identifier. More...
 

Threads tables definition macros

#define THD_TABLE_BEGIN   const thread_config_t nil_thd_configs[CH_CFG_NUM_THREADS + 1] = {
 Start of user threads table. More...
 
#define THD_TABLE_ENTRY(wap, name, funcp, arg)
 Entry of user threads table. More...
 
#define THD_TABLE_END
 End of user threads table. More...
 

Memory alignment support macros

#define MEM_ALIGN_MASK(a)   ((size_t)(a) - 1U)
 Alignment mask constant. More...
 
#define MEM_ALIGN_PREV(p, a)   ((size_t)(p) & ~MEM_ALIGN_MASK(a))
 Aligns to the previous aligned memory address. More...
 
#define MEM_ALIGN_NEXT(p, a)
 Aligns to the new aligned memory address. More...
 
#define MEM_IS_ALIGNED(p, a)   (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)
 Returns whatever a pointer or memory size is aligned. More...
 
#define MEM_IS_VALID_ALIGNMENT(a)   (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))
 Returns whatever a constant is a valid alignment. More...
 

Working Areas

#define THD_WORKING_AREA_SIZE(n)
 Calculates the total Working Area size. More...
 
#define THD_WORKING_AREA(s, n)   PORT_WORKING_AREA(s, n)
 Static working area allocation. More...
 

Threads abstraction macros

#define THD_FUNCTION(tname, arg)   PORT_THD_FUNCTION(tname, arg)
 Thread declaration macro. More...
 

ISRs abstraction macros

#define CH_IRQ_IS_VALID_PRIORITY(prio)   PORT_IRQ_IS_VALID_PRIORITY(prio)
 Priority level validation macro. More...
 
#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio)   PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio)
 Priority level validation macro. More...
 
#define CH_IRQ_PROLOGUE()
 IRQ handler enter code. More...
 
#define CH_IRQ_EPILOGUE()
 IRQ handler exit code. More...
 
#define CH_IRQ_HANDLER(id)   PORT_IRQ_HANDLER(id)
 Standard normal IRQ handler declaration. More...
 

Fast ISRs abstraction macros

#define CH_FAST_IRQ_HANDLER(id)   PORT_FAST_IRQ_HANDLER(id)
 Standard fast IRQ handler declaration. More...
 

Time conversion utilities

#define TIME_S2I(secs)   ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY))
 Seconds to time interval. More...
 
#define TIME_MS2I(msecs)
 Milliseconds to time interval. More...
 
#define TIME_US2I(usecs)
 Microseconds to time interval. More...
 
#define TIME_I2S(interval)
 Time interval to seconds. More...
 
#define TIME_I2MS(interval)
 Time interval to milliseconds. More...
 
#define TIME_I2US(interval)
 Time interval to microseconds. More...
 

Threads queues

#define _THREADS_QUEUE_DATA(name)   {(cnt_t)0}
 Data part of a static threads queue object initializer. More...
 
#define _THREADS_QUEUE_DECL(name)   threads_queue_t name = _THREADS_QUEUE_DATA(name)
 Static threads queue object initializer. More...
 

Semaphores macros

#define _SEMAPHORE_DATA(name, n)   {n}
 Data part of a static semaphore initializer. More...
 
#define SEMAPHORE_DECL(name, n)   semaphore_t name = _SEMAPHORE_DATA(name, n)
 Static semaphore initializer. More...
 

Macro Functions

#define chSysGetRealtimeCounterX()   (rtcnt_t)port_rt_get_counter_value()
 Returns the current value of the system real time counter. More...
 
#define chSysDisable()
 Raises the system interrupt priority mask to the maximum level. More...
 
#define chSysSuspend()
 Raises the system interrupt priority mask to system level. More...
 
#define chSysEnable()
 Lowers the system interrupt priority mask to user level. More...
 
#define chSysLock()
 Enters the kernel lock state. More...
 
#define chSysUnlock()
 Leaves the kernel lock state. More...
 
#define chSysLockFromISR()
 Enters the kernel lock state from within an interrupt handler. More...
 
#define chSysUnlockFromISR()
 Leaves the kernel lock state from within an interrupt handler. More...
 
#define chSchIsRescRequiredI()   ((bool)(nil.current != nil.next))
 Evaluates if a reschedule is required. More...
 
#define chThdGetSelfX()   nil.current
 Returns a pointer to the current thread_t. More...
 
#define chThdSleepSeconds(secs)   chThdSleep(TIME_S2I(secs))
 Delays the invoking thread for the specified number of seconds. More...
 
#define chThdSleepMilliseconds(msecs)   chThdSleep(TIME_MS2I(msecs))
 Delays the invoking thread for the specified number of milliseconds. More...
 
#define chThdSleepMicroseconds(usecs)   chThdSleep(TIME_US2I(usecs))
 Delays the invoking thread for the specified number of microseconds. More...
 
#define chThdSleepS(timeout)   (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
 Suspends the invoking thread for the specified time. More...
 
#define chThdSleepUntilS(abstime)
 Suspends the invoking thread until the system time arrives to the specified value. More...
 
#define chThdQueueObjectInit(tqp)   ((tqp)->cnt = (cnt_t)0)
 Initializes a threads queue object. More...
 
#define chThdQueueIsEmptyI(tqp)   ((bool)(tqp->cnt >= (cnt_t)0))
 Evaluates to true if the specified queue is empty. More...
 
#define chSemObjectInit(sp, n)   ((sp)->cnt = n)
 Initializes a semaphore with the specified counter value. More...
 
#define chSemWait(sp)   chSemWaitTimeout(sp, TIME_INFINITE)
 Performs a wait operation on a semaphore. More...
 
#define chSemWaitS(sp)   chSemWaitTimeoutS(sp, TIME_INFINITE)
 Performs a wait operation on a semaphore. More...
 
#define chSemFastWaitI(sp)   ((sp)->cnt--)
 Decreases the semaphore counter. More...
 
#define chSemFastSignalI(sp)   ((sp)->cnt++)
 Increases the semaphore counter. More...
 
#define chSemGetCounterI(sp)   ((sp)->cnt)
 Returns the semaphore counter current value. More...
 
#define chVTGetSystemTimeX()   (nil.systime)
 Current system time. More...
 
#define chVTTimeElapsedSinceX(start)   chTimeDiffX((start), chVTGetSystemTimeX())
 Returns the elapsed time since the specified start time. More...
 
#define chTimeAddX(systime, interval)   ((systime_t)(systime) + (systime_t)(interval))
 Adds an interval to a system time returning a system time. More...
 
#define chTimeDiffX(start, end)   ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start))))
 Subtracts two system times returning an interval. More...
 
#define chTimeIsInRangeX(time, start, end)
 Checks if the specified time is within the specified time range. More...
 
#define chDbgCheck(c)
 Function parameters check. More...
 
#define chDbgAssert(c, r)
 Condition assertion. More...
 

Typedefs

typedef uint32_t systime_t
 Type of system time. More...
 
typedef uint32_t sysinterval_t
 Type of time interval. More...
 
typedef uint64_t time_conv_t
 Type of time conversion variable. More...
 
typedef struct nil_thread thread_t
 Type of a structure representing a thread. More...
 
typedef struct nil_threads_queue threads_queue_t
 Type of a queue of threads. More...
 
typedef threads_queue_t semaphore_t
 Type of a structure representing a semaphore. More...
 
typedef void(* tfunc_t) (void *p)
 Thread function. More...
 
typedef struct nil_thread_cfg thread_config_t
 Type of a structure representing a thread static configuration. More...
 
typedef thread_tthread_reference_t
 Type of a thread reference. More...
 
typedef struct nil_system nil_system_t
 Type of a structure representing the system. More...
 

Data Structures

struct  nil_threads_queue
 Structure representing a queue of threads. More...
 
struct  nil_thread_cfg
 Structure representing a thread static configuration. More...
 
struct  nil_thread
 Structure representing a thread. More...
 
struct  nil_system
 System data structure. More...
 

Functions

void _dbg_check_disable (void)
 Guard code for chSysDisable(). More...
 
void _dbg_check_suspend (void)
 Guard code for chSysSuspend(). More...
 
void _dbg_check_enable (void)
 Guard code for chSysEnable(). More...
 
void _dbg_check_lock (void)
 Guard code for chSysLock(). More...
 
void _dbg_check_unlock (void)
 Guard code for chSysUnlock(). More...
 
void _dbg_check_lock_from_isr (void)
 Guard code for chSysLockFromIsr(). More...
 
void _dbg_check_unlock_from_isr (void)
 Guard code for chSysUnlockFromIsr(). More...
 
void _dbg_check_enter_isr (void)
 Guard code for CH_IRQ_PROLOGUE(). More...
 
void _dbg_check_leave_isr (void)
 Guard code for CH_IRQ_EPILOGUE(). More...
 
void chDbgCheckClassI (void)
 I-class functions context check. More...
 
void chDbgCheckClassS (void)
 S-class functions context check. More...
 
void chSysInit (void)
 Initializes the kernel. More...
 
void chSysHalt (const char *reason)
 Halts the system. More...
 
void chSysTimerHandlerI (void)
 Time management handler. More...
 
void chSysUnconditionalLock (void)
 Unconditionally enters the kernel lock state. More...
 
void chSysUnconditionalUnlock (void)
 Unconditionally leaves the kernel lock state. More...
 
syssts_t chSysGetStatusAndLockX (void)
 Returns the execution status and enters a critical zone. More...
 
void chSysRestoreStatusX (syssts_t sts)
 Restores the specified execution status and leaves a critical zone. More...
 
bool chSysIsCounterWithinX (rtcnt_t cnt, rtcnt_t start, rtcnt_t end)
 Realtime window test. More...
 
void chSysPolledDelayX (rtcnt_t cycles)
 Polled delay. More...
 
thread_tchSchReadyI (thread_t *tp, msg_t msg)
 Makes the specified thread ready for execution. More...
 
bool chSchIsPreemptionRequired (void)
 Evaluates if preemption is required. More...
 
void chSchDoReschedule (void)
 Switches to the first thread on the runnable queue. More...
 
void chSchRescheduleS (void)
 Reschedules if needed. More...
 
msg_t chSchGoSleepTimeoutS (tstate_t newstate, sysinterval_t timeout)
 Puts the current thread to sleep into the specified state with timeout specification. More...
 
msg_t chThdSuspendTimeoutS (thread_reference_t *trp, sysinterval_t timeout)
 Sends the current thread sleeping and sets a reference variable. More...
 
void chThdResumeI (thread_reference_t *trp, msg_t msg)
 Wakes up a thread waiting on a thread reference object. More...
 
void chThdSleep (sysinterval_t timeout)
 Suspends the invoking thread for the specified time. More...
 
void chThdSleepUntil (systime_t abstime)
 Suspends the invoking thread until the system time arrives to the specified value. More...
 
msg_t chThdEnqueueTimeoutS (threads_queue_t *tqp, sysinterval_t timeout)
 Enqueues the caller thread on a threads queue object. More...
 
void chThdDoDequeueNextI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up one thread from the threads queue object. More...
 
void chThdDequeueNextI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up one thread from the threads queue object, if any. More...
 
void chThdDequeueAllI (threads_queue_t *tqp, msg_t msg)
 Dequeues and wakes up all threads from the threads queue object. More...
 
msg_t chSemWaitTimeout (semaphore_t *sp, sysinterval_t timeout)
 Performs a wait operation on a semaphore with timeout specification. More...
 
msg_t chSemWaitTimeoutS (semaphore_t *sp, sysinterval_t timeout)
 Performs a wait operation on a semaphore with timeout specification. More...
 
void chSemSignal (semaphore_t *sp)
 Performs a signal operation on a semaphore. More...
 
void chSemSignalI (semaphore_t *sp)
 Performs a signal operation on a semaphore. More...
 
void chSemReset (semaphore_t *sp, cnt_t n)
 Performs a reset operation on the semaphore. More...
 
void chSemResetI (semaphore_t *sp, cnt_t n)
 Performs a reset operation on the semaphore. More...
 
void chEvtSignal (thread_t *tp, eventmask_t mask)
 Adds a set of event flags directly to the specified thread_t. More...
 
void chEvtSignalI (thread_t *tp, eventmask_t mask)
 Adds a set of event flags directly to the specified thread_t. More...
 
eventmask_t chEvtWaitAnyTimeout (eventmask_t mask, sysinterval_t timeout)
 Waits for any of the specified events. More...
 

Variables

nil_system_t nil
 System data structures. More...
 

Macro Definition Documentation

#define _CHIBIOS_NIL_

ChibiOS/NIL identification macro.

Definition at line 44 of file nil/include/ch.h.

#define CH_KERNEL_STABLE   0

Stable release flag.

Definition at line 49 of file nil/include/ch.h.

#define CH_KERNEL_VERSION   "3.0.0"

Kernel version string.

Definition at line 58 of file nil/include/ch.h.

#define CH_KERNEL_MAJOR   3

Kernel version major number.

Definition at line 63 of file nil/include/ch.h.

#define CH_KERNEL_MINOR   0

Kernel version minor number.

Definition at line 68 of file nil/include/ch.h.

#define CH_KERNEL_PATCH   0

Kernel version patch number.

Definition at line 73 of file nil/include/ch.h.

#define FALSE   0

Generic 'false' preprocessor boolean constant.

Note
It is meant to be used in configuration files as switch.

Definition at line 84 of file nil/include/ch.h.

#define TRUE   1

Generic 'true' preprocessor boolean constant.

Note
It is meant to be used in configuration files as switch.

Definition at line 92 of file nil/include/ch.h.

#define MSG_OK   (msg_t)0

OK wakeup message.

Definition at line 100 of file nil/include/ch.h.

#define MSG_TIMEOUT   (msg_t)-1

Wake-up caused by a timeout condition.

Definition at line 101 of file nil/include/ch.h.

#define MSG_RESET   (msg_t)-2

Wake-up caused by a reset condition.

Definition at line 104 of file nil/include/ch.h.

#define TIME_IMMEDIATE   ((sysinterval_t)-1)

Zero time specification for some functions with a timeout specification.

Note
Not all functions accept TIME_IMMEDIATE as timeout parameter, see the specific function documentation.

Definition at line 119 of file nil/include/ch.h.

#define TIME_INFINITE   ((sysinterval_t)0)

Infinite time specification for all functions with a timeout specification.

Definition at line 125 of file nil/include/ch.h.

#define TIME_MAX_INTERVAL   ((sysinterval_t)-2)

Maximum interval constant usable as timeout.

Definition at line 130 of file nil/include/ch.h.

#define TIME_MAX_SYSTIME   ((systime_t)-1)

Maximum system of system time before it wraps.

Definition at line 135 of file nil/include/ch.h.

#define NIL_STATE_READY   (tstate_t)0

Thread ready or executing.

Definition at line 142 of file nil/include/ch.h.

Referenced by chSchReadyI().

#define NIL_STATE_SLEEPING   (tstate_t)1

Thread sleeping.

Definition at line 145 of file nil/include/ch.h.

#define NIL_STATE_SUSP   (tstate_t)2

Thread suspended.

Definition at line 146 of file nil/include/ch.h.

Referenced by chThdSuspendTimeoutS().

#define NIL_STATE_WTQUEUE   (tstate_t)3

On queue or semaph.

Definition at line 147 of file nil/include/ch.h.

Referenced by chSemWaitTimeoutS(), and chThdEnqueueTimeoutS().

#define NIL_STATE_WTOREVT   (tstate_t)4

Waiting for events.

Definition at line 148 of file nil/include/ch.h.

Referenced by chEvtWaitAnyTimeout().

#define ALL_EVENTS   ((eventmask_t)-1)

All events allowed mask.

Definition at line 163 of file nil/include/ch.h.

#define EVENT_MASK (   eid)    ((eventmask_t)(1 << (eid)))

Returns an event mask from an event identifier.

Definition at line 168 of file nil/include/ch.h.

#define CH_CFG_USE_FACTORY   TRUE

Objects Factory APIs.

If enabled then the objects factory APIs are included in the kernel.

Note
The default is FALSE.

Definition at line 297 of file nil/include/ch.h.

#define CH_CFG_FACTORY_MAX_NAMES_LENGTH   8

Maximum length for object names.

If the specified length is zero then the name is stored by pointer but this could have unintended side effects.

Definition at line 306 of file nil/include/ch.h.

#define CH_CFG_FACTORY_OBJECTS_REGISTRY   TRUE

Enables the registry of generic objects.

Definition at line 313 of file nil/include/ch.h.

#define CH_CFG_FACTORY_GENERIC_BUFFERS   TRUE

Enables factory for generic buffers.

Definition at line 320 of file nil/include/ch.h.

#define CH_CFG_FACTORY_SEMAPHORES   TRUE

Enables factory for semaphores.

Definition at line 327 of file nil/include/ch.h.

#define CH_CFG_FACTORY_MAILBOXES   TRUE

Enables factory for mailboxes.

Definition at line 334 of file nil/include/ch.h.

#define CH_CFG_FACTORY_OBJ_FIFOS   TRUE

Enables factory for objects FIFOs.

Definition at line 341 of file nil/include/ch.h.

#define THD_IDLE_BASE   (&__main_thread_stack_base__)

Boundaries of the idle thread boundaries, only required if stack checking is enabled.

Definition at line 545 of file nil/include/ch.h.

Referenced by chSysInit().

#define __CH_STRINGIFY (   a)    #a

Utility to make the parameter a quoted string.

Definition at line 744 of file nil/include/ch.h.

#define THD_TABLE_BEGIN   const thread_config_t nil_thd_configs[CH_CFG_NUM_THREADS + 1] = {

Start of user threads table.

Definition at line 753 of file nil/include/ch.h.

#define THD_TABLE_ENTRY (   wap,
  name,
  funcp,
  arg 
)
Value:
{wap, ((stkalign_t *)(wap)) + (sizeof (wap) / sizeof(stkalign_t)), \
name, funcp, arg},
uint64_t stkalign_t
Type of stack and memory alignment enforcement.
Definition: chcore.h:156

Entry of user threads table.

Definition at line 759 of file nil/include/ch.h.

#define THD_TABLE_END
Value:
{THD_IDLE_BASE, THD_IDLE_END, "idle", NULL, NULL} \
};
#define THD_IDLE_BASE

End of user threads table.

Definition at line 766 of file nil/include/ch.h.

#define MEM_ALIGN_MASK (   a)    ((size_t)(a) - 1U)

Alignment mask constant.

Parameters
[in]aalignment, must be a power of two

Definition at line 779 of file nil/include/ch.h.

#define MEM_ALIGN_PREV (   p,
 
)    ((size_t)(p) & ~MEM_ALIGN_MASK(a))

Aligns to the previous aligned memory address.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 787 of file nil/include/ch.h.

#define MEM_ALIGN_NEXT (   p,
 
)
Value:
MEM_ALIGN_PREV((size_t)(p) + \
MEM_ALIGN_MASK(a), (a))
#define MEM_ALIGN_MASK(a)
Alignment mask constant.
#define MEM_ALIGN_PREV(p, a)
Aligns to the previous aligned memory address.

Aligns to the new aligned memory address.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 795 of file nil/include/ch.h.

#define MEM_IS_ALIGNED (   p,
 
)    (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)

Returns whatever a pointer or memory size is aligned.

Parameters
[in]pvariable to be aligned
[in]aalignment, must be a power of two

Definition at line 804 of file nil/include/ch.h.

#define MEM_IS_VALID_ALIGNMENT (   a)    (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))

Returns whatever a constant is a valid alignment.

Valid alignments are powers of two.

Parameters
[in]aalignment to be checked, must be a constant

Definition at line 812 of file nil/include/ch.h.

#define THD_WORKING_AREA_SIZE (   n)
Value:
#define PORT_WA_SIZE(n)
Computes the thread working area global size.
Definition: chcore.h:207
#define PORT_STACK_ALIGN
Stack alignment constant.
Definition: chcore.h:56
#define MEM_ALIGN_NEXT(p, a)
Aligns to the new aligned memory address.

Calculates the total Working Area size.

Parameters
[in]nthe stack size to be assigned to the thread
Returns
The total used memory in bytes.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 827 of file nil/include/ch.h.

#define THD_WORKING_AREA (   s,
 
)    PORT_WORKING_AREA(s, n)

Static working area allocation.

This macro is used to allocate a static thread working area aligned as both position and size.

Parameters
[in]sthe name to be assigned to the stack array
[in]nthe stack size to be assigned to the thread
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 840 of file nil/include/ch.h.

#define THD_FUNCTION (   tname,
  arg 
)    PORT_THD_FUNCTION(tname, arg)

Thread declaration macro.

Note
Thread declarations should be performed using this macro because the port layer could define optimizations for thread functions.

Definition at line 851 of file nil/include/ch.h.

#define CH_IRQ_IS_VALID_PRIORITY (   prio)    PORT_IRQ_IS_VALID_PRIORITY(prio)

Priority level validation macro.

This macro determines if the passed value is a valid priority level for the underlying architecture.

Parameters
[in]priothe priority level
Returns
Priority range result.
Return values
falseif the priority is invalid or if the architecture does not support priorities.
trueif the priority is valid.

Definition at line 869 of file nil/include/ch.h.

#define CH_IRQ_IS_VALID_KERNEL_PRIORITY (   prio)    PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio)

Priority level validation macro.

This macro determines if the passed value is a valid priority level that cannot preempt the kernel critical zone.

Parameters
[in]priothe priority level
Returns
Priority range result.
Return values
falseif the priority is invalid or if the architecture does not support priorities.
trueif the priority is valid.

Definition at line 887 of file nil/include/ch.h.

#define CH_IRQ_PROLOGUE ( )
Value:
_dbg_check_enter_isr()
#define PORT_IRQ_PROLOGUE()
IRQ prologue code.
Definition: chcore.h:237

IRQ handler enter code.

Note
Usually IRQ handlers functions are also declared naked.
On some architectures this macro can be empty.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 900 of file nil/include/ch.h.

#define CH_IRQ_EPILOGUE ( )
Value:
_dbg_check_leave_isr(); \
#define PORT_IRQ_EPILOGUE()
IRQ epilogue code.
Definition: chcore.h:244

IRQ handler exit code.

Note
Usually IRQ handlers function are also declared naked.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 910 of file nil/include/ch.h.

#define CH_IRQ_HANDLER (   id)    PORT_IRQ_HANDLER(id)

Standard normal IRQ handler declaration.

Note
id can be a function name or a vector number depending on the port implementation.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 921 of file nil/include/ch.h.

#define CH_FAST_IRQ_HANDLER (   id)    PORT_FAST_IRQ_HANDLER(id)

Standard fast IRQ handler declaration.

Note
id can be a function name or a vector number depending on the port implementation.
Not all architectures support fast interrupts.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 935 of file nil/include/ch.h.

#define TIME_S2I (   secs)    ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY))

Seconds to time interval.

Converts from seconds to system ticks number.

Note
The result is rounded upward to the next tick boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]secsnumber of seconds
Returns
The number of ticks.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 955 of file nil/include/ch.h.

#define TIME_MS2I (   msecs)
Value:
((sysinterval_t)((((time_conv_t)(msecs) * \
(time_conv_t)CH_CFG_ST_FREQUENCY) + \
(time_conv_t)999) / (time_conv_t)1000))
uint64_t time_conv_t
Type of time conversion variable.
Definition: chtime.h:150
uint32_t sysinterval_t
Type of time interval.
uint64_t time_conv_t
Type of time conversion variable.

Milliseconds to time interval.

Converts from milliseconds to system ticks number.

Note
The result is rounded upward to the next tick boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]msecsnumber of milliseconds
Returns
The number of ticks.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 971 of file nil/include/ch.h.

#define TIME_US2I (   usecs)
Value:
((sysinterval_t)((((time_conv_t)(usecs) * \
(time_conv_t)CH_CFG_ST_FREQUENCY) + \
(time_conv_t)999999) / (time_conv_t)1000000))
uint64_t time_conv_t
Type of time conversion variable.
Definition: chtime.h:150
uint32_t sysinterval_t
Type of time interval.
uint64_t time_conv_t
Type of time conversion variable.

Microseconds to time interval.

Converts from microseconds to system ticks number.

Note
The result is rounded upward to the next tick boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]usecsnumber of microseconds
Returns
The number of ticks.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 989 of file nil/include/ch.h.

#define TIME_I2S (   interval)
Value:
(time_secs_t)(((time_conv_t)(interval) + \
(time_conv_t)CH_CFG_ST_FREQUENCY - \
(time_conv_t)1) / (time_conv_t)CH_CFG_ST_FREQUENCY)
uint32_t time_secs_t
Type of seconds.
Definition: chtime.h:131
uint64_t time_conv_t
Type of time conversion variable.
Definition: chtime.h:150
uint64_t time_conv_t
Type of time conversion variable.

Time interval to seconds.

Converts from system ticks number to seconds.

Note
The result is rounded up to the next second boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]intervalinterval in ticks
Returns
The number of seconds.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1007 of file nil/include/ch.h.

#define TIME_I2MS (   interval)
Value:
(time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \
(time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
(time_conv_t)CH_CFG_ST_FREQUENCY)
uint64_t time_conv_t
Type of time conversion variable.
Definition: chtime.h:150
uint32_t time_msecs_t
Type of milliseconds.
Definition: chtime.h:137
uint64_t time_conv_t
Type of time conversion variable.

Time interval to milliseconds.

Converts from system ticks number to milliseconds.

Note
The result is rounded up to the next millisecond boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]intervalinterval in ticks
Returns
The number of milliseconds.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1025 of file nil/include/ch.h.

#define TIME_I2US (   interval)
Value:
(time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \
(time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
(time_conv_t)CH_CFG_ST_FREQUENCY)
uint64_t time_conv_t
Type of time conversion variable.
Definition: chtime.h:150
uint32_t time_msecs_t
Type of milliseconds.
Definition: chtime.h:137
uint64_t time_conv_t
Type of time conversion variable.

Time interval to microseconds.

Converts from system ticks number to microseconds.

Note
The result is rounded up to the next microsecond boundary.
Use of this macro for large values is not secure because integer overflows, make sure your value can be correctly converted.
Parameters
[in]intervalinterval in ticks
Returns
The number of microseconds.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1043 of file nil/include/ch.h.

#define _THREADS_QUEUE_DATA (   name)    {(cnt_t)0}

Data part of a static threads queue object initializer.

This macro should be used when statically initializing a threads queue that is part of a bigger structure.

Parameters
[in]namethe name of the threads queue variable

Definition at line 1059 of file nil/include/ch.h.

#define _THREADS_QUEUE_DECL (   name)    threads_queue_t name = _THREADS_QUEUE_DATA(name)

Static threads queue object initializer.

Statically initialized threads queues require no explicit initialization using queue_init().

Parameters
[in]namethe name of the threads queue variable

Definition at line 1068 of file nil/include/ch.h.

#define _SEMAPHORE_DATA (   name,
 
)    {n}

Data part of a static semaphore initializer.

This macro should be used when statically initializing a semaphore that is part of a bigger structure.

Parameters
[in]namethe name of the semaphore variable
[in]nthe counter initial value, this value must be non-negative

Definition at line 1085 of file nil/include/ch.h.

#define SEMAPHORE_DECL (   name,
 
)    semaphore_t name = _SEMAPHORE_DATA(name, n)

Static semaphore initializer.

Statically initialized semaphores require no explicit initialization using chSemInit().

Parameters
[in]namethe name of the semaphore variable
[in]nthe counter initial value, this value must be non-negative

Definition at line 1096 of file nil/include/ch.h.

#define chSysGetRealtimeCounterX ( )    (rtcnt_t)port_rt_get_counter_value()

Returns the current value of the system real time counter.

Note
This function is only available if the port layer supports the option PORT_SUPPORTS_RT.
Returns
The value of the system realtime counter of type rtcnt_t.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 1114 of file nil/include/ch.h.

#define chSysDisable (   void)
Value:
{ \
_dbg_check_disable(); \
}
static void port_disable(void)
Disables all the interrupt sources.
Definition: chcore.h:388

Raises the system interrupt priority mask to the maximum level.

All the maskable interrupt sources are disabled regardless their hardware priority.

Note
Do not invoke this API from within a kernel lock.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 1125 of file nil/include/ch.h.

#define chSysSuspend (   void)
Value:
{ \
_dbg_check_suspend(); \
}
static void port_suspend(void)
Disables the interrupt sources below kernel-level priority.
Definition: chcore.h:396

Raises the system interrupt priority mask to system level.

The interrupt sources that should not be able to preempt the kernel are disabled, interrupt sources with higher priority are still enabled.

Note
Do not invoke this API from within a kernel lock.
This API is no replacement for chSysLock(), the chSysLock() could do more than just disable the interrupts.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 1141 of file nil/include/ch.h.

Referenced by chSysInit().

#define chSysEnable (   void)
Value:
{ \
_dbg_check_enable(); \
}
static void port_enable(void)
Enables all the interrupt sources.
Definition: chcore.h:403

Lowers the system interrupt priority mask to user level.

All the interrupt sources are enabled.

Note
Do not invoke this API from within a kernel lock.
This API is no replacement for chSysUnlock(), the chSysUnlock() could do more than just enable the interrupts.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 1155 of file nil/include/ch.h.

Referenced by chSysInit().

#define chSysLock (   void)
Value:
{ \
_dbg_check_lock(); \
}
static void port_lock(void)
Kernel-lock action.
Definition: chcore.h:351

Enters the kernel lock state.

Function Class:Special function, this function has special requirements see the notes.

Definition at line 1165 of file nil/include/ch.h.

Referenced by chBSemSignal(), chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAllocAligned(), chCoreAllocAlignedWithOffset(), chDbgResumeTrace(), chDbgSuspendTrace(), chDbgWriteTrace(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMaskWithFlags(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chMsgRelease(), chMsgSend(), chMsgWait(), chMtxLock(), chMtxTryLock(), chMtxUnlock(), chMtxUnlockAll(), chPipeReset(), chPoolAlloc(), chPoolFree(), chRegFirstThread(), chRegNextThread(), chSemReset(), chSemSignal(), chSemSignalWait(), chSemWait(), chSemWaitTimeout(), chSysGetStatusAndLockX(), chSysUnconditionalLock(), chThdAddRef(), chThdCreate(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), chThdCreateSuspended(), chThdExit(), chThdRelease(), chThdResume(), chThdSetPriority(), chThdSleep(), chThdSleepUntil(), chThdSleepUntilWindowed(), chThdStart(), chThdTerminate(), chThdWait(), chThdYield(), chVTGetSystemTime(), chVTIsArmed(), chVTReset(), and chVTSet().

#define chSysUnlock (   void)
Value:
{ \
_dbg_check_unlock(); \
}
static void port_unlock(void)
Kernel-unlock action.
Definition: chcore.h:360

Leaves the kernel lock state.

Function Class:Special function, this function has special requirements see the notes.

Definition at line 1175 of file nil/include/ch.h.

Referenced by chBSemSignal(), chCondBroadcast(), chCondSignal(), chCondWait(), chCondWaitTimeout(), chCoreAllocAligned(), chCoreAllocAlignedWithOffset(), chDbgResumeTrace(), chDbgSuspendTrace(), chDbgWriteTrace(), chEvtAddEvents(), chEvtBroadcastFlags(), chEvtGetAndClearEvents(), chEvtGetAndClearFlags(), chEvtRegisterMaskWithFlags(), chEvtSignal(), chEvtUnregister(), chEvtWaitAll(), chEvtWaitAllTimeout(), chEvtWaitAny(), chEvtWaitAnyTimeout(), chEvtWaitOne(), chEvtWaitOneTimeout(), chGuardedPoolAllocTimeout(), chGuardedPoolFree(), chMBFetchTimeout(), chMBPostAheadTimeout(), chMBPostTimeout(), chMBReset(), chMsgRelease(), chMsgSend(), chMsgWait(), chMtxLock(), chMtxTryLock(), chMtxUnlock(), chMtxUnlockAll(), chPipeReset(), chPoolAlloc(), chPoolFree(), chRegFirstThread(), chRegNextThread(), chSemReset(), chSemSignal(), chSemSignalWait(), chSemWait(), chSemWaitTimeout(), chSysInit(), chSysRestoreStatusX(), chSysUnconditionalUnlock(), chThdAddRef(), chThdCreate(), chThdCreateFromHeap(), chThdCreateFromMemoryPool(), chThdCreateStatic(), chThdCreateSuspended(), chThdRelease(), chThdResume(), chThdSetPriority(), chThdSleep(), chThdSleepUntil(), chThdSleepUntilWindowed(), chThdStart(), chThdTerminate(), chThdWait(), chThdYield(), chVTGetSystemTime(), chVTIsArmed(), chVTReset(), and chVTSet().

#define chSysLockFromISR (   void)
Value:
{ \
_dbg_check_lock_from_isr(); \
}
static void port_lock_from_isr(void)
Kernel-lock action from an interrupt handler.
Definition: chcore.h:370

Enters the kernel lock state from within an interrupt handler.

Note
This API may do nothing on some architectures, it is required because on ports that support preemptable interrupt handlers it is required to raise the interrupt mask to the same level of the system mutual exclusion zone.
It is good practice to invoke this API before invoking any I-class syscall from an interrupt handler.
This API must be invoked exclusively from interrupt handlers.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 1192 of file nil/include/ch.h.

Referenced by chSchGoSleepS(), chSysGetStatusAndLockX(), chSysTimerHandlerI(), and chVTDoTickI().

#define chSysUnlockFromISR (   void)
Value:
{ \
_dbg_check_unlock_from_isr(); \
}
static void port_unlock_from_isr(void)
Kernel-unlock action from an interrupt handler.
Definition: chcore.h:380

Leaves the kernel lock state from within an interrupt handler.

Note
This API may do nothing on some architectures, it is required because on ports that support preemptable interrupt handlers it is required to raise the interrupt mask to the same level of the system mutual exclusion zone.
It is good practice to invoke this API after invoking any I-class syscall from an interrupt handler.
This API must be invoked exclusively from interrupt handlers.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 1210 of file nil/include/ch.h.

Referenced by chSchGoSleepS(), chSysRestoreStatusX(), chSysTimerHandlerI(), and chVTDoTickI().

#define chSchIsRescRequiredI (   void)    ((bool)(nil.current != nil.next))

Evaluates if a reschedule is required.

Return values
trueif there is a thread that must go in running state immediately.
falseif preemption is not required.
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1224 of file nil/include/ch.h.

Referenced by chSchIsPreemptionRequired(), and chSchRescheduleS().

#define chThdGetSelfX (   void)    nil.current

Returns a pointer to the current thread_t.

Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 1231 of file nil/include/ch.h.

Referenced by chMtxGetNextMutexX(), chThdSuspendS(), and chThdSuspendTimeoutS().

#define chThdSleepSeconds (   secs)    chThdSleep(TIME_S2I(secs))

Delays the invoking thread for the specified number of seconds.

Note
The specified time is rounded up to a value allowed by the real system clock.
The maximum specified value is implementation dependent.
Parameters
[in]secstime in seconds, must be different from zero
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1243 of file nil/include/ch.h.

#define chThdSleepMilliseconds (   msecs)    chThdSleep(TIME_MS2I(msecs))

Delays the invoking thread for the specified number of milliseconds.

Note
The specified time is rounded up to a value allowed by the real system clock.
The maximum specified value is implementation dependent.
Parameters
[in]msecstime in milliseconds, must be different from zero
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1256 of file nil/include/ch.h.

#define chThdSleepMicroseconds (   usecs)    chThdSleep(TIME_US2I(usecs))

Delays the invoking thread for the specified number of microseconds.

Note
The specified time is rounded up to a value allowed by the real system clock.
The maximum specified value is implementation dependent.
Parameters
[in]usecstime in microseconds, must be different from zero
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1269 of file nil/include/ch.h.

#define chThdSleepS (   timeout)    (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)

Suspends the invoking thread for the specified time.

Parameters
[in]timeoutthe delay in system ticks
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1278 of file nil/include/ch.h.

Referenced by chThdSleep(), chThdSleepUntil(), and chThdSleepUntilWindowed().

#define chThdSleepUntilS (   abstime)
Value:
#define chTimeDiffX(start, end)
Subtracts two system times returning an interval.
#define NIL_STATE_SLEEPING
Thread sleeping.
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
Definition: chschd.c:375
#define chVTGetSystemTimeX()
Current system time.

Suspends the invoking thread until the system time arrives to the specified value.

Parameters
[in]abstimeabsolute system time
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1289 of file nil/include/ch.h.

Referenced by chThdSleepUntil().

#define chThdQueueObjectInit (   tqp)    ((tqp)->cnt = (cnt_t)0)

Initializes a threads queue object.

Parameters
[out]tqppointer to the threads queue object
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 1300 of file nil/include/ch.h.

Referenced by chMBObjectInit(), and chPipeObjectInit().

#define chThdQueueIsEmptyI (   tqp)    ((bool)(tqp->cnt >= (cnt_t)0))

Evaluates to true if the specified queue is empty.

Parameters
[out]tqppointer to the threads queue object
Returns
The queue status.
Return values
falseif the queue is not empty.
trueif the queue is empty.
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1312 of file nil/include/ch.h.

#define chSemObjectInit (   sp,
 
)    ((sp)->cnt = n)

Initializes a semaphore with the specified counter value.

Parameters
[out]sppointer to a semaphore_t structure
[in]ninitial value of the semaphore counter. Must be non-negative.
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 1324 of file nil/include/ch.h.

#define chSemWait (   sp)    chSemWaitTimeout(sp, TIME_INFINITE)

Performs a wait operation on a semaphore.

Parameters
[in]sppointer to a semaphore_t structure
Returns
A message specifying how the invoking thread has been released from the semaphore.
Return values
CH_MSG_OKif the thread has not stopped on the semaphore or the semaphore has been signaled.
CH_MSG_RSTif the semaphore has been reset using chSemReset().
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1338 of file nil/include/ch.h.

#define chSemWaitS (   sp)    chSemWaitTimeoutS(sp, TIME_INFINITE)

Performs a wait operation on a semaphore.

Parameters
[in]sppointer to a semaphore_t structure
Returns
A message specifying how the invoking thread has been released from the semaphore.
Return values
CH_MSG_OKif the thread has not stopped on the semaphore or the semaphore has been signaled.
CH_MSG_RSTif the semaphore has been reset using chSemReset().
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 1352 of file nil/include/ch.h.

#define chSemFastWaitI (   sp)    ((sp)->cnt--)

Decreases the semaphore counter.

This macro can be used when the counter is known to be positive.

Parameters
[in]sppointer to a semaphore_t structure
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1362 of file nil/include/ch.h.

Referenced by chGuardedPoolAllocI().

#define chSemFastSignalI (   sp)    ((sp)->cnt++)

Increases the semaphore counter.

This macro can be used when the counter is known to be not negative.

Parameters
[in]sppointer to a semaphore_t structure
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1373 of file nil/include/ch.h.

Referenced by chSchGoSleepS().

#define chSemGetCounterI (   sp)    ((sp)->cnt)

Returns the semaphore counter current value.

Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1380 of file nil/include/ch.h.

Referenced by chGuardedPoolAllocI().

#define chVTGetSystemTimeX (   void)    (nil.systime)

Current system time.

Returns the number of system ticks since the chSysInit() invocation.

Note
The counter can reach its maximum and then restart from zero.
This function can be called from any context but its atomicity is not guaranteed on architectures whose word size is less than systime_t size.
Returns
The system time in ticks.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 1397 of file nil/include/ch.h.

Referenced by chSchGoSleepTimeoutS(), chThdSleepUntil(), chThdSleepUntilWindowed(), chVTDoResetI(), chVTDoSetI(), and trace_next().

#define chVTTimeElapsedSinceX (   start)    chTimeDiffX((start), chVTGetSystemTimeX())

Returns the elapsed time since the specified start time.

Parameters
[in]startstart time
Returns
The elapsed time.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 1410 of file nil/include/ch.h.

#define chTimeAddX (   systime,
  interval 
)    ((systime_t)(systime) + (systime_t)(interval))

Adds an interval to a system time returning a system time.

Parameters
[in]systimebase system time
[in]intervalinterval to be added
Returns
The new system time.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 1422 of file nil/include/ch.h.

Referenced by chSchGoSleepTimeoutS(), chSysTimerHandlerI(), chVTDoResetI(), chVTDoSetI(), chVTDoTickI(), and chVTGetTimersStateI().

#define chTimeDiffX (   start,
  end 
)    ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start))))

Subtracts two system times returning an interval.

Parameters
[in]startfirst system time
[in]endsecond system time
Returns
The interval representing the time difference.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 1434 of file nil/include/ch.h.

Referenced by chSysTimerHandlerI(), chThdSleepUntil(), chThdSleepUntilWindowed(), chVTDoResetI(), chVTDoSetI(), chVTDoTickI(), chVTGetTimersStateI(), and chVTTimeElapsedSinceX().

#define chTimeIsInRangeX (   time,
  start,
  end 
)
Value:
((bool)((systime_t)((systime_t)(time) - (systime_t)(start)) < \
(systime_t)((systime_t)(end) - (systime_t)(start))))
uint64_t systime_t
Type of system time.
Definition: chtime.h:107
uint32_t systime_t
Type of system time.

Checks if the specified time is within the specified time range.

Note
When start==end then the function returns always true because the whole time range is specified.
Parameters
[in]timethe time to be verified
[in]startthe start of the time window (inclusive)
[in]endthe end of the time window (non inclusive)
Return values
truecurrent time within the specified time window.
falsecurrent time not within the specified time window.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 1450 of file nil/include/ch.h.

Referenced by chSchGoSleepTimeoutS(), chThdSleepUntilWindowed(), chVTIsSystemTimeWithin(), and chVTIsSystemTimeWithinX().

#define chDbgCheck (   c)
Value:
do { \
/*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
if (CH_DBG_ENABLE_CHECKS != FALSE) { \
if (!(c)) { \
/*lint -restore*/ \
chSysHalt(__func__); \
} \
} \
} while (false)
#define FALSE
Generic &#39;false&#39; preprocessor boolean constant.
void chSysHalt(const char *reason)
Halts the system.
Definition: chsys.c:198

Function parameters check.

If the condition check fails then the kernel panics and halts.

Note
The condition is tested only if the CH_DBG_ENABLE_CHECKS switch is specified in chconf.h else the macro does nothing.
Parameters
[in]cthe condition to be verified to be true
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1465 of file nil/include/ch.h.

#define chDbgAssert (   c,
 
)
Value:
do { \
/*lint -save -e506 -e774 [2.1, 14.3] Can be a constant by design.*/ \
if (CH_DBG_ENABLE_ASSERTS != FALSE) { \
if (!(c)) { \
/*lint -restore*/ \
chSysHalt(__func__); \
} \
} \
} while (false)
#define FALSE
Generic &#39;false&#39; preprocessor boolean constant.
void chSysHalt(const char *reason)
Halts the system.
Definition: chsys.c:198

Condition assertion.

If the condition check fails then the kernel panics with a message and halts.

Note
The condition is tested only if the CH_DBG_ENABLE_ASSERTS switch is specified in chconf.h else the macro does nothing.
The remark string is not currently used except for putting a comment in the code about the assertion.
Parameters
[in]cthe condition to be verified to be true
[in]ra remark string
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1491 of file nil/include/ch.h.

Typedef Documentation

typedef uint32_t systime_t

Type of system time.

Note
It is selectable in configuration between 16 or 32 bits.

Definition at line 561 of file nil/include/ch.h.

typedef uint32_t sysinterval_t

Type of time interval.

Note
It is selectable in configuration between 16 or 32 bits.

Definition at line 567 of file nil/include/ch.h.

typedef uint64_t time_conv_t

Type of time conversion variable.

Note
This type must have double width than other time types, it is only used internally for conversions.

Definition at line 574 of file nil/include/ch.h.

typedef struct nil_thread thread_t

Type of a structure representing a thread.

Note
It is required as an early definition.

Definition at line 586 of file nil/include/ch.h.

Type of a queue of threads.

Definition at line 600 of file nil/include/ch.h.

Type of a structure representing a semaphore.

Note
Semaphores are implemented on thread queues, the object is the same, the behavior is slightly different.

Definition at line 608 of file nil/include/ch.h.

typedef void(* tfunc_t) (void *p)

Thread function.

Definition at line 614 of file nil/include/ch.h.

Type of a structure representing a thread static configuration.

Definition at line 619 of file nil/include/ch.h.

Type of a thread reference.

Definition at line 635 of file nil/include/ch.h.

typedef struct nil_system nil_system_t

Type of a structure representing the system.

Definition at line 672 of file nil/include/ch.h.

Function Documentation

void _dbg_check_disable ( void  )

Guard code for chSysDisable().

Function Class:Not an API, this function is for internal use only.

Definition at line 65 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Here is the call graph for this function:

void _dbg_check_suspend ( void  )

Guard code for chSysSuspend().

Function Class:Not an API, this function is for internal use only.

Definition at line 77 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Here is the call graph for this function:

void _dbg_check_enable ( void  )

Guard code for chSysEnable().

Function Class:Not an API, this function is for internal use only.

Definition at line 89 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Here is the call graph for this function:

void _dbg_check_lock ( void  )

Guard code for chSysLock().

Function Class:Not an API, this function is for internal use only.

Definition at line 101 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Here is the call graph for this function:

void _dbg_check_unlock ( void  )

Guard code for chSysUnlock().

Function Class:Not an API, this function is for internal use only.

Definition at line 114 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Here is the call graph for this function:

void _dbg_check_lock_from_isr ( void  )

Guard code for chSysLockFromIsr().

Function Class:Not an API, this function is for internal use only.

Definition at line 127 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Here is the call graph for this function:

void _dbg_check_unlock_from_isr ( void  )

Guard code for chSysUnlockFromIsr().

Function Class:Not an API, this function is for internal use only.

Definition at line 140 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Here is the call graph for this function:

void _dbg_check_enter_isr ( void  )

Guard code for CH_IRQ_PROLOGUE().

Function Class:Not an API, this function is for internal use only.

Definition at line 153 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, nil_system::lock_cnt, port_lock_from_isr(), and port_unlock_from_isr().

Here is the call graph for this function:

void _dbg_check_leave_isr ( void  )

Guard code for CH_IRQ_EPILOGUE().

Function Class:Not an API, this function is for internal use only.

Definition at line 168 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, nil_system::lock_cnt, port_lock_from_isr(), and port_unlock_from_isr().

Here is the call graph for this function:

void chDbgCheckClassI ( void  )

I-class functions context check.

Verifies that the system is in an appropriate state for invoking an I-class API function. A panic is generated if the state is not compatible.

Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 186 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Referenced by chEvtSignalI(), chSchReadyI(), chSemResetI(), chSemSignalI(), chSysTimerHandlerI(), chThdDequeueAllI(), and chThdDequeueNextI().

Here is the call graph for this function:

void chDbgCheckClassS ( void  )

S-class functions context check.

Verifies that the system is in an appropriate state for invoking an S-class API function. A panic is generated if the state is not compatible.

Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 201 of file ch.c.

References chSysHalt(), nil_system::isr_cnt, and nil_system::lock_cnt.

Referenced by chSchGoSleepTimeoutS(), chSchRescheduleS(), chSemWaitTimeoutS(), and chThdEnqueueTimeoutS().

Here is the call graph for this function:

void chSysInit ( void  )

Initializes the kernel.

Initializes the kernel structures, the current instructions flow becomes the idle thread upon return. The idle thread must not invoke any kernel primitive able to change state to not runnable.

Note
This function assumes that the nil global variable has been zeroed by the runtime environment. If this is not the case then make sure to clear it before calling this function.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 220 of file ch.c.

References _core_init(), _factory_init(), _heap_init(), nil_thread_cfg::arg, CH_CFG_NUM_THREADS, CH_CFG_SYSTEM_INIT_HOOK, CH_CFG_THREAD_EXT_INIT_HOOK, chSysSuspend, chSysUnlock, nil_system::current, nil_thread_cfg::funcp, nil_system::isr_cnt, nil_system::lock_cnt, nil_system::next, PORT_SETUP_CONTEXT, port_switch, THD_IDLE_BASE, nil_system::threads, ch_thread::wabase, nil_thread_cfg::wbase, and nil_thread_cfg::wend.

Here is the call graph for this function:

void chSysHalt ( const char *  reason)

Halts the system.

This function is invoked by the operating system when an unrecoverable error is detected, for example because a programming error in the application code that triggers an assertion while in debug mode.

Note
Can be invoked from any system state.
Parameters
[in]reasonpointer to an error string
Function Class:Special function, this function has special requirements see the notes.

Definition at line 301 of file ch.c.

References _trace_halt(), ch, CH_CFG_SYSTEM_HALT_HOOK, ch_system::dbg, nil_system::dbg_panic_msg, ch_system_debug::panic_msg, and port_disable().

Referenced by _dbg_check_disable(), _dbg_check_enable(), _dbg_check_enter_isr(), _dbg_check_leave_isr(), _dbg_check_lock(), _dbg_check_lock_from_isr(), _dbg_check_suspend(), _dbg_check_unlock(), _dbg_check_unlock_from_isr(), chDbgCheckClassI(), and chDbgCheckClassS().

Here is the call graph for this function:

void chSysTimerHandlerI ( void  )

Time management handler.

Note
This handler has to be invoked by a periodic ISR in order to reschedule the waiting threads.
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 326 of file ch.c.

References CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheckClassI(), chSchReadyI(), chSysLockFromISR, chSysUnlockFromISR, chTimeAddX, chTimeDiffX, nil_system::lasttime, MSG_TIMEOUT, nil_system::nexttime, nil_system::systime, and nil_system::threads.

Here is the call graph for this function:

void chSysUnconditionalLock ( void  )

Unconditionally enters the kernel lock state.

Note
Can be called without previous knowledge of the current lock state. The final state is "s-locked".
Function Class:Special function, this function has special requirements see the notes.

Definition at line 426 of file ch.c.

References chSysLock, port_get_irq_status(), and port_irq_enabled().

Here is the call graph for this function:

void chSysUnconditionalUnlock ( void  )

Unconditionally leaves the kernel lock state.

Note
Can be called without previous knowledge of the current lock state. The final state is "normal".
Function Class:Special function, this function has special requirements see the notes.

Definition at line 440 of file ch.c.

References chSysUnlock, port_get_irq_status(), and port_irq_enabled().

Here is the call graph for this function:

syssts_t chSysGetStatusAndLockX ( void  )

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.

Postcondition
The system is in a critical zone.
Returns
The previous system status, the encoding of this status word is architecture-dependent and opaque.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 460 of file ch.c.

References chSysLock, chSysLockFromISR, port_get_irq_status(), port_irq_enabled(), and port_is_isr_context().

Here is the call graph for this function:

void chSysRestoreStatusX ( syssts_t  sts)

Restores the specified execution status and leaves a critical zone.

Note
A call to chSchRescheduleS() is automatically performed if exiting the critical zone and if not in ISR context.
Parameters
[in]ststhe system status to be restored.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 483 of file ch.c.

References chSchRescheduleS(), chSysUnlock, chSysUnlockFromISR, port_irq_enabled(), and port_is_isr_context().

Here is the call graph for this function:

bool chSysIsCounterWithinX ( rtcnt_t  cnt,
rtcnt_t  start,
rtcnt_t  end 
)

Realtime window test.

This function verifies if the current realtime counter value lies within the specified range or not. The test takes care of the realtime counter wrapping to zero on overflow.

Note
When start==end then the function returns always true because the whole time range is specified.
This function is only available if the port layer supports the option PORT_SUPPORTS_RT.
Parameters
[in]cntthe counter value to be tested
[in]startthe start of the time window (inclusive)
[in]endthe end of the time window (non inclusive)
Return values
truecurrent time within the specified time window.
falsecurrent time not within the specified time window.
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 515 of file ch.c.

Referenced by chSysPolledDelayX().

void chSysPolledDelayX ( rtcnt_t  cycles)

Polled delay.

Note
The real delay is always few cycles in excess of the specified value.
This function is only available if the port layer supports the option PORT_SUPPORTS_RT.
Parameters
[in]cyclesnumber of cycles
Function Class:This is an X-Class API, this function can be invoked from any context.

Definition at line 531 of file ch.c.

References chSysGetRealtimeCounterX, and chSysIsCounterWithinX().

Here is the call graph for this function:

thread_t * chSchReadyI ( thread_t tp,
msg_t  msg 
)

Makes the specified thread ready for execution.

Parameters
[in]tppointer to the thread_t object
[in]msgthe wakeup message
Returns
The same reference passed as parameter.

Definition at line 548 of file ch.c.

References CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheck, chDbgCheckClassI(), nil_system::current, nil_system::next, NIL_STATE_READY, ch_thread::state, and nil_system::threads.

Referenced by chEvtSignalI(), chSemResetI(), chSemSignalI(), chSysTimerHandlerI(), chThdDequeueAllI(), chThdDoDequeueNextI(), and chThdResumeI().

Here is the call graph for this function:

bool chSchIsPreemptionRequired ( void  )

Evaluates if preemption is required.

The decision is taken by comparing the relative priorities and depending on the state of the round robin timeout counter.

Note
Not a user function, it is meant to be invoked by the scheduler itself or from within the port layer.
Return values
trueif there is a thread that must go in running state immediately.
falseif preemption is not required.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 577 of file ch.c.

References chSchIsRescRequiredI.

void chSchDoReschedule ( void  )

Switches to the first thread on the runnable queue.

Note
Not a user function, it is meant to be invoked by the scheduler itself or from within the port layer.
Function Class:Special function, this function has special requirements see the notes.

Definition at line 589 of file ch.c.

References CH_CFG_IDLE_LEAVE_HOOK, CH_CFG_NUM_THREADS, nil_system::current, nil_system::next, port_switch, and nil_system::threads.

Referenced by chSchRescheduleS().

void chSchRescheduleS ( void  )

Reschedules if needed.

Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 604 of file ch.c.

References chDbgCheckClassS(), chSchDoReschedule(), and chSchIsRescRequiredI.

Referenced by chEvtSignal(), chSemReset(), chSemSignal(), and chSysRestoreStatusX().

Here is the call graph for this function:

msg_t chSchGoSleepTimeoutS ( tstate_t  newstate,
sysinterval_t  timeout 
)

Puts the current thread to sleep into the specified state with timeout specification.

The thread goes into a sleeping state, if it is not awakened explicitly within the specified system time then it is forcibly awakened with a NIL_MSG_TMO low level message.

Parameters
[in]newstatethe new thread state or a semaphore pointer
[in]timeoutthe number of ticks before the operation timeouts. the following special values are allowed:
  • TIME_INFINITE no timeout.
Returns
The wakeup message.
Return values
NIL_MSG_TMOif a timeout occurred.
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 630 of file ch.c.

References CH_CFG_IDLE_ENTER_HOOK, CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheckClassS(), chTimeAddX, chTimeIsInRangeX, chVTGetSystemTimeX, nil_system::current, nil_system::lasttime, nil_system::next, nil_system::nexttime, port_switch, ch_thread::state, nil_system::threads, and TIME_INFINITE.

Referenced by chEvtWaitAnyTimeout(), chSemWaitTimeoutS(), chThdEnqueueTimeoutS(), and chThdSuspendTimeoutS().

Here is the call graph for this function:

msg_t chThdSuspendTimeoutS ( thread_reference_t trp,
sysinterval_t  timeout 
)

Sends the current thread sleeping and sets a reference variable.

Note
This function must reschedule, it can only be called from thread context.
Parameters
[in]trpa pointer to a thread reference object
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_INFINITE no timeout.
Returns
The wake up message.
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 711 of file ch.c.

References chDbgAssert, chSchGoSleepTimeoutS(), nil_system::current, and NIL_STATE_SUSP.

Here is the call graph for this function:

void chThdResumeI ( thread_reference_t trp,
msg_t  msg 
)

Wakes up a thread waiting on a thread reference object.

Note
This function must not reschedule because it can be called from ISR context.
Parameters
[in]trpa pointer to a thread reference object
[in]msgthe message code
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 730 of file ch.c.

References chDbgAssert, and chSchReadyI().

Here is the call graph for this function:

void chThdSleep ( sysinterval_t  timeout)

Suspends the invoking thread for the specified time.

Parameters
[in]timeoutthe delay in system ticks
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 749 of file ch.c.

References chSysLock, chSysUnlock, and chThdSleepS.

void chThdSleepUntil ( systime_t  abstime)

Suspends the invoking thread until the system time arrives to the specified value.

Parameters
[in]abstimeabsolute system time
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 764 of file ch.c.

References chSysLock, chSysUnlock, and chThdSleepUntilS.

msg_t chThdEnqueueTimeoutS ( threads_queue_t tqp,
sysinterval_t  timeout 
)

Enqueues the caller thread on a threads queue object.

The caller thread is enqueued and put to sleep until it is dequeued or the specified timeouts expires.

Parameters
[in]tqppointer to the threads queue object
[in]timeoutthe timeout in system ticks, the special values are handled as follow:
  • TIME_INFINITE the thread enters an infinite sleep state.
  • TIME_IMMEDIATE the thread is not enqueued and the function returns MSG_TIMEOUT as if a timeout occurred.
Returns
The message from osalQueueWakeupOneI() or osalQueueWakeupAllI() functions.
Return values
MSG_TIMEOUTif the thread has not been dequeued within the specified timeout or if the function has been invoked with TIME_IMMEDIATE as timeout specification.
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 794 of file ch.c.

References chDbgAssert, chDbgCheck, chDbgCheckClassS(), chSchGoSleepTimeoutS(), nil_system::current, MSG_TIMEOUT, NIL_STATE_WTQUEUE, and TIME_IMMEDIATE.

Here is the call graph for this function:

void chThdDoDequeueNextI ( threads_queue_t tqp,
msg_t  msg 
)

Dequeues and wakes up one thread from the threads queue object.

Dequeues one thread from the queue without checking if the queue is empty.

Precondition
The queue must contain at least an object.
Parameters
[in]tqppointer to the threads queue object
[in]msgthe message code
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 821 of file ch.c.

References CH_CFG_NUM_THREADS, chDbgAssert, chSchReadyI(), and nil_system::threads.

Referenced by chThdDequeueAllI(), and chThdDequeueNextI().

Here is the call graph for this function:

void chThdDequeueNextI ( threads_queue_t tqp,
msg_t  msg 
)

Dequeues and wakes up one thread from the threads queue object, if any.

Parameters
[in]tqppointer to the threads queue object
[in]msgthe message code
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 852 of file ch.c.

References chDbgCheck, chDbgCheckClassI(), and chThdDoDequeueNextI().

Here is the call graph for this function:

void chThdDequeueAllI ( threads_queue_t tqp,
msg_t  msg 
)

Dequeues and wakes up all threads from the threads queue object.

Parameters
[in]tqppointer to the threads queue object
[in]msgthe message code
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 870 of file ch.c.

References CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheck, chDbgCheckClassI(), chSchReadyI(), and nil_system::threads.

Here is the call graph for this function:

msg_t chSemWaitTimeout ( semaphore_t sp,
sysinterval_t  timeout 
)

Performs a wait operation on a semaphore with timeout specification.

Parameters
[in]sppointer to a semaphore_t structure
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
A message specifying how the invoking thread has been released from the semaphore.
Return values
NIL_MSG_OKif the thread has not stopped on the semaphore or the semaphore has been signaled.
NIL_MSG_RSTif the semaphore has been reset using chSemReset().
NIL_MSG_TMOif the semaphore has not been signaled or reset within the specified timeout.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 914 of file ch.c.

References chSemWaitTimeoutS(), chSysLock, and chSysUnlock.

Here is the call graph for this function:

msg_t chSemWaitTimeoutS ( semaphore_t sp,
sysinterval_t  timeout 
)

Performs a wait operation on a semaphore with timeout specification.

Parameters
[in]sppointer to a semaphore_t structure
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
A message specifying how the invoking thread has been released from the semaphore.
Return values
NIL_MSG_OKif the thread has not stopped on the semaphore or the semaphore has been signaled.
NIL_MSG_RSTif the semaphore has been reset using chSemReset().
NIL_MSG_TMOif the semaphore has not been signaled or reset within the specified timeout.
Function Class:This is an S-Class API, this function can be invoked from within a system lock zone by threads only.

Definition at line 943 of file ch.c.

References chDbgCheck, chDbgCheckClassS(), chSchGoSleepTimeoutS(), ch_semaphore::cnt, nil_system::current, MSG_OK, MSG_TIMEOUT, NIL_STATE_WTQUEUE, and TIME_IMMEDIATE.

Referenced by chSemWaitTimeout().

Here is the call graph for this function:

void chSemSignal ( semaphore_t sp)

Performs a signal operation on a semaphore.

Parameters
[in]sppointer to a semaphore_t structure
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 970 of file ch.c.

References chSchRescheduleS(), chSemSignalI(), chSysLock, and chSysUnlock.

Here is the call graph for this function:

void chSemSignalI ( semaphore_t sp)

Performs a signal operation on a semaphore.

Postcondition
This function does not reschedule so a call to a rescheduling function must be performed before unlocking the kernel. Note that interrupt handlers always reschedule on exit so an explicit reschedule must not be performed in ISRs.
Parameters
[in]sppointer to a semaphore_t structure
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 989 of file ch.c.

References CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheck, chDbgCheckClassI(), chSchReadyI(), ch_semaphore::cnt, MSG_OK, and nil_system::threads.

Referenced by chSemSignal().

Here is the call graph for this function:

void chSemReset ( semaphore_t sp,
cnt_t  n 
)

Performs a reset operation on the semaphore.

Postcondition
After invoking this function all the threads waiting on the semaphore, if any, are released and the semaphore counter is set to the specified, non negative, value.
Parameters
[in]sppointer to a semaphore_t structure
[in]nthe new value of the semaphore counter. The value must be non-negative.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1025 of file ch.c.

References chSchRescheduleS(), chSemResetI(), chSysLock, and chSysUnlock.

Here is the call graph for this function:

void chSemResetI ( semaphore_t sp,
cnt_t  n 
)

Performs a reset operation on the semaphore.

Postcondition
After invoking this function all the threads waiting on the semaphore, if any, are released and the semaphore counter is set to the specified, non negative, value.
This function does not reschedule so a call to a rescheduling function must be performed before unlocking the kernel. Note that interrupt handlers always reschedule on exit so an explicit reschedule must not be performed in ISRs.
Parameters
[in]sppointer to a semaphore_t structure
[in]nthe new value of the semaphore counter. The value must be non-negative.
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1049 of file ch.c.

References CH_CFG_NUM_THREADS, chDbgAssert, chDbgCheck, chDbgCheckClassI(), chSchReadyI(), ch_semaphore::cnt, MSG_RESET, and nil_system::threads.

Referenced by chSemReset().

Here is the call graph for this function:

void chEvtSignal ( thread_t tp,
eventmask_t  mask 
)

Adds a set of event flags directly to the specified thread_t.

Parameters
[in]tpthe thread to be signaled
[in]maskthe event flags set to be ORed
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1086 of file ch.c.

References chEvtSignalI(), chSchRescheduleS(), chSysLock, and chSysUnlock.

Here is the call graph for this function:

void chEvtSignalI ( thread_t tp,
eventmask_t  mask 
)

Adds a set of event flags directly to the specified thread_t.

Postcondition
This function does not reschedule so a call to a rescheduling function must be performed before unlocking the kernel. Note that interrupt handlers always reschedule on exit so an explicit reschedule must not be performed in ISRs.
Parameters
[in]tpthe thread to be signaled
[in]maskthe event flags set to be ORed
Function Class:This is an I-Class API, this function can be invoked from within a system lock zone by both threads and interrupt handlers.

Definition at line 1106 of file ch.c.

References chDbgCheck, chDbgCheckClassI(), chSchReadyI(), ch_thread::ewmask, and MSG_OK.

Referenced by chEvtSignal().

Here is the call graph for this function:

eventmask_t chEvtWaitAnyTimeout ( eventmask_t  mask,
sysinterval_t  timeout 
)

Waits for any of the specified events.

The function waits for any event among those specified in mask to become pending then the events are cleared and returned.

Parameters
[in]maskmask of the event flags that the function should wait for, ALL_EVENTS enables all the events
[in]timeoutthe number of ticks before the operation timeouts, the following special values are allowed:
  • TIME_IMMEDIATE immediate timeout.
  • TIME_INFINITE no timeout.
Returns
The mask of the served and cleared events.
Return values
0if the operation has timed out.
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 1136 of file ch.c.

References chSchGoSleepTimeoutS(), chSysLock, chSysUnlock, nil_system::current, ch_thread::ewmask, MSG_OK, NIL_STATE_WTOREVT, and TIME_IMMEDIATE.

Here is the call graph for this function:

Variable Documentation

System data structures.

Definition at line 41 of file ch.c.