git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@778 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2009-02-17 19:58:46 +00:00
parent 7fe2bf4789
commit 3d2f2081ce
24 changed files with 1435 additions and 975 deletions

View File

@ -239,8 +239,8 @@
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXESS) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXESS TRUE
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**

View File

@ -239,8 +239,8 @@
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXESS) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXESS TRUE
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**

View File

@ -239,8 +239,8 @@
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXESS) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXESS TRUE
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**

View File

@ -239,8 +239,8 @@
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXESS) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXESS TRUE
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**

View File

@ -239,8 +239,8 @@
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXESS) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXESS TRUE
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**

View File

@ -239,8 +239,8 @@
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXESS) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXESS TRUE
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**

View File

@ -27,14 +27,25 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
/*===========================================================================*/
/* Kernel parameters. */
/*===========================================================================*/
/**
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_OPTIMIZE_SPEED
#define CH_OPTIMIZE_SPEED TRUE
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
#define CH_FREQUENCY 1000
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
#define CH_TIME_QUANTUM 20
#endif
/**
@ -43,10 +54,10 @@
* For performance and code size reasons the recommended setting is to leave
* this option disabled.<br>
* You can use this option if you need to merge ChibiOS/RT with external
* libraries that require nested lock/unlock operations.
* libraries that require nested lock/unlock operations.
* @note The default is @p FALSE.
*/
#ifndef CH_USE_NESTED_LOCKS
#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
#define CH_USE_NESTED_LOCKS FALSE
#endif
@ -55,185 +66,10 @@
* on threads of equal priority.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_ROUNDROBIN
#if !defined(CH_USE_ROUNDROBIN) || defined(__DOXYGEN__)
#define CH_USE_ROUNDROBIN TRUE
#endif
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_WAITEXIT
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_SEMAPHORES
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_PRIORITY
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMSW
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_TIMEOUT
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MUTEXES
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#ifndef CH_USE_CONDVARS
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#ifndef CH_USE_CONDVARS_TIMEOUT
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_EVENTS
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#ifndef CH_USE_EVENTS_TIMEOUT
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MESSAGES
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#ifndef CH_USE_MESSAGES_EVENT
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#ifndef CH_USE_MESSAGES_PRIORITY
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES_HALFDUPLEX
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#ifndef CH_USE_QUEUES_TIMEOUT
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#ifndef CH_USE_SERIAL_FULLDUPLEX
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#ifndef CH_USE_SERIAL_HALFDUPLEX
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#ifndef CH_USE_HEAP
#define CH_USE_HEAP TRUE
#endif
/**
* Number of RAM bytes to use as system heap. If set to zero then the whole
* available RAM is used as system heap.
@ -241,54 +77,22 @@
* provide the @p __heap_base__ and @p __heap_end__ symbols.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_HEAP_SIZE
#if !defined(CH_HEAP_SIZE) || defined(__DOXYGEN__)
#define CH_HEAP_SIZE 512
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_USE_MALLOC_HEAP
#define CH_USE_MALLOC_HEAP FALSE
#endif
/*===========================================================================*/
/* Performance options. */
/*===========================================================================*/
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MEMPOOLS
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#ifndef CH_USE_DYNAMIC
#define CH_USE_DYNAMIC TRUE
#endif
/**
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_FREQUENCY
#define CH_FREQUENCY 1000
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#ifndef CH_TIME_QUANTUM
#define CH_TIME_QUANTUM 20
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
#define CH_OPTIMIZE_SPEED TRUE
#endif
/**
@ -309,13 +113,234 @@
#define CH_CURRP_REGISTER_CACHE "reg"
#endif
/*===========================================================================*/
/* Subsystem options. */
/*===========================================================================*/
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_MESSAGES_EVENT) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the Asynchronous Messages (Mailboxes) APIs are included
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#if !defined(CH_USE_QUEUES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#if !defined(CH_USE_SERIAL_FULLDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#if !defined(CH_USE_SERIAL_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
#define CH_USE_HEAP TRUE
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
#define CH_USE_MALLOC_HEAP FALSE
#endif
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
#define CH_USE_DYNAMIC TRUE
#endif
/*===========================================================================*/
/* Debug options. */
/*===========================================================================*/
/**
* Debug option, if enabled all the assertions in the kernel code are
* activated. This includes function parameters checks and consistency
* checks inside the kernel.
* checks inside the kernel.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_ASSERTS
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_ASSERTS FALSE
#endif
@ -324,22 +349,43 @@
* activated.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_TRACE
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_TRACE FALSE
#endif
/**
* Debug option, if enabled the threads working area is filled with a byte
* pattern when a thread is created.
* Debug option, if enabled a runtime stack check is performed.
* @note The stack check is performed in a architecture/port dependent way. It
* may not be implemented at all.
*/
#ifndef CH_DBG_FILL_THREADS
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_STACK_CHECK FALSE
#endif
/**
* Debug option, if enabled the threads working area is filled with a byte
* pattern when a thread is created.
*/
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
#define CH_DBG_FILL_THREADS FALSE
#endif
/**
* Debug option, if enabled a field is added to the @p Thread structure that
* counts the system ticks occurred while executing the thread.
*/
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
#define CH_DBG_THREADS_PROFILING FALSE
#endif
/*===========================================================================*/
/* Kernel hooks. */
/*===========================================================================*/
/**
* User fields added to the end of the @p Thread structure.
*/
#ifndef THREAD_EXT_FIELDS
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
#define THREAD_EXT_FIELDS \
struct { \
/* Add thread custom fields here.*/ \
@ -350,7 +396,7 @@ struct { \
* User initialization code added to the @p chThdInit() API.
* @note It is invoked from within @p chThdInit().
*/
#ifndef THREAD_EXT_INIT
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
#define THREAD_EXT_INIT(tp) { \
/* Add thread initialization code here.*/ \
}
@ -360,7 +406,7 @@ struct { \
* User finalization code added to the @p chThdExit() API.
* @note It is inserted into lock zone.
*/
#ifndef THREAD_EXT_EXIT
#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
#define THREAD_EXT_EXIT(tp) { \
/* Add thread finalization code here.*/ \
}
@ -370,7 +416,7 @@ struct { \
* Code inserted inside the idle thread loop immediately after an interrupt
* resumed execution.
*/
#ifndef IDLE_LOOP_HOOK
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
#define IDLE_LOOP_HOOK() { \
/* Idle loop code here.*/ \
}

View File

@ -27,14 +27,25 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
/*===========================================================================*/
/* Kernel parameters. */
/*===========================================================================*/
/**
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_OPTIMIZE_SPEED
#define CH_OPTIMIZE_SPEED TRUE
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
#define CH_FREQUENCY 1000
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
#define CH_TIME_QUANTUM 20
#endif
/**
@ -43,10 +54,10 @@
* For performance and code size reasons the recommended setting is to leave
* this option disabled.<br>
* You can use this option if you need to merge ChibiOS/RT with external
* libraries that require nested lock/unlock operations.
* libraries that require nested lock/unlock operations.
* @note The default is @p FALSE.
*/
#ifndef CH_USE_NESTED_LOCKS
#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
#define CH_USE_NESTED_LOCKS FALSE
#endif
@ -55,185 +66,10 @@
* on threads of equal priority.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_ROUNDROBIN
#if !defined(CH_USE_ROUNDROBIN) || defined(__DOXYGEN__)
#define CH_USE_ROUNDROBIN TRUE
#endif
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_WAITEXIT
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_SEMAPHORES
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_PRIORITY
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMSW
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_TIMEOUT
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MUTEXES
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#ifndef CH_USE_CONDVARS
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#ifndef CH_USE_CONDVARS_TIMEOUT
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_EVENTS
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#ifndef CH_USE_EVENTS_TIMEOUT
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MESSAGES
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#ifndef CH_USE_MESSAGES_EVENT
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#ifndef CH_USE_MESSAGES_PRIORITY
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES_HALFDUPLEX
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#ifndef CH_USE_QUEUES_TIMEOUT
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#ifndef CH_USE_SERIAL_FULLDUPLEX
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#ifndef CH_USE_SERIAL_HALFDUPLEX
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#ifndef CH_USE_HEAP
#define CH_USE_HEAP TRUE
#endif
/**
* Number of RAM bytes to use as system heap. If set to zero then the whole
* available RAM is used as system heap.
@ -241,54 +77,22 @@
* provide the @p __heap_base__ and @p __heap_end__ symbols.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_HEAP_SIZE
#if !defined(CH_HEAP_SIZE) || defined(__DOXYGEN__)
#define CH_HEAP_SIZE 512
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_USE_MALLOC_HEAP
#define CH_USE_MALLOC_HEAP FALSE
#endif
/*===========================================================================*/
/* Performance options. */
/*===========================================================================*/
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MEMPOOLS
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#ifndef CH_USE_DYNAMIC
#define CH_USE_DYNAMIC TRUE
#endif
/**
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_FREQUENCY
#define CH_FREQUENCY 1000
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#ifndef CH_TIME_QUANTUM
#define CH_TIME_QUANTUM 20
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
#define CH_OPTIMIZE_SPEED TRUE
#endif
/**
@ -309,13 +113,234 @@
#define CH_CURRP_REGISTER_CACHE "reg"
#endif
/*===========================================================================*/
/* Subsystem options. */
/*===========================================================================*/
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_MESSAGES_EVENT) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the Asynchronous Messages (Mailboxes) APIs are included
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#if !defined(CH_USE_QUEUES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#if !defined(CH_USE_SERIAL_FULLDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#if !defined(CH_USE_SERIAL_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
#define CH_USE_HEAP TRUE
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
#define CH_USE_MALLOC_HEAP FALSE
#endif
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
#define CH_USE_DYNAMIC TRUE
#endif
/*===========================================================================*/
/* Debug options. */
/*===========================================================================*/
/**
* Debug option, if enabled all the assertions in the kernel code are
* activated. This includes function parameters checks and consistency
* checks inside the kernel.
* checks inside the kernel.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_ASSERTS
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_ASSERTS FALSE
#endif
@ -324,22 +349,43 @@
* activated.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_TRACE
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_TRACE FALSE
#endif
/**
* Debug option, if enabled the threads working area is filled with a byte
* pattern when a thread is created.
* Debug option, if enabled a runtime stack check is performed.
* @note The stack check is performed in a architecture/port dependent way. It
* may not be implemented at all.
*/
#ifndef CH_DBG_FILL_THREADS
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_STACK_CHECK FALSE
#endif
/**
* Debug option, if enabled the threads working area is filled with a byte
* pattern when a thread is created.
*/
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
#define CH_DBG_FILL_THREADS FALSE
#endif
/**
* Debug option, if enabled a field is added to the @p Thread structure that
* counts the system ticks occurred while executing the thread.
*/
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
#define CH_DBG_THREADS_PROFILING FALSE
#endif
/*===========================================================================*/
/* Kernel hooks. */
/*===========================================================================*/
/**
* User fields added to the end of the @p Thread structure.
*/
#ifndef THREAD_EXT_FIELDS
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
#define THREAD_EXT_FIELDS \
struct { \
/* Add thread custom fields here.*/ \
@ -350,7 +396,7 @@ struct { \
* User initialization code added to the @p chThdInit() API.
* @note It is invoked from within @p chThdInit().
*/
#ifndef THREAD_EXT_INIT
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
#define THREAD_EXT_INIT(tp) { \
/* Add thread initialization code here.*/ \
}
@ -360,7 +406,7 @@ struct { \
* User finalization code added to the @p chThdExit() API.
* @note It is inserted into lock zone.
*/
#ifndef THREAD_EXT_EXIT
#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
#define THREAD_EXT_EXIT(tp) { \
/* Add thread finalization code here.*/ \
}
@ -370,7 +416,7 @@ struct { \
* Code inserted inside the idle thread loop immediately after an interrupt
* resumed execution.
*/
#ifndef IDLE_LOOP_HOOK
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
#define IDLE_LOOP_HOOK() { \
/* Idle loop code here.*/ \
}

View File

@ -27,14 +27,25 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
/*===========================================================================*/
/* Kernel parameters. */
/*===========================================================================*/
/**
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_OPTIMIZE_SPEED
#define CH_OPTIMIZE_SPEED TRUE
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
#define CH_FREQUENCY 100
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
#define CH_TIME_QUANTUM 10
#endif
/**
@ -43,10 +54,10 @@
* For performance and code size reasons the recommended setting is to leave
* this option disabled.<br>
* You can use this option if you need to merge ChibiOS/RT with external
* libraries that require nested lock/unlock operations.
* libraries that require nested lock/unlock operations.
* @note The default is @p FALSE.
*/
#ifndef CH_USE_NESTED_LOCKS
#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
#define CH_USE_NESTED_LOCKS FALSE
#endif
@ -55,185 +66,10 @@
* on threads of equal priority.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_ROUNDROBIN
#if !defined(CH_USE_ROUNDROBIN) || defined(__DOXYGEN__)
#define CH_USE_ROUNDROBIN TRUE
#endif
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_WAITEXIT
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_SEMAPHORES
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_PRIORITY
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMSW
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_TIMEOUT
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MUTEXES
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#ifndef CH_USE_CONDVARS
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#ifndef CH_USE_CONDVARS_TIMEOUT
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_EVENTS
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#ifndef CH_USE_EVENTS_TIMEOUT
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MESSAGES
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#ifndef CH_USE_MESSAGES_EVENT
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#ifndef CH_USE_MESSAGES_PRIORITY
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES_HALFDUPLEX
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#ifndef CH_USE_QUEUES_TIMEOUT
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#ifndef CH_USE_SERIAL_FULLDUPLEX
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#ifndef CH_USE_SERIAL_HALFDUPLEX
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#ifndef CH_USE_HEAP
#define CH_USE_HEAP TRUE
#endif
/**
* Number of RAM bytes to use as system heap. If set to zero then the whole
* available RAM is used as system heap.
@ -241,54 +77,22 @@
* provide the @p __heap_base__ and @p __heap_end__ symbols.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_HEAP_SIZE
#if !defined(CH_HEAP_SIZE) || defined(__DOXYGEN__)
#define CH_HEAP_SIZE 512
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_USE_MALLOC_HEAP
#define CH_USE_MALLOC_HEAP FALSE
#endif
/*===========================================================================*/
/* Performance options. */
/*===========================================================================*/
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MEMPOOLS
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#ifndef CH_USE_DYNAMIC
#define CH_USE_DYNAMIC TRUE
#endif
/**
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_FREQUENCY
#define CH_FREQUENCY 100
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#ifndef CH_TIME_QUANTUM
#define CH_TIME_QUANTUM 10
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
#define CH_OPTIMIZE_SPEED TRUE
#endif
/**
@ -309,13 +113,234 @@
#define CH_CURRP_REGISTER_CACHE "reg"
#endif
/*===========================================================================*/
/* Subsystem options. */
/*===========================================================================*/
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_MESSAGES_EVENT) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the Asynchronous Messages (Mailboxes) APIs are included
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#if !defined(CH_USE_QUEUES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#if !defined(CH_USE_SERIAL_FULLDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#if !defined(CH_USE_SERIAL_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
#define CH_USE_HEAP TRUE
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
#define CH_USE_MALLOC_HEAP FALSE
#endif
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
#define CH_USE_DYNAMIC TRUE
#endif
/*===========================================================================*/
/* Debug options. */
/*===========================================================================*/
/**
* Debug option, if enabled all the assertions in the kernel code are
* activated. This includes function parameters checks and consistency
* checks inside the kernel.
* checks inside the kernel.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_ASSERTS
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_ASSERTS FALSE
#endif
@ -324,22 +349,43 @@
* activated.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_TRACE
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_TRACE FALSE
#endif
/**
* Debug option, if enabled the threads working area is filled with a byte
* pattern when a thread is created.
* Debug option, if enabled a runtime stack check is performed.
* @note The stack check is performed in a architecture/port dependent way. It
* may not be implemented at all.
*/
#ifndef CH_DBG_FILL_THREADS
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_STACK_CHECK FALSE
#endif
/**
* Debug option, if enabled the threads working area is filled with a byte
* pattern when a thread is created.
*/
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
#define CH_DBG_FILL_THREADS FALSE
#endif
/**
* Debug option, if enabled a field is added to the @p Thread structure that
* counts the system ticks occurred while executing the thread.
*/
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
#define CH_DBG_THREADS_PROFILING FALSE
#endif
/*===========================================================================*/
/* Kernel hooks. */
/*===========================================================================*/
/**
* User fields added to the end of the @p Thread structure.
*/
#ifndef THREAD_EXT_FIELDS
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
#define THREAD_EXT_FIELDS \
struct { \
/* Add thread custom fields here.*/ \
@ -350,7 +396,7 @@ struct { \
* User initialization code added to the @p chThdInit() API.
* @note It is invoked from within @p chThdInit().
*/
#ifndef THREAD_EXT_INIT
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
#define THREAD_EXT_INIT(tp) { \
/* Add thread initialization code here.*/ \
}
@ -360,7 +406,7 @@ struct { \
* User finalization code added to the @p chThdExit() API.
* @note It is inserted into lock zone.
*/
#ifndef THREAD_EXT_EXIT
#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
#define THREAD_EXT_EXIT(tp) { \
/* Add thread finalization code here.*/ \
}
@ -370,7 +416,7 @@ struct { \
* Code inserted inside the idle thread loop immediately after an interrupt
* resumed execution.
*/
#ifndef IDLE_LOOP_HOOK
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
#define IDLE_LOOP_HOOK() { \
/* Idle loop code here.*/ \
}

View File

@ -239,8 +239,8 @@
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXESS) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXESS TRUE
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**

