42#define __CHIBIOS_NIL__
47#define CH_KERNEL_STABLE 1
56#define CH_KERNEL_VERSION "4.1.3"
61#define CH_KERNEL_MAJOR 4
66#define CH_KERNEL_MINOR 1
71#define CH_KERNEL_PATCH 3
82#if !defined(FALSE) || defined(__DOXYGEN__)
90#if !defined(TRUE) || defined(__DOXYGEN__)
99#define MSG_OK (msg_t)0
100#define MSG_TIMEOUT (msg_t)-1
102#define MSG_RESET (msg_t)-2
116#define TIME_IMMEDIATE ((sysinterval_t)-1)
122#define TIME_INFINITE ((sysinterval_t)0)
127#define TIME_MAX_INTERVAL ((sysinterval_t)-2)
132#define TIME_MAX_SYSTIME ((systime_t)-1)
139#define NIL_STATE_WTSTART (tstate_t)0
141#define NIL_STATE_READY (tstate_t)1
143#define NIL_STATE_SLEEPING (tstate_t)2
144#define NIL_STATE_SUSPENDED (tstate_t)3
145#define NIL_STATE_WTEXIT (tstate_t)4
146#define NIL_STATE_WTQUEUE (tstate_t)5
147#define NIL_STATE_WTOREVT (tstate_t)6
148#define NIL_STATE_WTANDEVT (tstate_t)7
149#define NIL_STATE_SNDMSGQ (tstate_t)8
151#define NIL_STATE_WTMSG (tstate_t)10
153#define NIL_STATE_FINAL (tstate_t)11
155#define NIL_THD_IS_WTSTART(tp) ((tp)->state == NIL_STATE_WTSTART)
156#define NIL_THD_IS_READY(tp) ((tp)->state == NIL_STATE_READY)
157#define NIL_THD_IS_SLEEPING(tp) ((tp)->state == NIL_STATE_SLEEPING)
158#define NIL_THD_IS_SUSPENDED(tp) ((tp)->state == NIL_STATE_SUSPENDED)
159#define NIL_THD_IS_WTEXIT(tp) ((tp)->state == NIL_STATE_WTEXIT)
160#define NIL_THD_IS_WTQUEUE(tp) ((tp)->state == NIL_STATE_WTQUEUE)
161#define NIL_THD_IS_WTOREVT(tp) ((tp)->state == NIL_STATE_WTOREVT)
162#define NIL_THD_IS_WTANDEVT(tp) ((tp)->state == NIL_STATE_WTANDEVT)
163#define NIL_THD_IS_SNDMSGQ(tp) ((tp)->state == NIL_STATE_SNDMSGQ)
164#define NIL_THD_IS_WTMSG(tp) ((tp)->state == NIL_STATE_WTMSG)
165#define NIL_THD_IS_FINAL(tp) ((tp)->state == NIL_STATE_FINAL)
167#define CH_STATE_NAMES \
168 "WTSTART", "READY", "SLEEPING", "SUSPENDED", "WTEXIT", "WTQUEUE", \
169 "WTOREVT", "WTANDEVT", "SNDMSGQ", "SNDMSG", "WTMSG", "FINAL"
176#define CH_CFG_USE_REGISTRY FALSE
191#if !defined(CH_CFG_MAX_THREADS) || defined(__DOXYGEN__)
192#error "CH_CFG_MAX_THREADS not defined in chconf.h"
195#if !defined(CH_CFG_AUTOSTART_THREADS) || defined(__DOXYGEN__)
196#error "CH_CFG_AUTOSTART_THREADS not defined in chconf.h"
199#if !defined(CH_CFG_ST_RESOLUTION) || defined(__DOXYGEN__)
200#error "CH_CFG_ST_RESOLUTION not defined in chconf.h"
203#if !defined(CH_CFG_ST_FREQUENCY) || defined(__DOXYGEN__)
204#error "CH_CFG_ST_FREQUENCY not defined in chconf.h"
207#if !defined(CH_CFG_ST_TIMEDELTA) || defined(__DOXYGEN__)
208#error "CH_CFG_ST_TIMEDELTA not defined in chconf.h"
211#if !defined(CH_CFG_USE_WAITEXIT)
212#error "CH_CFG_USE_WAITEXIT not defined in chconf.h"
215#if !defined(CH_CFG_USE_MESSAGES) || defined(__DOXYGEN__)
216#error "CH_CFG_USE_MESSAGES not defined in chconf.h"
219#if !defined(CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
220#error "CH_CFG_USE_SEMAPHORES not defined in chconf.h"
223#if !defined(CH_CFG_USE_EVENTS)
224#error "CH_CFG_USE_EVENTS not defined in chconf.h"
227#if !defined(CH_CFG_USE_MUTEXES) || defined(__DOXYGEN__)
228#error "CH_CFG_USE_MUTEXES not defined in chconf.h"
231#if !defined(CH_DBG_STATISTICS) || defined(__DOXYGEN__)
232#error "CH_DBG_STATISTICS not defined in chconf.h"
235#if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
236#error "CH_DBG_SYSTEM_STATE_CHECK not defined in chconf.h"
239#if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
240#error "CH_DBG_ENABLE_CHECKS not defined in chconf.h"
243#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
244#error "CH_DBG_ENABLE_ASSERTS not defined in chconf.h"
247#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
248#error "CH_DBG_ENABLE_STACK_CHECK not defined in chconf.h"
251#if !defined(CH_CFG_SYSTEM_INIT_HOOK) || defined(__DOXYGEN__)
252#error "CH_CFG_SYSTEM_INIT_HOOK not defined in chconf.h"
255#if !defined(CH_CFG_THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
256#error "CH_CFG_THREAD_EXT_FIELDS not defined in chconf.h"
259#if !defined(CH_CFG_THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
260#error "CH_CFG_THREAD_EXT_INIT_HOOK not defined in chconf.h"
263#if !defined(CH_CFG_THREAD_EXIT_HOOK) || defined(__DOXYGEN__)
264#error "CH_CFG_THREAD_EXIT_HOOK not defined in chconf.h"
267#if !defined(CH_CFG_IDLE_ENTER_HOOK) || defined(__DOXYGEN__)
268#error "CH_CFG_IDLE_ENTER_HOOK not defined in chconf.h"
271#if !defined(CH_CFG_IDLE_LEAVE_HOOK) || defined(__DOXYGEN__)
272#error "CH_CFG_IDLE_LEAVE_HOOK not defined in chconf.h"
275#if !defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
276#error "CH_CFG_SYSTEM_HALT_HOOK not defined in chconf.h"
280#if !defined(CH_CUSTOMER_LIC_NIL) || !defined(CH_LICENSE_FEATURES)
281#error "malformed chlicense.h"
284#if CH_CUSTOMER_LIC_NIL == FALSE
285#error "ChibiOS/NIL not licensed"
288#if (CH_LICENSE_FEATURES != CH_FEATURES_FULL) && \
289 (CH_LICENSE_FEATURES != CH_FEATURES_INTERMEDIATE) && \
290 (CH_LICENSE_FEATURES != CH_FEATURES_BASIC)
291#error "invalid CH_LICENSE_FEATURES setting"
295#if (CH_LICENSE_FEATURES == CH_FEATURES_INTERMEDIATE) || \
296 (CH_LICENSE_FEATURES == CH_FEATURES_BASIC)
299#if CH_CFG_ST_FREQUENCY > 1000
300#undef CH_CFG_ST_FREQUENCY
301#define CH_CFG_ST_FREQUENCY 1000
308#if CH_LICENSE_FEATURES == CH_FEATURES_BASIC
311#undef CH_CFG_ST_TIMEDELTA
312#define CH_CFG_ST_TIMEDELTA 0
315#undef CH_CFG_USE_MESSAGES
316#define CH_CFG_USE_MESSAGES FALSE
320#if !defined(_CHIBIOS_NIL_CONF_)
321#error "missing or wrong configuration file"
324#if !defined(_CHIBIOS_NIL_CONF_VER_4_0_)
325#error "obsolete or unknown configuration file"
328#if CH_CFG_MAX_THREADS < 1
329#error "at least one thread must be defined"
332#if CH_CFG_MAX_THREADS > 16
333#error "ChibiOS/NIL is not recommended for thread-intensive applications," \
334 "consider ChibiOS/RT instead"
337#if (CH_CFG_ST_RESOLUTION != 16) && (CH_CFG_ST_RESOLUTION != 32)
338#error "invalid CH_CFG_ST_RESOLUTION specified, must be 16 or 32"
341#if CH_CFG_ST_FREQUENCY <= 0
342#error "invalid CH_CFG_ST_FREQUENCY specified, must be greater than zero"
345#if (CH_CFG_ST_TIMEDELTA < 0) || (CH_CFG_ST_TIMEDELTA == 1)
346#error "invalid CH_CFG_ST_TIMEDELTA specified, must " \
347 "be zero or greater than one"
350#if CH_CFG_USE_MUTEXES == TRUE
351#error "mutexes not yet supported"
354#if CH_DBG_STATISTICS == TRUE
355#error "statistics not yet supported"
358#if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || \
359 (CH_DBG_ENABLE_CHECKS == TRUE) || \
360 (CH_DBG_ENABLE_ASSERTS == TRUE) || \
361 (CH_DBG_ENABLE_STACK_CHECK == TRUE)
362#define NIL_DBG_ENABLED TRUE
364#define NIL_DBG_ENABLED FALSE
369#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
370#define THD_IDLE_BASE (&__main_thread_stack_base__)
371#define THD_IDLE_END (&__main_thread_stack_end__)
373#define THD_IDLE_BASE NULL
374#define THD_IDLE_END NULL
378#if defined(port_get_lock_status) && defined(port_is_locked)
379#define CH_PORT_SUPPORTS_RECURSIVE_LOCKS TRUE
381#define CH_PORT_SUPPORTS_RECURSIVE_LOCKS FALSE
388#if defined(PORT_DOES_NOT_PROVIDE_TYPES) || defined(__DOXYGEN__)
397#if (PORT_ARCH_REGISTERS_WIDTH == 32) || defined(__DOXYGEN__)
406#elif PORT_ARCH_REGISTERS_WIDTH == 16
409typedef int16_t
msg_t;
413typedef int16_t
cnt_t;
415#elif PORT_ARCH_REGISTERS_WIDTH == 8
418typedef int16_t
msg_t;
425#error "unsupported PORT_ARCH_REGISTERS_WIDTH value"
430#if (CH_CFG_ST_RESOLUTION == 32) || defined(__DOXYGEN__)
487#if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
533#if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
536#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
542#if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
545#if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
548#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
571#if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
577#if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
587#if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__)
597#if (NIL_DBG_ENABLED == TRUE) || defined(__DOXYGEN__)
617#if CH_DBG_SYSTEM_STATE_CHECK == TRUE
618#define __dbg_enter_lock() (nil.lock_cnt = (cnt_t)1)
619#define __dbg_leave_lock() (nil.lock_cnt = (cnt_t)0)
625#define __CH_STRINGIFY(a) #a
634#define THD_TABLE_BEGIN \
635 const thread_descriptor_t nil_thd_configs[] = {
640#define THD_TABLE_THREAD(_prio, _name, _wap, _funcp, _arg) \
644 .wend = THD_WORKING_AREA_END(_wap), \
653#define THD_TABLE_END \
656 .wbase = THD_IDLE_BASE, \
657 .wend = THD_IDLE_END, \
658 .prio = CH_CFG_MAX_THREADS, \
674#define MEM_ALIGN_MASK(a) ((size_t)(a) - 1U)
682#define MEM_ALIGN_PREV(p, a) ((size_t)(p) & ~MEM_ALIGN_MASK(a))
690#define MEM_ALIGN_NEXT(p, a) MEM_ALIGN_PREV((size_t)(p) + \
691 MEM_ALIGN_MASK(a), (a))
699#define MEM_IS_ALIGNED(p, a) (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)
707#define MEM_IS_VALID_ALIGNMENT(a) \
708 (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))
723#define THD_WORKING_AREA_SIZE(n) MEM_ALIGN_NEXT(PORT_WA_SIZE(n), \
736#define THD_WORKING_AREA(s, n) PORT_WORKING_AREA(s, n)
748#define THD_WORKING_AREA_END(wa) \
749 ((wa) + ((sizeof wa) / sizeof (stkalign_t)))
760#define THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg)
778#if defined(PORT_IRQ_IS_VALID_PRIORITY) || defined(__DOXYGEN__)
779#define CH_IRQ_IS_VALID_PRIORITY(prio) \
780 PORT_IRQ_IS_VALID_PRIORITY(prio)
782#define CH_IRQ_IS_VALID_PRIORITY(prio) false
796#if defined(PORT_IRQ_IS_VALID_KERNEL_PRIORITY) || defined(__DOXYGEN__)
797#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) \
798 PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio)
800#define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) false
810#define CH_IRQ_PROLOGUE() \
811 PORT_IRQ_PROLOGUE(); \
812 __dbg_check_enter_isr()
820#define CH_IRQ_EPILOGUE() \
821 __dbg_check_leave_isr(); \
831#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
846#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
866#define TIME_S2I(secs) \
867 ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY))
882#define TIME_MS2I(msecs) \
883 ((sysinterval_t)((((time_conv_t)(msecs) * \
884 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
885 (time_conv_t)999) / (time_conv_t)1000))
900#define TIME_US2I(usecs) \
901 ((sysinterval_t)((((time_conv_t)(usecs) * \
902 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
903 (time_conv_t)999999) / (time_conv_t)1000000))
918#define TIME_I2S(interval) \
919 (time_secs_t)(((time_conv_t)(interval) + \
920 (time_conv_t)CH_CFG_ST_FREQUENCY - \
921 (time_conv_t)1) / (time_conv_t)CH_CFG_ST_FREQUENCY)
936#define TIME_I2MS(interval) \
937 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \
938 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
939 (time_conv_t)CH_CFG_ST_FREQUENCY)
954#define TIME_I2US(interval) \
955 (time_usecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \
956 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
957 (time_conv_t)CH_CFG_ST_FREQUENCY)
971#define __THREADS_QUEUE_DATA(name) {(cnt_t)0}
980#define THREADS_QUEUE_DECL(name) \
981 threads_queue_t name = __THREADS_QUEUE_DATA(name)
998#if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
999#define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
1010#define chSysDisable() { \
1012 __dbg_check_disable(); \
1026#define chSysSuspend() { \
1028 __dbg_check_suspend(); \
1040#define chSysEnable() { \
1041 __dbg_check_enable(); \
1050#define chSysLock() { \
1052 __dbg_check_lock(); \
1060#define chSysUnlock() { \
1061 __dbg_check_unlock(); \
1077#define chSysLockFromISR() { \
1078 port_lock_from_isr(); \
1079 __dbg_check_lock_from_isr(); \
1095#define chSysUnlockFromISR() { \
1096 __dbg_check_unlock_from_isr(); \
1097 port_unlock_from_isr(); \
1108#define chSchGoSleepS(newstate) chSchGoSleepTimeoutS(newstate, TIME_INFINITE)
1118#define chSchWakeupS(ntp, msg) do { \
1119 chSchReadyI(ntp, msg); \
1120 chSchRescheduleS(); \
1132#define chSchIsRescRequiredI() ((bool)(nil.current != nil.next))
1139#define chThdGetSelfX() nil.current
1149#define chThdGetPriorityX(void) (tprio_t)(nil.current - &nil.threads[0])
1161#define chThdResumeS(trp, msg) do { \
1162 chThdResumeI(trp, msg); \
1163 chSchRescheduleS(); \
1176#define chThdSleepSeconds(secs) chThdSleep(TIME_S2I(secs))
1189#define chThdSleepMilliseconds(msecs) chThdSleep(TIME_MS2I(msecs))
1202#define chThdSleepMicroseconds(usecs) chThdSleep(TIME_US2I(usecs))
1211#define chThdSleepS(timeout) \
1212 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
1222#define chThdSleepUntilS(abstime) \
1223 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, \
1224 chTimeDiffX(chVTGetSystemTimeX(), (abstime)))
1233#define chThdQueueObjectInit(tqp) ((tqp)->cnt = (cnt_t)0)
1245#define chThdQueueIsEmptyI(tqp) ((bool)(tqp->cnt >= (cnt_t)0))
1260#if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
1261#define chVTGetSystemTimeX() (nil.systime)
1263#define chVTGetSystemTimeX() port_timer_get_time()
1274#define chVTTimeElapsedSinceX(start) \
1275 chTimeDiffX((start), chVTGetSystemTimeX())
1290#define chVTIsSystemTimeWithinX(start, end) \
1291 chTimeIsInRangeX(chVTGetSystemTimeX(), start, end)
1302#define chTimeAddX(systime, interval) \
1303 ((systime_t)(systime) + (systime_t)(interval))
1314#define chTimeDiffX(start, end) \
1315 ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start))))
1327#if !defined(chDbgCheck)
1328#define chDbgCheck(c) do { \
1330 if (CH_DBG_ENABLE_CHECKS != FALSE) { \
1333 chSysHalt(__func__); \
1353#if !defined(chDbgAssert)
1354#define chDbgAssert(c, r) do { \
1356 if (CH_DBG_ENABLE_ASSERTS != FALSE) { \
1359 chSysHalt(__func__); \
1367#if CH_DBG_SYSTEM_STATE_CHECK == FALSE
1368#define __dbg_enter_lock()
1369#define __dbg_leave_lock()
1370#define __dbg_check_disable()
1371#define __dbg_check_suspend()
1372#define __dbg_check_enable()
1373#define __dbg_check_lock()
1374#define __dbg_check_unlock()
1375#define __dbg_check_lock_from_isr()
1376#define __dbg_check_unlock_from_isr()
1377#define __dbg_check_enter_isr()
1378#define __dbg_check_leave_isr()
1379#define chDbgCheckClassI()
1380#define chDbgCheckClassS()
1387#if !defined(__DOXYGEN__)
1388#if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
1418#if CH_CFG_USE_WAITEXIT == TRUE
1430#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.