aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorgdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-02-07 12:42:29 +0000
committergdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4>2009-02-07 12:42:29 +0000
commitb08638d7c8e46b3a207705a2e55fdfe4b78cfb3e (patch)
treef9e60d830d48036b3012822a4eedb909c3c4ce25 /src
parent37c2720510cf319159d19398533169711d092f6b (diff)
downloadChibiOS-b08638d7c8e46b3a207705a2e55fdfe4b78cfb3e.tar.gz
ChibiOS-b08638d7c8e46b3a207705a2e55fdfe4b78cfb3e.tar.bz2
ChibiOS-b08638d7c8e46b3a207705a2e55fdfe4b78cfb3e.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@735 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'src')
-rw-r--r--src/chcond.c6
-rw-r--r--src/chdebug.c6
-rw-r--r--src/chevents.c9
-rw-r--r--src/chheap.c16
-rw-r--r--src/chlists.c2
-rw-r--r--src/chmempools.c2
-rw-r--r--src/chmsg.c8
-rw-r--r--src/chmtx.c4
-rw-r--r--src/chqueues.c12
-rw-r--r--src/chschd.c20
-rw-r--r--src/chsem.c8
-rw-r--r--src/chserial.c4
-rw-r--r--src/chsys.c8
-rw-r--r--src/chthreads.c34
-rw-r--r--src/include/ch.h20
-rw-r--r--src/include/condvars.h6
-rw-r--r--src/include/debug.h11
-rw-r--r--src/include/events.h8
-rw-r--r--src/include/inline.h2
-rw-r--r--src/include/lists.h4
-rw-r--r--src/include/mempools.h2
-rw-r--r--src/include/messages.h4
-rw-r--r--src/include/mutexes.h2
-rw-r--r--src/include/queues.h8
-rw-r--r--src/include/scheduler.h6
-rw-r--r--src/include/semaphores.h6
-rw-r--r--src/include/serial.h4
-rw-r--r--src/include/sys.h24
-rw-r--r--src/include/threads.h30
-rw-r--r--src/templates/chconf.h178
30 files changed, 278 insertions, 176 deletions
diff --git a/src/chcond.c b/src/chcond.c
index 7b37e454c..d6a68bb72 100644
--- a/src/chcond.c
+++ b/src/chcond.c
@@ -30,7 +30,7 @@
#include <ch.h>
-#if defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES)
+#if CH_USE_CONDVARS && CH_USE_MUTEXES
/**
* @brief Initializes s @p CondVar structure.
@@ -150,7 +150,7 @@ msg_t chCondWaitS(CondVar *cp) {
return msg; /* returns the wakeup message */
}
-#ifdef CH_USE_CONDVARS_TIMEOUT
+#if CH_USE_CONDVARS_TIMEOUT
/**
* @brief Waits on the condition variable releasing the mutex lock.
* @details Releases the mutex, waits on the condition variable, and finally
@@ -208,6 +208,6 @@ msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time) {
}
#endif /* CH_USE_CONDVARS_TIMEOUT */
-#endif /* defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES) */
+#endif /* CH_USE_CONDVARS && CH_USE_MUTEXES */
/** @} */
diff --git a/src/chdebug.c b/src/chdebug.c
index 8fa67bbf7..4a16e2d2a 100644
--- a/src/chdebug.c
+++ b/src/chdebug.c
@@ -26,7 +26,7 @@
#include <ch.h>
-#ifdef CH_USE_DEBUG
+#if CH_USE_DEBUG
char *panicmsg;
@@ -35,7 +35,7 @@ char *panicmsg;
*/
void debug_init(void) {
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
dbgtb.tb_size = TRACE_BUFFER_SIZE;
dbgtb.tb_ptr = &dbgtb.tb_buffer[0];
#endif
@@ -55,7 +55,7 @@ void chDbgPanic(char *msg) {
chSysHalt();
}
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
/**
* @brief Public trace buffer.
*/
diff --git a/src/chevents.c b/src/chevents.c
index 7f75fbe42..c49b90874 100644
--- a/src/chevents.c
+++ b/src/chevents.c
@@ -25,7 +25,7 @@
*/
#include <ch.h>
-#ifdef CH_USE_EVENTS
+#if CH_USE_EVENTS
/**
* @brief Registers an Event Listener on an Event Source.
*
@@ -193,8 +193,7 @@ void chEvtDispatch(const evhandler_t handlers[], eventmask_t mask) {
}
}
-#if defined(CH_OPTIMIZE_SPEED) || !defined(CH_USE_EVENTS_TIMEOUT) || \
- defined(__DOXIGEN__)
+#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT || defined(__DOXIGEN__)
/**
* @brief A pending event among those specified in @p ewmask is selected,
* cleared and its mask returned.
@@ -271,9 +270,9 @@ eventmask_t chEvtWaitAll(eventmask_t ewmask) {
chSysUnlock();
return ewmask;
}
-#endif /* defined(CH_OPTIMIZE_SPEED) || !defined(CH_USE_EVENTS_TIMEOUT) */
+#endif /* CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT */
-#ifdef CH_USE_EVENTS_TIMEOUT
+#if CH_USE_EVENTS_TIMEOUT
/**
* @brief Waits for a single event.
* @details A pending event among those specified in @p ewmask is selected,
diff --git a/src/chheap.c b/src/chheap.c
index 46b26f7d8..5193f19b8 100644
--- a/src/chheap.c
+++ b/src/chheap.c
@@ -26,9 +26,9 @@
#include <ch.h>
-#ifdef CH_USE_HEAP
+#if CH_USE_HEAP
-#ifndef CH_USE_MALLOC_HEAP
+#if !CH_USE_MALLOC_HEAP
#define MAGIC 0xF5A0
#define ALIGN_TYPE void *
@@ -45,11 +45,11 @@ struct header {
static struct {
struct header free; /* Guaranteed to be not adjacent to the heap */
-#if defined(CH_USE_MUTEXES)
+#if CH_USE_MUTEXES
#define H_LOCK() chMtxLock(&heap.hmtx)
#define H_UNLOCK() chMtxUnlock()
Mutex hmtx;
-#elif defined(CH_USE_SEMAPHORES)
+#elif CH_USE_SEMAPHORES
#define H_LOCK() chSemWait(&heap.hsem)
#define H_UNLOCK() chSemSignal(&heap.hsem)
Semaphore hsem;
@@ -86,7 +86,7 @@ void heap_init(void) {
hp->h_next = NULL;
heap.free.h_next = hp;
heap.free.h_size = 0;
-#if defined(CH_USE_MUTEXES)
+#if CH_USE_MUTEXES
chMtxInit(&heap.hmtx);
#else
chSemInit(&heap.hsem, 1);
@@ -219,11 +219,11 @@ size_t chHeapStatus(size_t *sizep) {
#include <stdlib.h>
-#if defined(CH_USE_MUTEXES)
+#if CH_USE_MUTEXES
#define H_LOCK() chMtxLock(&hmtx)
#define H_UNLOCK() chMtxLock(&hmtx)
static Mutex hmtx;
-#elif defined(CH_USE_SEMAPHORES)
+#elif CH_USE_SEMAPHORES
#define H_LOCK() chSemWait(&hsem)
#define H_UNLOCK() chSemSignal(&hsem)
static Semaphore hsem;
@@ -233,7 +233,7 @@ static Semaphore hsem;
void heap_init(void) {
-#if defined(CH_USE_MUTEXES)
+#if CH_USE_MUTEXES
chMtxInit(&hmtx);
#else
chSemInit(&hsem, 1);
diff --git a/src/chlists.c b/src/chlists.c
index fbd9e6a51..82526feb2 100644
--- a/src/chlists.c
+++ b/src/chlists.c
@@ -25,7 +25,7 @@
*/
#include <ch.h>
-#if !defined(CH_OPTIMIZE_SPEED) || defined(__DOXIGEN__)
+#if !CH_OPTIMIZE_SPEED || defined(__DOXIGEN__)
/**
* @brief Inserts a thread into a priority ordered queue.
*
diff --git a/src/chmempools.c b/src/chmempools.c
index 1095f1c2b..f052bb1e2 100644
--- a/src/chmempools.c
+++ b/src/chmempools.c
@@ -26,7 +26,7 @@
#include <ch.h>
-#ifdef CH_USE_MEMPOOLS
+#if CH_USE_MEMPOOLS
/**
* @brief Initializes an empty memory pool.
diff --git a/src/chmsg.c b/src/chmsg.c
index 1afe1bc99..c2aee871e 100644
--- a/src/chmsg.c
+++ b/src/chmsg.c
@@ -26,9 +26,9 @@
#include <ch.h>
-#ifdef CH_USE_MESSAGES
+#if CH_USE_MESSAGES
-#ifdef CH_USE_MESSAGES_PRIORITY
+#if CH_USE_MESSAGES_PRIORITY
#define msg_insert(tp, qp) prio_insert(tp, qp)
#else
#define msg_insert(tp, qp) queue_insert(tp, qp)
@@ -59,7 +59,7 @@ msg_t chMsgSend(Thread *tp, msg_t msg) {
return msg;
}
-#if defined(CH_USE_EVENTS) && defined(CH_USE_MESSAGES_EVENT)
+#if CH_USE_EVENTS && CH_USE_MESSAGES_EVENT
/**
* @brief Sends a message to the specified thread and atomically pends an
* events set.
@@ -90,7 +90,7 @@ msg_t chMsgSendWithEvent(Thread *tp, msg_t msg, eventmask_t mask) {
chSysUnlock();
return msg;
}
-#endif /* defined(CH_USE_EVENTS) && defined(CH_USE_MESSAGES_EVENT) */
+#endif /* CH_USE_EVENTS && CH_USE_MESSAGES_EVENT */
/**
* @brief Suspends the thread and waits for an incoming message.
diff --git a/src/chmtx.c b/src/chmtx.c
index 3a110f595..e441a5729 100644
--- a/src/chmtx.c
+++ b/src/chmtx.c
@@ -26,7 +26,7 @@
#include <ch.h>
-#ifdef CH_USE_MUTEXES
+#if CH_USE_MUTEXES
/**
* @brief Initializes s @p Mutex structure.
@@ -88,7 +88,7 @@ void chMtxLockS(Mutex *mp) {
/* boost the owner of this mutex if needed */
tp = tp->p_wtmtxp->m_owner;
continue;
-#ifdef CH_USE_MESSAGES_PRIORITY
+#if CH_USE_MESSAGES_PRIORITY
case PRSNDMSG:
/* requeue tp with its new priority on (?) */
prio_insert(dequeue(tp), &tp->p_wtthdp->p_msgqueue);
diff --git a/src/chqueues.c b/src/chqueues.c
index 69067efd4..968ab273e 100644
--- a/src/chqueues.c
+++ b/src/chqueues.c
@@ -26,7 +26,7 @@
#include <ch.h>
-#ifdef CH_USE_QUEUES
+#if CH_USE_QUEUES
/**
* @brief Initializes an input queue.
@@ -116,7 +116,7 @@ msg_t chIQGet(Queue *qp) {
return b;
}
-#if defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT)
+#if CH_USE_QUEUES_TIMEOUT && CH_USE_SEMAPHORES_TIMEOUT
/**
* @brief Gets a byte from the input queue.
* @details If the queue is empty then the calling thread is suspended until
@@ -151,7 +151,7 @@ msg_t chIQGetTimeout(Queue *qp, systime_t time) {
chSysUnlock();
return b;
}
-#endif /* defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT) */
+#endif /* (CH_USE_QUEUES_TIMEOUT && CH_USE_SEMAPHORES_TIMEOUT */
/**
* @brief Reads some data from the input queue into the specified buffer.
@@ -323,7 +323,7 @@ size_t chOQWrite(Queue *qp, uint8_t *buffer, size_t n) {
}
#endif /* CH_USE_QUEUES */
-#ifdef CH_USE_QUEUES_HALFDUPLEX
+#if CH_USE_QUEUES_HALFDUPLEX
/**
* @brief Initializes an half duplex queue.
*
@@ -380,7 +380,7 @@ msg_t chHDQGetReceive(HalfDuplexQueue *qp) {
return b;
}
-#if defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT)
+#if CH_USE_QUEUES_TIMEOUT && CH_USE_SEMAPHORES_TIMEOUT
/**
* @brief Reads a byte from the receive queue.
* @details If the queue is empty or is in transmission mode then the invoking
@@ -418,7 +418,7 @@ msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time) {
chSysUnlock();
return b;
}
-#endif /* defined(CH_USE_QUEUES_TIMEOUT) && defined(CH_USE_SEMAPHORES_TIMEOUT) */
+#endif /* CH_USE_QUEUES_TIMEOUT && CH_USE_SEMAPHORES_TIMEOUT */
/**
* @brief Writes a byte into the transmit queue.
diff --git a/src/chschd.c b/src/chschd.c
index c3ee0c4a8..a07db5737 100644
--- a/src/chschd.c
+++ b/src/chschd.c
@@ -38,7 +38,7 @@ void scheduler_init(void) {
queue_init(&rlist);
rlist.r_prio = NOPRIO;
-#ifdef CH_USE_ROUNDROBIN
+#if CH_USE_ROUNDROBIN
rlist.r_preempt = CH_TIME_QUANTUM;
#endif
}
@@ -53,7 +53,7 @@ void scheduler_init(void) {
* be called soon after.
* @note The function is not meant to be used in the user code directly.
*/
-#ifdef CH_OPTIMIZE_SPEED
+#if CH_OPTIMIZE_SPEED
/* NOTE: it is inlined in this module only.*/
INLINE Thread *chSchReadyI(Thread *tp) {
#else
@@ -85,10 +85,10 @@ void chSchGoSleepS(tstate_t newstate) {
(otp = currp)->p_state = newstate;
(currp = fifo_remove((void *)&rlist))->p_state = PRCURR;
-#ifdef CH_USE_ROUNDROBIN
+#if CH_USE_ROUNDROBIN
rlist.r_preempt = CH_TIME_QUANTUM;
#endif
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
chDbgTrace(otp, currp);
#endif
chSysSwitchI(otp, currp);
@@ -101,7 +101,7 @@ static void wakeup(void *p) {
Thread *tp = (Thread *)p;
switch (tp->p_state) {
-#ifdef CH_USE_SEMAPHORES
+#if CH_USE_SEMAPHORES
case PRWTSEM:
chSemFastSignalI(tp->p_wtsemp);
/* Falls into, intentional. */
@@ -168,10 +168,10 @@ void chSchWakeupS(Thread *ntp, msg_t msg) {
chSchReadyI(otp);
/* change the to-be-run thread to running state */
(currp = ntp)->p_state = PRCURR;
-#ifdef CH_USE_ROUNDROBIN
+#if CH_USE_ROUNDROBIN
rlist.r_preempt = CH_TIME_QUANTUM;
#endif
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
/* trace the context switch */
chDbgTrace(otp, ntp);
#endif
@@ -191,10 +191,10 @@ void chSchDoRescheduleI(void) {
/* pick the first thread from the ready queue and makes it current */
(currp = fifo_remove((void *)&rlist))->p_state = PRCURR;
chSchReadyI(otp);
-#ifdef CH_USE_ROUNDROBIN
+#if CH_USE_ROUNDROBIN
rlist.r_preempt = CH_TIME_QUANTUM;
#endif
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
chDbgTrace(otp, currp);
#endif
chSysSwitchI(otp, currp);
@@ -223,7 +223,7 @@ void chSchRescheduleS(void) {
bool_t chSchRescRequiredI(void) {
tprio_t p1 = firstprio(&rlist);
tprio_t p2 = currp->p_prio;
-#ifdef CH_USE_ROUNDROBIN
+#if CH_USE_ROUNDROBIN
/* If the running thread has not reached its time quantum, reschedule only
* if the first thread on the ready queue has a higher priority.
* Otherwise, if the running thread has used up its time quantum, reschedule
diff --git a/src/chsem.c b/src/chsem.c
index bb6070dd7..578108dff 100644
--- a/src/chsem.c
+++ b/src/chsem.c
@@ -26,9 +26,9 @@
#include <ch.h>
-#ifdef CH_USE_SEMAPHORES
+#if CH_USE_SEMAPHORES
-#ifdef CH_USE_SEMAPHORES_PRIORITY
+#if CH_USE_SEMAPHORES_PRIORITY
#define sem_insert(tp, qp) prio_insert(tp, qp)
#else
#define sem_insert(tp, qp) queue_insert(tp, qp)
@@ -127,7 +127,7 @@ msg_t chSemWaitS(Semaphore *sp) {
return RDY_OK;
}
-#ifdef CH_USE_SEMAPHORES_TIMEOUT
+#if CH_USE_SEMAPHORES_TIMEOUT
/**
* @brief Performs a wait operation on a semaphore with timeout specification.
*
@@ -210,7 +210,7 @@ void chSemSignalI(Semaphore *sp) {
}
}
-#ifdef CH_USE_SEMSW
+#if CH_USE_SEMSW
/**
* @brief Performs atomic signal and wait operations on two semaphores.
*
diff --git a/src/chserial.c b/src/chserial.c
index 9a2dd4018..cb0dfd6b6 100644
--- a/src/chserial.c
+++ b/src/chserial.c
@@ -26,7 +26,7 @@
#include <ch.h>
-#ifdef CH_USE_SERIAL_FULLDUPLEX
+#if CH_USE_SERIAL_FULLDUPLEX
/**
* @brief Initializes a generic full duplex driver.
* @details The HW dependent part of the initialization has to be performed
@@ -117,7 +117,7 @@ dflags_t chFDDGetAndClearFlags(FullDuplexDriver *sd) {
}
#endif /* CH_USE_SERIAL_FULLDUPLEX */
-#ifdef CH_USE_SERIAL_HALFDUPLEX
+#if CH_USE_SERIAL_HALFDUPLEX
/**
* @brief Initializes a generic half duplex driver.
* @details The HW dependent part of the initialization has to be performed
diff --git a/src/chsys.c b/src/chsys.c
index 49f4fd241..2b48278af 100644
--- a/src/chsys.c
+++ b/src/chsys.c
@@ -63,7 +63,7 @@ void chSysInit(void) {
scheduler_init();
debug_init();
vt_init();
-#ifdef CH_USE_HEAP
+#if CH_USE_HEAP
heap_init();
#endif
@@ -93,7 +93,7 @@ void chSysInit(void) {
*/
void chSysTimerHandlerI(void) {
-#ifdef CH_USE_ROUNDROBIN
+#if CH_USE_ROUNDROBIN
/* running thread has not used up quantum yet? */
if (rlist.r_preempt > 0)
/* decrement remaining quantum */
@@ -102,7 +102,7 @@ void chSysTimerHandlerI(void) {
chVTDoTickI();
}
-#if defined(CH_USE_NESTED_LOCKS) && !defined(CH_OPTIMIZE_SPEED)
+#if CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED
void chSysLock(void) {
chDbgAssert(currp->p_locks >= 0, "chinit.c, chSysLock()");
@@ -116,6 +116,6 @@ void chSysUnlock(void) {
if (--currp->p_locks == 0)
port_unlock();
}
-#endif /* defined(CH_USE_NESTED_LOCKS) && !defined(CH_OPTIMIZE_SPEED) */
+#endif /* CH_USE_NESTED_LOCKS && !CH_OPTIMIZE_SPEED */
/** @} */
diff --git a/src/chthreads.c b/src/chthreads.c
index 24a7aa329..5b80687d6 100644
--- a/src/chthreads.c
+++ b/src/chthreads.c
@@ -34,28 +34,28 @@ Thread *init_thread(Thread *tp, tprio_t prio) {
tp->p_flags = P_MEM_MODE_STATIC;
tp->p_prio = prio;
tp->p_state = PRSUSPENDED;
-#ifdef CH_USE_NESTED_LOCKS
+#if CH_USE_NESTED_LOCKS
tp->p_locks = 0;
#endif
-#ifdef CH_USE_MUTEXES
+#if CH_USE_MUTEXES
/* realprio is the thread's own, non-inherited, priority */
tp->p_realprio = prio;
tp->p_mtxlist = NULL;
#endif
-#ifdef CH_USE_WAITEXIT
+#if CH_USE_WAITEXIT
tp->p_waiting = NULL;
#endif
-#ifdef CH_USE_MESSAGES
+#if CH_USE_MESSAGES
queue_init(&tp->p_msgqueue);
#endif
-#ifdef CH_USE_EVENTS
+#if CH_USE_EVENTS
tp->p_epending = 0;
#endif
THREAD_EXT_INIT(tp);
return tp;
}
-#ifdef CH_USE_DEBUG
+#if CH_USE_DEBUG
static void memfill(uint8_t *p, uint32_t n, uint8_t v) {
while (n)
@@ -91,7 +91,7 @@ Thread *chThdInit(void *workspace, size_t wsize,
chDbgAssert((wsize >= THD_WA_SIZE(0)) && (prio <= HIGHPRIO) &&
(workspace != NULL) && (pf != NULL),
"chthreads.c, chThdInit()");
-#ifdef CH_USE_DEBUG
+#if CH_USE_DEBUG
memfill(workspace, wsize, MEM_FILL_PATTERN);
#endif
SETUP_CONTEXT(workspace, wsize, pf, arg);
@@ -119,7 +119,7 @@ Thread *chThdCreateStatic(void *workspace, size_t wsize,
return chThdResume(chThdInit(workspace, wsize, prio, pf, arg));
}
-#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_HEAP)
+#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP
/**
* @brief Creates a new thread allocating the memory from the heap.
*
@@ -150,9 +150,9 @@ Thread *chThdCreateFromHeap(size_t wsize, tprio_t prio,
tp->p_flags = P_MEM_MODE_HEAP;
return chThdResume(tp);
}
-#endif /* defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_HEAP) */
+#endif /* CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP */
-#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_MEMPOOLS)
+#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_MEMPOOLS
/**
* @brief Creates a new thread allocating the memory from the specified Memory
* Pool.
@@ -186,7 +186,7 @@ Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
tp->p_mpool = mp;
return chThdResume(tp);
}
-#endif /* defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_MEMPOOLS) */
+#endif /* CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_MEMPOOLS */
/**
* @brief Changes the running thread priority then reschedules if necessary.
@@ -198,7 +198,7 @@ void chThdSetPriority(tprio_t newprio) {
chDbgAssert(newprio <= HIGHPRIO, "chthreads.c, chThdSetPriority()");
chSysLock();
-#ifdef CH_USE_MUTEXES
+#if CH_USE_MUTEXES
if (currp->p_prio != currp->p_realprio) {
if (newprio > currp->p_prio)
currp->p_prio = newprio;
@@ -284,14 +284,14 @@ void chThdExit(msg_t msg) {
chSysLock();
tp->p_exitcode = msg;
THREAD_EXT_EXIT(tp);
-#ifdef CH_USE_WAITEXIT
+#if CH_USE_WAITEXIT
if (tp->p_waiting != NULL)
chSchReadyI(tp->p_waiting);
#endif
chSchGoSleepS(PREXIT);
}
-#ifdef CH_USE_WAITEXIT
+#if CH_USE_WAITEXIT
/**
* @brief Blocks the execution of the invoking thread until the specified
* thread terminates then the exit code is returned.
@@ -329,7 +329,7 @@ msg_t chThdWait(Thread *tp) {
chSchGoSleepS(PRWAIT);
}
msg = tp->p_exitcode;
-#ifndef CH_USE_DYNAMIC
+#if !CH_USE_DYNAMIC
chSysUnlock();
return msg;
#else /* CH_USE_DYNAMIC */
@@ -339,12 +339,12 @@ msg_t chThdWait(Thread *tp) {
chSysUnlock();
switch (mode) {
-#ifdef CH_USE_HEAP
+#if CH_USE_HEAP
case P_MEM_MODE_HEAP:
chHeapFree(tp);
break;
#endif
-#ifdef CH_USE_MEMPOOLS
+#if CH_USE_MEMPOOLS
case P_MEM_MODE_MEMPOOL:
chPoolFree(tp->p_mpool, tp);
break;
diff --git a/src/include/ch.h b/src/include/ch.h
index 374941e3e..8303d90f6 100644
--- a/src/include/ch.h
+++ b/src/include/ch.h
@@ -52,6 +52,16 @@
*/
#define CH_KERNEL_PATCH 0
+/*
+ * Common values.
+ */
+#ifndef FALSE
+#define FALSE 0
+#endif
+#ifndef TRUE
+#define TRUE (!FALSE)
+#endif
+
#include <chconf.h>
#include <chtypes.h>
#include "lists.h"
@@ -72,16 +82,6 @@
#include "serial.h"
#include "debug.h"
-/*
- * Common values.
- */
-#ifndef FALSE
-#define FALSE 0
-#endif
-#ifndef TRUE
-#define TRUE (!FALSE)
-#endif
-
#endif /* _CH_H_ */
/** @} */
diff --git a/src/include/condvars.h b/src/include/condvars.h
index a311ba526..90c78eccf 100644
--- a/src/include/condvars.h
+++ b/src/include/condvars.h
@@ -31,7 +31,7 @@
#ifndef _CONDVARS_H_
#define _CONDVARS_H_
-#if defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES)
+#if CH_USE_CONDVARS && CH_USE_MUTEXES
/**
* @brief CondVar structure.
@@ -50,7 +50,7 @@ extern "C" {
void chCondBroadcastI(CondVar *cp);
msg_t chCondWait(CondVar *cp);
msg_t chCondWaitS(CondVar *cp);
-#ifdef CH_USE_CONDVARS_TIMEOUT
+#if CH_USE_CONDVARS_TIMEOUT
msg_t chCondWaitTimeout(CondVar *cp, systime_t time);
msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time);
#endif
@@ -58,7 +58,7 @@ extern "C" {
}
#endif
-#endif /* defined(CH_USE_CONDVARS) && defined(CH_USE_MUTEXES) */
+#endif /* CH_USE_CONDVARS && CH_USE_MUTEXES */
#endif /* _CONDVARS_H_ */
diff --git a/src/include/debug.h b/src/include/debug.h
index a6b4ca7c1..37400d967 100644
--- a/src/include/debug.h
+++ b/src/include/debug.h
@@ -27,16 +27,21 @@
#ifndef _DEBUG_H_
#define _DEBUG_H_
-#ifdef CH_USE_DEBUG
+#if CH_USE_DEBUG
+/**
+ * @brief Trace buffer entries.
+ */
#ifndef TRACE_BUFFER_SIZE
#define TRACE_BUFFER_SIZE 64
#endif
/**
- * Fill value for threads working area in debug mode.
+ * @brief Fill value for threads working area in debug mode.
*/
+#ifndef MEM_FILL_PATTERN
#define MEM_FILL_PATTERN 0x55
+#endif
/**
* @brief Trace buffer record.
@@ -91,7 +96,7 @@ extern "C" {
#endif /* CH_USE_DEBUG */
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
#ifdef __cplusplus
extern "C" {
#endif
diff --git a/src/include/events.h b/src/include/events.h
index 5def8f065..ada7812d1 100644
--- a/src/include/events.h
+++ b/src/include/events.h
@@ -27,7 +27,7 @@
#ifndef _EVENTS_H_
#define _EVENTS_H_
-#ifdef CH_USE_EVENTS
+#if CH_USE_EVENTS
/** All events allowed mask.*/
#define ALL_EVENTS -1
@@ -89,12 +89,12 @@ extern "C" {
void chEvtBroadcast(EventSource *esp);
void chEvtBroadcastI(EventSource *esp);
void chEvtDispatch(const evhandler_t handlers[], eventmask_t mask);
-#if defined(CH_OPTIMIZE_SPEED) || !defined(CH_USE_EVENTS_TIMEOUT)
+#if CH_OPTIMIZE_SPEED || !CH_USE_EVENTS_TIMEOUT
eventmask_t chEvtWaitOne(eventmask_t ewmask);
eventmask_t chEvtWaitAny(eventmask_t ewmask);
eventmask_t chEvtWaitAll(eventmask_t ewmask);
#endif
-#ifdef CH_USE_EVENTS_TIMEOUT
+#if CH_USE_EVENTS_TIMEOUT
eventmask_t chEvtWaitOneTimeout(eventmask_t ewmask, systime_t time);
eventmask_t chEvtWaitAnyTimeout(eventmask_t ewmask, systime_t time);
eventmask_t chEvtWaitAllTimeout(eventmask_t ewmask, systime_t time);
@@ -116,7 +116,7 @@ extern "C" {
*/
#define chEvtRegister(esp, elp, eid) chEvtRegisterMask(esp, elp, EVENT_MASK(eid))
-#if !defined(CH_OPTIMIZE_SPEED) && defined(CH_USE_EVENTS_TIMEOUT)
+#if !CH_OPTIMIZE_SPEED && CH_USE_EVENTS_TIMEOUT
#define chEvtWaitOne(ewmask) chEvtWaitOneTimeout(ewmask, TIME_INFINITE)
#define chEvtWaitAny(ewmask) chEvtWaitAnyTimeout(ewmask, TIME_INFINITE)
#define chEvtWaitAll(ewmask) chEvtWaitAllTimeout(ewmask, TIME_INFINITE)
diff --git a/src/include/inline.h b/src/include/inline.h
index 6f99ff329..0da909f8f 100644
--- a/src/include/inline.h
+++ b/src/include/inline.h
@@ -32,7 +32,7 @@
* Note: static inlined functions do not duplicate the code in every module
* this is true for GCC, not sure about other compilers.
*/
-#ifdef CH_OPTIMIZE_SPEED
+#if CH_OPTIMIZE_SPEED
static INLINE void prio_insert(Thread *tp, ThreadsQueue *tqp) {
Thread *cp = tqp->p_next;
diff --git a/src/include/lists.h b/src/include/lists.h
index a86d8175e..b858a7c69 100644
--- a/src/include/lists.h
+++ b/src/include/lists.h
@@ -63,7 +63,7 @@ typedef struct {
*/
#define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp))
-#ifndef CH_OPTIMIZE_SPEED
+#if !CH_OPTIMIZE_SPEED
#ifdef __cplusplus
extern "C" {
@@ -79,7 +79,7 @@ extern "C" {
}
#endif
-#endif /* CH_OPTIMIZE_SPEED */
+#endif /* !CH_OPTIMIZE_SPEED */
#endif /* _LISTS_H_ */
diff --git a/src/include/mempools.h b/src/include/mempools.h
index 7bf67c77a..537ca3425 100644
--- a/src/include/mempools.h
+++ b/src/include/mempools.h
@@ -27,7 +27,7 @@
#ifndef _MEMPOOLS_H_
#define _MEMPOOLS_H_
-#ifdef CH_USE_MEMPOOLS
+#if CH_USE_MEMPOOLS
/**
* @brief Memory pool free object header.
diff --git a/src/include/messages.h b/src/include/messages.h
index c74febaf5..1c4876b81 100644
--- a/src/include/messages.h
+++ b/src/include/messages.h
@@ -27,7 +27,7 @@
#ifndef _MESSAGES_H_
#define _MESSAGES_H_
-#ifdef CH_USE_MESSAGES
+#if CH_USE_MESSAGES
/**
* Evaluates to TRUE if the thread has pending messages.
@@ -49,7 +49,7 @@ extern "C" {
msg_t chMsgGet(void);
void chMsgRelease(msg_t msg);
-#if defined(CH_USE_EVENTS) && defined(CH_USE_MESSAGES_EVENT)
+#if CH_USE_EVENTS && CH_USE_MESSAGES_EVENT
msg_t chMsgSendWithEvent(Thread *tp, msg_t msg, eventmask_t mask);
#endif
#ifdef __cplusplus
diff --git a/src/include/mutexes.h b/src/include/mutexes.h
index d3e987ddf..16b59f695 100644
--- a/src/include/mutexes.h
+++ b/src/include/mutexes.h
@@ -27,7 +27,7 @@
#ifndef _MUTEXES_H_
#define _MUTEXES_H_
-#ifdef CH_USE_MUTEXES
+#if CH_USE_MUTEXES
/**
* @brief Mutex structure.
diff --git a/src/include/queues.h b/src/include/queues.h
index 418ff73a8..36495f1a7 100644
--- a/src/include/queues.h
+++ b/src/include/queues.h
@@ -41,7 +41,7 @@ typedef void (*qnotify_t)(void);
/** Returned by the queue functions if the queue is full. */
#define Q_FULL -4
-#ifdef CH_USE_QUEUES
+#if CH_USE_QUEUES
/**
* @brief I/O queue structure.
* @details This structure is used by both Input and Output Queues,
@@ -94,7 +94,7 @@ extern "C" {
msg_t chIQPutI(Queue *qp, uint8_t b);
msg_t chIQGet(Queue *qp);
size_t chIQRead(Queue *qp, uint8_t *buffer, size_t n);
-#ifdef CH_USE_QUEUES_TIMEOUT
+#if CH_USE_QUEUES_TIMEOUT
msg_t chIQGetTimeout(Queue *qp, systime_t time);
#endif
@@ -112,7 +112,7 @@ extern "C" {
#endif
#endif /* CH_USE_QUEUES */
-#ifdef CH_USE_QUEUES_HALFDUPLEX
+#if CH_USE_QUEUES_HALFDUPLEX
/**
* @brief Half duplex queue structure.
*/
@@ -163,7 +163,7 @@ extern "C" {
void chHDQPutTransmit(HalfDuplexQueue *qp, uint8_t b);
msg_t chHDQGetTransmitI(HalfDuplexQueue *qp);
msg_t chHDQPutReceiveI(HalfDuplexQueue *qp, uint8_t b);
-#ifdef CH_USE_QUEUES_TIMEOUT
+#if CH_USE_QUEUES_TIMEOUT
msg_t chHDQGetReceiveTimeout(HalfDuplexQueue *qp, systime_t time);
#endif
#ifdef __cplusplus
diff --git a/src/include/scheduler.h b/src/include/scheduler.h
index 25df4a3bd..612ee8c55 100644
--- a/src/include/scheduler.h
+++ b/src/include/scheduler.h
@@ -61,10 +61,10 @@ typedef struct {
tprio_t r_prio; /**< This field must be initialized to
zero.*/
/* End of the fields shared with the Thread structure. */
-#ifdef CH_USE_ROUNDROBIN
+#if CH_USE_ROUNDROBIN
cnt_t r_preempt; /**< Round robin counter.*/
#endif
-#ifndef CH_CURRP_REGISTER_CACHE
+#if !CH_CURRP_REGISTER_CACHE
Thread *r_current; /**< The currently running thread.*/
#endif
} ReadyList;
@@ -89,7 +89,7 @@ extern "C" {
}
#endif
-#ifdef CH_CURRP_REGISTER_CACHE
+#if CH_CURRP_REGISTER_CACHE
register Thread *currp asm(CH_CURRP_REGISTER_CACHE);
#else
#define currp rlist.r_current
diff --git a/src/include/semaphores.h b/src/include/semaphores.h
index bb25b4609..25f11b06b 100644
--- a/src/include/semaphores.h
+++ b/src/include/semaphores.h
@@ -27,7 +27,7 @@
#ifndef _SEMAPHORES_H_
#define _SEMAPHORES_H_
-#ifdef CH_USE_SEMAPHORES
+#if CH_USE_SEMAPHORES
/**
* @brief Semaphore structure.
@@ -46,13 +46,13 @@ extern "C" {
void chSemResetI(Semaphore *sp, cnt_t n);
msg_t chSemWait(Semaphore *sp);
msg_t chSemWaitS(Semaphore *sp);
-#ifdef CH_USE_SEMAPHORES_TIMEOUT
+#if CH_USE_SEMAPHORES_TIMEOUT
msg_t chSemWaitTimeout(Semaphore *sp, systime_t time);
msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time);
#endif
void chSemSignal(Semaphore *sp);
void chSemSignalI(Semaphore *sp);
-#ifdef CH_USE_SEMSW
+#if CH_USE_SEMSW
msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw);
#endif
#ifdef __cplusplus
diff --git a/src/include/serial.h b/src/include/serial.h
index 6a6299cf3..ebb3392bb 100644
--- a/src/include/serial.h
+++ b/src/include/serial.h
@@ -45,7 +45,7 @@
/** Serial Driver condition flags type.*/
typedef uint16_t dflags_t;
-#ifdef CH_USE_SERIAL_FULLDUPLEX
+#if CH_USE_SERIAL_FULLDUPLEX
/**
* @brief Full Duplex Serial Driver main structure.
@@ -110,7 +110,7 @@ extern "C" {
#endif /* CH_USE_SERIAL_FULLDUPLEX */
-#ifdef CH_USE_SERIAL_HALFDUPLEX
+#if CH_USE_SERIAL_HALFDUPLEX
/**
* @brief Full Duplex Serial Driver main structure.
diff --git a/src/include/sys.h b/src/include/sys.h
index f559b5f52..ccc71ae7f 100644
--- a/src/include/sys.h
+++ b/src/include/sys.h
@@ -96,16 +96,16 @@
* a better idea to use the semaphores or mutexes instead.
* @see CH_USE_NESTED_LOCKS
*/
-#if defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
-#if defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
+#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__)
+#if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
#define chSysLock() { \
if (currp->p_locks++ == 0) \
- port_lock(); \
+ port_lock(); \
}
-#endif /* defined(CH_OPTIMIZE_SPEED) */
-#else /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* CH_OPTIMIZE_SPEED */
+#else /* !CH_USE_NESTED_LOCKS */
#define chSysLock() port_lock()
-#endif /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* !CH_USE_NESTED_LOCKS */
/**
* @brief Leaves the kernel lock mode.
@@ -114,16 +114,16 @@
* a better idea to use the semaphores or mutexes instead.
* @see CH_USE_NESTED_LOCKS
*/
-#if defined(CH_USE_NESTED_LOCKS) || defined(__DOXYGEN__)
-#if defined(CH_OPTIMIZE_SPEED) || defined(__DOXYGEN__)
+#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__)
+#if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
#define chSysUnlock() { \
if (--currp->p_locks == 0) \
- port_unlock(); \
+ port_unlock(); \
}
-#endif /* defined(CH_OPTIMIZE_SPEED) */
-#else /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* CH_OPTIMIZE_SPEED */
+#else /* !CH_USE_NESTED_LOCKS */
#define chSysUnlock() port_unlock()
-#endif /* !defined(CH_USE_NESTED_LOCKS) */
+#endif /* !CH_USE_NESTED_LOCKS */
/**
* @brief Enters the kernel lock mode from within an interrupt handler.
diff --git a/src/include/threads.h b/src/include/threads.h
index c3f89d99b..3c279bf3c 100644
--- a/src/include/threads.h
+++ b/src/include/threads.h
@@ -47,7 +47,7 @@ struct Thread {
tstate_t p_state; /**< Current thread state.*/
tmode_t p_flags; /**< Various flags.*/
struct context p_ctx; /**< Processor context.*/
-#ifdef CH_USE_NESTED_LOCKS
+#if CH_USE_NESTED_LOCKS
cnt_t p_locks; /**< Number of nested locks.*/
#endif
/*
@@ -59,27 +59,27 @@ struct Thread {
msg_t p_rdymsg; /**< Thread wakeup code.*/
msg_t p_exitcode; /**< The thread exit code
(@p PREXIT state).*/
-#ifdef CH_USE_SEMAPHORES
+#if CH_USE_SEMAPHORES
Semaphore *p_wtsemp; /**< Semaphore where the thread is
waiting on (@p PRWTSEM state).*/
#endif
-#ifdef CH_USE_MUTEXES
+#if CH_USE_MUTEXES
Mutex *p_wtmtxp; /**< Mutex where the thread is waiting
on (@p PRWTMTX state).*/
#endif
-#ifdef CH_USE_CONDVARS
+#if CH_USE_CONDVARS
CondVar *p_wtcondp; /**< CondVar where the thread is
waiting on (@p PRWTCOND state).*/
#endif
-#ifdef CH_USE_MESSAGES
+#if CH_USE_MESSAGES
Thread *p_wtthdp; /**< Destination thread for message
send @p PRSNDMSG state).*/
#endif
-#ifdef CH_USE_EVENTS
+#if CH_USE_EVENTS
eventmask_t p_ewmask; /**< Enabled events mask (@p PRWTOREVT
or @p PRWTANDEVT states).*/
#endif
-#ifdef CH_USE_TRACE
+#if CH_USE_TRACE
void *p_wtobjp; /**< Generic kernel object pointer used
for opaque access.*/
#endif
@@ -87,23 +87,23 @@ struct Thread {
/*
* Start of the optional fields.
*/
-#ifdef CH_USE_WAITEXIT
+#if CH_USE_WAITEXIT
Thread *p_waiting; /**< Thread waiting for termination.*/
#endif
-#ifdef CH_USE_MESSAGES
+#if CH_USE_MESSAGES
ThreadsQueue p_msgqueue; /**< Message queue.*/
msg_t p_msg; /**< The message.*/
#endif
-#ifdef CH_USE_EVENTS
+#if CH_USE_EVENTS
eventmask_t p_epending; /**< Pending events mask.*/
#endif
-#ifdef CH_USE_MUTEXES
+#if CH_USE_MUTEXES
Mutex *p_mtxlist; /**< List of the mutexes owned by this
thread, @p NULL terminated.*/
tprio_t p_realprio; /**< Thread's own, non-inherited,
priority.*/
#endif
-#if defined(CH_USE_DYNAMIC) && defined(CH_USE_MEMPOOLS)
+#if CH_USE_DYNAMIC && CH_USE_MEMPOOLS
void *p_mpool; /**< Memory Pool where the thread
workspace is returned.*/
#endif
@@ -164,11 +164,11 @@ extern "C" {
tprio_t prio, tfunc_t pf, void *arg);
Thread *chThdCreateStatic(void *workspace, size_t wsize,
tprio_t prio, tfunc_t pf, void *arg);
-#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_HEAP)
+#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_HEAP
Thread *chThdCreateFromHeap(size_t wsize, tprio_t prio,
tfunc_t pf, void *arg);
#endif
-#if defined(CH_USE_DYNAMIC) && defined(CH_USE_WAITEXIT) && defined(CH_USE_MEMPOOLS)
+#if CH_USE_DYNAMIC && CH_USE_WAITEXIT && CH_USE_MEMPOOLS
Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
tfunc_t pf, void *arg);
#endif
@@ -178,7 +178,7 @@ extern "C" {
void chThdSleep(systime_t time);
void chThdSleepUntil(systime_t time);
void chThdExit(msg_t msg);
-#ifdef CH_USE_WAITEXIT
+#if CH_USE_WAITEXIT
msg_t chThdWait(Thread *tp);
#endif
#ifdef __cplusplus
diff --git a/src/templates/chconf.h b/src/templates/chconf.h
index 8863b0061..f05f8b0b5 100644
--- a/src/templates/chconf.h
+++ b/src/templates/chconf.h
@@ -27,17 +27,15 @@
#ifndef _CHCONF_H_
#define _CHCONF_H_
-/*
- * NOTE: this is just documentation for doxigen, the real configuration file
- * is the one into the project directories.
- */
-
/**
* 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.
*/
-#define CH_OPTIMIZE_SPEED
+#ifndef CH_OPTIMIZE_SPEED
+#define CH_OPTIMIZE_SPEED TRUE
+#endif
/**
* If enabled then the use of nested @p chSysLock() / @p chSysUnlock()
@@ -46,135 +44,195 @@
* 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.
+ * @note The default is @p FALSE.
*/
-#define CH_USE_NESTED_LOCKS
+#ifndef CH_USE_NESTED_LOCKS
+#define CH_USE_NESTED_LOCKS FALSE
+#endif
/**
* If specified then the kernel performs the round robin scheduling algorithm
* on threads of equal priority.
- * @note The default is ON.
+ * @note The default is @p TRUE.
*/
-#define CH_USE_ROUNDROBIN
+#ifndef CH_USE_ROUNDROBIN
+#define CH_USE_ROUNDROBIN TRUE
+#endif
/**
* If specified then the @p chThdWait() function is included in the kernel.
+ * @note The default is @p TRUE.
*/
-#define CH_USE_WAITEXIT
+#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.
*/
-#define CH_USE_SEMAPHORES
+#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 recommended default is OFF unless you have some specific
- * requirements.
+ * @note The default is @p FALSE. Enable this if you have special requirements.
* @note Requires @p CH_USE_SEMAPHORES.
*/
-#define CH_USE_SEMAPHORES_PRIORITY
+#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.
*/
-#define CH_USE_SEMSW
+#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.
*/
-#define CH_USE_SEMAPHORES_TIMEOUT
+#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.
*/
-#define CH_USE_MUTEXES
+#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.
*/
-#define CH_USE_CONDVARS
+#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.
*/
-#define CH_USE_CONDVARS_TIMEOUT
+#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.
*/
-#define CH_USE_EVENTS
+#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.
*/
-#define CH_USE_EVENTS_TIMEOUT
+#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.
*/
-#define CH_USE_MESSAGES
+#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.
*/
-#define CH_USE_MESSAGES_EVENT
+#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.
*/
-#define CH_USE_MESSAGES_PRIORITY
+#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.
*/
-#define CH_USE_QUEUES
+#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.
*/
-#define CH_USE_QUEUES_HALFDUPLEX
+#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.
*/
-#define CH_USE_QUEUES_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.
*/
-#define CH_USE_SERIAL_FULLDUPLEX
+#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.
*/
-#define CH_USE_SERIAL_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.
*/
-#define CH_USE_HEAP
+#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
@@ -183,41 +241,55 @@
* provide the @p __heap_base__ and @p __heap_end__ symbols.
* @note Requires @p CH_USE_HEAP.
*/
-#define CH_HEAP_SIZE 0
+#ifndef CH_HEAP_SIZE
+#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.
- * @note The recommended setting is OFF.
*/
-#define CH_USE_MALLOC_HEAP
+#ifndef CH_USE_MALLOC_HEAP
+#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.
*/
-#define CH_USE_MEMPOOLS
+#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.
*/
-#define CH_USE_DYNAMIC
+#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.
*/
-#define CH_FREQUENCY 1000
+#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.
*/
-#define CH_TIME_QUANTUM 20
+#ifndef CH_TIME_QUANTUM
+#define CH_TIME_QUANTUM 20
+#endif
/**
* If enabled defines a CPU register to be used as storage for the global
@@ -230,44 +302,70 @@
* @note If this option is enabled then ALL the libraries linked to the
* ChibiOS/RT code <b>must</b> be recompiled with the GCC option @p
* -ffixed-@<reg@>.
+ * @note This option must be enabled in the Makefile, it is listed here for
+ * documentation.
*/
-#define CH_CURRP_REGISTER_CACHE "reg"
+#if defined(__DOXYGEN__)
+#define CH_CURRP_REGISTER_CACHE "reg"
+#endif
/**
* Debug option, if enableed includes basic debug support to the kernel.
* @note The debug support is port-dependent, it may be not present on some
* targets. In that case stub functions will be included.
+ * @note The default is @p FALSE.
*/
-#define CH_USE_DEBUG
+#ifndef CH_USE_DEBUG
+#define CH_USE_DEBUG FALSE
+#endif
/**
* Debug option, includes the threads context switch tracing feature.
+ * @note The default is @p FALSE.
*/
-#define CH_USE_TRACE
+#ifndef CH_USE_TRACE
+#define CH_USE_TRACE FALSE
+#endif
/**
* User fields added to the end of the @p Thread structure.
*/
+#ifndef THREAD_EXT_FIELDS
#define THREAD_EXT_FIELDS \
struct { \
/* Add thread custom fields here.*/ \
};
+#endif
/**
* User initialization code added to the @p chThdInit() API.
* @note It is invoked from within @p chThdInit().
*/
+#ifndef THREAD_EXT_INIT
#define THREAD_EXT_INIT(tp) { \
/* Add thread initialization code here.*/ \
}
+#endif
/**
* User finalization code added to the @p chThdExit() API.
* @note It is inserted into lock zone.
*/
+#ifndef THREAD_EXT_EXIT
#define THREAD_EXT_EXIT(tp) { \
/* Add thread finalization code here.*/ \
}
+#endif
+
+/**
+ * Code inserted inside the idle thread loop immediately after an interrupt
+ * resumed execution.
+ */
+#ifndef IDLE_LOOP_HOOK
+#define IDLE_LOOP_HOOK() { \
+ /* Idle loop code here.*/ \
+}
+#endif
#endif /* _CHCONF_H_ */