View File

@ -1308,10 +1308,14 @@ PREDEFINED = __DOXYGEN__ \
CH_USE_HEAP=1 \
CH_USE_MEMPOOLS=1 \
CH_USE_MESSAGES=1 \
CH_USE_MAILBOXES=1 \
CH_USE_MESSAGES_EVENT=1 \
CH_USE_DEBUG=1 \
CH_USE_TRACE=1 \
CH_USE_DYNAMIC=1 \
CH_DBG_ENABLE_ASSERTS=1 \
CH_DBG_ENABLE_TRACE=1 \
CH_DBG_ENABLE_STACK_CHECK=1 \
CH_DBG_FILL_THREADS=1 \
CH_DBG_THREADS_PROFILING=1 \
CH_USE_ROUNDROBIN=1
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then

View File

@ -281,15 +281,15 @@
/** @} */
/**
* @defgroup Messages Messages
* @defgroup Messages Synchronous Messages
* @{
* Synchronous inter-thread messages.
* <h2>Operation Mode</h2>
* Messages are an easy to use and fast IPC mechanism, threads can both serve
* messages and send messages to other threads, the mechanism allows data to
* be carried in both directions. Data is not copied between the client and
* server threads but just a pointer passed so the exchange is very time
* efficient.<br>
* Synchronoud messages are an easy to use and fast IPC mechanism, threads
* can both serve messages and send messages to other threads, the mechanism
* allows data to be carried in both directions. Data is not copied between
* the client and server threads but just a pointer passed so the exchange
* is very time efficient.<br>
* Messages are usually processed in FIFO order but it is possible to process
* them in priority order by specifying CH_USE_MESSAGES_PRIORITY
* in @p chconf.h.<br>
@ -301,6 +301,30 @@
*/
/** @} */
/**
* @defgroup Mailboxes Mailboxes
* @{
* Asynchronous messages.
* <h2>Operation mode</h2>
* A mailbox is an asynchronous communication mechanism.<br>
* The following operations are possible on a mailbox:
* - <b>Post</b>: Posts a message on the mailbox in FIFO order.
* - <b>Post Ahead</b>: Posts a message on the mailbox with high priority.
* - <b>Fetch</b>: A message is fetched from the mailbox and removed from
* the queue.
* - <b>Reset</b>: The mailbox is emptied and all the stored messages lost.
* .
* A message is a variable of type msg_t that is guaranteed to have the
* same size of and be compatible with pointers (an explicit cast is needed).
* If larger messages need to be exchanged then a pointer to a structure can
* be posted in the mailbox but the posting side has no predefined way to
* know when the message has been processed. A possible approach is to
* allocate memory (from a memory pool as example) from the posting side and
* free it on the fetching side. Another approach is to set a "done" flag into
* the structure pointed by the message.
*/
/** @} */
/**
* @defgroup IOQueues I/O Queues
* @{

152
src/chmboxes.c Normal file
View File

@ -0,0 +1,152 @@
/*
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file chmboxes.c
* @brief Mailboxes code.
* @addtogroup Mailboxes
* @{
*/
#include <ch.h>
#if CH_USE_MAILBOXES
/**
* @brief Initializes a Mailbox object.
*
* @param[out] mbp the pointer to the Mailbox structure to be initialized
* @param[in] buf the circular messages buffer
* @param[in] n the buffer size as number of @p msg_t
*/
void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) {
mbp->mb_buffer = mbp->mb_wrptr = mbp->mb_rdptr = buf;
mbp->mb_top = &buf[n];
chSemInit(&mbp->mb_emptysem, n);
chSemInit(&mbp->mb_fullsem, 0);
}
/**
* @brief Resets a Mailbox object.
* @details All the waiting threads are resumed with status @p RDY_RESET and
* the queued messages are lost.
*
* @param[in] mbp the pointer to an initialized Mailbox object
*/
void chMBReset(Mailbox *mbp) {
chSysLock();
mbp->mb_wrptr = mbp->mb_rdptr = mbp->mb_buffer;
chSemResetI(&mbp->mb_emptysem, mbp->mb_top - mbp->mb_buffer);
chSemResetI(&mbp->mb_fullsem, 0);
chSchRescheduleS();
chSysUnlock();
}
/**
* @brief Posts a message into a mailbox.
* @details The invoking thread waits until a empty slot in the mailbox becomes
* available or the specified time runs out.
*
* @param[in] mbp the pointer to an initialized Mailbox object
* @param[in] msg the message to be posted on the mailbox
* @param[in] timeout the number of ticks before the operation fails
* @return The operation status.
* @retval RDY_OK if the message was correctly posted.
* @retval RDY_RESET if the mailbox was reset while waiting.
* @retval RDY_TIMEOUT if the operation timed out.
*/
msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t timeout) {
msg_t rdymsg;
chSysLock();
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, timeout);
if (rdymsg == RDY_OK) {
*mbp->mb_wrptr++ = msg;
if (mbp->mb_wrptr >= mbp->mb_top)
mbp->mb_wrptr = mbp->mb_buffer;
chSemSignalI(&mbp->mb_fullsem);
chSchRescheduleS();
}
chSysUnlock();
return rdymsg;
}
/**
* @brief Posts an high priority message into a mailbox.
* @details The invoking thread waits until a empty slot in the mailbox becomes
* available or the specified time runs out.
*
* @param[in] mbp the pointer to an initialized Mailbox object
* @param[in] msg the message to be posted on the mailbox
* @param[in] timeout the number of ticks before the operation timeouts
* @return The operation status.
* @retval RDY_OK if the message was correctly posted.
* @retval RDY_RESET if the mailbox was reset while waiting.
* @retval RDY_TIMEOUT if the operation timed out.
*/
msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t timeout) {
msg_t rdymsg;
chSysLock();
rdymsg = chSemWaitTimeoutS(&mbp->mb_emptysem, timeout);
if (rdymsg == RDY_OK) {
if (--mbp->mb_rdptr < mbp->mb_buffer)
mbp->mb_rdptr = mbp->mb_top - 1;
*mbp->mb_rdptr = msg;
chSemSignalI(&mbp->mb_fullsem);
chSchRescheduleS();
}
chSysUnlock();
return rdymsg;
}
/**
* @brief Retrieves a message from a mailbox.
* @details The invoking thread waits until a message is posted in the mailbox
* or the specified time runs out.
*
* @param[in] mbp the pointer to an initialized Mailbox object
* @param[out] msgp pointer to a message variable for the received message
* @param[in] timeout the number of ticks before the operation timeouts
* @return The operation status.
* @retval RDY_OK if a message was correctly fetched.
* @retval RDY_RESET if the mailbox was reset while waiting.
* @retval RDY_TIMEOUT if the operation timed out.
*/
msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t timeout) {
msg_t rdymsg;
chSysLock();
rdymsg = chSemWaitTimeoutS(&mbp->mb_fullsem, timeout);
if (rdymsg == RDY_OK) {
*msgp = *mbp->mb_rdptr++;
if (mbp->mb_rdptr >= mbp->mb_top)
mbp->mb_rdptr = mbp->mb_buffer;
chSemSignalI(&mbp->mb_emptysem);
chSchRescheduleS();
}
chSysUnlock();
return rdymsg;
}
#endif /* CH_USE_MAILBOXES */
/** @} */

