aboutsummaryrefslogtreecommitdiffstats
path: root/os/kernel
diff options
context:
space:
mode:
authorbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-08-28 13:39:56 +0000
committerbarthess <barthess@35acf78f-673a-0410-8e92-d51de3d6d3f4>2011-08-28 13:39:56 +0000
commitfc492c6d190610cc9537360edf44d6dc5d072a2c (patch)
tree53fb1786e058f872671fb3adca4e73c708716d54 /os/kernel
parentda23780899ae4b9ce1bbe0cb9109da1c87fe0fa1 (diff)
parent663214d0e6728d153fd4118324e69c75c574327c (diff)
downloadChibiOS-fc492c6d190610cc9537360edf44d6dc5d072a2c.tar.gz
ChibiOS-fc492c6d190610cc9537360edf44d6dc5d072a2c.tar.bz2
ChibiOS-fc492c6d190610cc9537360edf44d6dc5d072a2c.zip
I2C. Merge code from trunk.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/i2c_dev@3263 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/kernel')
-rw-r--r--os/kernel/include/ch.h5
-rw-r--r--os/kernel/include/chbsem.h5
-rw-r--r--os/kernel/include/chdebug.h11
-rw-r--r--os/kernel/include/chevents.h13
-rw-r--r--os/kernel/include/chfiles.h7
-rw-r--r--os/kernel/include/chioch.h26
-rw-r--r--os/kernel/include/chmboxes.h5
-rw-r--r--os/kernel/include/chmemcore.h4
-rw-r--r--os/kernel/include/chmsg.h5
-rw-r--r--os/kernel/include/chmtx.h5
-rw-r--r--os/kernel/include/chqueues.h55
-rw-r--r--os/kernel/include/chregistry.h6
-rw-r--r--os/kernel/include/chschd.h35
-rw-r--r--os/kernel/include/chsem.h5
-rw-r--r--os/kernel/include/chstreams.h5
-rw-r--r--os/kernel/include/chsys.h13
-rw-r--r--os/kernel/include/chthreads.h84
-rw-r--r--os/kernel/include/chvt.h44
-rw-r--r--os/kernel/src/chmsg.c2
-rw-r--r--os/kernel/src/chthreads.c3
20 files changed, 240 insertions, 98 deletions
diff --git a/os/kernel/include/ch.h b/os/kernel/include/ch.h
index db96d4338..35b01af2c 100644
--- a/os/kernel/include/ch.h
+++ b/os/kernel/include/ch.h
@@ -43,6 +43,10 @@
#define CH_KERNEL_VERSION "2.3.3unstable"
/**
+ * @name Kernel version
+ * @{
+ */
+/**
* @brief Kernel version major number.
*/
#define CH_KERNEL_MAJOR 2
@@ -56,6 +60,7 @@
* @brief Kernel version patch number.
*/
#define CH_KERNEL_PATCH 3
+/** @} */
/*
* Common values.
diff --git a/os/kernel/include/chbsem.h b/os/kernel/include/chbsem.h
index e0e1ca865..2d8815c3c 100644
--- a/os/kernel/include/chbsem.h
+++ b/os/kernel/include/chbsem.h
@@ -85,6 +85,10 @@ typedef struct {
BinarySemaphore name = _BSEMAPHORE_DATA(name, taken)
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Initializes a binary semaphore.
*
* @param[out] bsp pointer to a @p BinarySemaphore structure
@@ -238,6 +242,7 @@ typedef struct {
* @iclass
*/
#define chBSemGetStateI(bsp) ((bsp)->bs_sem.s_cnt > 0 ? FALSE : TRUE)
+/** @} */
#endif /* CH_USE_SEMAPHORES */
diff --git a/os/kernel/include/chdebug.h b/os/kernel/include/chdebug.h
index f3bf6b026..d11eb2eb2 100644
--- a/os/kernel/include/chdebug.h
+++ b/os/kernel/include/chdebug.h
@@ -132,7 +132,10 @@ extern ch_trace_buffer_t dbg_trace_buffer;
/*===========================================================================*/
#if CH_DBG_ENABLE_CHECKS || defined(__DOXYGEN__)
-
+/**
+ * @name Macro Functions
+ * @{
+ */
/**
* @brief Function parameter check.
* @details If the condition check fails then the kernel panics and halts.
@@ -150,6 +153,7 @@ extern ch_trace_buffer_t dbg_trace_buffer;
chDbgPanic(__QUOTE_THIS(func)"()"); \
}
#endif /* !defined(chDbgCheck) */
+/** @} */
#else /* !CH_DBG_ENABLE_CHECKS */
#define chDbgCheck(c, func) { \
(void)(c), (void)__QUOTE_THIS(func)"()"; \
@@ -162,6 +166,10 @@ extern ch_trace_buffer_t dbg_trace_buffer;
#if CH_DBG_ENABLE_ASSERTS || defined(__DOXYGEN__)
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Condition assertion.
* @details If the condition check fails then the kernel panics with the
* specified message and halts.
@@ -184,6 +192,7 @@ extern ch_trace_buffer_t dbg_trace_buffer;
chDbgPanic(m); \
}
#endif /* !defined(chDbgAssert) */
+/** @} */
#else /* !CH_DBG_ENABLE_ASSERTS */
#define chDbgAssert(c, m, r) {(void)(c);}
#endif /* !CH_DBG_ENABLE_ASSERTS */
diff --git a/os/kernel/include/chevents.h b/os/kernel/include/chevents.h
index e808caec3..de89118b4 100644
--- a/os/kernel/include/chevents.h
+++ b/os/kernel/include/chevents.h
@@ -78,13 +78,21 @@ typedef void (*evhandler_t)(eventid_t);
*/
#define EVENTSOURCE_DECL(name) EventSource name = _EVENTSOURCE_DATA(name)
-/** All events allowed mask.*/
+/**
+ * @brief All events allowed mask.
+ */
#define ALL_EVENTS ((eventmask_t)-1)
-/** Returns the event mask from the event identifier.*/
+/**
+ * @brief Returns an event mask from an event identifier.
+ */
#define EVENT_MASK(eid) ((eventmask_t)(1 << (eid)))
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Registers an Event Listener on an Event Source.
* @note Multiple Event Listeners can use the same event identifier, the
* listener will share the callback function.
@@ -147,6 +155,7 @@ typedef void (*evhandler_t)(eventid_t);
* @iclass
*/
#define chEvtBroadcastI(esp) chEvtBroadcastFlagsI(esp, 0)
+/** @} */
#ifdef __cplusplus
extern "C" {
diff --git a/os/kernel/include/chfiles.h b/os/kernel/include/chfiles.h
index ff3f8274e..69a63965e 100644
--- a/os/kernel/include/chfiles.h
+++ b/os/kernel/include/chfiles.h
@@ -74,6 +74,8 @@ typedef uint32_t fileoffset_t;
_base_sequential_stream_data
/**
+ * @extends BaseSequentialStreamVMT
+ *
* @brief @p BaseFileStream virtual methods table.
*/
struct BaseFilelStreamVMT {
@@ -93,6 +95,10 @@ typedef struct {
} BaseFileStream;
/**
+ * @name Macro Functions (BaseFileStream)
+ * @{
+ */
+/**
* @brief Base file Stream close.
* @details The function closes a file stream.
*
@@ -138,6 +144,7 @@ typedef struct {
* @api
*/
#define chFileStreamSeek ((ip)->vmt->lseek(ip, offset))
+/** @} */
#endif /* _CHFILES_H_ */
diff --git a/os/kernel/include/chioch.h b/os/kernel/include/chioch.h
index 02757c7e9..3361926e3 100644
--- a/os/kernel/include/chioch.h
+++ b/os/kernel/include/chioch.h
@@ -67,6 +67,8 @@
_base_sequential_stream_data
/**
+ * @extends BaseSequentialStreamVMT
+ *
* @brief @p BaseChannel virtual methods table.
*/
struct BaseChannelVMT { \
@@ -87,6 +89,10 @@ typedef struct {
} BaseChannel;
/**
+ * @name Macro Functions (BaseChannel)
+ * @{
+ */
+/**
* @brief Channel output check.
* @details This function verifies if a subsequent put/write operation would
* block.
@@ -227,9 +233,13 @@ typedef struct {
*/
#define chIOReadTimeout(ip, bp, n, time) \
((ip)->vmt->readt(ip, bp, n, time))
+/** @} */
-#if CH_USE_EVENTS
-
+#if CH_USE_EVENTS || defined(__DOXYGEN__)
+/**
+ * @name I/O status flags
+ * @{
+ */
/** @brief No pending conditions.*/
#define IO_NO_ERROR 0
/** @brief Connection happened.*/
@@ -242,6 +252,7 @@ typedef struct {
#define IO_OUTPUT_EMPTY 8
/** @brief Transmission end.*/
#define IO_TRANSMISSION_END 16
+/** @} */
/**
* @brief Type of an I/O condition flags mask.
@@ -267,6 +278,8 @@ typedef uint_fast16_t ioflags_t;
ioflags_t flags;
/**
+ * @extends BaseChannelVMT
+ *
* @brief @p BaseAsynchronousChannel virtual methods table.
*/
struct BaseAsynchronousChannelVMT {
@@ -287,6 +300,10 @@ typedef struct {
} BaseAsynchronousChannel;
/**
+ * @name Macro Functions (BaseAsynchronousChannel)
+ * @{
+ */
+/**
* @brief Returns the I/O condition event source.
* @details The event source is broadcasted when an I/O condition happens.
*
@@ -299,7 +316,7 @@ typedef struct {
#define chIOGetEventSource(ip) (&((ip)->event))
/**
- * @brief Adds condition flags to the channel's mask.
+ * @brief Adds status flags to the channel's mask.
* @details This function is usually called from the I/O ISTs in order to
* notify I/O conditions such as data events, errors, signal
* changes etc.
@@ -316,7 +333,7 @@ typedef struct {
}
/**
- * @brief Returns and clears the errors mask associated to the channel.
+ * @brief Returns and clears the status flags associated to the channel.
*
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class
@@ -326,6 +343,7 @@ typedef struct {
* @api
*/
#define chIOGetAndClearFlags(ip) ((ip)->vmt->getflags(ip))
+/** @} */
/**
* @brief Default implementation of the @p getflags virtual method.
diff --git a/os/kernel/include/chmboxes.h b/os/kernel/include/chmboxes.h
index 4a1706302..60cb7a5c1 100644
--- a/os/kernel/include/chmboxes.h
+++ b/os/kernel/include/chmboxes.h
@@ -73,6 +73,10 @@ extern "C" {
#endif
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Returns the mailbox buffer size.
*
* @param[in] mbp the pointer to an initialized Mailbox object
@@ -120,6 +124,7 @@ extern "C" {
* @iclass
*/
#define chMBPeekI(mbp) (*(mbp)->mb_rdptr)
+/** @} */
/**
* @brief Data part of a static mailbox initializer.
diff --git a/os/kernel/include/chmemcore.h b/os/kernel/include/chmemcore.h
index cf608c4e8..5f72a3585 100644
--- a/os/kernel/include/chmemcore.h
+++ b/os/kernel/include/chmemcore.h
@@ -37,6 +37,9 @@
typedef void *(*memgetfunc_t)(size_t size);
/**
+ * @name Alignment support macros
+ */
+/**
* @brief Alignment size constant.
*/
#define MEM_ALIGN_SIZE sizeof(stkalign_t)
@@ -61,6 +64,7 @@ typedef void *(*memgetfunc_t)(size_t size);
* the type @p align_t.
*/
#define MEM_IS_ALIGNED(p) (((size_t)(p) & MEM_ALIGN_MASK) == 0)
+/** @} */
#if CH_USE_MEMCORE || defined(__DOXYGEN__)
diff --git a/os/kernel/include/chmsg.h b/os/kernel/include/chmsg.h
index 1803c719d..2bae02dea 100644
--- a/os/kernel/include/chmsg.h
+++ b/os/kernel/include/chmsg.h
@@ -32,6 +32,10 @@
#if CH_USE_MESSAGES || defined(__DOXYGEN__)
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Evaluates to TRUE if the thread has pending messages.
*
* @iclass
@@ -74,6 +78,7 @@
* @sclass
*/
#define chMsgReleaseS(tp, msg) chSchWakeupS(tp, msg)
+/** @} */
#ifdef __cplusplus
extern "C" {
diff --git a/os/kernel/include/chmtx.h b/os/kernel/include/chmtx.h
index 9f2d5a0d3..831d48a89 100644
--- a/os/kernel/include/chmtx.h
+++ b/os/kernel/include/chmtx.h
@@ -77,12 +77,17 @@ extern "C" {
#define MUTEX_DECL(name) Mutex name = _MUTEX_DATA(name)
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Returns @p TRUE if the mutex queue contains at least a waiting
* thread.
*
* @sclass
*/
#define chMtxQueueNotEmptyS(mp) notempty(&(mp)->m_queue)
+/** @} */
#endif /* CH_USE_MUTEXES */
diff --git a/os/kernel/include/chqueues.h b/os/kernel/include/chqueues.h
index a2df59dad..4917ac837 100644
--- a/os/kernel/include/chqueues.h
+++ b/os/kernel/include/chqueues.h
@@ -31,16 +31,16 @@
#if CH_USE_QUEUES || defined(__DOXYGEN__)
-/** @brief Returned by the queue functions if the operation is successful.*/
-#define Q_OK RDY_OK
-/** @brief Returned by the queue functions if a timeout occurs.*/
-#define Q_TIMEOUT RDY_TIMEOUT
-/** @brief Returned by the queue functions if the queue has been reset.*/
-#define Q_RESET RDY_RESET
-/** @brief Returned by the queue functions if the queue is empty.*/
-#define Q_EMPTY -3
-/** @brief Returned by the queue functions if the queue is full.*/
-#define Q_FULL -4
+/**
+ * @name Queue functions returned status value
+ * @{
+ */
+#define Q_OK RDY_OK /**< @brief Operation successful. */
+#define Q_TIMEOUT RDY_TIMEOUT /**< @brief Timeout condition. */
+#define Q_RESET RDY_RESET /**< @brief Queue has been reset. */
+#define Q_EMPTY -3 /**< @brief Queue empty. */
+#define Q_FULL -4 /**< @brief Queue full, */
+/** @} */
/**
* @brief Type of a generic I/O queue structure.
@@ -71,6 +71,10 @@ struct GenericQueue {
};
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Returns the queue's buffer size.
*
* @param[in] qp pointer to a @p GenericQueue structure.
@@ -90,7 +94,8 @@ struct GenericQueue {
*
* @iclass
*/
-#define chQSpaceI(qp) ((size_t)((qp)->q_counter))
+#define chQSpaceI(qp) ((qp)->q_counter)
+/** @} */
/**
* @extends GenericQueue
@@ -106,6 +111,10 @@ struct GenericQueue {
typedef GenericQueue InputQueue;
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Returns the filled space into an input queue.
*
* @param[in] iqp pointer to an @p InputQueue structure
@@ -165,6 +174,7 @@ typedef GenericQueue InputQueue;
* @api
*/
#define chIQGet(iqp) chIQGetTimeout(iqp, TIME_INFINITE)
+/** @} */
/**
* @brief Data part of a static input queue initializer.
@@ -212,15 +222,19 @@ typedef GenericQueue InputQueue;
*/
typedef GenericQueue OutputQueue;
- /**
- * @brief Returns the filled space into an output queue.
- *
- * @param[in] oqp pointer to an @p OutputQueue structure
- * @return The number of full bytes in the queue.
- * @retval 0 if the queue is empty.
- *
- * @iclass
- */
+/**
+ * @name Macro Functions
+ * @{
+ */
+/**
+ * @brief Returns the filled space into an output queue.
+ *
+ * @param[in] oqp pointer to an @p OutputQueue structure
+ * @return The number of full bytes in the queue.
+ * @retval 0 if the queue is empty.
+ *
+ * @iclass
+ */
#define chOQGetFullI(oqp) (chQSizeI(oqp) - chQSpaceI(oqp))
/**
@@ -274,6 +288,7 @@ typedef GenericQueue OutputQueue;
* @api
*/
#define chOQPut(oqp, b) chOQPutTimeout(oqp, b, TIME_INFINITE)
+ /** @} */
/**
* @brief Data part of a static output queue initializer.
diff --git a/os/kernel/include/chregistry.h b/os/kernel/include/chregistry.h
index 0967f699e..8f7ebd4b9 100644
--- a/os/kernel/include/chregistry.h
+++ b/os/kernel/include/chregistry.h
@@ -31,6 +31,10 @@
#if CH_USE_REGISTRY || defined(__DOXYGEN__)
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Sets the current thread name.
* @pre This function only stores the pointer to the name if the option
* @p CH_USE_REGISTRY is enabled else no action is performed.
@@ -52,13 +56,13 @@
* @retval NULL if the thread name has not been set.
*/
#define chRegGetThreadName(tp) ((tp)->p_name)
+/** @} */
#else /* !CH_USE_REGISTRY */
#define chRegSetThreadName(p)
#define chRegGetThreadName(tp) NULL
#endif /* !CH_USE_REGISTRY */
#if CH_USE_REGISTRY || defined(__DOXYGEN__)
-
/**
* @brief Removes a thread from the registry list.
* @note This macro is not meant for use in application code.
diff --git a/os/kernel/include/chschd.h b/os/kernel/include/chschd.h
index 0e933e8ba..0e490c26a 100644
--- a/os/kernel/include/chschd.h
+++ b/os/kernel/include/chschd.h
@@ -29,22 +29,35 @@
#ifndef _CHSCHD_H_
#define _CHSCHD_H_
-/** @brief Default thread wakeup low level message.*/
-#define RDY_OK 0
-/** @brief Low level message sent to a thread awakened by a timeout.*/
-#define RDY_TIMEOUT -1
-/** @brief Low level message sent to a thread awakened by a reset operation.*/
-#define RDY_RESET -2
+/**
+ * @name Wakeup status codes
+ * @{
+ */
+#define RDY_OK 0 /**< @brief Normal wakeup message. */
+#define RDY_TIMEOUT -1 /**< @brief Wakeup caused by a timeout
+ condition. */
+#define RDY_RESET -2 /**< @brief Wakeup caused by a reset
+ condition. */
+/** @} */
+/**
+ * @name Priority constants
+ * @{
+ */
#define NOPRIO 0 /**< @brief Ready list header priority. */
#define IDLEPRIO 1 /**< @brief Idle thread priority. */
#define LOWPRIO 2 /**< @brief Lowest user priority. */
#define NORMALPRIO 64 /**< @brief Normal user priority. */
#define HIGHPRIO 127 /**< @brief Highest user priority. */
#define ABSPRIO 255 /**< @brief Greatest possible priority. */
+/** @} */
/**
- * @brief Zero time specification for some syscalls with a timeout
+ * @name Special time constants
+ * @{
+ */
+/**
+ * @brief Zero time specification for some functions with a timeout
* specification.
* @note Not all functions accept @p TIME_IMMEDIATE as timeout parameter,
* see the specific function documentation.
@@ -52,10 +65,11 @@
#define TIME_IMMEDIATE ((systime_t)0)
/**
- * @brief Infinite time specification for all the syscalls with a timeout
+ * @brief Infinite time specification for all functions with a timeout
* specification.
*/
#define TIME_INFINITE ((systime_t)-1)
+/** @} */
/**
* @brief Returns the priority of the first thread on the given ready list.
@@ -148,6 +162,10 @@ extern "C" {
#endif
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Determines if the current thread must reschedule.
* @details This function returns @p TRUE if there is a ready thread with
* higher priority.
@@ -209,6 +227,7 @@ extern "C" {
chSchDoReschedule(); \
}
#endif /* CH_TIME_QUANTUM == 0 */
+/** @} */
#endif /* _CHSCHD_H_ */
diff --git a/os/kernel/include/chsem.h b/os/kernel/include/chsem.h
index 04e079466..5f1c37a0a 100644
--- a/os/kernel/include/chsem.h
+++ b/os/kernel/include/chsem.h
@@ -83,6 +83,10 @@ extern "C" {
#define SEMAPHORE_DECL(name, n) Semaphore name = _SEMAPHORE_DATA(name, n)
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Decreases the semaphore counter.
* @details This macro can be used when the counter is known to be positive.
*
@@ -105,6 +109,7 @@ extern "C" {
* @iclass
*/
#define chSemGetCounterI(sp) ((sp)->s_cnt)
+/** @} */
#endif /* CH_USE_SEMAPHORES */
diff --git a/os/kernel/include/chstreams.h b/os/kernel/include/chstreams.h
index 0bd763366..57883601d 100644
--- a/os/kernel/include/chstreams.h
+++ b/os/kernel/include/chstreams.h
@@ -74,6 +74,10 @@ typedef struct {
} BaseSequentialStream;
/**
+ * @name Macro Functions (BaseSequentialStream)
+ * @{
+ */
+/**
* @brief Sequential Stream write.
* @details The function writes data from a buffer to a stream.
*
@@ -103,6 +107,7 @@ typedef struct {
* @api
*/
#define chSequentialStreamRead(ip, bp, n) ((ip)->vmt->read(ip, bp, n))
+/** @} */
#endif /* _CHSTREAMS_H_ */
diff --git a/os/kernel/include/chsys.h b/os/kernel/include/chsys.h
index f807182ac..b69736a1d 100644
--- a/os/kernel/include/chsys.h
+++ b/os/kernel/include/chsys.h
@@ -29,6 +29,10 @@
#ifndef _CHSYS_H_
#define _CHSYS_H_
+/**
+ * @name Macro Functions
+ * @{
+ */
#if !CH_NO_IDLE_THREAD || defined(__DOXYGEN__)
/**
* @brief Returns a pointer to the idle thread.
@@ -177,8 +181,12 @@
dbg_check_unlock_from_isr(); \
port_unlock_from_isr(); \
}
+/** @} */
/**
+ * @name ISRs abstraction macros
+ */
+/**
* @brief IRQ handler enter code.
* @note Usually IRQ handlers functions are also declared naked.
* @note On some architectures this macro can be empty.
@@ -211,8 +219,12 @@
* @special
*/
#define CH_IRQ_HANDLER(id) PORT_IRQ_HANDLER(id)
+/** @} */
/**
+ * @name Fast ISRs abstraction macros
+ */
+/**
* @brief Standard fast IRQ handler declaration.
* @note @p id can be a function name or a vector number depending on the
* port implementation.
@@ -221,6 +233,7 @@
* @special
*/
#define CH_FAST_IRQ_HANDLER(id) PORT_FAST_IRQ_HANDLER(id)
+/** @} */
#ifdef __cplusplus
extern "C" {
diff --git a/os/kernel/include/chthreads.h b/os/kernel/include/chthreads.h
index a0a668df4..bd3f21296 100644
--- a/os/kernel/include/chthreads.h
+++ b/os/kernel/include/chthreads.h
@@ -30,6 +30,43 @@
#define _CHTHREADS_H_
/**
+ * @name Thread states
+ * @{
+ */
+#define THD_STATE_READY 0 /**< @brief Waiting on the ready list. */
+#define THD_STATE_CURRENT 1 /**< @brief Currently running. */
+#define THD_STATE_SUSPENDED 2 /**< @brief Created in suspended state. */
+#define THD_STATE_WTSEM 3 /**< @brief Waiting on a semaphore. */
+#define THD_STATE_WTMTX 4 /**< @brief Waiting on a mutex. */
+#define THD_STATE_WTCOND 5 /**< @brief Waiting on a condition
+ variable. */
+#define THD_STATE_SLEEPING 6 /**< @brief Waiting in @p chThdSleep()
+ or @p chThdSleepUntil(). */
+#define THD_STATE_WTEXIT 7 /**< @brief Waiting in @p chThdWait(). */
+#define THD_STATE_WTOREVT 8 /**< @brief Waiting for an event. */
+#define THD_STATE_WTANDEVT 9 /**< @brief Waiting for several events. */
+#define THD_STATE_SNDMSGQ 10 /**< @brief Sending a message, in queue.*/
+#define THD_STATE_SNDMSG 11 /**< @brief Sent a message, waiting
+ answer. */
+#define THD_STATE_WTMSG 12 /**< @brief Waiting for a message. */
+#define THD_STATE_WTQUEUE 13 /**< @brief Waiting on an I/O queue. */
+#define THD_STATE_FINAL 14 /**< @brief Thread terminated. */
+/** @} */
+
+/**
+ * @name Thread flags and attributes
+ * @{
+ */
+#define THD_MEM_MODE_MASK 3 /**< @brief Thread memory mode mask. */
+#define THD_MEM_MODE_STATIC 0 /**< @brief Static thread. */
+#define THD_MEM_MODE_HEAP 1 /**< @brief Thread allocated from a
+ Memory Heap. */
+#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread allocated from a
+ Memory Pool. */
+#define THD_TERMINATE 4 /**< @brief Termination requested flag. */
+/** @} */
+
+/**
* @extends ThreadsQueue
*
* @brief Structure representing a thread.
@@ -163,52 +200,16 @@ struct Thread {
#endif
};
-/** @brief Thread state: Ready to run, waiting on the ready list.*/
-#define THD_STATE_READY 0
-/** @brief Thread state: Currently running.*/
-#define THD_STATE_CURRENT 1
-/** @brief Thread state: Thread created in suspended state.*/
-#define THD_STATE_SUSPENDED 2
-/** @brief Thread state: Waiting on a semaphore.*/
-#define THD_STATE_WTSEM 3
-/** @brief Thread state: Waiting on a mutex.*/
-#define THD_STATE_WTMTX 4
-/** @brief Thread state: Waiting in @p chCondWait().*/
-#define THD_STATE_WTCOND 5
-/** @brief Thread state: Waiting in @p chThdSleep() or @p chThdSleepUntil().*/
-#define THD_STATE_SLEEPING 6
-/** @brief Thread state: Waiting in @p chThdWait().*/
-#define THD_STATE_WTEXIT 7
-/** @brief Thread state: Waiting in @p chEvtWaitXXX().*/
-#define THD_STATE_WTOREVT 8
-/** @brief Thread state: Waiting in @p chEvtWaitAllTimeout().*/
-#define THD_STATE_WTANDEVT 9
-/** @brief Thread state: Waiting in @p chMsgSend() (queued).*/
-#define THD_STATE_SNDMSGQ 10
-/** @brief Thread state: Waiting in @p chMsgSend() (not queued).*/
-#define THD_STATE_SNDMSG 11
-/** @brief Thread state: Waiting in @p chMsgWait().*/
-#define THD_STATE_WTMSG 12
-/** @brief Thread state: Waiting on an I/O queue.*/
-#define THD_STATE_WTQUEUE 13
-/** @brief Thread state: After termination.*/
-#define THD_STATE_FINAL 14
-
-/*
- * Various flags into the thread p_flags field.
- */
-#define THD_MEM_MODE_MASK 3 /**< @brief Thread memory mode mask. */
-#define THD_MEM_MODE_STATIC 0 /**< @brief Thread memory mode: static. */
-#define THD_MEM_MODE_HEAP 1 /**< @brief Thread memory mode: heap. */
-#define THD_MEM_MODE_MEMPOOL 2 /**< @brief Thread memory mode: pool. */
-#define THD_TERMINATE 4 /**< @brief Termination requested. */
-
/**
* @brief Thread function.
*/
typedef msg_t (*tfunc_t)(void *);
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Returns a pointer to the current @p Thread.
*
* @api
@@ -262,7 +263,7 @@ typedef msg_t (*tfunc_t)(void *);
#define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE)
/**
- * @brief Resumes a thread created with @p chThdInit().
+ * @brief Resumes a thread created with @p chThdCreateI().
*
* @param[in] tp pointer to the thread
*
@@ -321,6 +322,7 @@ typedef msg_t (*tfunc_t)(void *);
* @api
*/
#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec))
+/** @} */
/*
* Threads APIs.
diff --git a/os/kernel/include/chvt.h b/os/kernel/include/chvt.h
index e75e966d5..0038e3d0a 100644
--- a/os/kernel/include/chvt.h
+++ b/os/kernel/include/chvt.h
@@ -30,25 +30,30 @@
#define _CHVT_H_
/**
- * @brief Time conversion utility.
+ * @name Time conversion utilities
+ * @{
+ */
+/**
+ * @brief Seconds to system ticks.
* @details Converts from seconds to system ticks number.
* @note The result is rounded upward to the next tick boundary.
*/
#define S2ST(sec) ((systime_t)((sec) * CH_FREQUENCY))
/**
- * @brief Time conversion utility.
+ * @brief Milliseconds t0 system ticks.
* @details Converts from milliseconds to system ticks number.
* @note The result is rounded upward to the next tick boundary.
*/
#define MS2ST(msec) ((systime_t)(((((msec) - 1L) * CH_FREQUENCY) / 1000L) + 1L))
/**
- * @brief Time conversion utility.
+ * @brief Microseconds to system ticks.
* @details Converts from microseconds to system ticks number.
* @note The result is rounded upward to the next tick boundary.
*/
#define US2ST(usec) ((systime_t)(((((usec) - 1L) * CH_FREQUENCY) / 1000000L) + 1L))
+/** @} */
/**
* @brief Virtual Timer callback function.
@@ -95,6 +100,10 @@ typedef struct {
extern VTList vtlist;
/**
+ * @name Macro Functions
+ * @{
+ */
+/**
* @brief Virtual timers ticker.
*
* @iclass
@@ -115,20 +124,6 @@ extern VTList vtlist;
} \
}
-/*
- * Virtual Timers APIs.
- */
-#ifdef __cplusplus
-extern "C" {
-#endif
- void _vt_init(void);
- void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par);
- void chVTResetI(VirtualTimer *vtp);
- bool_t chTimeIsWithin(systime_t start, systime_t end);
-#ifdef __cplusplus
-}
-#endif
-
/**
* @brief Returns TRUE if the speciified timer is armed.
*
@@ -148,6 +143,21 @@ extern "C" {
* @api
*/
#define chTimeNow() (vtlist.vt_systime)
+/** @} */
+
+/*
+ * Virtual Timers APIs.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+ void _vt_init(void);
+ void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par);
+ void chVTResetI(VirtualTimer *vtp);
+ bool_t chTimeIsWithin(systime_t start, systime_t end);
+#ifdef __cplusplus
+}
+#endif
#endif /* _CHVT_H_ */
diff --git a/os/kernel/src/chmsg.c b/os/kernel/src/chmsg.c
index 5002a892a..403df1580 100644
--- a/os/kernel/src/chmsg.c
+++ b/os/kernel/src/chmsg.c
@@ -109,7 +109,7 @@ Thread *chMsgWait(void) {
}
/**
- * @brief Releases the thread waiting on top of the messages queue.
+ * @brief Releases a sender thread specifying a response message.
* @pre Invoke this function only after a message has been received
* using @p chMsgWait().
*
diff --git a/os/kernel/src/chthreads.c b/os/kernel/src/chthreads.c
index 19accdb55..46039561b 100644
--- a/os/kernel/src/chthreads.c
+++ b/os/kernel/src/chthreads.c
@@ -80,9 +80,6 @@ Thread *_thread_init(Thread *tp, tprio_t prio) {
#if CH_USE_EVENTS
tp->p_epending = 0;
#endif
-#if CH_USE_NESTED_LOCKS
- tp->p_locks = 0;
-#endif
#if CH_DBG_THREADS_PROFILING
tp->p_time = 0;
#endif