Go to the documentation of this file.
42 #define __CHIBIOS_NIL__
47 #define CH_KERNEL_STABLE 0
56 #define CH_KERNEL_VERSION "4.1.0"
61 #define CH_KERNEL_MAJOR 4
66 #define CH_KERNEL_MINOR 1
71 #define CH_KERNEL_PATCH 0
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
381 #if defined(PORT_DOES_NOT_PROVIDE_TYPES) || defined(__DOXYGEN__)
390 #if (PORT_ARCH_REGISTERS_WIDTH == 32) || defined(__DOXYGEN__)
399 #elif PORT_ARCH_REGISTERS_WIDTH == 16
402 typedef int16_t
msg_t;
406 typedef int16_t
cnt_t;
408 #elif PORT_ARCH_REGISTERS_WIDTH == 8
411 typedef int16_t
msg_t;
415 typedef int8_t
cnt_t;
418 #error "unsupported PORT_ARCH_REGISTERS_WIDTH value"
423 #if (CH_CFG_ST_RESOLUTION == 32) || defined(__DOXYGEN__)
480 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
526 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
529 #if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
535 #if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
538 #if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
541 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
564 #if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
570 #if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
580 #if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__)
590 #if (NIL_DBG_ENABLED == TRUE) || defined(__DOXYGEN__)
610 #if CH_DBG_SYSTEM_STATE_CHECK == TRUE
611 #define __dbg_enter_lock() (nil.lock_cnt = (cnt_t)1)
612 #define __dbg_leave_lock() (nil.lock_cnt = (cnt_t)0)
618 #define __CH_STRINGIFY(a) #a
627 #define THD_TABLE_BEGIN \
628 const thread_descriptor_t nil_thd_configs[] = {
633 #define THD_TABLE_THREAD(_prio, _name, _wap, _funcp, _arg) \
637 .wend = THD_WORKING_AREA_END(_wap), \
646 #define THD_TABLE_END \
649 .wbase = THD_IDLE_BASE, \
650 .wend = THD_IDLE_END, \
651 .prio = CH_CFG_MAX_THREADS, \
667 #define MEM_ALIGN_MASK(a) ((size_t)(a) - 1U)
675 #define MEM_ALIGN_PREV(p, a) ((size_t)(p) & ~MEM_ALIGN_MASK(a))
683 #define MEM_ALIGN_NEXT(p, a) MEM_ALIGN_PREV((size_t)(p) + \
684 MEM_ALIGN_MASK(a), (a))
692 #define MEM_IS_ALIGNED(p, a) (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)
700 #define MEM_IS_VALID_ALIGNMENT(a) \
701 (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))
716 #define THD_WORKING_AREA_SIZE(n) MEM_ALIGN_NEXT(PORT_WA_SIZE(n), \
729 #define THD_WORKING_AREA(s, n) PORT_WORKING_AREA(s, n)
741 #define THD_WORKING_AREA_END(wa) \
742 ((wa) + ((sizeof wa) / sizeof (stkalign_t)))
753 #define THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg)
771 #if defined(PORT_IRQ_IS_VALID_PRIORITY) || defined(__DOXYGEN__)
772 #define CH_IRQ_IS_VALID_PRIORITY(prio) \
773 PORT_IRQ_IS_VALID_PRIORITY(prio)
775 #define CH_IRQ_IS_VALID_PRIORITY(prio) false
789 #if defined(PORT_IRQ_IS_VALID_KERNEL_PRIORITY) || defined(__DOXYGEN__)
790 #define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) \
791 PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio)
793 #define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) false
803 #define CH_IRQ_PROLOGUE() \
804 PORT_IRQ_PROLOGUE(); \
805 __dbg_check_enter_isr()
813 #define CH_IRQ_EPILOGUE() \
814 __dbg_check_leave_isr(); \
824 #define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
839 #define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
859 #define TIME_S2I(secs) \
860 ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY))
875 #define TIME_MS2I(msecs) \
876 ((sysinterval_t)((((time_conv_t)(msecs) * \
877 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
878 (time_conv_t)999) / (time_conv_t)1000))
893 #define TIME_US2I(usecs) \
894 ((sysinterval_t)((((time_conv_t)(usecs) * \
895 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
896 (time_conv_t)999999) / (time_conv_t)1000000))
911 #define TIME_I2S(interval) \
912 (time_secs_t)(((time_conv_t)(interval) + \
913 (time_conv_t)CH_CFG_ST_FREQUENCY - \
914 (time_conv_t)1) / (time_conv_t)CH_CFG_ST_FREQUENCY)
929 #define TIME_I2MS(interval) \
930 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \
931 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
932 (time_conv_t)CH_CFG_ST_FREQUENCY)
947 #define TIME_I2US(interval) \
948 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \
949 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
950 (time_conv_t)CH_CFG_ST_FREQUENCY)
964 #define __THREADS_QUEUE_DATA(name) {(cnt_t)0}
973 #define THREADS_QUEUE_DECL(name) \
974 threads_queue_t name = __THREADS_QUEUE_DATA(name)
991 #if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
992 #define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
1003 #define chSysDisable() { \
1005 __dbg_check_disable(); \
1019 #define chSysSuspend() { \
1021 __dbg_check_suspend(); \
1033 #define chSysEnable() { \
1034 __dbg_check_enable(); \
1043 #define chSysLock() { \
1045 __dbg_check_lock(); \
1053 #define chSysUnlock() { \
1054 __dbg_check_unlock(); \
1070 #define chSysLockFromISR() { \
1071 port_lock_from_isr(); \
1072 __dbg_check_lock_from_isr(); \
1088 #define chSysUnlockFromISR() { \
1089 __dbg_check_unlock_from_isr(); \
1090 port_unlock_from_isr(); \
1101 #define chSchGoSleepS(newstate) chSchGoSleepTimeoutS(newstate, TIME_INFINITE)
1111 #define chSchWakeupS(ntp, msg) do { \
1112 chSchReadyI(ntp, msg); \
1113 chSchRescheduleS(); \
1125 #define chSchIsRescRequiredI() ((bool)(nil.current != nil.next))
1132 #define chThdGetSelfX() nil.current
1142 #define chThdGetPriorityX(void) (tprio_t)(nil.current - &nil.threads[0])
1154 #define chThdResumeS(trp, msg) do { \
1155 chThdResumeI(trp, msg); \
1156 chSchRescheduleS(); \
1169 #define chThdSleepSeconds(secs) chThdSleep(TIME_S2I(secs))
1182 #define chThdSleepMilliseconds(msecs) chThdSleep(TIME_MS2I(msecs))
1195 #define chThdSleepMicroseconds(usecs) chThdSleep(TIME_US2I(usecs))
1204 #define chThdSleepS(timeout) \
1205 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
1215 #define chThdSleepUntilS(abstime) \
1216 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, \
1217 chTimeDiffX(chVTGetSystemTimeX(), (abstime)))
1226 #define chThdQueueObjectInit(tqp) ((tqp)->cnt = (cnt_t)0)
1238 #define chThdQueueIsEmptyI(tqp) ((bool)(tqp->cnt >= (cnt_t)0))
1253 #if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
1254 #define chVTGetSystemTimeX() (nil.systime)
1256 #define chVTGetSystemTimeX() port_timer_get_time()
1267 #define chVTTimeElapsedSinceX(start) \
1268 chTimeDiffX((start), chVTGetSystemTimeX())
1283 #define chVTIsSystemTimeWithinX(start, end) \
1284 chTimeIsInRangeX(chVTGetSystemTimeX(), start, end)
1295 #define chTimeAddX(systime, interval) \
1296 ((systime_t)(systime) + (systime_t)(interval))
1307 #define chTimeDiffX(start, end) \
1308 ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start))))
1320 #if !defined(chDbgCheck)
1321 #define chDbgCheck(c) do { \
1323 if (CH_DBG_ENABLE_CHECKS != FALSE) { \
1326 chSysHalt(__func__); \
1346 #if !defined(chDbgAssert)
1347 #define chDbgAssert(c, r) do { \
1349 if (CH_DBG_ENABLE_ASSERTS != FALSE) { \
1352 chSysHalt(__func__); \
1360 #if CH_DBG_SYSTEM_STATE_CHECK == FALSE
1361 #define __dbg_enter_lock()
1362 #define __dbg_leave_lock()
1363 #define __dbg_check_disable()
1364 #define __dbg_check_suspend()
1365 #define __dbg_check_enable()
1366 #define __dbg_check_lock()
1367 #define __dbg_check_unlock()
1368 #define __dbg_check_lock_from_isr()
1369 #define __dbg_check_unlock_from_isr()
1370 #define __dbg_check_enter_isr()
1371 #define __dbg_check_leave_isr()
1372 #define chDbgCheckClassI()
1373 #define chDbgCheckClassS()
1380 #if !defined(__DOXYGEN__)
1381 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
1382 extern stkalign_t __main_thread_stack_base__, __main_thread_stack_end__;
1411 #if CH_CFG_USE_WAITEXIT == TRUE
1423 #if CH_DBG_SYSTEM_STATE_CHECK == TRUE
1424 void __dbg_check_disable(
void);
1425 void __dbg_check_suspend(
void);
1426 void __dbg_check_enable(
void);
1427 void __dbg_check_lock(
void);
1428 void __dbg_check_unlock(
void);
1429 void __dbg_check_lock_from_isr(
void);
1430 void __dbg_check_unlock_from_isr(
void);
1431 void __dbg_check_enter_isr(
void);
1432 void __dbg_check_leave_isr(
void);
1433 void chDbgCheckClassI(
void);
1434 void chDbgCheckClassS(
void);
threads_queue_t * tqp
Pointer to thread queue.
struct port_context ctx
Processor context.
void chSysRestoreStatusX(syssts_t sts)
Restores the specified execution status and leaves a critical zone.
void chSysHalt(const char *reason)
Halts the system.
bool chSysIsCounterWithinX(rtcnt_t cnt, rtcnt_t start, rtcnt_t end)
Realtime window test.
msg_t chThdSuspendTimeoutS(thread_reference_t *trp, sysinterval_t timeout)
Sends the current thread sleeping and sets a reference variable.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
uint64_t port_stkalign_t
Type of stack and memory alignment enforcement.
port_stkalign_t stkalign_t
void chSysUnconditionalUnlock(void)
Unconditionally leaves the kernel lock state.
msg_t msg
Wake-up/exit message.
License Module macros and structures.
const char * name
Thread name, for debugging.
void(* tfunc_t)(void *p)
Thread function.
Structure representing a thread descriptor.
volatile cnt_t cnt
Threads Queue counter.
uint64_t systime_t
Type of system time.
uint64_t time_conv_t
Type of time conversion variable.
System instance data structure.
msg_t sntmsg
Sent message.
void chSysTimerHandlerI(void)
Handles time ticks for round robin preemption and timer increments.
const char *volatile dbg_panic_msg
Panic message.
port_stkalign_t stkalign_t
thread_t * tp
Pointer to thread.
systime_t nexttime
Time of the next scheduled tick event.
semaphore_t * semp
Pointer to semaphore.
thread_t * chThdCreateI(const thread_descriptor_t *tdp)
Creates a new thread into a static memory area.
void * arg
Thread function argument.
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.
ChibiOS/LIB main include file.
msg_t chSchGoSleepTimeoutS(tstate_t newstate, sysinterval_t timeout)
Puts the current thread to sleep into the specified state with timeout specification.
void chThdDequeueAllI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up all threads from the threads queue object.
msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread on a threads queue object.
cnt_t isr_cnt
ISR nesting level.
thread_t * thread_reference_t
Type of a thread reference.
uint32_t systime_t
Type of system time.
os_instance_t nil
System data structures.
void chThdDoDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object.
void chSysUnconditionalLock(void)
Unconditionally enters the kernel lock state.
stkalign_t * wabase
Thread stack boundary.
tfunc_t funcp
Thread function.
stkalign_t * wbase
Thread working area base.
void chThdResumeI(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Structure representing a thread.
void chSysPolledDelayX(rtcnt_t cycles)
Polled delay.
thread_reference_t * trp
Pointer to thread reference.
stkalign_t * wend
Thread working area end.
msg_t chThdWait(thread_t *tp)
Blocks the execution of the invoking thread until the specified thread terminates then the exit code ...
uint32_t port_rtcnt_t
Realtime counter.
Structure representing a queue of threads.
Port related template macros and structures.
eventmask_t epmask
Pending events mask.
#define CH_CFG_MAX_THREADS
Maximum number of user threads in the application.
systime_t lasttime
System time of the last tick event.
Structure representing a thread.
Type of a thread descriptor.
threads_queue_t semaphore_t
Type of a structure representing a semaphore.
syssts_t chSysGetStatusAndLockX(void)
Returns the execution status and enters a critical zone.
void chSchRescheduleS(void)
Performs a reschedule if a higher priority thread is runnable.
volatile systime_t systime
System time.
Nil RTOS events header file.
eventmask_t ewmask
Enabled events mask.
void chSchDoPreemption(void)
Switches to the first thread on the runnable queue.
tstate_t state
Thread state.
thread_t * next
Pointer to the next thread to be executed.
bool chSchIsPreemptionRequired(void)
Evaluates if preemption is required.
thread_t * current
Pointer to the running thread.
Nil RTOS synchronous messages header file.
uint64_t sysinterval_t
Type of time interval.
void chThdSleep(sysinterval_t time)
Suspends the invoking thread for the specified time.
volatile sysinterval_t timeout
Timeout counter, zero if disabled.
thread_t * chThdCreate(const thread_descriptor_t *tdp)
Creates a new thread into a static memory area.
void chThdDequeueNextI(threads_queue_t *tqp, msg_t msg)
Dequeues and wakes up one thread from the threads queue object, if any.
Template port system types.
void chSysInit(void)
System initialization.
uint32_t sysinterval_t
Type of time interval.
os_instance_t * nsp
Pointer to nil base struct.
tprio_t prio
Thread priority slot.
void chThdResume(thread_reference_t *trp, msg_t msg)
Wakes up a thread waiting on a thread reference object.
Nil RTOS semaphores header file.
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.
uint32_t port_syssts_t
System status word.
cnt_t lock_cnt
Lock nesting level.
bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
Platform dependent part of the thread_t structure.
void chThdSleepUntil(systime_t time)
Suspends the invoking thread until the system time arrives to the specified value.
void chThdExit(msg_t msg)
Terminates the current thread.
thread_t threads[CH_CFG_MAX_THREADS+1]
Thread structures for all the defined threads.
#define CH_CFG_THREAD_EXT_FIELDS
Threads descriptor structure extension.