View File

@ -177,7 +177,7 @@ size_t chIQRead(Queue *qp, uint8_t *buffer, size_t n) {
chSysUnlock();
break;
}
chSemFastWaitS(&qp->q_sem);
chSemFastWaitI(&qp->q_sem);
*buffer++ = *qp->q_rdptr++;
if (qp->q_rdptr >= qp->q_top)
qp->q_rdptr = qp->q_buffer;
@ -302,7 +302,7 @@ size_t chOQWrite(Queue *qp, uint8_t *buffer, size_t n) {
chSysUnlock();
break;
}
chSemFastWaitS(&qp->q_sem);
chSemFastWaitI(&qp->q_sem);
*qp->q_wrptr++ = *buffer++;
if (qp->q_wrptr >= qp->q_top)
qp->q_wrptr = qp->q_buffer;

View File

@ -100,6 +100,9 @@ void chSysTimerHandlerI(void) {
if (rlist.r_preempt > 0)
/* decrement remaining quantum */
rlist.r_preempt--;
#endif
#if CH_DBG_THREADS_PROFILING
currp->p_time++;
#endif
chVTDoTickI();
}

View File

@ -37,6 +37,9 @@ Thread *init_thread(Thread *tp, tprio_t prio) {
#if CH_USE_NESTED_LOCKS
tp->p_locks = 0;
#endif
#if CH_DBG_THREADS_PROFILING
tp->p_time = 0;
#endif
#if CH_USE_MUTEXES
/* realprio is the thread's own, non-inherited, priority */
tp->p_realprio = prio;

View File

@ -74,6 +74,7 @@
#include "condvars.h"
#include "events.h"
#include "messages.h"
#include "mailboxes.h"
#include "heap.h"
#include "mempools.h"
#include "threads.h"

85
src/include/mailboxes.h Normal file
View File

@ -0,0 +1,85 @@
/*
ChibiOS/RT - Copyright (C) 2006-2007 Giovanni Di Sirio.
This file is part of ChibiOS/RT.
ChibiOS/RT is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
ChibiOS/RT is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/**
* @file mailboxes.h
* @brief Mailboxes macros and structures.
* @addtogroup Mailboxes
* @{
*/
#ifndef _MAILBOXES_H_
#define _MAILBOXES_H_
#if CH_USE_MAILBOXES
typedef struct {
msg_t *mb_buffer; /**< Pointer to the mailbox buffer.*/
msg_t *mb_top; /**< Pointer to the first location
after the buffer.*/
msg_t *mb_wrptr; /**< Write pointer.*/
msg_t *mb_rdptr; /**< Read pointer.*/
Semaphore mb_fullsem; /**< Full counter @p Semaphore.*/
Semaphore mb_emptysem; /**< Empty counter @p Semaphore.*/
} Mailbox;
#ifdef __cplusplus
extern "C" {
#endif
void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n);
void chMBReset(Mailbox *mbp);
msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t timeout);
msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t timeout);
msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t timeout);
#ifdef __cplusplus
}
#endif
/**
* Verifies if the mailbox has space for an immediate message.
* @param[in] mbp the pointer to an initialized Mailbox object
* @return The number of empty message slots.
* @note Can be invoked in any system state but if invoked out of a locked
* state then the returned value may change after reading.
*/
#define chMBHasSpace(mbp) chSemGetCounterI(&(mbp)->mb_emptysem)
/**
* Verifies if the mailbox has incoming messages.
* @param[in] mbp the pointer to an initialized Mailbox object
* @return The number of queued messages.
* @note Can be invoked in any system state but if invoked out of a locked
* state then the returned value may change after reading.
*/
#define chMBContainsMessages(mbp) chSemGetCounterI(&(mbp)->mb_fullsem)
/**
* Returns the next message in the queue without removing it.
* @note A message must be waiting in the queue for this function to work or
* it would return garbage. The correct way to use this macro is to
* use @p chMBContainsMessages() and then use this macro, all within
* a lock state.
*/
#define chMBPeek(mbp) (*(mbp)->mb_rdptr)
#endif /* CH_USE_MAILBOXES */
#endif /* _MAILBOXES_H_ */
/** @} */

