41#define __CHIBIOS_NIL__
46#define CH_KERNEL_STABLE 1
55#define CH_KERNEL_VERSION "4.1.4"
60#define CH_KERNEL_MAJOR 4
65#define CH_KERNEL_MINOR 1
70#define CH_KERNEL_PATCH 4
81#if !defined(FALSE) || defined(__DOXYGEN__)
89#if !defined(TRUE) || defined(__DOXYGEN__)
98#define MSG_OK (msg_t)0
99#define MSG_TIMEOUT (msg_t)-1
101#define MSG_RESET (msg_t)-2
115#define TIME_IMMEDIATE ((sysinterval_t)-1)
121#define TIME_INFINITE ((sysinterval_t)0)
126#define TIME_MAX_INTERVAL ((sysinterval_t)-2)
131#define TIME_MAX_SYSTIME ((systime_t)-1)
138#define NIL_STATE_WTSTART (tstate_t)0
140#define NIL_STATE_READY (tstate_t)1
142#define NIL_STATE_SLEEPING (tstate_t)2
143#define NIL_STATE_SUSPENDED (tstate_t)3
144#define NIL_STATE_WTEXIT (tstate_t)4
145#define NIL_STATE_WTQUEUE (tstate_t)5
146#define NIL_STATE_WTOREVT (tstate_t)6
147#define NIL_STATE_WTANDEVT (tstate_t)7
148#define NIL_STATE_SNDMSGQ (tstate_t)8
150#define NIL_STATE_WTMSG (tstate_t)10
152#define NIL_STATE_FINAL (tstate_t)11
154#define NIL_THD_IS_WTSTART(tp) ((tp)->state == NIL_STATE_WTSTART)
155#define NIL_THD_IS_READY(tp) ((tp)->state == NIL_STATE_READY)
156#define NIL_THD_IS_SLEEPING(tp) ((tp)->state == NIL_STATE_SLEEPING)
157#define NIL_THD_IS_SUSPENDED(tp) ((tp)->state == NIL_STATE_SUSPENDED)
158#define NIL_THD_IS_WTEXIT(tp) ((tp)->state == NIL_STATE_WTEXIT)
159#define NIL_THD_IS_WTQUEUE(tp) ((tp)->state == NIL_STATE_WTQUEUE)
160#define NIL_THD_IS_WTOREVT(tp) ((tp)->state == NIL_STATE_WTOREVT)
161#define NIL_THD_IS_WTANDEVT(tp) ((tp)->state == NIL_STATE_WTANDEVT)
162#define NIL_THD_IS_SNDMSGQ(tp) ((tp)->state == NIL_STATE_SNDMSGQ)
163#define NIL_THD_IS_WTMSG(tp) ((tp)->state == NIL_STATE_WTMSG)
164#define NIL_THD_IS_FINAL(tp) ((tp)->state == NIL_STATE_FINAL)
166#define CH_STATE_NAMES \
167 "WTSTART", "READY", "SLEEPING", "SUSPENDED", "WTEXIT", "WTQUEUE", \
168 "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "FINAL"
175#define CH_CFG_USE_REGISTRY FALSE
190#if !defined(CH_CFG_MAX_THREADS) || defined(__DOXYGEN__)
191#error "CH_CFG_MAX_THREADS not defined in chconf.h"
194#if !defined(CH_CFG_AUTOSTART_THREADS) || defined(__DOXYGEN__)
195#error "CH_CFG_AUTOSTART_THREADS not defined in chconf.h"
198#if !defined(CH_CFG_ST_RESOLUTION) || defined(__DOXYGEN__)
199#error "CH_CFG_ST_RESOLUTION not defined in chconf.h"
202#if !defined(CH_CFG_ST_FREQUENCY) || defined(__DOXYGEN__)
203#error "CH_CFG_ST_FREQUENCY not defined in chconf.h"
206#if !defined(CH_CFG_ST_TIMEDELTA) || defined(__DOXYGEN__)
207#error "CH_CFG_ST_TIMEDELTA not defined in chconf.h"
210#if !defined(CH_CFG_USE_WAITEXIT)
211#error "CH_CFG_USE_WAITEXIT not defined in chconf.h"
214#if !defined(CH_CFG_USE_MESSAGES) || defined(__DOXYGEN__)
215#error "CH_CFG_USE_MESSAGES not defined in chconf.h"
218#if !defined(CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
219#error "CH_CFG_USE_SEMAPHORES not defined in chconf.h"
222#if !defined(CH_CFG_USE_EVENTS)
223#error "CH_CFG_USE_EVENTS not defined in chconf.h"
226#if !defined(CH_CFG_USE_MUTEXES) || defined(__DOXYGEN__)
227#error "CH_CFG_USE_MUTEXES not defined in chconf.h"
230#if !defined(CH_DBG_STATISTICS) || defined(__DOXYGEN__)
231#error "CH_DBG_STATISTICS not defined in chconf.h"
234#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
235#error "CH_DBG_SYSTEM_STATE_CHECK not defined in chconf.h"
238#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
239#error "CH_DBG_ENABLE_CHECKS not defined in chconf.h"
242#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
243#error "CH_DBG_ENABLE_ASSERTS not defined in chconf.h"
246#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
247#error "CH_DBG_ENABLE_STACK_CHECK not defined in chconf.h"
250#if !defined(CH_CFG_SYSTEM_INIT_HOOK) || defined(__DOXYGEN__)
251#error "CH_CFG_SYSTEM_INIT_HOOK not defined in chconf.h"
254#if !defined(CH_CFG_THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
255#error "CH_CFG_THREAD_EXT_FIELDS not defined in chconf.h"
258#if !defined(CH_CFG_THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
259#error "CH_CFG_THREAD_EXT_INIT_HOOK not defined in chconf.h"
262#if !defined(CH_CFG_THREAD_EXIT_HOOK) || defined(__DOXYGEN__)
263#error "CH_CFG_THREAD_EXIT_HOOK not defined in chconf.h"
266#if !defined(CH_CFG_IDLE_ENTER_HOOK) || defined(__DOXYGEN__)
267#error "CH_CFG_IDLE_ENTER_HOOK not defined in chconf.h"
270#if !defined(CH_CFG_IDLE_LEAVE_HOOK) || defined(__DOXYGEN__)
271#error "CH_CFG_IDLE_LEAVE_HOOK not defined in chconf.h"
274#if !defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
275#error "CH_CFG_SYSTEM_HALT_HOOK not defined in chconf.h"
279#if !defined(CH_CUSTOMER_LIC_NIL) || !defined(CH_LICENSE_FEATURES)
280#error "malformed chlicense.h"
283#if CH_CUSTOMER_LIC_NIL == FALSE
284#error "ChibiOS/NIL not licensed"
287#if (CH_LICENSE_FEATURES != CH_FEATURES_FULL) && \
288 (CH_LICENSE_FEATURES != CH_FEATURES_INTERMEDIATE) && \
289 (CH_LICENSE_FEATURES != CH_FEATURES_BASIC)
290#error "invalid CH_LICENSE_FEATURES setting"
294#if (CH_LICENSE_FEATURES == CH_FEATURES_INTERMEDIATE) || \
295 (CH_LICENSE_FEATURES == CH_FEATURES_BASIC)
298#if CH_CFG_ST_FREQUENCY > 1000
299#undef CH_CFG_ST_FREQUENCY
300#define CH_CFG_ST_FREQUENCY 1000
307#if CH_LICENSE_FEATURES == CH_FEATURES_BASIC
310#undef CH_CFG_ST_TIMEDELTA
311#define CH_CFG_ST_TIMEDELTA 0
314#undef CH_CFG_USE_MESSAGES
315#define CH_CFG_USE_MESSAGES FALSE
319#if !defined(_CHIBIOS_NIL_CONF_)
320#error "missing or wrong configuration file"
323#if !defined(_CHIBIOS_NIL_CONF_VER_4_0_)
324#error "obsolete or unknown configuration file"
327#if CH_CFG_MAX_THREADS < 1
328#error "at least one thread must be defined"
331#if CH_CFG_MAX_THREADS > 16
332#error "ChibiOS/NIL is not recommended for thread-intensive applications," \
333 "consider ChibiOS/RT instead"
336#if (CH_CFG_ST_RESOLUTION != 16) && (CH_CFG_ST_RESOLUTION != 32)
337#error "invalid CH_CFG_ST_RESOLUTION specified, must be 16 or 32"
340#if CH_CFG_ST_FREQUENCY <= 0
341#error "invalid CH_CFG_ST_FREQUENCY specified, must be greater than zero"
344#if (CH_CFG_ST_TIMEDELTA < 0) || (CH_CFG_ST_TIMEDELTA == 1)
345#error "invalid CH_CFG_ST_TIMEDELTA specified, must " \
346 "be zero or greater than one"
349#if CH_CFG_USE_MUTEXES == TRUE
350#error "mutexes not yet supported"
353#if CH_DBG_STATISTICS == TRUE
354#error "statistics not yet supported"
357#if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || \
358 (CH_DBG_ENABLE_CHECKS == TRUE) || \
359 (CH_DBG_ENABLE_ASSERTS == TRUE) || \
360 (CH_DBG_ENABLE_STACK_CHECK == TRUE)
361#define NIL_DBG_ENABLED TRUE
363#define NIL_DBG_ENABLED FALSE
368#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
369#define THD_IDLE_BASE (&__main_thread_stack_base__)
370#define THD_IDLE_END (&__main_thread_stack_end__)
372#define THD_IDLE_BASE NULL
373#define THD_IDLE_END NULL
380#if defined(PORT_DOES_NOT_PROVIDE_TYPES) || defined(__DOXYGEN__)
389#if (PORT_ARCH_REGISTERS_WIDTH == 32) || defined(__DOXYGEN__)
398#elif PORT_ARCH_REGISTERS_WIDTH == 16
401typedef int16_t
msg_t;
405typedef int16_t
cnt_t;
407#elif PORT_ARCH_REGISTERS_WIDTH == 8
410typedef int16_t
msg_t;
417#error "unsupported PORT_ARCH_REGISTERS_WIDTH value"
422#if (CH_CFG_ST_RESOLUTION == 32) || defined(__DOXYGEN__)
479#if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
492#if defined(port_get_lock_status) && defined(port_is_locked)
493#define CH_PORT_SUPPORTS_RECURSIVE_LOCKS TRUE
495#define CH_PORT_SUPPORTS_RECURSIVE_LOCKS FALSE
532#if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
535#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
541#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
544#if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
547#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
570#if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
576#if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
586#if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__)
596#if (NIL_DBG_ENABLED == TRUE) || defined(__DOXYGEN__)
616#if CH_DBG_SYSTEM_STATE_CHECK == TRUE
617#define __dbg_enter_lock() (nil.lock_cnt = (cnt_t)1)
618#define __dbg_leave_lock() (nil.lock_cnt = (cnt_t)0)
624#define __CH_STRINGIFY(a) #a
633#define THD_TABLE_BEGIN \
634 const thread_descriptor_t nil_thd_configs[] = {
639#define THD_TABLE_THREAD(_prio, _name, _wap, _funcp, _arg) \
643 .wend = THD_WORKING_AREA_END(_wap), \
652#define THD_TABLE_END \
655 .wbase = THD_IDLE_BASE, \
656 .wend = THD_IDLE_END, \
657 .prio = CH_CFG_MAX_THREADS, \
673#define MEM_ALIGN_MASK(a) ((size_t)(a) - 1U)
681#define MEM_ALIGN_PREV(p, a) ((size_t)(p) & ~MEM_ALIGN_MASK(a))
689#define MEM_ALIGN_NEXT(p, a) MEM_ALIGN_PREV((size_t)(p) + \
690 MEM_ALIGN_MASK(a), (a))
698#define MEM_IS_ALIGNED(p, a) (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)
706#define MEM_IS_VALID_ALIGNMENT(a) \
707 (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))
722#define THD_WORKING_AREA_SIZE(n) MEM_ALIGN_NEXT(PORT_WA_SIZE(n), \
735#define THD_WORKING_AREA(s, n) PORT_WORKING_AREA(s, n)
747#define THD_WORKING_AREA_END(wa) \
748 ((wa) + ((sizeof wa) / sizeof (stkalign_t)))
759#define THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg)
777#if defined(PORT_IRQ_IS_VALID_PRIORITY) || defined(__DOXYGEN__)
778#define CH_IRQ_IS_VALID_PRIORITY(prio) \
779 PORT_IRQ_IS_VALID_PRIORITY(prio)
781#define CH_IRQ_IS_VALID_PRIORITY(prio) false
795#if defined(PORT_IRQ_IS_VALID_KERNEL_PRIORITY) || defined(__DOXYGEN__)
796#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) \
797 PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio)
799#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) false
809#define CH_IRQ_PROLOGUE() \
810 PORT_IRQ_PROLOGUE(); \
811 __dbg_check_enter_isr()
819#define CH_IRQ_EPILOGUE() \
820 __dbg_check_leave_isr(); \
830#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
845#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
865#define TIME_S2I(secs) \
866 ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY))
881#define TIME_MS2I(msecs) \
882 ((sysinterval_t)((((time_conv_t)(msecs) * \
883 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
884 (time_conv_t)999) / (time_conv_t)1000))
899#define TIME_US2I(usecs) \
900 ((sysinterval_t)((((time_conv_t)(usecs) * \
901 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
902 (time_conv_t)999999) / (time_conv_t)1000000))
917#define TIME_I2S(interval) \
918 (time_secs_t)(((time_conv_t)(interval) + \
919 (time_conv_t)CH_CFG_ST_FREQUENCY - \
920 (time_conv_t)1) / (time_conv_t)CH_CFG_ST_FREQUENCY)
935#define TIME_I2MS(interval) \
936 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \
937 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
938 (time_conv_t)CH_CFG_ST_FREQUENCY)
953#define TIME_I2US(interval) \
954 (time_usecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \
955 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
956 (time_conv_t)CH_CFG_ST_FREQUENCY)
970#define __THREADS_QUEUE_DATA(name) {(cnt_t)0}
979#define THREADS_QUEUE_DECL(name) \
980 threads_queue_t name = __THREADS_QUEUE_DATA(name)
997#if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
998#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
1009#define chSysDisable() { \
1011 __dbg_check_disable(); \
1025#define chSysSuspend() { \
1027 __dbg_check_suspend(); \
1039#define chSysEnable() { \
1040 __dbg_check_enable(); \
1049#define chSysLock() { \
1051 __dbg_check_lock(); \
1059#define chSysUnlock() { \
1060 __dbg_check_unlock(); \
1076#define chSysLockFromISR() { \
1077 port_lock_from_isr(); \
1078 __dbg_check_lock_from_isr(); \
1094#define chSysUnlockFromISR() { \
1095 __dbg_check_unlock_from_isr(); \
1096 port_unlock_from_isr(); \
1107#define chSchGoSleepS(newstate) chSchGoSleepTimeoutS(newstate, TIME_INFINITE)
1117#define chSchWakeupS(ntp, msg) do { \
1118 chSchReadyI(ntp, msg); \
1119 chSchRescheduleS(); \
1131#define chSchIsRescRequiredI() ((bool)(nil.current != nil.next))
1138#define chThdGetSelfX() nil.current
1148#define chThdGetPriorityX(void) (tprio_t)(nil.current - &nil.threads[0])
1160#define chThdResumeS(trp, msg) do { \
1161 chThdResumeI(trp, msg); \
1162 chSchRescheduleS(); \
1175#define chThdSleepSeconds(secs) chThdSleep(TIME_S2I(secs))
1188#define chThdSleepMilliseconds(msecs) chThdSleep(TIME_MS2I(msecs))
1201#define chThdSleepMicroseconds(usecs) chThdSleep(TIME_US2I(usecs))
1210#define chThdSleepS(timeout) \
1211 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
1221#define chThdSleepUntilS(abstime) \
1222 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, \
1223 chTimeDiffX(chVTGetSystemTimeX(), (abstime)))
1232#define chThdQueueObjectInit(tqp) ((tqp)->cnt = (cnt_t)0)
1244#define chThdQueueIsEmptyI(tqp) ((bool)(tqp->cnt >= (cnt_t)0))
1259#if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
1260#define chVTGetSystemTimeX() (nil.systime)
1262#define chVTGetSystemTimeX() port_timer_get_time()
1273#define chVTTimeElapsedSinceX(start) \
1274 chTimeDiffX((start), chVTGetSystemTimeX())
1289#define chVTIsSystemTimeWithinX(start, end) \
1290 chTimeIsInRangeX(chVTGetSystemTimeX(), start, end)
1301#define chTimeAddX(systime, interval) \
1302 ((systime_t)(systime) + (systime_t)(interval))
1313#define chTimeDiffX(start, end) \
1314 ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start))))
1326#if !defined(chDbgCheck)
1327#define chDbgCheck(c) do { \
1329 if (CH_DBG_ENABLE_CHECKS != FALSE) { \
1332 chSysHalt(__func__); \
1352#if !defined(chDbgAssert)
1353#define chDbgAssert(c, r) do { \
1355 if (CH_DBG_ENABLE_ASSERTS != FALSE) { \
1358 chSysHalt(__func__); \
1366#if CH_DBG_SYSTEM_STATE_CHECK == FALSE
1367#define __dbg_enter_lock()
1368#define __dbg_leave_lock()
1369#define __dbg_check_disable()
1370#define __dbg_check_suspend()
1371#define __dbg_check_enable()
1372#define __dbg_check_lock()
1373#define __dbg_check_unlock()
1374#define __dbg_check_lock_from_isr()
1375#define __dbg_check_unlock_from_isr()
1376#define __dbg_check_enter_isr()
1377#define __dbg_check_leave_isr()
1378#define chDbgCheckClassI()
1379#define chDbgCheckClassS()
1386#if !defined(__DOXYGEN__)
1387#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
1417#if CH_CFG_USE_WAITEXIT == TRUE
1429#if CH_DBG_SYSTEM_STATE_CHECK == TRUE
Port related template macros and structures.
Nil RTOS events header file.
ChibiOS/LIB main include file.
License Module macros and structures.
Template port system types.
#define CH_CFG_THREAD_EXT_FIELDS
Threads descriptor structure extension.
#define CH_CFG_MAX_THREADS
Maximum number of user threads in the application.
#define __dbg_check_unlock()
struct nil_threads_queue threads_queue_t
Type of a queue of threads.
void(* tfunc_t)(void *p)
Thread function.
#define __dbg_check_leave_isr()
#define __dbg_check_suspend()
uint32_t sysinterval_t
Type of time interval.
struct nil_os_instance os_instance_t
Type of a structure representing the system.
os_instance_t nil
System data structures.
cnt_t nil_ready_all(void *p, cnt_t cnt, msg_t msg)
Puts in ready state all thread matching the specified status and associated object.
#define chDbgCheckClassS()
#define __dbg_check_lock()
#define chDbgCheckClassI()
struct nil_thread thread_t
Type of a structure representing a thread.
thread_t * thread_reference_t
Type of a thread reference.
#define __dbg_check_disable()
thread_t * nil_find_thread(tstate_t state, void *p)
Retrieves the highest priority thread in the specified state and associated to the specified object.
#define __dbg_check_enter_isr()
#define __dbg_check_enable()
uint32_t systime_t
Type of system time.
threads_queue_t semaphore_t
Type of a structure representing a semaphore.
port_stkalign_t stkalign_t
#define __dbg_check_unlock_from_isr()
#define __dbg_check_lock_from_isr()
struct ch_os_instance os_instance_t
Type of an OS instance structure.
thread_t * thread_reference_t
Type of a thread reference.
port_stkalign_t stkalign_t
struct ch_thread thread_t
Type of a thread structure.
uint64_t port_stkalign_t
Type of stack and memory alignment enforcement.
uint32_t port_rtcnt_t
Realtime counter.
uint32_t port_syssts_t
System status word.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
bool chSchIsPreemptionRequired(void)
Evaluates if preemption is required.
void chSchDoPreemption(void)
Switches to the first thread on the runnable queue.
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
struct ch_semaphore semaphore_t
Semaphore structure.
stkalign_t __main_thread_stack_end__
syssts_t chSysGetStatusAndLockX(void)
Returns the execution status and enters a critical zone.
bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end)
Realtime window test.
void chSysTimerHandlerI(void)
Handles time ticks for round robin preemption and timer increments.
void chSysPolledDelayX(rtcnt_t cycles)
Polled delay.
static void chSysUnconditionalLock(void)
Unconditionally enters the kernel lock state.
void chSysRestoreStatusX(syssts_t sts)
Restores the specified execution status and leaves a critical zone.
static void chSysUnconditionalUnlock(void)
Unconditionally leaves the kernel lock state.
stkalign_t __main_thread_stack_base__
void chSysInit(void)
System initialization.
void chSysHalt(const char *reason)
Halts the system.
msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread on a threads queue object.
void(* tfunc_t)(void *p)
Thread function.
void chThdExit(msg_t msg)
Terminates the current thread.
msg_t chThdWait(thread_t *tp)
Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...
void chThdResume(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
msg_t chThdSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout)
Sends the current thread sleeping and sets a reference variable.
thread_t * chThdCreateI(const thread_descriptor_t *tdp)
Creates a new thread.
void chThdResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
static void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object.
void chThdSleep(sysinterval_t time)
Suspends the invoking thread for the specified time.
void chThdSleepUntil(systime_t time)
Suspends the invoking thread until the system time arrives to the specified value.
void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object, if any.
thread_t * chThdCreate(const thread_descriptor_t *tdp)
Creates a new thread.
void chThdDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the threads queue object.
uint64_t systime_t
Type of system time.
static bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
uint64_t time_conv_t
Type of time conversion variable.
uint64_t sysinterval_t
Type of time interval.
Nil RTOS synchronous messages header file.
Nil RTOS semaphores header file.
thread_t * next
Pointer to the next thread to be executed.
cnt_t lock_cnt
Lock nesting level.
volatile systime_t systime
System time.
const char *volatile dbg_panic_msg
Panic message.
systime_t lasttime
System time of the last tick event.
thread_t threads[CH_CFG_MAX_THREADS+1]
Thread structures for all the defined threads.
thread_t * current
Pointer to the running thread.
systime_t nexttime
Time of the next scheduled tick event.
cnt_t isr_cnt
ISR nesting level.
Structure representing a thread descriptor.
stkalign_t * wend
Thread working area end.
tprio_t prio
Thread priority slot.
tfunc_t funcp
Thread function.
stkalign_t * wbase
Thread working area base.
const char * name
Thread name, for debugging.
void * arg
Thread function argument.
Structure representing a thread.
eventmask_t epmask
Pending events mask.
stkalign_t * wabase
Thread stack boundary.
thread_reference_t * trp
Pointer to thread reference.
struct port_context ctx
Processor context.
thread_t * tp
Pointer to thread.
msg_t msg
Wake-up/exit message.
union nil_thread::@026120306060255304310364300164041237270105045230 u1
msg_t sntmsg
Sent message.
eventmask_t ewmask
Enabled events mask.
volatile sysinterval_t timeout
Timeout counter, zero if disabled.
semaphore_t * semp
Pointer to semaphore.
tstate_t state
Thread state.
threads_queue_t * tqp
Pointer to thread queue.
os_instance_t * nsp
Pointer to nil base struct.
Structure representing a queue of threads.
volatile cnt_t cnt
Threads Queue counter.
Platform dependent part of the thread_t structure.
Type of a thread descriptor.