Go to the documentation of this file.
47 #define CH_KERNEL_STABLE 1
56 #define CH_KERNEL_VERSION "4.0.2"
61 #define CH_KERNEL_MAJOR 4
66 #define CH_KERNEL_MINOR 0
71 #define CH_KERNEL_PATCH 2
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"
184 #if !defined(CH_CFG_MAX_THREADS) || defined(__DOXYGEN__)
185 #error "CH_CFG_MAX_THREADS not defined in chconf.h"
188 #if !defined(CH_CFG_AUTOSTART_THREADS) || defined(__DOXYGEN__)
189 #error "CH_CFG_AUTOSTART_THREADS not defined in chconf.h"
192 #if !defined(CH_CFG_ST_RESOLUTION) || defined(__DOXYGEN__)
193 #error "CH_CFG_ST_RESOLUTION not defined in chconf.h"
196 #if !defined(CH_CFG_ST_FREQUENCY) || defined(__DOXYGEN__)
197 #error "CH_CFG_ST_FREQUENCY not defined in chconf.h"
200 #if !defined(CH_CFG_ST_TIMEDELTA) || defined(__DOXYGEN__)
201 #error "CH_CFG_ST_TIMEDELTA not defined in chconf.h"
204 #if !defined(CH_CFG_USE_WAITEXIT)
205 #error "CH_CFG_USE_WAITEXIT not defined in chconf.h"
208 #if !defined(CH_CFG_USE_MESSAGES) || defined(__DOXYGEN__)
209 #error "CH_CFG_USE_MESSAGES not defined in chconf.h"
212 #if !defined(CH_CFG_USE_SEMAPHORES) || defined(__DOXYGEN__)
213 #error "CH_CFG_USE_SEMAPHORES not defined in chconf.h"
216 #if !defined(CH_CFG_USE_EVENTS)
217 #error "CH_CFG_USE_EVENTS not defined in chconf.h"
220 #if !defined(CH_CFG_USE_MUTEXES) || defined(__DOXYGEN__)
221 #error "CH_CFG_USE_MUTEXES not defined in chconf.h"
224 #if !defined(CH_DBG_STATISTICS) || defined(__DOXYGEN__)
225 #error "CH_DBG_STATISTICS not defined in chconf.h"
228 #if !defined(CH_DBG_SYSTEM_STATE_CHECK) || defined(__DOXYGEN__)
229 #error "CH_DBG_SYSTEM_STATE_CHECK not defined in chconf.h"
232 #if !defined(CH_DBG_ENABLE_CHECKS) || defined(__DOXYGEN__)
233 #error "CH_DBG_ENABLE_CHECKS not defined in chconf.h"
236 #if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
237 #error "CH_DBG_ENABLE_ASSERTS not defined in chconf.h"
240 #if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
241 #error "CH_DBG_ENABLE_STACK_CHECK not defined in chconf.h"
244 #if !defined(CH_CFG_SYSTEM_INIT_HOOK) || defined(__DOXYGEN__)
245 #error "CH_CFG_SYSTEM_INIT_HOOK not defined in chconf.h"
248 #if !defined(CH_CFG_THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
249 #error "CH_CFG_THREAD_EXT_FIELDS not defined in chconf.h"
252 #if !defined(CH_CFG_THREAD_EXT_INIT_HOOK) || defined(__DOXYGEN__)
253 #error "CH_CFG_THREAD_EXT_INIT_HOOK not defined in chconf.h"
256 #if !defined(CH_CFG_THREAD_EXIT_HOOK) || defined(__DOXYGEN__)
257 #error "CH_CFG_THREAD_EXIT_HOOK not defined in chconf.h"
260 #if !defined(CH_CFG_IDLE_ENTER_HOOK) || defined(__DOXYGEN__)
261 #error "CH_CFG_IDLE_ENTER_HOOK not defined in chconf.h"
264 #if !defined(CH_CFG_IDLE_LEAVE_HOOK) || defined(__DOXYGEN__)
265 #error "CH_CFG_IDLE_LEAVE_HOOK not defined in chconf.h"
268 #if !defined(CH_CFG_SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
269 #error "CH_CFG_SYSTEM_HALT_HOOK not defined in chconf.h"
273 #if !defined(CH_CUSTOMER_LIC_NIL) || !defined(CH_LICENSE_FEATURES)
274 #error "malformed chlicense.h"
277 #if CH_CUSTOMER_LIC_NIL == FALSE
278 #error "ChibiOS/NIL not licensed"
281 #if (CH_LICENSE_FEATURES != CH_FEATURES_FULL) && \
282 (CH_LICENSE_FEATURES != CH_FEATURES_INTERMEDIATE) && \
283 (CH_LICENSE_FEATURES != CH_FEATURES_BASIC)
284 #error "invalid CH_LICENSE_FEATURES setting"
288 #if (CH_LICENSE_FEATURES == CH_FEATURES_INTERMEDIATE) || \
289 (CH_LICENSE_FEATURES == CH_FEATURES_BASIC)
292 #if CH_CFG_ST_FREQUENCY > 1000
293 #undef CH_CFG_ST_FREQUENCY
294 #define CH_CFG_ST_FREQUENCY 1000
301 #if CH_LICENSE_FEATURES == CH_FEATURES_BASIC
304 #undef CH_CFG_ST_TIMEDELTA
305 #define CH_CFG_ST_TIMEDELTA 0
308 #undef CH_CFG_USE_MESSAGES
309 #define CH_CFG_USE_MESSAGES FALSE
313 #if !defined(_CHIBIOS_NIL_CONF_)
314 #error "missing or wrong configuration file"
317 #if !defined(_CHIBIOS_NIL_CONF_VER_4_0_)
318 #error "obsolete or unknown configuration file"
321 #if CH_CFG_MAX_THREADS < 1
322 #error "at least one thread must be defined"
325 #if CH_CFG_MAX_THREADS > 16
326 #error "ChibiOS/NIL is not recommended for thread-intensive applications," \
327 "consider ChibiOS/RT instead"
330 #if (CH_CFG_ST_RESOLUTION != 16) && (CH_CFG_ST_RESOLUTION != 32)
331 #error "invalid CH_CFG_ST_RESOLUTION specified, must be 16 or 32"
334 #if CH_CFG_ST_FREQUENCY <= 0
335 #error "invalid CH_CFG_ST_FREQUENCY specified, must be greater than zero"
338 #if (CH_CFG_ST_TIMEDELTA < 0) || (CH_CFG_ST_TIMEDELTA == 1)
339 #error "invalid CH_CFG_ST_TIMEDELTA specified, must " \
340 "be zero or greater than one"
343 #if CH_CFG_USE_MUTEXES == TRUE
344 #error "mutexes not yet supported"
347 #if CH_DBG_STATISTICS == TRUE
348 #error "statistics not yet supported"
351 #if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || \
352 (CH_DBG_ENABLE_CHECKS == TRUE) || \
353 (CH_DBG_ENABLE_ASSERTS == TRUE) || \
354 (CH_DBG_ENABLE_STACK_CHECK == TRUE)
355 #define NIL_DBG_ENABLED TRUE
357 #define NIL_DBG_ENABLED FALSE
362 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
363 #define THD_IDLE_BASE (&__main_thread_stack_base__)
364 #define THD_IDLE_END (&__main_thread_stack_end__)
366 #define THD_IDLE_BASE NULL
367 #define THD_IDLE_END NULL
374 #if (CH_CFG_ST_RESOLUTION == 32) || defined(__DOXYGEN__)
431 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
477 #if (CH_CFG_USE_SEMAPHORES == TRUE) || defined(__DOXYGEN__)
480 #if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
486 #if (CH_CFG_USE_EVENTS == TRUE) || defined(__DOXYGEN__)
489 #if (CH_CFG_USE_MESSAGES == TRUE) || defined(__DOXYGEN__)
492 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
515 #if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
521 #if (CH_CFG_ST_TIMEDELTA > 0) || defined(__DOXYGEN__)
531 #if (CH_DBG_SYSTEM_STATE_CHECK == TRUE) || defined(__DOXYGEN__)
541 #if (NIL_DBG_ENABLED == TRUE) || defined(__DOXYGEN__)
561 #if CH_DBG_SYSTEM_STATE_CHECK == TRUE
562 #define _dbg_enter_lock() (nil.lock_cnt = (cnt_t)1)
563 #define _dbg_leave_lock() (nil.lock_cnt = (cnt_t)0)
569 #define __CH_STRINGIFY(a) #a
578 #define THD_TABLE_BEGIN \
579 const thread_descriptor_t nil_thd_configs[] = {
584 #define THD_TABLE_THREAD(_prio, _name, _wap, _funcp, _arg) \
588 .wend = THD_WORKING_AREA_END(_wap), \
597 #define THD_TABLE_END \
600 .wbase = THD_IDLE_BASE, \
601 .wend = THD_IDLE_END, \
602 .prio = CH_CFG_MAX_THREADS, \
618 #define MEM_ALIGN_MASK(a) ((size_t)(a) - 1U)
626 #define MEM_ALIGN_PREV(p, a) ((size_t)(p) & ~MEM_ALIGN_MASK(a))
634 #define MEM_ALIGN_NEXT(p, a) MEM_ALIGN_PREV((size_t)(p) + \
635 MEM_ALIGN_MASK(a), (a))
643 #define MEM_IS_ALIGNED(p, a) (((size_t)(p) & MEM_ALIGN_MASK(a)) == 0U)
651 #define MEM_IS_VALID_ALIGNMENT(a) \
652 (((size_t)(a) != 0U) && (((size_t)(a) & ((size_t)(a) - 1U)) == 0U))
667 #define THD_WORKING_AREA_SIZE(n) MEM_ALIGN_NEXT(PORT_WA_SIZE(n), \
680 #define THD_WORKING_AREA(s, n) PORT_WORKING_AREA(s, n)
692 #define THD_WORKING_AREA_END(wa) \
693 ((wa) + ((sizeof wa) / sizeof (stkalign_t)))
704 #define THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg)
722 #if defined(PORT_IRQ_IS_VALID_PRIORITY) || defined(__DOXYGEN__)
723 #define CH_IRQ_IS_VALID_PRIORITY(prio) \
724 PORT_IRQ_IS_VALID_PRIORITY(prio)
726 #define CH_IRQ_IS_VALID_PRIORITY(prio) false
740 #if defined(PORT_IRQ_IS_VALID_KERNEL_PRIORITY) || defined(__DOXYGEN__)
741 #define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) \
742 PORT_IRQ_IS_VALID_KERNEL_PRIORITY(prio)
744 #define CH_IRQ_IS_VALID_KERNEL_PRIORITY(prio) false
754 #define CH_IRQ_PROLOGUE() \
755 PORT_IRQ_PROLOGUE(); \
756 _dbg_check_enter_isr()
764 #define CH_IRQ_EPILOGUE() \
765 _dbg_check_leave_isr(); \
775 #define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
790 #define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
810 #define TIME_S2I(secs) \
811 ((sysinterval_t)((time_conv_t)(secs) * (time_conv_t)CH_CFG_ST_FREQUENCY))
826 #define TIME_MS2I(msecs) \
827 ((sysinterval_t)((((time_conv_t)(msecs) * \
828 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
829 (time_conv_t)999) / (time_conv_t)1000))
844 #define TIME_US2I(usecs) \
845 ((sysinterval_t)((((time_conv_t)(usecs) * \
846 (time_conv_t)CH_CFG_ST_FREQUENCY) + \
847 (time_conv_t)999999) / (time_conv_t)1000000))
862 #define TIME_I2S(interval) \
863 (time_secs_t)(((time_conv_t)(interval) + \
864 (time_conv_t)CH_CFG_ST_FREQUENCY - \
865 (time_conv_t)1) / (time_conv_t)CH_CFG_ST_FREQUENCY)
880 #define TIME_I2MS(interval) \
881 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000) + \
882 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
883 (time_conv_t)CH_CFG_ST_FREQUENCY)
898 #define TIME_I2US(interval) \
899 (time_msecs_t)((((time_conv_t)(interval) * (time_conv_t)1000000) + \
900 (time_conv_t)CH_CFG_ST_FREQUENCY - (time_conv_t)1) / \
901 (time_conv_t)CH_CFG_ST_FREQUENCY)
915 #define _THREADS_QUEUE_DATA(name) {(cnt_t)0}
924 #define THREADS_QUEUE_DECL(name) \
925 threads_queue_t name = _THREADS_QUEUE_DATA(name)
941 #define _SEMAPHORE_DATA(name, n) {n}
952 #define SEMAPHORE_DECL(name, n) semaphore_t name = _SEMAPHORE_DATA(name, n)
969 #if (PORT_SUPPORTS_RT == TRUE) || defined(__DOXYGEN__)
970 #define chSysGetRealtimeCounterX() (rtcnt_t)port_rt_get_counter_value()
981 #define chSysDisable() { \
983 _dbg_check_disable(); \
997 #define chSysSuspend() { \
999 _dbg_check_suspend(); \
1011 #define chSysEnable() { \
1012 _dbg_check_enable(); \
1021 #define chSysLock() { \
1023 _dbg_check_lock(); \
1031 #define chSysUnlock() { \
1032 _dbg_check_unlock(); \
1048 #define chSysLockFromISR() { \
1049 port_lock_from_isr(); \
1050 _dbg_check_lock_from_isr(); \
1066 #define chSysUnlockFromISR() { \
1067 _dbg_check_unlock_from_isr(); \
1068 port_unlock_from_isr(); \
1079 #define chSchGoSleepS(newstate) chSchGoSleepTimeoutS(newstate, TIME_INFINITE)
1089 #define chSchWakeupS(ntp, msg) do { \
1090 chSchReadyI(ntp, msg); \
1091 chSchRescheduleS(); \
1103 #define chSchIsRescRequiredI() ((bool)(nil.current != nil.next))
1110 #define chThdGetSelfX() nil.current
1120 #define chThdGetPriorityX(void) (tprio_t)(nil.current - &nil.threads[0])
1132 #define chThdResumeS(trp, msg) do { \
1133 chThdResumeI(trp, msg); \
1134 chSchRescheduleS(); \
1147 #define chThdSleepSeconds(secs) chThdSleep(TIME_S2I(secs))
1160 #define chThdSleepMilliseconds(msecs) chThdSleep(TIME_MS2I(msecs))
1173 #define chThdSleepMicroseconds(usecs) chThdSleep(TIME_US2I(usecs))
1182 #define chThdSleepS(timeout) \
1183 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, timeout)
1193 #define chThdSleepUntilS(abstime) \
1194 (void) chSchGoSleepTimeoutS(NIL_STATE_SLEEPING, \
1195 chTimeDiffX(chVTGetSystemTimeX(), (abstime)))
1204 #define chThdQueueObjectInit(tqp) ((tqp)->cnt = (cnt_t)0)
1216 #define chThdQueueIsEmptyI(tqp) ((bool)(tqp->cnt >= (cnt_t)0))
1231 #if (CH_CFG_ST_TIMEDELTA == 0) || defined(__DOXYGEN__)
1232 #define chVTGetSystemTimeX() (nil.systime)
1234 #define chVTGetSystemTimeX() port_timer_get_time()
1245 #define chVTTimeElapsedSinceX(start) \
1246 chTimeDiffX((start), chVTGetSystemTimeX())
1261 #define chVTIsSystemTimeWithinX(start, end) \
1262 chTimeIsInRangeX(chVTGetSystemTimeX(), start, end)
1273 #define chTimeAddX(systime, interval) \
1274 ((systime_t)(systime) + (systime_t)(interval))
1285 #define chTimeDiffX(start, end) \
1286 ((sysinterval_t)((systime_t)((systime_t)(end) - (systime_t)(start))))
1298 #if !defined(chDbgCheck)
1299 #define chDbgCheck(c) do { \
1301 if (CH_DBG_ENABLE_CHECKS != FALSE) { \
1304 chSysHalt(__func__); \
1324 #if !defined(chDbgAssert)
1325 #define chDbgAssert(c, r) do { \
1327 if (CH_DBG_ENABLE_ASSERTS != FALSE) { \
1330 chSysHalt(__func__); \
1338 #if CH_DBG_SYSTEM_STATE_CHECK == FALSE
1339 #define _dbg_enter_lock()
1340 #define _dbg_leave_lock()
1341 #define _dbg_check_disable()
1342 #define _dbg_check_suspend()
1343 #define _dbg_check_enable()
1344 #define _dbg_check_lock()
1345 #define _dbg_check_unlock()
1346 #define _dbg_check_lock_from_isr()
1347 #define _dbg_check_unlock_from_isr()
1348 #define _dbg_check_enter_isr()
1349 #define _dbg_check_leave_isr()
1350 #define chDbgCheckClassI()
1351 #define chDbgCheckClassS()
1358 #if !defined(__DOXYGEN__)
1359 #if (CH_DBG_ENABLE_STACK_CHECK == TRUE) || defined(__DOXYGEN__)
1360 extern stkalign_t __main_thread_stack_base__, __main_thread_stack_end__;
1389 #if CH_CFG_USE_WAITEXIT == TRUE
1401 #if CH_DBG_SYSTEM_STATE_CHECK == TRUE
1402 void _dbg_check_disable(
void);
1403 void _dbg_check_suspend(
void);
1404 void _dbg_check_enable(
void);
1405 void _dbg_check_lock(
void);
1406 void _dbg_check_unlock(
void);
1407 void _dbg_check_lock_from_isr(
void);
1408 void _dbg_check_unlock_from_isr(
void);
1409 void _dbg_check_enter_isr(
void);
1410 void _dbg_check_leave_isr(
void);
1411 void chDbgCheckClassI(
void);
1412 void chDbgCheckClassS(
void);
threads_queue_t * tqp
Pointer to thread queue.
struct port_context ctx
Processor context.
const char *volatile dbg_panic_msg
Panic message.
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 * next
Pointer to the next thread to be executed.
thread_t * chSchReadyI(thread_t *tp)
Inserts a thread in the Ready List placing it behind its peers.
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.
volatile systime_t systime
System time.
Structure representing a thread descriptor.
volatile cnt_t cnt
Threads Queue counter.
cnt_t lock_cnt
Lock nesting level.
uint64_t systime_t
Type of system time.
uint64_t time_conv_t
Type of time conversion variable.
msg_t sntmsg
Sent message.
void chSysTimerHandlerI(void)
Handles time ticks for round robin preemption and timer increments.
thread_t * tp
Pointer to thread.
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.
void chSchDoReschedule(void)
Switches to the first thread on the runnable queue.
nil_system_t nil
System data structures.
msg_t chThdEnqueueTimeoutS(threads_queue_t *tqp, sysinterval_t timeout)
Enqueues the caller thread on a threads queue object.
uint64_t stkalign_t
Type of stack and memory alignment enforcement.
thread_t * thread_reference_t
Type of a thread reference.
uint32_t systime_t
Type of system time.
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 ...
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.
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.
thread_t threads[CH_CFG_MAX_THREADS+1]
Thread structures for all the defined threads.
Nil RTOS events header file.
eventmask_t ewmask
Enabled events mask.
tstate_t state
Thread state.
cnt_t isr_cnt
ISR nesting level.
bool chSchIsPreemptionRequired(void)
Evaluates if preemption is required.
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.
void chSysInit(void)
ChibiOS/RT initialization.
thread_t * current
Pointer to the running thread.
uint32_t sysinterval_t
Type of time interval.
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.
nil_system_t * nsp
Pointer to nil base struct.
systime_t lasttime
System time of the last tick event.
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.
bool chTimeIsInRangeX(systime_t time, systime_t start, systime_t end)
Checks if the specified time is within the specified time range.
systime_t nexttime
Time of the next scheduled tick event.
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.
#define CH_CFG_THREAD_EXT_FIELDS
Threads descriptor structure extension.