View File

@ -63,7 +63,7 @@ extern "C" {
* Decreases the semaphore counter, this macro can be used when it is ensured
* that the counter would not become negative.
*/
#define chSemFastWaitS(sp) ((sp)->s_cnt--)
#define chSemFastWaitI(sp) ((sp)->s_cnt--)
/**
* Increases the semaphore counter, this macro can be used when the counter is
@ -74,7 +74,7 @@ extern "C" {
/**
* Returns the semaphore counter current value.
*/
#define chSemGetCounter(sp) ((sp)->s_cnt)
#define chSemGetCounterI(sp) ((sp)->s_cnt)
#endif /* CH_USE_SEMAPHORES */

View File

@ -43,13 +43,9 @@
/**
* @brief Performs a context switch.
* @details This is the most critical code in any port, this function
* is responsible for the context switch between 2 threads.
*
* @param otp the thread to be switched out
* @param ntp the thread to be switched in
* @note The implementation of this code affects <b>directly</b> the context
* switch performance so optimize here as much as you can.
*/
#define chSysSwitchI(otp, ntp) port_switch(otp, ntp)

View File

@ -49,6 +49,10 @@ struct Thread {
struct context p_ctx; /**< Processor context.*/
#if CH_USE_NESTED_LOCKS
cnt_t p_locks; /**< Number of nested locks.*/
#endif
#if CH_DBG_THREADS_PROFILING
systime_t p_time; /**< Consumed time.
@note This field can overflow.*/
#endif
/*
* The following fields are merged in unions because they are all

View File

@ -1,13 +1,13 @@
# List of all the ChibiOS/RT kernel files, there is no need to remove the files
# from this list, you can disable parts of the kernel by editing chconf.h.
KERNSRC = ../../src/chsys.c ../../src/chdebug.c \
../../src/chlists.c ../../src/chvt.c \
../../src/chschd.c ../../src/chthreads.c \
../../src/chsem.c ../../src/chmtx.c \
../../src/chcond.c ../../src/chevents.c \
../../src/chmsg.c ../../src/chqueues.c \
../../src/chheap.c ../../src/chmempools.c \
../../src/chserial.c
KERNSRC = ../../src/chsys.c ../../src/chdebug.c \
../../src/chlists.c ../../src/chvt.c \
../../src/chschd.c ../../src/chthreads.c \
../../src/chsem.c ../../src/chmtx.c \
../../src/chcond.c ../../src/chevents.c \
../../src/chmsg.c ../../src/chmboxes.c \
../../src/chqueues.c ../../src/chheap.c \
../../src/chmempools.c ../../src/chserial.c
# Required include directories
KERNINC = ../../src/include

View File

@ -27,14 +27,25 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
/*===========================================================================*/
/* Kernel parameters. */
/*===========================================================================*/
/**
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_OPTIMIZE_SPEED
#define CH_OPTIMIZE_SPEED TRUE
#if !defined(CH_FREQUENCY) || defined(__DOXYGEN__)
#define CH_FREQUENCY 1000
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#if !defined(CH_TIME_QUANTUM) || defined(__DOXYGEN__)
#define CH_TIME_QUANTUM 20
#endif
/**
@ -43,10 +54,10 @@
* For performance and code size reasons the recommended setting is to leave
* this option disabled.<br>
* You can use this option if you need to merge ChibiOS/RT with external
* libraries that require nested lock/unlock operations.
* libraries that require nested lock/unlock operations.
* @note The default is @p FALSE.
*/
#ifndef CH_USE_NESTED_LOCKS
#if !defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
#define CH_USE_NESTED_LOCKS FALSE
#endif
@ -55,185 +66,10 @@
* on threads of equal priority.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_ROUNDROBIN
#if !defined(CH_USE_ROUNDROBIN) || defined(__DOXYGEN__)
#define CH_USE_ROUNDROBIN TRUE
#endif
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_WAITEXIT
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_SEMAPHORES
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_PRIORITY
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMSW
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_SEMAPHORES_TIMEOUT
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MUTEXES
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#ifndef CH_USE_CONDVARS
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#ifndef CH_USE_CONDVARS_TIMEOUT
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_EVENTS
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#ifndef CH_USE_EVENTS_TIMEOUT
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MESSAGES
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#ifndef CH_USE_MESSAGES_EVENT
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#ifndef CH_USE_MESSAGES_PRIORITY
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#ifndef CH_USE_QUEUES_HALFDUPLEX
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#ifndef CH_USE_QUEUES_TIMEOUT
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#ifndef CH_USE_SERIAL_FULLDUPLEX
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#ifndef CH_USE_SERIAL_HALFDUPLEX
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#ifndef CH_USE_HEAP
#define CH_USE_HEAP TRUE
#endif
/**
* Number of RAM bytes to use as system heap. If set to zero then the whole
* available RAM is used as system heap.
@ -241,54 +77,22 @@
* provide the @p __heap_base__ and @p __heap_end__ symbols.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_HEAP_SIZE
#if !defined(CH_HEAP_SIZE) || defined(__DOXYGEN__)
#define CH_HEAP_SIZE 0
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#ifndef CH_USE_MALLOC_HEAP
#define CH_USE_MALLOC_HEAP FALSE
#endif
/*===========================================================================*/
/* Performance options. */
/*===========================================================================*/
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* If specified then time efficient rather than space efficient code is used
* when two possible implementations exist.
* @note This is not related to the compiler optimization options.
* @note The default is @p TRUE.
*/
#ifndef CH_USE_MEMPOOLS
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#ifndef CH_USE_DYNAMIC
#define CH_USE_DYNAMIC TRUE
#endif
/**
* Frequency of the system timer that drives the system ticks. This also
* defines the system tick time unit.
*/
#ifndef CH_FREQUENCY
#define CH_FREQUENCY 1000
#endif
/**
* This constant is the number of system ticks allowed for the threads before
* preemption occurs. This option is only meaningful if the option
* @p CH_USE_ROUNDROBIN is also active.
*/
#ifndef CH_TIME_QUANTUM
#define CH_TIME_QUANTUM 20
#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
#define CH_OPTIMIZE_SPEED TRUE
#endif
/**
@ -309,13 +113,234 @@
#define CH_CURRP_REGISTER_CACHE "reg"
#endif
/*===========================================================================*/
/* Subsystem options. */
/*===========================================================================*/
/**
* If specified then the @p chThdWait() function is included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_WAITEXIT) || defined(__DOXYGEN__)
#define CH_USE_WAITEXIT TRUE
#endif
/**
* If specified then the Semaphores APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_SEMAPHORES) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES TRUE
#endif
/**
* If enabled then the threads are enqueued on semaphores by priority rather
* than FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_PRIORITY FALSE
#endif
/**
* If specified then the Semaphores the @p chSemWaitSignal() API is included
* in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMSW) || defined(__DOXYGEN__)
#define CH_USE_SEMSW TRUE
#endif
/**
* If specified then the Semaphores with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_SEMAPHORES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_SEMAPHORES_TIMEOUT TRUE
#endif
/**
* If specified then the Mutexes APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MUTEXES) || defined(__DOXYGEN__)
#define CH_USE_MUTEXES TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES.
*/
#if !defined(CH_USE_CONDVARS) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS TRUE
#endif
/**
* If specified then the Conditional Variables APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_CONDVARS.
*/
#if !defined(CH_USE_CONDVARS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_CONDVARS_TIMEOUT TRUE
#endif
/**
* If specified then the Event flags APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_EVENTS) || defined(__DOXYGEN__)
#define CH_USE_EVENTS TRUE
#endif
/**
* If specified then the @p chEvtWaitXXXTimeout() functions are included in
* the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_EVENTS_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_EVENTS_TIMEOUT TRUE
#endif
/**
* If specified then the Synchronous Messages APIs are included in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MESSAGES) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES TRUE
#endif
/**
* If specified then the @p chMsgSendWithEvent() function is included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MESSAGES and @p CH_USE_EVENTS.
*/
#if !defined(CH_USE_MESSAGES_EVENT) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_EVENT TRUE
#endif
/**
* If enabled then messages are served by priority rather than in FIFO order.
* @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_MESSAGES.
*/
#if !defined(CH_USE_MESSAGES_PRIORITY) || defined(__DOXYGEN__)
#define CH_USE_MESSAGES_PRIORITY FALSE
#endif
/**
* If specified then the Asynchronous Messages (Mailboxes) APIs are included
* in the kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MAILBOXES) || defined(__DOXYGEN__)
#define CH_USE_MAILBOXES TRUE
#endif
/**
* If specified then the I/O queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES) || defined(__DOXYGEN__)
#define CH_USE_QUEUES TRUE
#endif
/**
* If specified then the half duplex queues APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_SEMAPHORES.
*/
#if !defined(CH_USE_QUEUES_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_HALFDUPLEX TRUE
#endif
/**
* If specified then the I/O queues with timeout APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES and @p CH_USE_SEMAPHORES_TIMEOUT.
*/
#if !defined(CH_USE_QUEUES_TIMEOUT) || defined(__DOXYGEN__)
#define CH_USE_QUEUES_TIMEOUT TRUE
#endif
/**
* If specified then the full duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES.
*/
#if !defined(CH_USE_SERIAL_FULLDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_FULLDUPLEX TRUE
#endif
/**
* If specified then the half duplex serial driver APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_QUEUES_HALFDUPLEX.
*/
#if !defined(CH_USE_SERIAL_HALFDUPLEX) || defined(__DOXYGEN__)
#define CH_USE_SERIAL_HALFDUPLEX TRUE
#endif
/**
* If specified then the memory heap allocator APIs are included in the kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_MUTEXES or @p CH_USE_SEMAPHORES.
* @note Mutexes are recommended.
*/
#if !defined(CH_USE_HEAP) || defined(__DOXYGEN__)
#define CH_USE_HEAP TRUE
#endif
/**
* If enabled enforces the use of the C-runtime @p malloc() and @p free()
* functions as backend for the system heap allocator.
* @note The default is @p FALSE.
* @note Requires @p CH_USE_HEAP.
*/
#if !defined(CH_USE_MALLOC_HEAP) || defined(__DOXYGEN__)
#define CH_USE_MALLOC_HEAP FALSE
#endif
/**
* If specified then the memory pools allocator APIs are included in the
* kernel.
* @note The default is @p TRUE.
*/
#if !defined(CH_USE_MEMPOOLS) || defined(__DOXYGEN__)
#define CH_USE_MEMPOOLS TRUE
#endif
/**
* If specified then the dynamic threads creation APIs are included in the
* kernel.
* @note The default is @p TRUE.
* @note Requires @p CH_USE_WAITEXIT.
*/
#if !defined(CH_USE_DYNAMIC) || defined(__DOXYGEN__)
#define CH_USE_DYNAMIC TRUE
#endif
/*===========================================================================*/
/* Debug options. */
/*===========================================================================*/
/**
* Debug option, if enabled all the assertions in the kernel code are
* activated. This includes function parameters checks and consistency
* checks inside the kernel.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_ASSERTS
#if !defined(CH_DBG_ENABLE_ASSERTS) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_ASSERTS FALSE
#endif
@ -324,22 +349,43 @@
* activated.
* @note The default is @p FALSE.
*/
#ifndef CH_DBG_ENABLE_TRACE
#if !defined(CH_DBG_ENABLE_TRACE) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_TRACE FALSE
#endif
/**
* Debug option, if enabled a runtime stack check is performed.
* @note The stack check is performed in a architecture/port dependent way. It
* may not be implemented at all.
*/
#if !defined(CH_DBG_ENABLE_STACK_CHECK) || defined(__DOXYGEN__)
#define CH_DBG_ENABLE_STACK_CHECK FALSE
#endif
/**
* Debug option, if enabled the threads working area is filled with a byte
* pattern when a thread is created.
*/
#ifndef CH_DBG_FILL_THREADS
#if !defined(CH_DBG_FILL_THREADS) || defined(__DOXYGEN__)
#define CH_DBG_FILL_THREADS FALSE
#endif
/**
* Debug option, if enabled a field is added to the @p Thread structure that
* counts the system ticks occurred while executing the thread.
*/
#if !defined(CH_DBG_THREADS_PROFILING) || defined(__DOXYGEN__)
#define CH_DBG_THREADS_PROFILING FALSE
#endif
/*===========================================================================*/
/* Kernel hooks. */
/*===========================================================================*/
/**
* User fields added to the end of the @p Thread structure.
*/
#ifndef THREAD_EXT_FIELDS
#if !defined(THREAD_EXT_FIELDS) || defined(__DOXYGEN__)
#define THREAD_EXT_FIELDS \
struct { \
/* Add thread custom fields here.*/ \
@ -350,7 +396,7 @@ struct { \
* User initialization code added to the @p chThdInit() API.
* @note It is invoked from within @p chThdInit().
*/
#ifndef THREAD_EXT_INIT
#if !defined(THREAD_EXT_INIT) || defined(__DOXYGEN__)
#define THREAD_EXT_INIT(tp) { \
/* Add thread initialization code here.*/ \
}
@ -360,7 +406,7 @@ struct { \
* User finalization code added to the @p chThdExit() API.
* @note It is inserted into lock zone.
*/
#ifndef THREAD_EXT_EXIT
#if !defined(THREAD_EXT_EXIT) || defined(__DOXYGEN__)
#define THREAD_EXT_EXIT(tp) { \
/* Add thread finalization code here.*/ \
}
@ -370,7 +416,7 @@ struct { \
* Code inserted inside the idle thread loop immediately after an interrupt
* resumed execution.
*/
#ifndef IDLE_LOOP_HOOK
#if !defined(IDLE_LOOP_HOOK) || defined(__DOXYGEN__)
#define IDLE_LOOP_HOOK() { \
/* Idle loop code here.*/ \
}

View File

@ -119,9 +119,13 @@ void port_halt(void) {
/**
* @brief Performs a context switch between two threads.
* @details This is the most critical code in any port, this function
* is responsible for the context switch between 2 threads.
*
* @param otp the thread to be switched out
* @param ntp the thread to be switched in
* @note The implementation of this code affects <b>directly</b> the context
* switch performance so optimize here as much as you can.
*/
void port_switch(Thread *otp, Thread *ntp) {
}