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

This commit is contained in:
gdisirio 2010-09-21 10:22:06 +00:00
parent 16855e1a4e
commit 07351222e6
42 changed files with 519 additions and 104 deletions

View File

@ -189,7 +189,27 @@ TAB_SIZE = 2
# will result in a user-defined paragraph with heading "Side Effects:". # will result in a user-defined paragraph with heading "Side Effects:".
# You can put \n's in the value part of an alias to insert newlines. # You can put \n's in the value part of an alias to insert newlines.
ALIASES = ALIASES = "iclass=@par Function Class:\n This is an \
<b>I-Class</b> API, this function can be \
invoked from within a system lock zone by both \
threads and interrupt handlers." \
"sclass=@par Function Class:\n This is an \
<b>S-Class</b> API, this function can be \
invoked from within a system lock zone by threads \
only." \
"api=@par Function Class:\n Normal API, this \
function can be invoked by regular system threads \
but not from within a lock zone." \
"notapi=@par Function Class:\n Not an API, this \
function is for internal use only." \
"isr=@par Function Class:\n Interrupt handler, \
this function should not be directly invoked." \
"init=@par Function Class:\n Initializer, this \
function just initializes an object and can be \
invoked before the kernel is initialized." \
"special=@par Function Class:\n Special function, \
this function has special requirements see the \
notes."
# Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C
# sources only. Doxygen will then generate output that is more tailored for C. # sources only. Doxygen will then generate output that is more tailored for C.

View File

@ -137,7 +137,7 @@ static void serve_interrupt(SerialDriver *sdp) {
case IIR_SRC_TIMEOUT: case IIR_SRC_TIMEOUT:
case IIR_SRC_RX: case IIR_SRC_RX:
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQIsEmpty(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chEvtBroadcastI(&sdp->ievent); chEvtBroadcastI(&sdp->ievent);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
while (u->LSR & LSR_RBR_FULL) { while (u->LSR & LSR_RBR_FULL) {

View File

@ -137,7 +137,7 @@ static void serve_interrupt(SerialDriver *sdp) {
case IIR_SRC_TIMEOUT: case IIR_SRC_TIMEOUT:
case IIR_SRC_RX: case IIR_SRC_RX:
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQIsEmpty(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chEvtBroadcastI(&sdp->ievent); chEvtBroadcastI(&sdp->ievent);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
while (u->LSR & LSR_RBR_FULL) { while (u->LSR & LSR_RBR_FULL) {

View File

@ -144,7 +144,7 @@ static void serve_interrupt(SerialDriver *sdp) {
case IIR_SRC_TIMEOUT: case IIR_SRC_TIMEOUT:
case IIR_SRC_RX: case IIR_SRC_RX:
chSysLockFromIsr(); chSysLockFromIsr();
if (chIQIsEmpty(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chEvtBroadcastI(&sdp->ievent); chEvtBroadcastI(&sdp->ievent);
chSysUnlockFromIsr(); chSysUnlockFromIsr();
while (u->UART_LSR & LSR_RBR_FULL) { while (u->UART_LSR & LSR_RBR_FULL) {

View File

@ -61,12 +61,12 @@ static size_t reads(void *ip, uint8_t *bp, size_t n) {
static bool_t putwouldblock(void *ip) { static bool_t putwouldblock(void *ip) {
return chOQIsFull(&((SerialDriver *)ip)->oqueue); return chOQIsFullI(&((SerialDriver *)ip)->oqueue);
} }
static bool_t getwouldblock(void *ip) { static bool_t getwouldblock(void *ip) {
return chIQIsEmpty(&((SerialDriver *)ip)->iqueue); return chIQIsEmptyI(&((SerialDriver *)ip)->iqueue);
} }
static msg_t putt(void *ip, uint8_t b, systime_t timeout) { static msg_t putt(void *ip, uint8_t b, systime_t timeout) {
@ -192,7 +192,7 @@ void sdIncomingDataI(SerialDriver *sdp, uint8_t b) {
chDbgCheck(sdp != NULL, "sdIncomingDataI"); chDbgCheck(sdp != NULL, "sdIncomingDataI");
if (chIQIsEmpty(&sdp->iqueue)) if (chIQIsEmptyI(&sdp->iqueue))
chEvtBroadcastI(&sdp->ievent); chEvtBroadcastI(&sdp->ievent);
if (chIQPutI(&sdp->iqueue, b) < Q_OK) if (chIQPutI(&sdp->iqueue, b) < Q_OK)
sdAddFlagsI(sdp, SD_OVERRUN_ERROR); sdAddFlagsI(sdp, SD_OVERRUN_ERROR);

View File

@ -91,6 +91,8 @@ typedef struct {
* - @a FALSE, the initial state is not taken. * - @a FALSE, the initial state is not taken.
* - @a TRUE, the initial state is taken. * - @a TRUE, the initial state is taken.
* . * .
*
* @init
*/ */
#define chBSemInit(bsp, taken) chSemInit(&bsp->bs_sem, taken ? 0 : 1) #define chBSemInit(bsp, taken) chSemInit(&bsp->bs_sem, taken ? 0 : 1)
@ -98,9 +100,13 @@ typedef struct {
* @brief Wait operation on the binary semaphore. * @brief Wait operation on the binary semaphore.
* *
* @param[in] bsp pointer to a @p BinarySemaphore structure * @param[in] bsp pointer to a @p BinarySemaphore structure
* @retval RDY_OK if the binary semaphore had been successfully taken. * @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the binary semaphore has been successfully taken.
* @retval RDY_RESET if the binary semaphore has been reset using * @retval RDY_RESET if the binary semaphore has been reset using
* @p bsemReset(). * @p bsemReset().
*
* @api
*/ */
#define chBSemWait(bsp) chSemWait(&bsp->bs_sem) #define chBSemWait(bsp) chSemWait(&bsp->bs_sem)
@ -108,9 +114,13 @@ typedef struct {
* @brief Wait operation on the binary semaphore. * @brief Wait operation on the binary semaphore.
* *
* @param[in] bsp pointer to a @p BinarySemaphore structure * @param[in] bsp pointer to a @p BinarySemaphore structure
* @retval RDY_OK if the binary semaphore had been successfully taken. * @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the binary semaphore has been successfully taken.
* @retval RDY_RESET if the binary semaphore has been reset using * @retval RDY_RESET if the binary semaphore has been reset using
* @p bsemReset(). * @p bsemReset().
*
* @sclass
*/ */
#define chBSemWaitS(bsp) chSemWaitS(&bsp->bs_sem) #define chBSemWaitS(bsp) chSemWaitS(&bsp->bs_sem)
@ -123,11 +133,15 @@ typedef struct {
* - @a TIME_IMMEDIATE immediate timeout. * - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @retval RDY_OK if the binary semaphore had been successfully taken. * @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the binary semaphore has been successfully taken.
* @retval RDY_RESET if the binary semaphore has been reset using * @retval RDY_RESET if the binary semaphore has been reset using
* @p bsemReset(). * @p bsemReset().
* @retval RDY_TIMEOUT if the binary semaphore was not signaled or reset * @retval RDY_TIMEOUT if the binary semaphore has not been signaled or reset
* within the specified timeout. * within the specified timeout.
*
* @api
*/ */
#define chBSemWaitTimeout(bsp, time) chSemWaitTimeout(&bsp->bs_sem, time) #define chBSemWaitTimeout(bsp, time) chSemWaitTimeout(&bsp->bs_sem, time)
@ -140,11 +154,15 @@ typedef struct {
* - @a TIME_IMMEDIATE immediate timeout. * - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @retval RDY_OK if the binary semaphore had been successfully taken. * @return A message specifying how the invoking thread has been
* released from the semaphore.
* @retval RDY_OK if the binary semaphore has been successfully taken.
* @retval RDY_RESET if the binary semaphore has been reset using * @retval RDY_RESET if the binary semaphore has been reset using
* @p bsemReset(). * @p bsemReset().
* @retval RDY_TIMEOUT if the binary semaphore was not signaled or reset * @retval RDY_TIMEOUT if the binary semaphore has not been signaled or reset
* within the specified timeout. * within the specified timeout.
*
* @sclass
*/ */
#define chBSemWaitTimeoutS(bsp, time) chSemWaitTimeoutS(&bsp->bs_sem, time) #define chBSemWaitTimeoutS(bsp, time) chSemWaitTimeoutS(&bsp->bs_sem, time)
@ -159,6 +177,8 @@ typedef struct {
* - @a FALSE, the new state is not taken. * - @a FALSE, the new state is not taken.
* - @a TRUE, the new state is taken. * - @a TRUE, the new state is taken.
* . * .
*
* @api
*/ */
#define chBSemReset(bsp, taken) chSemReset(&bsp->bs_sem, taken ? 0 : 1) #define chBSemReset(bsp, taken) chSemReset(&bsp->bs_sem, taken ? 0 : 1)
@ -174,6 +194,8 @@ typedef struct {
* - @a FALSE, the new state is not taken. * - @a FALSE, the new state is not taken.
* - @a TRUE, the new state is taken. * - @a TRUE, the new state is taken.
* . * .
*
* @iclass
*/ */
#define chBSemResetI(bsp, taken) chSemResetI(&bsp->bs_sem, taken ? 0 : 1) #define chBSemResetI(bsp, taken) chSemResetI(&bsp->bs_sem, taken ? 0 : 1)
@ -181,6 +203,8 @@ typedef struct {
* @brief Performs a signal operation on a binary semaphore. * @brief Performs a signal operation on a binary semaphore.
* *
* @param[in] bsp pointer to a @p BinarySemaphore structure * @param[in] bsp pointer to a @p BinarySemaphore structure
*
* @api
*/ */
#define chBSemSignal(bsp) { \ #define chBSemSignal(bsp) { \
chSysLock(); \ chSysLock(); \
@ -194,6 +218,8 @@ typedef struct {
* @note This function does not reschedule. * @note This function does not reschedule.
* *
* @param[in] bsp pointer to a @p BinarySemaphore structure * @param[in] bsp pointer to a @p BinarySemaphore structure
*
* @iclass
*/ */
#define chBSemSignalI(bsp) { \ #define chBSemSignalI(bsp) { \
if (bsp->bs_sem.s_cnt < 1) \ if (bsp->bs_sem.s_cnt < 1) \
@ -207,6 +233,8 @@ typedef struct {
* @return The binary semaphore current state. * @return The binary semaphore current state.
* @retval FALSE if the binary semaphore is not taken. * @retval FALSE if the binary semaphore is not taken.
* @retval TRUE if the binary semaphore is taken. * @retval TRUE if the binary semaphore is taken.
*
* @iclass
*/ */
#define chBSemGetStateI(bsp) ((bsp)->bs_sem.s_cnt > 0 ? 0 : 1) #define chBSemGetStateI(bsp) ((bsp)->bs_sem.s_cnt > 0 ? 0 : 1)

View File

@ -91,6 +91,8 @@ typedef struct {
* *
* @param[in] c the condition to be verified to be true * @param[in] c the condition to be verified to be true
* @param[in] func the undecorated function name * @param[in] func the undecorated function name
*
* @api
*/ */
#define chDbgCheck(c, func) { \ #define chDbgCheck(c, func) { \
if (!(c)) \ if (!(c)) \
@ -117,6 +119,8 @@ typedef struct {
* @param[in] c the condition to be verified to be true * @param[in] c the condition to be verified to be true
* @param[in] m the text message * @param[in] m the text message
* @param[in] r a remark string * @param[in] r a remark string
*
* @api
*/ */
#define chDbgAssert(c, m, r) { \ #define chDbgAssert(c, m, r) { \
if (!(c)) \ if (!(c)) \

View File

@ -90,6 +90,8 @@ typedef struct EventSource {
* function. * function.
* The value must range between zero and the size, in bit, * The value must range between zero and the size, in bit,
* of the @p eventid_t type minus one. * of the @p eventid_t type minus one.
*
* @api
*/ */
#define chEvtRegister(esp, elp, eid) \ #define chEvtRegister(esp, elp, eid) \
chEvtRegisterMask(esp, elp, EVENT_MASK(eid)) chEvtRegisterMask(esp, elp, EVENT_MASK(eid))
@ -100,17 +102,20 @@ typedef struct EventSource {
* because it just prepares a @p EventSource structure. * because it just prepares a @p EventSource structure.
* *
* @param[in] esp pointer to the @p EventSource structure * @param[in] esp pointer to the @p EventSource structure
*
* @init
*/ */
#define chEvtInit(esp) \ #define chEvtInit(esp) \
((esp)->es_next = (EventListener *)(void *)(esp)) ((esp)->es_next = (EventListener *)(void *)(esp))
/** /**
* @brief Verifies if there is at least one @p EventListener registered. * @brief Verifies if there is at least one @p EventListener registered.
* @note Can be called with interrupts disabled or enabled.
* *
* @param[in] esp pointer to the @p EventSource structure * @param[in] esp pointer to the @p EventSource structure
*
* @iclass
*/ */
#define chEvtIsListening(esp) \ #define chEvtIsListeningI(esp) \
((void *)(esp) != (void *)(esp)->es_next) ((void *)(esp) != (void *)(esp)->es_next)
/** /**

View File

@ -96,6 +96,8 @@ typedef struct {
* @details The function closes a file stream. * @details The function closes a file stream.
* *
* @param[in] ip pointer to a @p BaseFileStream or derived class * @param[in] ip pointer to a @p BaseFileStream or derived class
*
* @api
*/ */
#define chFileStreamClose(ip) ((ip)->vmt->close(ip)) #define chFileStreamClose(ip) ((ip)->vmt->close(ip))
@ -103,6 +105,8 @@ typedef struct {
* @brief Returns an implementation dependent error code. * @brief Returns an implementation dependent error code.
* *
* @param[in] ip pointer to a @p BaseFileStream or derived class * @param[in] ip pointer to a @p BaseFileStream or derived class
*
* @api
*/ */
#define chFileStreamGetError ((ip)->vmt->geterror(ip)) #define chFileStreamGetError ((ip)->vmt->geterror(ip))
@ -110,6 +114,8 @@ typedef struct {
* @brief Returns the current file size. * @brief Returns the current file size.
* *
* @param[in] ip pointer to a @p BaseFileStream or derived class * @param[in] ip pointer to a @p BaseFileStream or derived class
*
* @api
*/ */
#define chFileStreamGetSize ((ip)->vmt->getposition(ip)) #define chFileStreamGetSize ((ip)->vmt->getposition(ip))
@ -117,6 +123,8 @@ typedef struct {
* @brief Returns the current file pointer position. * @brief Returns the current file pointer position.
* *
* @param[in] ip pointer to a @p BaseFileStream or derived class * @param[in] ip pointer to a @p BaseFileStream or derived class
*
* @api
*/ */
#define chFileStreamGetPosition ((ip)->vmt->getposition(ip)) #define chFileStreamGetPosition ((ip)->vmt->getposition(ip))
@ -125,6 +133,8 @@ typedef struct {
* *
* @param[in] ip pointer to a @p BaseFileStream or derived class * @param[in] ip pointer to a @p BaseFileStream or derived class
* @param[in] offset new absolute position * @param[in] offset new absolute position
*
* @api
*/ */
#define chFileStreamSeek ((ip)->vmt->lseek(ip, offset)) #define chFileStreamSeek ((ip)->vmt->lseek(ip, offset))

View File

@ -91,11 +91,13 @@ typedef struct {
* block. * block.
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
* @return The output queue status: * @return The output queue status.
* @retval FALSE if the output queue has space and would not block a * @retval FALSE if the output queue has space and would not block a
* write operation. * write operation.
* @retval TRUE if the output queue is full and would block a write * @retval TRUE if the output queue is full and would block a write
* operation. * operation.
*
* @api
*/ */
#define chIOPutWouldBlock(ip) ((ip)->vmt->putwouldblock(ip)) #define chIOPutWouldBlock(ip) ((ip)->vmt->putwouldblock(ip))
@ -105,11 +107,13 @@ typedef struct {
* block. * block.
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
* @return The input queue status: * @return The input queue status.
* @retval FALSE if the input queue contains data and would not block a * @retval FALSE if the input queue contains data and would not block a
* read operation. * read operation.
* @retval TRUE if the input queue is empty and would block a read * @retval TRUE if the input queue is empty and would block a read
* operation. * operation.
*
* @api
*/ */
#define chIOGetWouldBlock(ip) ((ip)->vmt->getwouldblock(ip)) #define chIOGetWouldBlock(ip) ((ip)->vmt->getwouldblock(ip))
@ -120,9 +124,11 @@ typedef struct {
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
* @param[in] b the byte value to be written to the channel * @param[in] b the byte value to be written to the channel
* @return The operation status: * @return The operation status.
* @retval Q_OK if the operation succeeded. * @retval Q_OK if the operation succeeded.
* @retval Q_RESET if the channel associated queue (if any) was reset. * @retval Q_RESET if the channel associated queue (if any) was reset.
*
* @api
*/ */
#define chIOPut(ip, b) ((ip)->vmt->put(ip, b, TIME_INFINITE)) #define chIOPut(ip, b) ((ip)->vmt->put(ip, b, TIME_INFINITE))
@ -138,10 +144,12 @@ typedef struct {
* - @a TIME_IMMEDIATE immediate timeout. * - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @return The operation status: * @return The operation status.
* @retval Q_OK if the operation succeeded. * @retval Q_OK if the operation succeeded.
* @retval Q_TIMEOUT if the specified time expired. * @retval Q_TIMEOUT if the specified time expired.
* @retval Q_RESET if the channel associated queue (if any) was reset. * @retval Q_RESET if the channel associated queue (if any) was reset.
*
* @api
*/ */
#define chIOPutTimeout(ip, b, time) ((ip)->vmt->put(ip, b, time)) #define chIOPutTimeout(ip, b, time) ((ip)->vmt->put(ip, b, time))
@ -151,8 +159,11 @@ typedef struct {
* is not available then the calling thread is suspended. * is not available then the calling thread is suspended.
* *
* @param[in] ip pointer to a @p BaseChannel or derived class * @param[in] ip pointer to a @p BaseChannel or derived class
* @return A byte value from the queue or: * @return A byte value from the queue.
* @retval Q_RESET if the channel associated queue (if any) was reset. * @retval Q_RESET if the channel associated queue (if any) has been
* reset.
*
* @api
*/ */
#define chIOGet(ip) ((ip)->vmt->get(ip, TIME_INFINITE)) #define chIOGet(ip) ((ip)->vmt->get(ip, TIME_INFINITE))
@ -167,9 +178,12 @@ typedef struct {
* - @a TIME_IMMEDIATE immediate timeout. * - @a TIME_IMMEDIATE immediate timeout.
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @return A byte value from the queue or: * @return A byte value from the queue.
* @retval Q_TIMEOUT if the specified time expired. * @retval Q_TIMEOUT if the specified time expired.
* @retval Q_RESET if the channel associated queue (if any) was reset. * @retval Q_RESET if the channel associated queue (if any) has been
* reset.
*
* @api
*/ */
#define chIOGetTimeout(ip, time) ((ip)->vmt->get(ip, time)) #define chIOGetTimeout(ip, time) ((ip)->vmt->get(ip, time))
@ -187,6 +201,8 @@ typedef struct {
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @return The number of bytes transferred. * @return The number of bytes transferred.
*
* @api
*/ */
#define chIOWriteTimeout(ip, bp, n, time) \ #define chIOWriteTimeout(ip, bp, n, time) \
((ip)->vmt->writet(ip, bp, n, time)) ((ip)->vmt->writet(ip, bp, n, time))
@ -205,6 +221,8 @@ typedef struct {
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @return The number of bytes transferred. * @return The number of bytes transferred.
*
* @api
*/ */
#define chIOReadTimeout(ip, bp, n, time) \ #define chIOReadTimeout(ip, bp, n, time) \
((ip)->vmt->readt(ip, bp, n, time)) ((ip)->vmt->readt(ip, bp, n, time))
@ -255,6 +273,8 @@ typedef struct {
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived * @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class * class
* @return A pointer to an @p EventSource object. * @return A pointer to an @p EventSource object.
*
* @api
*/ */
#define chIOGetWriteEventSource(ip) (&((ip)->vmt->oevent)) #define chIOGetWriteEventSource(ip) (&((ip)->vmt->oevent))
@ -267,6 +287,8 @@ typedef struct {
* @param[in] ip pointer to a @p BaseAsynchronousChannel or derived * @param[in] ip pointer to a @p BaseAsynchronousChannel or derived
* class * class
* @return A pointer to an @p EventSource object. * @return A pointer to an @p EventSource object.
*
* @api
*/ */
#define chIOGetReadEventSource(ip) (&((ip)->vmt->ievent)) #define chIOGetReadEventSource(ip) (&((ip)->vmt->ievent))

View File

@ -35,23 +35,31 @@ typedef struct Thread Thread;
/** /**
* @brief Threads queue initialization. * @brief Threads queue initialization.
*
* @notapi
*/ */
#define queue_init(tqp) ((tqp)->p_next = (tqp)->p_prev = (Thread *)(tqp)); #define queue_init(tqp) ((tqp)->p_next = (tqp)->p_prev = (Thread *)(tqp));
/** /**
* @brief Threads list initialization. * @brief Threads list initialization.
*
* @notapi
*/ */
#define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp)) #define list_init(tlp) ((tlp)->p_next = (Thread *)(tlp))
/** /**
* @brief Evaluates to @p TRUE if the specified threads queue or list is * @brief Evaluates to @p TRUE if the specified threads queue or list is
* empty. * empty.
*
* @notapi
*/ */
#define isempty(p) ((p)->p_next == (Thread *)(p)) #define isempty(p) ((p)->p_next == (Thread *)(p))
/** /**
* @brief Evaluates to @p TRUE if the specified threads queue or list is * @brief Evaluates to @p TRUE if the specified threads queue or list is
* not empty. * not empty.
*
* @notapi
*/ */
#define notempty(p) ((p)->p_next != (Thread *)(p)) #define notempty(p) ((p)->p_next != (Thread *)(p))

View File

@ -72,8 +72,10 @@ extern "C" {
* @brief Returns the mailbox buffer size. * @brief Returns the mailbox buffer size.
* *
* @param[in] mbp the pointer to an initialized Mailbox object * @param[in] mbp the pointer to an initialized Mailbox object
*
* @iclass
*/ */
#define chMBSize(mbp) \ #define chMBSizeI(mbp) \
((mbp)->mb_top - (mbp)->mb_buffer) ((mbp)->mb_top - (mbp)->mb_buffer)
/** /**
@ -85,8 +87,10 @@ extern "C" {
* *
* @param[in] mbp the pointer to an initialized Mailbox object * @param[in] mbp the pointer to an initialized Mailbox object
* @return The number of empty message slots. * @return The number of empty message slots.
*
* @iclass
*/ */
#define chMBGetEmpty(mbp) chSemGetCounterI(&(mbp)->mb_emptysem) #define chMBGetEmptyI(mbp) chSemGetCounterI(&(mbp)->mb_emptysem)
/** /**
* @brief Returns the number of messages into the mailbox. * @brief Returns the number of messages into the mailbox.
@ -97,8 +101,10 @@ extern "C" {
* *
* @param[in] mbp the pointer to an initialized Mailbox object * @param[in] mbp the pointer to an initialized Mailbox object
* @return The number of queued messages. * @return The number of queued messages.
*
* @iclass
*/ */
#define chMBGetFull(mbp) chSemGetCounterI(&(mbp)->mb_fullsem) #define chMBGetFullI(mbp) chSemGetCounterI(&(mbp)->mb_fullsem)
/** /**
* @brief Returns the next message in the queue without removing it. * @brief Returns the next message in the queue without removing it.
@ -106,8 +112,10 @@ extern "C" {
* or it would return garbage. The correct way to use this macro is * or it would return garbage. The correct way to use this macro is
* to use @p chMBGetFull() and then use this macro, all within a * to use @p chMBGetFull() and then use this macro, all within a
* lock state. * lock state.
*
* @iclass
*/ */
#define chMBPeek(mbp) (*(mbp)->mb_rdptr) #define chMBPeekI(mbp) (*(mbp)->mb_rdptr)
/** /**
* @brief Data part of a static mailbox initializer. * @brief Data part of a static mailbox initializer.

View File

@ -32,12 +32,16 @@
/** /**
* @brief Evaluates to TRUE if the thread has pending messages. * @brief Evaluates to TRUE if the thread has pending messages.
*
* @iclass
*/ */
#define chMsgIsPendingI(tp) \ #define chMsgIsPendingI(tp) \
((tp)->p_msgqueue.p_next != (Thread *)&(tp)->p_msgqueue) ((tp)->p_msgqueue.p_next != (Thread *)&(tp)->p_msgqueue)
/** /**
* @brief Returns the first message in the queue. * @brief Returns the first message in the queue.
*
* @iclass
*/ */
#define chMsgGetI(tp) \ #define chMsgGetI(tp) \
((tp)->p_msgqueue.p_next->p_msg) ((tp)->p_msgqueue.p_next->p_msg)

View File

@ -78,6 +78,8 @@ extern "C" {
/** /**
* @brief Returns @p TRUE if the mutex queue contains at least a waiting * @brief Returns @p TRUE if the mutex queue contains at least a waiting
* thread. * thread.
*
* @sclass
*/ */
#define chMtxQueueNotEmptyS(mp) notempty(&(mp)->m_queue) #define chMtxQueueNotEmptyS(mp) notempty(&(mp)->m_queue)

View File

@ -72,8 +72,10 @@ typedef struct {
/** /**
* @brief Returns the queue's buffer size. * @brief Returns the queue's buffer size.
*
* @iclass
*/ */
#define chQSize(q) ((q)->q_top - (q)->q_buffer) #define chQSizeI(q) ((q)->q_top - (q)->q_buffer)
/** /**
* @brief Queue space. * @brief Queue space.
@ -81,8 +83,10 @@ typedef struct {
* space if used on an Output Queue. * space if used on an Output Queue.
* @note The returned value can be less than zero when there are waiting * @note The returned value can be less than zero when there are waiting
* threads on the internal semaphore. * threads on the internal semaphore.
*
* @iclass
*/ */
#define chQSpace(q) chSemGetCounterI(&(q)->q_sem) #define chQSpaceI(q) chSemGetCounterI(&(q)->q_sem)
/** /**
* @extends GenericQueue * @extends GenericQueue
@ -97,11 +101,19 @@ typedef struct {
*/ */
typedef GenericQueue InputQueue; typedef GenericQueue InputQueue;
/** @brief Evaluates to @p TRUE if the specified Input Queue is empty.*/ /**
#define chIQIsEmpty(q) ((bool_t)(chQSpace(q) <= 0)) * @brief Evaluates to @p TRUE if the specified Input Queue is empty.
*
* @iclass
*/
#define chIQIsEmptyI(q) ((bool_t)(chQSpaceI(q) <= 0))
/** @brief Evaluates to @p TRUE if the specified Input Queue is full.*/ /**
#define chIQIsFull(q) ((bool_t)(chQSpace(q) >= chQSize(q))) * @brief Evaluates to @p TRUE if the specified Input Queue is full.
*
* @iclass
*/
#define chIQIsFullI(q) ((bool_t)(chQSpaceI(q) >= chQSizeI(q)))
/** /**
* @brief Input queue read. * @brief Input queue read.
@ -110,8 +122,10 @@ typedef GenericQueue InputQueue;
* in the queue. * in the queue.
* *
* @param[in] iqp pointer to an @p InputQueue structure * @param[in] iqp pointer to an @p InputQueue structure
* @return A byte value from the queue or: * @return A byte value from the queue.
* @retval Q_RESET if the queue was reset. * @retval Q_RESET if the queue was reset.
*
* @api
*/ */
#define chIQGet(iqp) chIQGetTimeout(iqp, TIME_INFINITE) #define chIQGet(iqp) chIQGetTimeout(iqp, TIME_INFINITE)
@ -162,13 +176,17 @@ typedef GenericQueue OutputQueue;
/** /**
* @brief Evaluates to @p TRUE if the specified Output Queue is empty. * @brief Evaluates to @p TRUE if the specified Output Queue is empty.
*
* @iclass
*/ */
#define chOQIsEmpty(q) ((bool_t)(chQSpace(q) >= chQSize(q))) #define chOQIsEmptyI(q) ((bool_t)(chQSpaceI(q) >= chQSizeI(q)))
/** /**
* @brief Evaluates to @p TRUE if the specified Output Queue is full. * @brief Evaluates to @p TRUE if the specified Output Queue is full.
*
* @iclass
*/ */
#define chOQIsFull(q) ((bool_t)(chQSpace(q) <= 0)) #define chOQIsFullI(q) ((bool_t)(chQSpaceI(q) <= 0))
/** /**
* @brief Output queue write. * @brief Output queue write.
@ -178,9 +196,11 @@ typedef GenericQueue OutputQueue;
* *
* @param[in] oqp pointer to an @p OutputQueue structure * @param[in] oqp pointer to an @p OutputQueue structure
* @param[in] b the byte value to be written in the queue * @param[in] b the byte value to be written in the queue
* @return The operation status: * @return The operation status.
* @retval Q_OK if the operation succeeded. * @retval Q_OK if the operation succeeded.
* @retval Q_RESET if the queue was reset. * @retval Q_RESET if the queue was reset.
*
* @api
*/ */
#define chOQPut(oqp, b) chOQPutTimeout(oqp, b, TIME_INFINITE) #define chOQPut(oqp, b) chOQPutTimeout(oqp, b, TIME_INFINITE)

View File

@ -58,6 +58,8 @@
/** /**
* @brief Returns the priority of the first thread on the given ready list. * @brief Returns the priority of the first thread on the given ready list.
*
* @notapi
*/ */
#define firstprio(rlp) ((rlp)->p_next->p_prio) #define firstprio(rlp) ((rlp)->p_next->p_prio)
@ -111,6 +113,8 @@ register Thread *currp asm(CH_CURRP_REGISTER_CACHE);
* @brief Current thread pointer change macro. * @brief Current thread pointer change macro.
* @note This macro is not meant to be used in the application code but * @note This macro is not meant to be used in the application code but
* only from within the kernel. * only from within the kernel.
*
* @notapi
*/ */
#if !defined(PORT_OPTIMIZED_SETCURRP) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_SETCURRP) || defined(__DOXYGEN__)
#define setcurrp(tp) (currp = (tp)) #define setcurrp(tp) (currp = (tp))
@ -152,6 +156,8 @@ extern "C" {
* @brief Determines if the current thread must reschedule. * @brief Determines if the current thread must reschedule.
* @details This function returns @p TRUE if there is a ready thread with * @details This function returns @p TRUE if there is a ready thread with
* higher priority. * higher priority.
*
* @iclass
*/ */
#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDI) || defined(__DOXYGEN__)
#define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio) #define chSchIsRescRequiredI() (firstprio(&rlist.r_queue) > currp->p_prio)
@ -161,6 +167,8 @@ extern "C" {
* @brief Determines if yielding is possible. * @brief Determines if yielding is possible.
* @details This function returns @p TRUE if there is a ready thread with * @details This function returns @p TRUE if there is a ready thread with
* equal or higher priority. * equal or higher priority.
*
* @sclass
*/ */
#if !defined(PORT_OPTIMIZED_CANYIELDS) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_CANYIELDS) || defined(__DOXYGEN__)
#define chSchCanYieldS() (firstprio(&rlist.r_queue) >= currp->p_prio) #define chSchCanYieldS() (firstprio(&rlist.r_queue) >= currp->p_prio)
@ -170,6 +178,8 @@ extern "C" {
* @brief Yields the time slot. * @brief Yields the time slot.
* @details Yields the CPU control to the next thread in the ready list with * @details Yields the CPU control to the next thread in the ready list with
* equal or higher priority, if any. * equal or higher priority, if any.
*
* @sclass
*/ */
#if !defined(PORT_OPTIMIZED_DOYIELDS) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_DOYIELDS) || defined(__DOXYGEN__)
#define chSchDoYieldS() { \ #define chSchDoYieldS() { \

View File

@ -83,17 +83,24 @@ extern "C" {
/** /**
* @brief Decreases the semaphore counter. * @brief Decreases the semaphore counter.
* @details This macro can be used when the counter is known to be positive. * @details This macro can be used when the counter is known to be positive.
*
* @iclass
*/ */
#define chSemFastWaitI(sp) ((sp)->s_cnt--) #define chSemFastWaitI(sp) ((sp)->s_cnt--)
/** /**
* @brief Increases the semaphore counter. * @brief Increases the semaphore counter.
* @details This macro can be used when the counter is known to be not negative. * @details This macro can be used when the counter is known to be not
* negative.
*
* @iclass
*/ */
#define chSemFastSignalI(sp) ((sp)->s_cnt++) #define chSemFastSignalI(sp) ((sp)->s_cnt++)
/** /**
* @brief Returns the semaphore counter current value. * @brief Returns the semaphore counter current value.
*
* @iclass
*/ */
#define chSemGetCounterI(sp) ((sp)->s_cnt) #define chSemGetCounterI(sp) ((sp)->s_cnt)

View File

@ -83,6 +83,8 @@ typedef struct {
* be less than the specified number of bytes if the * be less than the specified number of bytes if the
* stream reaches a physical end of file and cannot be * stream reaches a physical end of file and cannot be
* extended. * extended.
*
* @api
*/ */
#define chSequentialStreamWrite(ip, bp, n) ((ip)->vmt->write(ip, bp, n)) #define chSequentialStreamWrite(ip, bp, n) ((ip)->vmt->write(ip, bp, n))
@ -96,6 +98,8 @@ typedef struct {
* @return The number of bytes transferred. The return value can * @return The number of bytes transferred. The return value can
* be less than the specified number of bytes if the * be less than the specified number of bytes if the
* stream reaches the end of the available data. * stream reaches the end of the available data.
*
* @api
*/ */
#define chSequentialStreamRead(ip, bp, n) ((ip)->vmt->read(ip, bp, n)) #define chSequentialStreamRead(ip, bp, n) ((ip)->vmt->read(ip, bp, n))

View File

@ -35,6 +35,8 @@
* object. * object.
* *
* @return Pointer to the idle thread, * @return Pointer to the idle thread,
*
* @api
*/ */
#define chSysGetIdleThread() ((Thread *)_idle_thread_wa) #define chSysGetIdleThread() ((Thread *)_idle_thread_wa)
@ -44,6 +46,9 @@
* unrecoverable error is detected, as example because a programming * unrecoverable error is detected, as example because a programming
* error in the application code that triggers an assertion while * error in the application code that triggers an assertion while
* in debug mode. * in debug mode.
* @note Can be invoked from any system state.
*
* @special
*/ */
#if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__) #if !defined(SYSTEM_HALT_HOOK) || defined(__DOXYGEN__)
#define chSysHalt() port_halt() #define chSysHalt() port_halt()
@ -56,9 +61,12 @@
/** /**
* @brief Performs a context switch. * @brief Performs a context switch.
* @note This function should nevel be used from user code directly.
* *
* @param[in] ntp the thread to be switched in * @param[in] ntp the thread to be switched in
* @param[in] otp the thread to be switched out * @param[in] otp the thread to be switched out
*
* @special
*/ */
#define chSysSwitchI(ntp, otp) port_switch(ntp, otp) #define chSysSwitchI(ntp, otp) port_switch(ntp, otp)
@ -66,9 +74,9 @@
* @brief Raises the system interrupt priority mask to the maximum level. * @brief Raises the system interrupt priority mask to the maximum level.
* @details All the maskable interrupt sources are disabled regardless their * @details All the maskable interrupt sources are disabled regardless their
* hardware priority. * hardware priority.
* @note The implementation is architecture dependent, it may just disable
* the interrupts or be exactly equivalent to @p chSysDisable().
* @note Do not invoke this API from within a kernel lock. * @note Do not invoke this API from within a kernel lock.
*
* @special
*/ */
#define chSysDisable() port_disable() #define chSysDisable() port_disable()
@ -77,22 +85,22 @@
* @details The interrupt sources that should not be able to preempt the kernel * @details The interrupt sources that should not be able to preempt the kernel
* are disabled, interrupt sources with higher priority are still * are disabled, interrupt sources with higher priority are still
* enabled. * enabled.
* @note The implementation is architecture dependent, it may just disable
* the interrupts.
* @note Do not invoke this API from within a kernel lock. * @note Do not invoke this API from within a kernel lock.
* @note This API is no replacement for @p chSysLock(), the @p chSysLock() * @note This API is no replacement for @p chSysLock(), the @p chSysLock()
* could do more than just disable the interrupts. * could do more than just disable the interrupts.
*
* @special
*/ */
#define chSysSuspend() port_suspend() #define chSysSuspend() port_suspend()
/** /**
* @brief Lowers the system interrupt priority mask to user level. * @brief Lowers the system interrupt priority mask to user level.
* @details All the interrupt sources are enabled. * @details All the interrupt sources are enabled.
* @note The implementation is architecture dependent, it may just enable
* the interrupts.
* @note Do not invoke this API from within a kernel lock. * @note Do not invoke this API from within a kernel lock.
* @note This API is no replacement for @p chSysUnlock(), the * @note This API is no replacement for @p chSysUnlock(), the
* @p chSysUnlock() could do more than just enable the interrupts. * @p chSysUnlock() could do more than just enable the interrupts.
*
* @special
*/ */
#define chSysEnable() port_enable() #define chSysEnable() port_enable()
@ -101,6 +109,8 @@
* @note The use of kernel lock mode is not recommended in the user code, * @note The use of kernel lock mode is not recommended in the user code,
* it is a better idea to use the semaphores or mutexes instead. * it is a better idea to use the semaphores or mutexes instead.
* @see CH_USE_NESTED_LOCKS * @see CH_USE_NESTED_LOCKS
*
* @special
*/ */
#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__) #if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__)
#if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__) #if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
@ -118,6 +128,8 @@
* @note The use of kernel lock mode is not recommended in the user code, * @note The use of kernel lock mode is not recommended in the user code,
* it is a better idea to use the semaphores or mutexes instead. * it is a better idea to use the semaphores or mutexes instead.
* @see CH_USE_NESTED_LOCKS * @see CH_USE_NESTED_LOCKS
*
* @special
*/ */
#if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__) #if CH_USE_NESTED_LOCKS || defined(__DOXYGEN__)
#if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__) #if CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
@ -139,6 +151,8 @@
* It is good practice to invoke this API before invoking any I-class * It is good practice to invoke this API before invoking any I-class
* syscall from an interrupt handler. * syscall from an interrupt handler.
* @note This API must be invoked exclusively from interrupt handlers. * @note This API must be invoked exclusively from interrupt handlers.
*
* @special
*/ */
#define chSysLockFromIsr() port_lock_from_isr() #define chSysLockFromIsr() port_lock_from_isr()
@ -151,7 +165,9 @@
* the system mutual exclusion zone.<br> * the system mutual exclusion zone.<br>
* It is good practice to invoke this API after invoking any I-class * It is good practice to invoke this API after invoking any I-class
* syscall from an interrupt handler. * syscall from an interrupt handler.
* @note This API must be invoked exclusively from interrupt handlers. * @note This API must be invoked exclusively from interrupt handlers.
*
* @special
*/ */
#define chSysUnlockFromIsr() port_unlock_from_isr() #define chSysUnlockFromIsr() port_unlock_from_isr()

View File

@ -244,11 +244,15 @@ extern "C" {
/** /**
* @brief Returns a pointer to the current @p Thread. * @brief Returns a pointer to the current @p Thread.
*
* @api
*/ */
#define chThdSelf() currp #define chThdSelf() currp
/** /**
* @brief Returns the current thread priority. * @brief Returns the current thread priority.
*
* @api
*/ */
#define chThdGetPriority() (currp->p_prio) #define chThdGetPriority() (currp->p_prio)
@ -258,11 +262,15 @@ extern "C" {
* @p CH_DBG_THREADS_PROFILING configuration option is enabled. * @p CH_DBG_THREADS_PROFILING configuration option is enabled.
* *
* @param[in] tp the pointer to the thread * @param[in] tp the pointer to the thread
*
* @api
*/ */
#define chThdGetTicks(tp) ((tp)->p_time) #define chThdGetTicks(tp) ((tp)->p_time)
/** /**
* @brief Returns the pointer to the @p Thread local storage area, if any. * @brief Returns the pointer to the @p Thread local storage area, if any.
*
* @api
*/ */
#define chThdLS() (void *)(currp + 1) #define chThdLS() (void *)(currp + 1)
@ -272,6 +280,8 @@ extern "C" {
* @param[in] tp the pointer to the thread * @param[in] tp the pointer to the thread
* @retval TRUE thread terminated. * @retval TRUE thread terminated.
* @retval FALSE thread not terminated. * @retval FALSE thread not terminated.
*
* @api
*/ */
#define chThdTerminated(tp) ((tp)->p_state == THD_STATE_FINAL) #define chThdTerminated(tp) ((tp)->p_state == THD_STATE_FINAL)
@ -280,6 +290,8 @@ extern "C" {
* *
* @retval TRUE termination request pended. * @retval TRUE termination request pended.
* @retval FALSE termination request not pended. * @retval FALSE termination request not pended.
*
* @api
*/ */
#define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE) #define chThdShouldTerminate() (currp->p_flags & THD_TERMINATE)
@ -287,6 +299,8 @@ extern "C" {
* @brief Resumes a thread created with @p chThdInit(). * @brief Resumes a thread created with @p chThdInit().
* *
* @param[in] tp the pointer to the thread * @param[in] tp the pointer to the thread
*
* @iclass
*/ */
#define chThdResumeI(tp) chSchReadyI(tp) #define chThdResumeI(tp) chSchReadyI(tp)
@ -301,6 +315,8 @@ extern "C" {
* interpreted as a normal time specification not as * interpreted as a normal time specification not as
* an immediate timeout specification. * an immediate timeout specification.
* . * .
*
* @sclass
*/ */
#define chThdSleepS(time) chSchGoSleepTimeoutS(THD_STATE_SLEEPING, time) #define chThdSleepS(time) chSchGoSleepTimeoutS(THD_STATE_SLEEPING, time)
@ -311,6 +327,8 @@ extern "C" {
* @note The maximum specified value is implementation dependent. * @note The maximum specified value is implementation dependent.
* *
* @param[in] sec the time in seconds * @param[in] sec the time in seconds
*
* @api
*/ */
#define chThdSleepSeconds(sec) chThdSleep(S2ST(sec)) #define chThdSleepSeconds(sec) chThdSleep(S2ST(sec))
@ -322,6 +340,8 @@ extern "C" {
* @note The maximum specified value is implementation dependent. * @note The maximum specified value is implementation dependent.
* *
* @param[in] msec the time in milliseconds * @param[in] msec the time in milliseconds
*
* @api
*/ */
#define chThdSleepMilliseconds(msec) chThdSleep(MS2ST(msec)) #define chThdSleepMilliseconds(msec) chThdSleep(MS2ST(msec))
@ -333,6 +353,8 @@ extern "C" {
* @note The maximum specified value is implementation dependent. * @note The maximum specified value is implementation dependent.
* *
* @param[in] usec the time in microseconds * @param[in] usec the time in microseconds
*
* @api
*/ */
#define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec)) #define chThdSleepMicroseconds(usec) chThdSleep(US2ST(usec))

View File

@ -94,6 +94,8 @@ extern VTList vtlist;
/** /**
* @brief Virtual timers ticker. * @brief Virtual timers ticker.
*
* @iclass
*/ */
#define chVTDoTickI() { \ #define chVTDoTickI() { \
vtlist.vt_systime++; \ vtlist.vt_systime++; \
@ -127,6 +129,8 @@ extern "C" {
/** /**
* @brief Returns TRUE if the speciified timer is armed. * @brief Returns TRUE if the speciified timer is armed.
*
* @iclass
*/ */
#define chVTIsArmedI(vtp) ((vtp)->vt_func != NULL) #define chVTIsArmedI(vtp) ((vtp)->vt_func != NULL)
@ -138,6 +142,8 @@ extern "C" {
* @note This function is designed to work with the @p chThdSleepUntil(). * @note This function is designed to work with the @p chThdSleepUntil().
* *
* @return The system time in ticks.r * @return The system time in ticks.r
*
* @api
*/ */
#define chTimeNow() (vtlist.vt_systime) #define chTimeNow() (vtlist.vt_systime)

View File

@ -43,10 +43,10 @@
/** /**
* @brief Initializes s @p CondVar structure. * @brief Initializes s @p CondVar structure.
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p CondVar structure.
* *
* @param[out] cp pointer to a @p CondVar structure * @param[out] cp pointer to a @p CondVar structure
*
* @init
*/ */
void chCondInit(CondVar *cp) { void chCondInit(CondVar *cp) {
@ -59,6 +59,8 @@ void chCondInit(CondVar *cp) {
* @brief Signals one thread that is waiting on the condition variable. * @brief Signals one thread that is waiting on the condition variable.
* *
* @param[in] cp pointer to the @p CondVar structure * @param[in] cp pointer to the @p CondVar structure
*
* @api
*/ */
void chCondSignal(CondVar *cp) { void chCondSignal(CondVar *cp) {
@ -78,6 +80,8 @@ void chCondSignal(CondVar *cp) {
* reschedule must not be performed in ISRs. * reschedule must not be performed in ISRs.
* *
* @param[in] cp pointer to the @p CondVar structure * @param[in] cp pointer to the @p CondVar structure
*
* @iclass
*/ */
void chCondSignalI(CondVar *cp) { void chCondSignalI(CondVar *cp) {
@ -91,6 +95,8 @@ void chCondSignalI(CondVar *cp) {
* @brief Signals all threads that are waiting on the condition variable. * @brief Signals all threads that are waiting on the condition variable.
* *
* @param[in] cp pointer to the @p CondVar structure * @param[in] cp pointer to the @p CondVar structure
*
* @api
*/ */
void chCondBroadcast(CondVar *cp) { void chCondBroadcast(CondVar *cp) {
@ -108,6 +114,8 @@ void chCondBroadcast(CondVar *cp) {
* reschedule must not be performed in ISRs. * reschedule must not be performed in ISRs.
* *
* @param[in] cp pointer to the @p CondVar structure * @param[in] cp pointer to the @p CondVar structure
*
* @iclass
*/ */
void chCondBroadcastI(CondVar *cp) { void chCondBroadcastI(CondVar *cp) {
@ -134,6 +142,8 @@ void chCondBroadcastI(CondVar *cp) {
* @p chCondSignal(). * @p chCondSignal().
* @retval RDY_RESET if the condvar has been signaled using * @retval RDY_RESET if the condvar has been signaled using
* @p chCondBroadcast(). * @p chCondBroadcast().
*
* @api
*/ */
msg_t chCondWait(CondVar *cp) { msg_t chCondWait(CondVar *cp) {
msg_t msg; msg_t msg;
@ -158,6 +168,8 @@ msg_t chCondWait(CondVar *cp) {
* @p chCondSignal(). * @p chCondSignal().
* @retval RDY_RESET if the condvar has been signaled using * @retval RDY_RESET if the condvar has been signaled using
* @p chCondBroadcast(). * @p chCondBroadcast().
*
* @sclass
*/ */
msg_t chCondWaitS(CondVar *cp) { msg_t chCondWaitS(CondVar *cp) {
Thread *ctp = currp; Thread *ctp = currp;
@ -204,6 +216,8 @@ msg_t chCondWaitS(CondVar *cp) {
* @p chCondBroadcast(). * @p chCondBroadcast().
* @retval RDY_TIMEOUT if the condvar has not been signaled within the * @retval RDY_TIMEOUT if the condvar has not been signaled within the
* specified timeout. * specified timeout.
*
* @api
*/ */
msg_t chCondWaitTimeout(CondVar *cp, systime_t time) { msg_t chCondWaitTimeout(CondVar *cp, systime_t time) {
msg_t msg; msg_t msg;
@ -239,6 +253,8 @@ msg_t chCondWaitTimeout(CondVar *cp, systime_t time) {
* @p chCondBroadcast(). * @p chCondBroadcast().
* @retval RDY_TIMEOUT if the condvar has not been signaled within the * @retval RDY_TIMEOUT if the condvar has not been signaled within the
* specified timeout. * specified timeout.
*
* @sclass
*/ */
msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time) { msg_t chCondWaitTimeoutS(CondVar *cp, systime_t time) {
Mutex *mp; Mutex *mp;

View File

@ -55,6 +55,8 @@ void trace_init(void) {
* @brief Inserts in the circular debug trace buffer a context switch record. * @brief Inserts in the circular debug trace buffer a context switch record.
* *
* @param[in] otp the thread being switched out * @param[in] otp the thread being switched out
*
* @notapi
*/ */
void chDbgTrace(Thread *otp) { void chDbgTrace(Thread *otp) {

View File

@ -68,6 +68,8 @@
* @param[in] elp pointer to the @p EventListener structure * @param[in] elp pointer to the @p EventListener structure
* @param[in] mask the mask of event flags to be ORed to the thread when * @param[in] mask the mask of event flags to be ORed to the thread when
* the event source is broadcasted * the event source is broadcasted
*
* @api
*/ */
void chEvtRegisterMask(EventSource *esp, EventListener *elp, eventmask_t mask) { void chEvtRegisterMask(EventSource *esp, EventListener *elp, eventmask_t mask) {
@ -91,6 +93,8 @@ void chEvtRegisterMask(EventSource *esp, EventListener *elp, eventmask_t mask) {
* *
* @param[in] esp pointer to the @p EventSource structure * @param[in] esp pointer to the @p EventSource structure
* @param[in] elp pointer to the @p EventListener structure * @param[in] elp pointer to the @p EventListener structure
*
* @api
*/ */
void chEvtUnregister(EventSource *esp, EventListener *elp) { void chEvtUnregister(EventSource *esp, EventListener *elp) {
EventListener *p; EventListener *p;
@ -114,6 +118,8 @@ void chEvtUnregister(EventSource *esp, EventListener *elp) {
* *
* @param[in] mask the events to be cleared * @param[in] mask the events to be cleared
* @return The pending events that were cleared. * @return The pending events that were cleared.
*
* @api
*/ */
eventmask_t chEvtClearFlags(eventmask_t mask) { eventmask_t chEvtClearFlags(eventmask_t mask) {
eventmask_t m; eventmask_t m;
@ -133,6 +139,8 @@ eventmask_t chEvtClearFlags(eventmask_t mask) {
* *
* @param[in] mask the event flags to be ORed * @param[in] mask the event flags to be ORed
* @return The current pending events mask. * @return The current pending events mask.
*
* @api
*/ */
eventmask_t chEvtAddFlags(eventmask_t mask) { eventmask_t chEvtAddFlags(eventmask_t mask) {
@ -149,6 +157,8 @@ eventmask_t chEvtAddFlags(eventmask_t mask) {
* *
* @param[in] tp the thread to be signaled * @param[in] tp the thread to be signaled
* @param[in] mask the event flags set to be ORed * @param[in] mask the event flags set to be ORed
*
* @api
*/ */
void chEvtSignal(Thread *tp, eventmask_t mask) { void chEvtSignal(Thread *tp, eventmask_t mask) {
@ -169,6 +179,8 @@ void chEvtSignal(Thread *tp, eventmask_t mask) {
* *
* @param[in] tp the thread to be signaled * @param[in] tp the thread to be signaled
* @param[in] mask the event flags set to be ORed * @param[in] mask the event flags set to be ORed
*
* @iclass
*/ */
void chEvtSignalI(Thread *tp, eventmask_t mask) { void chEvtSignalI(Thread *tp, eventmask_t mask) {
@ -188,6 +200,8 @@ void chEvtSignalI(Thread *tp, eventmask_t mask) {
* Source. * Source.
* *
* @param[in] esp pointer to the @p EventSource structure * @param[in] esp pointer to the @p EventSource structure
*
* @api
*/ */
void chEvtBroadcast(EventSource *esp) { void chEvtBroadcast(EventSource *esp) {
@ -206,6 +220,8 @@ void chEvtBroadcast(EventSource *esp) {
* reschedule must not be performed in ISRs. * reschedule must not be performed in ISRs.
* *
* @param[in] esp pointer to the @p EventSource structure * @param[in] esp pointer to the @p EventSource structure
*
* @iclass
*/ */
void chEvtBroadcastI(EventSource *esp) { void chEvtBroadcastI(EventSource *esp) {
EventListener *elp; EventListener *elp;
@ -225,6 +241,8 @@ void chEvtBroadcastI(EventSource *esp) {
* @param[in] mask mask of the event flags to be dispatched * @param[in] mask mask of the event flags to be dispatched
* @param[in] handlers an array of @p evhandler_t. The array must have size * @param[in] handlers an array of @p evhandler_t. The array must have size
* equal to the number of bits in eventmask_t. * equal to the number of bits in eventmask_t.
*
* @api
*/ */
void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask) { void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask) {
eventid_t eid; eventid_t eid;
@ -258,6 +276,8 @@ void chEvtDispatch(const evhandler_t *handlers, eventmask_t mask) {
* @param[in] mask mask of the event flags that the function should wait * @param[in] mask mask of the event flags that the function should wait
* for, @p ALL_EVENTS enables all the events * for, @p ALL_EVENTS enables all the events
* @return The mask of the lowest id served and cleared event. * @return The mask of the lowest id served and cleared event.
*
* @api
*/ */
eventmask_t chEvtWaitOne(eventmask_t mask) { eventmask_t chEvtWaitOne(eventmask_t mask) {
Thread *ctp = currp; Thread *ctp = currp;
@ -285,6 +305,8 @@ eventmask_t chEvtWaitOne(eventmask_t mask) {
* @param[in] mask mask of the event flags that the function should wait * @param[in] mask mask of the event flags that the function should wait
* for, @p ALL_EVENTS enables all the events * for, @p ALL_EVENTS enables all the events
* @return The mask of the served and cleared events. * @return The mask of the served and cleared events.
*
* @api
*/ */
eventmask_t chEvtWaitAny(eventmask_t mask) { eventmask_t chEvtWaitAny(eventmask_t mask) {
Thread *ctp = currp; Thread *ctp = currp;
@ -311,6 +333,8 @@ eventmask_t chEvtWaitAny(eventmask_t mask) {
* @param[in] mask mask of the event flags that the function should wait * @param[in] mask mask of the event flags that the function should wait
* for, @p ALL_EVENTS requires all the events * for, @p ALL_EVENTS requires all the events
* @return The mask of the served and cleared events. * @return The mask of the served and cleared events.
*
* @api
*/ */
eventmask_t chEvtWaitAll(eventmask_t mask) { eventmask_t chEvtWaitAll(eventmask_t mask) {
Thread *ctp = currp; Thread *ctp = currp;
@ -348,6 +372,8 @@ eventmask_t chEvtWaitAll(eventmask_t mask) {
* . * .
* @return The mask of the lowest id served and cleared event. * @return The mask of the lowest id served and cleared event.
* @retval 0 if the operation has timed out. * @retval 0 if the operation has timed out.
*
* @api
*/ */
eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) { eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) {
Thread *ctp = currp; Thread *ctp = currp;
@ -385,6 +411,8 @@ eventmask_t chEvtWaitOneTimeout(eventmask_t mask, systime_t time) {
* . * .
* @return The mask of the served and cleared events. * @return The mask of the served and cleared events.
* @retval 0 if the operation has timed out. * @retval 0 if the operation has timed out.
*
* @api
*/ */
eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) { eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) {
Thread *ctp = currp; Thread *ctp = currp;
@ -420,6 +448,8 @@ eventmask_t chEvtWaitAnyTimeout(eventmask_t mask, systime_t time) {
* . * .
* @return The mask of the served and cleared events. * @return The mask of the served and cleared events.
* @retval 0 if the operation has timed out. * @retval 0 if the operation has timed out.
*
* @api
*/ */
eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) { eventmask_t chEvtWaitAllTimeout(eventmask_t mask, systime_t time) {
Thread *ctp = currp; Thread *ctp = currp;

View File

@ -61,7 +61,8 @@ static MemoryHeap default_heap;
/** /**
* @brief Initializes the default heap. * @brief Initializes the default heap.
* @note Internal use only. *
* @notapi
*/ */
void heap_init(void) { void heap_init(void) {
default_heap.h_provider = chCoreAlloc; default_heap.h_provider = chCoreAlloc;
@ -82,6 +83,8 @@ void heap_init(void) {
* @param[out] heapp pointer to the memory heap descriptor to be initialized * @param[out] heapp pointer to the memory heap descriptor to be initialized
* @param[in] buf heap buffer base * @param[in] buf heap buffer base
* @param[in] size heap size * @param[in] size heap size
*
* @init
*/ */
void chHeapInit(MemoryHeap *heapp, void *buf, size_t size) { void chHeapInit(MemoryHeap *heapp, void *buf, size_t size) {
union heap_header *hp; union heap_header *hp;
@ -113,6 +116,8 @@ void chHeapInit(MemoryHeap *heapp, void *buf, size_t size) {
* size for alignment and fragmentation reasons. * size for alignment and fragmentation reasons.
* @return A pointer to the allocated block. * @return A pointer to the allocated block.
* @retval NULL if the block cannot be allocated. * @retval NULL if the block cannot be allocated.
*
* @api
*/ */
void *chHeapAlloc(MemoryHeap *heapp, size_t size) { void *chHeapAlloc(MemoryHeap *heapp, size_t size) {
union heap_header *qp, *hp, *fp; union heap_header *qp, *hp, *fp;
@ -173,6 +178,8 @@ void *chHeapAlloc(MemoryHeap *heapp, size_t size) {
* @brief Frees a previously allocated memory block. * @brief Frees a previously allocated memory block.
* *
* @param[in] p pointer to the memory block to be freed * @param[in] p pointer to the memory block to be freed
*
* @api
*/ */
void chHeapFree(void *p) { void chHeapFree(void *p) {
union heap_header *qp, *hp; union heap_header *qp, *hp;
@ -227,6 +234,8 @@ void chHeapFree(void *p) {
* @param[in] sizep pointer to a variable that will receive the total * @param[in] sizep pointer to a variable that will receive the total
* fragmented free space * fragmented free space
* @return The number of fragments in the heap. * @return The number of fragments in the heap.
*
* @api
*/ */
size_t chHeapStatus(MemoryHeap *heapp, size_t *sizep) { size_t chHeapStatus(MemoryHeap *heapp, size_t *sizep) {
union heap_header *qp; union heap_header *qp;

View File

@ -23,7 +23,7 @@
* *
* @addtogroup internals * @addtogroup internals
* @details All the functions present in this module, while public, are not * @details All the functions present in this module, while public, are not
* an OS API and should not be directly used in the user applications * OS APIs and should not be directly used in the user applications
* code. * code.
* @{ * @{
*/ */
@ -32,12 +32,13 @@
#if !CH_OPTIMIZE_SPEED || defined(__DOXYGEN__) #if !CH_OPTIMIZE_SPEED || defined(__DOXYGEN__)
/** /**
* @brief Inserts a thread into a priority ordered queue. * @brief Inserts a thread into a priority ordered queue.
* @note The insertion is done by scanning the list from the highest priority * @note The insertion is done by scanning the list from the highest
* toward the lowest. * priority toward the lowest.
* @note This function is @b not an API.
* *
* @param[in] tp the pointer to the thread to be inserted in the list * @param[in] tp the pointer to the thread to be inserted in the list
* @param[in] tqp the pointer to the threads list header * @param[in] tqp the pointer to the threads list header
*
* @notapi
*/ */
void prio_insert(Thread *tp, ThreadsQueue *tqp) { void prio_insert(Thread *tp, ThreadsQueue *tqp) {
@ -56,10 +57,11 @@ void prio_insert(Thread *tp, ThreadsQueue *tqp) {
/** /**
* @brief Inserts a Thread into a queue. * @brief Inserts a Thread into a queue.
* @note This function is @b not an API.
* *
* @param[in] tp the pointer to the thread to be inserted in the list * @param[in] tp the pointer to the thread to be inserted in the list
* @param[in] tqp the pointer to the threads list header * @param[in] tqp the pointer to the threads list header
*
* @notapi
*/ */
void queue_insert(Thread *tp, ThreadsQueue *tqp) { void queue_insert(Thread *tp, ThreadsQueue *tqp) {
@ -72,10 +74,11 @@ void queue_insert(Thread *tp, ThreadsQueue *tqp) {
* @brief Removes the first-out Thread from a queue and returns it. * @brief Removes the first-out Thread from a queue and returns it.
* @note If the queue is priority ordered then this function returns the * @note If the queue is priority ordered then this function returns the
* thread with the highest priority. * thread with the highest priority.
* @note This function is @b not an API.
* *
* @param[in] tqp the pointer to the threads list header * @param[in] tqp the pointer to the threads list header
* @return The removed thread pointer. * @return The removed thread pointer.
*
* @notapi
*/ */
Thread *fifo_remove(ThreadsQueue *tqp) { Thread *fifo_remove(ThreadsQueue *tqp) {
Thread *tp = tqp->p_next; Thread *tp = tqp->p_next;
@ -88,10 +91,11 @@ Thread *fifo_remove(ThreadsQueue *tqp) {
* @brief Removes the last-out Thread from a queue and returns it. * @brief Removes the last-out Thread from a queue and returns it.
* @note If the queue is priority ordered then this function returns the * @note If the queue is priority ordered then this function returns the
* thread with the lowest priority. * thread with the lowest priority.
* @note This function is @b not an API.
* *
* @param[in] tqp the pointer to the threads list header * @param[in] tqp the pointer to the threads list header
* @return The removed thread pointer. * @return The removed thread pointer.
*
* @notapi
*/ */
Thread *lifo_remove(ThreadsQueue *tqp) { Thread *lifo_remove(ThreadsQueue *tqp) {
Thread *tp = tqp->p_prev; Thread *tp = tqp->p_prev;
@ -104,10 +108,11 @@ Thread *lifo_remove(ThreadsQueue *tqp) {
* @brief Removes a Thread from a queue and returns it. * @brief Removes a Thread from a queue and returns it.
* @details The thread is removed from the queue regardless of its relative * @details The thread is removed from the queue regardless of its relative
* position and regardless the used insertion method. * position and regardless the used insertion method.
* @note This function is @b not an API.
* *
* @param[in] tp the pointer to the thread to be removed from the queue * @param[in] tp the pointer to the thread to be removed from the queue
* @return The removed thread pointer. * @return The removed thread pointer.
*
* @notapi
*/ */
Thread *dequeue(Thread *tp) { Thread *dequeue(Thread *tp) {
@ -118,10 +123,11 @@ Thread *dequeue(Thread *tp) {
/** /**
* @brief Pushes a Thread on top of a stack list. * @brief Pushes a Thread on top of a stack list.
* @note This function is @b not an API.
* *
* @param[in] tp the pointer to the thread to be inserted in the list * @param[in] tp the pointer to the thread to be inserted in the list
* @param[in] tlp the pointer to the threads list header * @param[in] tlp the pointer to the threads list header
*
* @notapi
*/ */
void list_insert(Thread *tp, ThreadsList *tlp) { void list_insert(Thread *tp, ThreadsList *tlp) {
@ -131,11 +137,12 @@ void list_insert(Thread *tp, ThreadsList *tlp) {
/** /**
* @brief Pops a Thread from the top of a stack list and returns it. * @brief Pops a Thread from the top of a stack list and returns it.
* @note The list must be non-empty before calling this function. * @pre The list must be non-empty before calling this function.
* @note This function is @b not an API.
* *
* @param[in] tlp the pointer to the threads list header * @param[in] tlp the pointer to the threads list header
* @return The removed thread pointer. * @return The removed thread pointer.
*
* @notapi
*/ */
Thread *list_remove(ThreadsList *tlp) { Thread *list_remove(ThreadsList *tlp) {

View File

@ -54,12 +54,12 @@
#if CH_USE_MAILBOXES || defined(__DOXYGEN__) #if CH_USE_MAILBOXES || defined(__DOXYGEN__)
/** /**
* @brief Initializes a Mailbox object. * @brief Initializes a Mailbox object.
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p Mailbox structure.
* *
* @param[out] mbp the pointer to the Mailbox structure to be initialized * @param[out] mbp the pointer to the Mailbox structure to be initialized
* @param[in] buf the circular messages buffer * @param[in] buf the circular messages buffer
* @param[in] n the buffer size as number of @p msg_t * @param[in] n the buffer size as number of @p msg_t
*
* @init
*/ */
void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) { void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) {
@ -77,6 +77,8 @@ void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) {
* the queued messages are lost. * the queued messages are lost.
* *
* @param[in] mbp the pointer to an initialized Mailbox object * @param[in] mbp the pointer to an initialized Mailbox object
*
* @api
*/ */
void chMBReset(Mailbox *mbp) { void chMBReset(Mailbox *mbp) {
@ -106,6 +108,8 @@ void chMBReset(Mailbox *mbp) {
* @retval RDY_OK if a message has been correctly posted. * @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting. * @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out. * @retval RDY_TIMEOUT if the operation has timed out.
*
* @api
*/ */
msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t time) { msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t time) {
msg_t rdymsg; msg_t rdymsg;
@ -132,6 +136,8 @@ msg_t chMBPost(Mailbox *mbp, msg_t msg, systime_t time) {
* @retval RDY_OK if a message has been correctly posted. * @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting. * @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out. * @retval RDY_TIMEOUT if the operation has timed out.
*
* @sclass
*/ */
msg_t chMBPostS(Mailbox *mbp, msg_t msg, systime_t time) { msg_t chMBPostS(Mailbox *mbp, msg_t msg, systime_t time) {
msg_t rdymsg; msg_t rdymsg;
@ -165,6 +171,8 @@ msg_t chMBPostS(Mailbox *mbp, msg_t msg, systime_t time) {
* @retval RDY_OK if a message has been correctly posted. * @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting. * @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out. * @retval RDY_TIMEOUT if the operation has timed out.
*
* @api
*/ */
msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t time) { msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t time) {
msg_t rdymsg; msg_t rdymsg;
@ -191,6 +199,8 @@ msg_t chMBPostAhead(Mailbox *mbp, msg_t msg, systime_t time) {
* @retval RDY_OK if a message has been correctly posted. * @retval RDY_OK if a message has been correctly posted.
* @retval RDY_RESET if the mailbox has been reset while waiting. * @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out. * @retval RDY_TIMEOUT if the operation has timed out.
*
* @sclass
*/ */
msg_t chMBPostAheadS(Mailbox *mbp, msg_t msg, systime_t time) { msg_t chMBPostAheadS(Mailbox *mbp, msg_t msg, systime_t time) {
msg_t rdymsg; msg_t rdymsg;
@ -224,6 +234,8 @@ msg_t chMBPostAheadS(Mailbox *mbp, msg_t msg, systime_t time) {
* @retval RDY_OK if a message has been correctly fetched. * @retval RDY_OK if a message has been correctly fetched.
* @retval RDY_RESET if the mailbox has been reset while waiting. * @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out. * @retval RDY_TIMEOUT if the operation has timed out.
*
* @api
*/ */
msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t time) { msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t time) {
msg_t rdymsg; msg_t rdymsg;
@ -250,6 +262,8 @@ msg_t chMBFetch(Mailbox *mbp, msg_t *msgp, systime_t time) {
* @retval RDY_OK if a message has been correctly fetched. * @retval RDY_OK if a message has been correctly fetched.
* @retval RDY_RESET if the mailbox has been reset while waiting. * @retval RDY_RESET if the mailbox has been reset while waiting.
* @retval RDY_TIMEOUT if the operation has timed out. * @retval RDY_TIMEOUT if the operation has timed out.
*
* @sclass
*/ */
msg_t chMBFetchS(Mailbox *mbp, msg_t *msgp, systime_t time) { msg_t chMBFetchS(Mailbox *mbp, msg_t *msgp, systime_t time) {
msg_t rdymsg; msg_t rdymsg;

View File

@ -50,7 +50,8 @@ static uint8_t *endmem;
/** /**
* @brief Low level memory manager initialization. * @brief Low level memory manager initialization.
* @note Internal use only. *
* @notapi
*/ */
void core_init(void) { void core_init(void) {
#if CH_MEMCORE_SIZE == 0 #if CH_MEMCORE_SIZE == 0
@ -76,6 +77,8 @@ void core_init(void) {
* @param[in] size the size of the block to be allocated * @param[in] size the size of the block to be allocated
* @return A pointer to the allocated memory block. * @return A pointer to the allocated memory block.
* @retval NULL allocation failed, core memory exhausted. * @retval NULL allocation failed, core memory exhausted.
*
* @api
*/ */
void *chCoreAlloc(size_t size) { void *chCoreAlloc(size_t size) {
void *p; void *p;
@ -95,6 +98,8 @@ void *chCoreAlloc(size_t size) {
* @param[in] size the size of the block to be allocated. * @param[in] size the size of the block to be allocated.
* @return A pointer to the allocated memory block. * @return A pointer to the allocated memory block.
* @retval NULL allocation failed, core memory exhausted. * @retval NULL allocation failed, core memory exhausted.
*
* @iclass
*/ */
void *chCoreAllocI(size_t size) { void *chCoreAllocI(size_t size) {
void *p; void *p;
@ -111,6 +116,8 @@ void *chCoreAllocI(size_t size) {
* @brief Core memory status. * @brief Core memory status.
* *
* @return The size, in bytes, of the free core memory. * @return The size, in bytes, of the free core memory.
*
* @api
*/ */
size_t chCoreStatus(void) { size_t chCoreStatus(void) {

View File

@ -37,8 +37,6 @@
#if CH_USE_MEMPOOLS || defined(__DOXYGEN__) #if CH_USE_MEMPOOLS || defined(__DOXYGEN__)
/** /**
* @brief Initializes an empty memory pool. * @brief Initializes an empty memory pool.
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p MemoryPool structure.
* @note The size is internally aligned to be a multiple of the * @note The size is internally aligned to be a multiple of the
* @p stkalign_t type size. * @p stkalign_t type size.
* *
@ -49,6 +47,8 @@
* @param[in] provider memory provider function for the memory pool or * @param[in] provider memory provider function for the memory pool or
* @p NULL if the pool is not allowed to grow * @p NULL if the pool is not allowed to grow
* automatically * automatically
*
* @init
*/ */
void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) { void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) {
@ -65,6 +65,8 @@ void chPoolInit(MemoryPool *mp, size_t size, memgetfunc_t provider) {
* @param[in] mp pointer to a @p MemoryPool structure * @param[in] mp pointer to a @p MemoryPool structure
* @return The pointer to the allocated object. * @return The pointer to the allocated object.
* @retval NULL if pool is empty. * @retval NULL if pool is empty.
*
* @iclass
*/ */
void *chPoolAllocI(MemoryPool *mp) { void *chPoolAllocI(MemoryPool *mp) {
void *objp; void *objp;
@ -86,6 +88,8 @@ void *chPoolAllocI(MemoryPool *mp) {
* @param[in] mp pointer to a @p MemoryPool structure * @param[in] mp pointer to a @p MemoryPool structure
* @return The pointer to the allocated object. * @return The pointer to the allocated object.
* @retval NULL if pool is empty. * @retval NULL if pool is empty.
*
* @api
*/ */
void *chPoolAlloc(MemoryPool *mp) { void *chPoolAlloc(MemoryPool *mp) {
void *objp; void *objp;
@ -105,6 +109,8 @@ void *chPoolAlloc(MemoryPool *mp) {
* *
* @param[in] mp pointer to a @p MemoryPool structure * @param[in] mp pointer to a @p MemoryPool structure
* @param[in] objp the pointer to the object to be released or added * @param[in] objp the pointer to the object to be released or added
*
* @iclass
*/ */
void chPoolFreeI(MemoryPool *mp, void *objp) { void chPoolFreeI(MemoryPool *mp, void *objp) {
struct pool_header *php = objp; struct pool_header *php = objp;
@ -125,6 +131,8 @@ void chPoolFreeI(MemoryPool *mp, void *objp) {
* *
* @param[in] mp pointer to a @p MemoryPool structure * @param[in] mp pointer to a @p MemoryPool structure
* @param[in] objp the pointer to the object to be released or added * @param[in] objp the pointer to the object to be released or added
*
* @api
*/ */
void chPoolFree(MemoryPool *mp, void *objp) { void chPoolFree(MemoryPool *mp, void *objp) {

View File

@ -61,6 +61,8 @@
* @param[in] tp the pointer to the thread * @param[in] tp the pointer to the thread
* @param[in] msg the message * @param[in] msg the message
* @return The answer message from @p chMsgRelease(). * @return The answer message from @p chMsgRelease().
*
* @api
*/ */
msg_t chMsgSend(Thread *tp, msg_t msg) { msg_t chMsgSend(Thread *tp, msg_t msg) {
Thread *ctp = currp; Thread *ctp = currp;
@ -88,6 +90,8 @@ msg_t chMsgSend(Thread *tp, msg_t msg) {
* because the sending thread is suspended until then. * because the sending thread is suspended until then.
* *
* @return The message. * @return The message.
*
* @api
*/ */
msg_t chMsgWait(void) { msg_t chMsgWait(void) {
msg_t msg; msg_t msg;
@ -114,6 +118,8 @@ msg_t chMsgWait(void) {
* *
* @return The message. * @return The message.
* @retval 0 if the queue is empty. * @retval 0 if the queue is empty.
*
* @api
*/ */
msg_t chMsgGet(void) { msg_t chMsgGet(void) {
msg_t msg; msg_t msg;
@ -130,6 +136,8 @@ msg_t chMsgGet(void) {
* using @p chMsgWait() or @p chMsgGet(). * using @p chMsgWait() or @p chMsgGet().
* *
* @param[in] msg the message returned to the message sender * @param[in] msg the message returned to the message sender
*
* @api
*/ */
void chMsgRelease(msg_t msg) { void chMsgRelease(msg_t msg) {

View File

@ -70,10 +70,10 @@
/** /**
* @brief Initializes s @p Mutex structure. * @brief Initializes s @p Mutex structure.
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p Mutex structure.
* *
* @param[out] mp pointer to a @p Mutex structure * @param[out] mp pointer to a @p Mutex structure
*
* @init
*/ */
void chMtxInit(Mutex *mp) { void chMtxInit(Mutex *mp) {
@ -89,6 +89,8 @@ void chMtxInit(Mutex *mp) {
* mutexes. * mutexes.
* *
* @param[in] mp pointer to the @p Mutex structure * @param[in] mp pointer to the @p Mutex structure
*
* @api
*/ */
void chMtxLock(Mutex *mp) { void chMtxLock(Mutex *mp) {
@ -105,6 +107,8 @@ void chMtxLock(Mutex *mp) {
* mutexes. * mutexes.
* *
* @param[in] mp pointer to the @p Mutex structure * @param[in] mp pointer to the @p Mutex structure
*
* @sclass
*/ */
void chMtxLockS(Mutex *mp) { void chMtxLockS(Mutex *mp) {
Thread *ctp = currp; Thread *ctp = currp;
@ -184,6 +188,8 @@ void chMtxLockS(Mutex *mp) {
* @return The operation status. * @return The operation status.
* @retval TRUE if the mutex has been successfully acquired * @retval TRUE if the mutex has been successfully acquired
* @retval FALSE if the lock attempt failed. * @retval FALSE if the lock attempt failed.
*
* @api
*/ */
bool_t chMtxTryLock(Mutex *mp) { bool_t chMtxTryLock(Mutex *mp) {
bool_t b; bool_t b;
@ -210,6 +216,8 @@ bool_t chMtxTryLock(Mutex *mp) {
* @return The operation status. * @return The operation status.
* @retval TRUE if the mutex has been successfully acquired * @retval TRUE if the mutex has been successfully acquired
* @retval FALSE if the lock attempt failed. * @retval FALSE if the lock attempt failed.
*
* @sclass
*/ */
bool_t chMtxTryLockS(Mutex *mp) { bool_t chMtxTryLockS(Mutex *mp) {
@ -230,6 +238,8 @@ bool_t chMtxTryLockS(Mutex *mp) {
* owned mutexes. * owned mutexes.
* *
* @return A pointer to the unlocked mutex. * @return A pointer to the unlocked mutex.
*
* @api
*/ */
Mutex *chMtxUnlock(void) { Mutex *chMtxUnlock(void) {
Thread *ctp = currp; Thread *ctp = currp;
@ -288,6 +298,8 @@ Mutex *chMtxUnlock(void) {
* function must be performed before unlocking the kernel. * function must be performed before unlocking the kernel.
* *
* @return A pointer to the unlocked mutex. * @return A pointer to the unlocked mutex.
*
* @sclass
*/ */
Mutex *chMtxUnlockS(void) { Mutex *chMtxUnlockS(void) {
Thread *ctp = currp; Thread *ctp = currp;
@ -342,6 +354,8 @@ Mutex *chMtxUnlockS(void) {
* mutexes one by one and not just because the call overhead, * mutexes one by one and not just because the call overhead,
* this function does not have any overhead related to the priority * this function does not have any overhead related to the priority
* inheritance mechanism. * inheritance mechanism.
*
* @api
*/ */
void chMtxUnlockAll(void) { void chMtxUnlockAll(void) {
Thread *ctp = currp; Thread *ctp = currp;

View File

@ -50,8 +50,6 @@
* @brief Initializes an input queue. * @brief Initializes an input queue.
* @details A Semaphore is internally initialized and works as a counter of * @details A Semaphore is internally initialized and works as a counter of
* the bytes contained in the queue. * the bytes contained in the queue.
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p InputQueue structure.
* @note The callback is invoked from within the S-Locked system state, * @note The callback is invoked from within the S-Locked system state,
* see @ref system_states. * see @ref system_states.
* *
@ -60,6 +58,8 @@
* @param[in] size size of the queue buffer * @param[in] size size of the queue buffer
* @param[in] infy pointer to a callback function that is invoked when * @param[in] infy pointer to a callback function that is invoked when
* data is read from the queue. The value can be @p NULL. * data is read from the queue. The value can be @p NULL.
*
* @init
*/ */
void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy) { void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy) {
@ -77,6 +77,8 @@ void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy) {
* obtain immediate attention from the high level layers. * obtain immediate attention from the high level layers.
* *
* @param[in] iqp pointer to an @p InputQueue structure * @param[in] iqp pointer to an @p InputQueue structure
*
* @iclass
*/ */
void chIQResetI(InputQueue *iqp) { void chIQResetI(InputQueue *iqp) {
@ -94,10 +96,12 @@ void chIQResetI(InputQueue *iqp) {
* @retval Q_OK if the operation has been completed with success. * @retval Q_OK if the operation has been completed with success.
* @retval Q_FULL if the queue is full and the operation cannot be * @retval Q_FULL if the queue is full and the operation cannot be
* completed. * completed.
*
* @iclass
*/ */
msg_t chIQPutI(InputQueue *iqp, uint8_t b) { msg_t chIQPutI(InputQueue *iqp, uint8_t b) {
if (chIQIsFull(iqp)) if (chIQIsFullI(iqp))
return Q_FULL; return Q_FULL;
*iqp->q_wrptr++ = b; *iqp->q_wrptr++ = b;
@ -122,6 +126,8 @@ msg_t chIQPutI(InputQueue *iqp, uint8_t b) {
* @return A byte value from the queue. * @return A byte value from the queue.
* @retval Q_TIMEOUT if the specified time expired. * @retval Q_TIMEOUT if the specified time expired.
* @retval Q_RESET if the queue was reset. * @retval Q_RESET if the queue was reset.
*
* @api
*/ */
msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) { msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) {
uint8_t b; uint8_t b;
@ -165,6 +171,8 @@ msg_t chIQGetTimeout(InputQueue *iqp, systime_t time) {
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @return The number of bytes effectively transferred. * @return The number of bytes effectively transferred.
*
* @api
*/ */
size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp, size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
size_t n, systime_t time) { size_t n, systime_t time) {
@ -175,7 +183,7 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
chSysLock(); chSysLock();
while (TRUE) { while (TRUE) {
if (chIQIsEmpty(iqp)) { if (chIQIsEmptyI(iqp)) {
if (nfy) if (nfy)
nfy(); nfy();
if ((chSemWaitTimeoutS(&iqp->q_sem, time) != RDY_OK)) { if ((chSemWaitTimeoutS(&iqp->q_sem, time) != RDY_OK)) {
@ -207,8 +215,6 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
* @brief Initializes an output queue. * @brief Initializes an output queue.
* @details A Semaphore is internally initialized and works as a counter of * @details A Semaphore is internally initialized and works as a counter of
* the free bytes in the queue. * the free bytes in the queue.
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p OutputQueue structure.
* @note The callback is invoked from within the S-Locked system state, * @note The callback is invoked from within the S-Locked system state,
* see @ref system_states. * see @ref system_states.
* *
@ -217,6 +223,8 @@ size_t chIQReadTimeout(InputQueue *iqp, uint8_t *bp,
* @param[in] size size of the queue buffer * @param[in] size size of the queue buffer
* @param[in] onfy pointer to a callback function that is invoked when * @param[in] onfy pointer to a callback function that is invoked when
* data is written to the queue. The value can be @p NULL. * data is written to the queue. The value can be @p NULL.
*
* @init
*/ */
void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy) { void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy) {
@ -234,6 +242,8 @@ void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy) {
* obtain immediate attention from the high level layers. * obtain immediate attention from the high level layers.
* *
* @param[in] oqp pointer to an @p OutputQueue structure * @param[in] oqp pointer to an @p OutputQueue structure
*
* @iclass
*/ */
void chOQResetI(OutputQueue *oqp) { void chOQResetI(OutputQueue *oqp) {
@ -258,6 +268,8 @@ void chOQResetI(OutputQueue *oqp) {
* @retval Q_OK if the operation succeeded. * @retval Q_OK if the operation succeeded.
* @retval Q_TIMEOUT if the specified time expired. * @retval Q_TIMEOUT if the specified time expired.
* @retval Q_RESET if the queue was reset. * @retval Q_RESET if the queue was reset.
*
* @api
*/ */
msg_t chOQPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) { msg_t chOQPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) {
msg_t msg; msg_t msg;
@ -285,11 +297,13 @@ msg_t chOQPutTimeout(OutputQueue *oqp, uint8_t b, systime_t time) {
* @param[in] oqp pointer to an @p OutputQueue structure * @param[in] oqp pointer to an @p OutputQueue structure
* @return The byte value from the queue. * @return The byte value from the queue.
* @retval Q_EMPTY if the queue is empty. * @retval Q_EMPTY if the queue is empty.
*
* @iclass
*/ */
msg_t chOQGetI(OutputQueue *oqp) { msg_t chOQGetI(OutputQueue *oqp) {
uint8_t b; uint8_t b;
if (chOQIsEmpty(oqp)) if (chOQIsEmptyI(oqp))
return Q_EMPTY; return Q_EMPTY;
b = *oqp->q_rdptr++; b = *oqp->q_rdptr++;
@ -320,6 +334,8 @@ msg_t chOQGetI(OutputQueue *oqp) {
* - @a TIME_INFINITE no timeout. * - @a TIME_INFINITE no timeout.
* . * .
* @return The number of bytes effectively transferred. * @return The number of bytes effectively transferred.
*
* @api
*/ */
size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp, size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp,
size_t n, systime_t time) { size_t n, systime_t time) {
@ -330,7 +346,7 @@ size_t chOQWriteTimeout(OutputQueue *oqp, const uint8_t *bp,
chSysLock(); chSysLock();
while (TRUE) { while (TRUE) {
if (chOQIsFull(oqp)) { if (chOQIsFullI(oqp)) {
if (nfy) if (nfy)
nfy(); nfy();
if ((chSemWaitTimeoutS(&oqp->q_sem, time) != RDY_OK)) { if ((chSemWaitTimeoutS(&oqp->q_sem, time) != RDY_OK)) {

View File

@ -58,6 +58,8 @@
* least one thread in the system. * least one thread in the system.
* *
* @return A reference to the most ancient thread. * @return A reference to the most ancient thread.
*
* @api
*/ */
Thread *chRegFirstThread(void) { Thread *chRegFirstThread(void) {
Thread *tp; Thread *tp;
@ -79,6 +81,8 @@ Thread *chRegFirstThread(void) {
* @param[in] tp pointer to the thread * @param[in] tp pointer to the thread
* @return A reference to the next thread. * @return A reference to the next thread.
* @retval NULL if there is no next thread. * @retval NULL if there is no next thread.
*
* @api
*/ */
Thread *chRegNextThread(Thread *tp) { Thread *chRegNextThread(Thread *tp) {
Thread *ntp; Thread *ntp;

View File

@ -41,7 +41,8 @@ ReadyList rlist;
/** /**
* @brief Scheduler initialization. * @brief Scheduler initialization.
* @note Internally invoked by the @p chSysInit(), not an API. *
* @notapi
*/ */
void scheduler_init(void) { void scheduler_init(void) {
@ -66,6 +67,8 @@ void scheduler_init(void) {
* *
* @param[in] tp the thread to be made ready * @param[in] tp the thread to be made ready
* @return The thread pointer. * @return The thread pointer.
*
* @iclass
*/ */
#if !defined(PORT_OPTIMIZED_READYI) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_READYI) || defined(__DOXYGEN__)
#if CH_OPTIMIZE_SPEED #if CH_OPTIMIZE_SPEED
@ -101,6 +104,8 @@ Thread *chSchReadyI(Thread *tp) {
* @ref thread_states are defined into @p threads.h. * @ref thread_states are defined into @p threads.h.
* *
* @param[in] newstate the new thread state * @param[in] newstate the new thread state
*
* @sclass
*/ */
#if !defined(PORT_OPTIMIZED_GOSLEEPS) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_GOSLEEPS) || defined(__DOXYGEN__)
void chSchGoSleepS(tstate_t newstate) { void chSchGoSleepS(tstate_t newstate) {
@ -163,6 +168,8 @@ static void wakeup(void *p) {
* . * .
* @return The wakeup message. * @return The wakeup message.
* @retval RDY_TIMEOUT if a timeout occurs. * @retval RDY_TIMEOUT if a timeout occurs.
*
* @sclass
*/ */
msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) { msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {
@ -194,6 +201,8 @@ msg_t chSchGoSleepTimeoutS(tstate_t newstate, systime_t time) {
* *
* @param[in] ntp the Thread to be made ready * @param[in] ntp the Thread to be made ready
* @param[in] msg message to the awakened thread * @param[in] msg message to the awakened thread
*
* @sclass
*/ */
#if !defined(PORT_OPTIMIZED_WAKEUPS) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_WAKEUPS) || defined(__DOXYGEN__)
void chSchWakeupS(Thread *ntp, msg_t msg) { void chSchWakeupS(Thread *ntp, msg_t msg) {
@ -222,6 +231,8 @@ void chSchWakeupS(Thread *ntp, msg_t msg) {
* @brief Switches to the first thread on the runnable queue. * @brief Switches to the first thread on the runnable queue.
* @note It is intended to be called if @p chSchRescRequiredI() evaluates * @note It is intended to be called if @p chSchRescRequiredI() evaluates
* to @p TRUE. * to @p TRUE.
*
* @iclass
*/ */
#if !defined(PORT_OPTIMIZED_DORESCHEDULEI) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_DORESCHEDULEI) || defined(__DOXYGEN__)
void chSchDoRescheduleI(void) { void chSchDoRescheduleI(void) {
@ -244,6 +255,8 @@ void chSchDoRescheduleI(void) {
* @brief Performs a reschedule if a higher priority thread is runnable. * @brief Performs a reschedule if a higher priority thread is runnable.
* @details If a thread with a higher priority than the current thread is in * @details If a thread with a higher priority than the current thread is in
* the ready list then make the higher priority thread running. * the ready list then make the higher priority thread running.
*
* @iclass
*/ */
#if !defined(PORT_OPTIMIZED_RESCHEDULES) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_RESCHEDULES) || defined(__DOXYGEN__)
void chSchRescheduleS(void) { void chSchRescheduleS(void) {
@ -262,6 +275,8 @@ void chSchRescheduleS(void) {
* *
* @retval TRUE if there is a thread that should go in running state. * @retval TRUE if there is a thread that should go in running state.
* @retval FALSE if a reschedule is not required. * @retval FALSE if a reschedule is not required.
*
* @iclass
*/ */
#if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) || defined(__DOXYGEN__) #if !defined(PORT_OPTIMIZED_ISRESCHREQUIREDEXI) || defined(__DOXYGEN__)
bool_t chSchIsRescRequiredExI(void) { bool_t chSchIsRescRequiredExI(void) {

View File

@ -68,12 +68,12 @@
/** /**
* @brief Initializes a semaphore with the specified counter value. * @brief Initializes a semaphore with the specified counter value.
* @note This function can be invoked before the kernel is initialized
* because it just prepares a @p Semaphore structure.
* *
* @param[out] sp pointer to a @p Semaphore structure * @param[out] sp pointer to a @p Semaphore structure
* @param[in] n initial value of the semaphore counter. Must be * @param[in] n initial value of the semaphore counter. Must be
* non-negative. * non-negative.
*
* @init
*/ */
void chSemInit(Semaphore *sp, cnt_t n) { void chSemInit(Semaphore *sp, cnt_t n) {
@ -95,6 +95,8 @@ void chSemInit(Semaphore *sp, cnt_t n) {
* @param[in] sp pointer to a @p Semaphore structure * @param[in] sp pointer to a @p Semaphore structure
* @param[in] n the new value of the semaphore counter. The value must * @param[in] n the new value of the semaphore counter. The value must
* be non-negative. * be non-negative.
*
* @api
*/ */
void chSemReset(Semaphore *sp, cnt_t n) { void chSemReset(Semaphore *sp, cnt_t n) {
@ -120,6 +122,8 @@ void chSemReset(Semaphore *sp, cnt_t n) {
* @param[in] sp pointer to a @p Semaphore structure * @param[in] sp pointer to a @p Semaphore structure
* @param[in] n the new value of the semaphore counter. The value must * @param[in] n the new value of the semaphore counter. The value must
* be non-negative. * be non-negative.
*
* @iclass
*/ */
void chSemResetI(Semaphore *sp, cnt_t n) { void chSemResetI(Semaphore *sp, cnt_t n) {
cnt_t cnt; cnt_t cnt;
@ -146,6 +150,8 @@ void chSemResetI(Semaphore *sp, cnt_t n) {
* @retval RDY_OK if the thread has not stopped on the semaphore or the * @retval RDY_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled. * semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset(). * @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
*
* @api
*/ */
msg_t chSemWait(Semaphore *sp) { msg_t chSemWait(Semaphore *sp) {
msg_t msg; msg_t msg;
@ -165,6 +171,8 @@ msg_t chSemWait(Semaphore *sp) {
* @retval RDY_OK if the thread has not stopped on the semaphore or the * @retval RDY_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled. * semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset(). * @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
*
* @sclass
*/ */
msg_t chSemWaitS(Semaphore *sp) { msg_t chSemWaitS(Semaphore *sp) {
@ -200,6 +208,8 @@ msg_t chSemWaitS(Semaphore *sp) {
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset(). * @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
* @retval RDY_TIMEOUT if the semaphore has not been signaled or reset within * @retval RDY_TIMEOUT if the semaphore has not been signaled or reset within
* the specified timeout. * the specified timeout.
*
* @api
*/ */
msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) { msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) {
msg_t msg; msg_t msg;
@ -226,6 +236,8 @@ msg_t chSemWaitTimeout(Semaphore *sp, systime_t time) {
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset(). * @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
* @retval RDY_TIMEOUT if the semaphore has not been signaled or reset within * @retval RDY_TIMEOUT if the semaphore has not been signaled or reset within
* the specified timeout. * the specified timeout.
*
* @sclass
*/ */
msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time) { msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time) {
@ -252,6 +264,8 @@ msg_t chSemWaitTimeoutS(Semaphore *sp, systime_t time) {
* @brief Performs a signal operation on a semaphore. * @brief Performs a signal operation on a semaphore.
* *
* @param[in] sp pointer to a @p Semaphore structure * @param[in] sp pointer to a @p Semaphore structure
*
* @api
*/ */
void chSemSignal(Semaphore *sp) { void chSemSignal(Semaphore *sp) {
@ -276,6 +290,8 @@ void chSemSignal(Semaphore *sp) {
* reschedule must not be performed in ISRs. * reschedule must not be performed in ISRs.
* *
* @param[in] sp pointer to a @p Semaphore structure * @param[in] sp pointer to a @p Semaphore structure
*
* @iclass
*/ */
void chSemSignalI(Semaphore *sp) { void chSemSignalI(Semaphore *sp) {
@ -308,6 +324,8 @@ void chSemSignalI(Semaphore *sp) {
* @retval RDY_OK if the thread has not stopped on the semaphore or the * @retval RDY_OK if the thread has not stopped on the semaphore or the
* semaphore has been signaled. * semaphore has been signaled.
* @retval RDY_RESET if the semaphore has been reset using @p chSemReset(). * @retval RDY_RESET if the semaphore has been reset using @p chSemReset().
*
* @api
*/ */
msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw) { msg_t chSemSignalWait(Semaphore *sps, Semaphore *spw) {
msg_t msg; msg_t msg;

View File

@ -66,6 +66,10 @@ void _idle_thread(void *p) {
* @pre Interrupts must be still disabled when @p chSysInit() is invoked * @pre Interrupts must be still disabled when @p chSysInit() is invoked
* and are internally enabled. * and are internally enabled.
* @post The main thread is created with priority @p NORMALPRIO. * @post The main thread is created with priority @p NORMALPRIO.
* @note This function has special, architecture-dependent, requirements,
* see the notes into the various port reference manuals.
*
* @special
*/ */
void chSysInit(void) { void chSysInit(void) {
static Thread mainthread; static Thread mainthread;
@ -100,10 +104,11 @@ void chSysInit(void) {
* @details Decrements the remaining time quantum of the running thread * @details Decrements the remaining time quantum of the running thread
* and preempts it when the quantum is used up. Increments system * and preempts it when the quantum is used up. Increments system
* time and manages the timers. * time and manages the timers.
*
* @note The frequency of the timer determines the system tick granularity * @note The frequency of the timer determines the system tick granularity
* and, together with the @p CH_TIME_QUANTUM macro, the round robin * and, together with the @p CH_TIME_QUANTUM macro, the round robin
* interval. * interval.
*
* @iclass
*/ */
void chSysTimerHandlerI(void) { void chSysTimerHandlerI(void) {

View File

@ -64,6 +64,8 @@
* @param[in] tp pointer to the thread * @param[in] tp pointer to the thread
* @param[in] prio the priority level for the new thread * @param[in] prio the priority level for the new thread
* @return The same thread pointer passed as parameter. * @return The same thread pointer passed as parameter.
*
* @notapi
*/ */
Thread *init_thread(Thread *tp, tprio_t prio) { Thread *init_thread(Thread *tp, tprio_t prio) {
@ -128,6 +130,8 @@ static void memfill(uint8_t *startp, uint8_t *endp, uint8_t v) {
* @p NULL. * @p NULL.
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p Thread structure allocated for
* the thread into the working space area. * the thread into the working space area.
*
* @api
*/ */
Thread *chThdInit(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg) { Thread *chThdInit(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg) {
/* Thread structure is layed out in the lower part of the thread workspace */ /* Thread structure is layed out in the lower part of the thread workspace */
@ -158,6 +162,8 @@ Thread *chThdInit(void *wsp, size_t size, tprio_t prio, tfunc_t pf, void *arg) {
* @p NULL. * @p NULL.
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p Thread structure allocated for
* the thread into the working space area. * the thread into the working space area.
*
* @api
*/ */
Thread *chThdCreateStatic(void *wsp, size_t size, Thread *chThdCreateStatic(void *wsp, size_t size,
tprio_t prio, tfunc_t pf, void *arg) { tprio_t prio, tfunc_t pf, void *arg) {
@ -185,6 +191,8 @@ Thread *chThdCreateStatic(void *wsp, size_t size,
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p Thread structure allocated for
* the thread into the working space area. * the thread into the working space area.
* @retval NULL if the memory cannot be allocated. * @retval NULL if the memory cannot be allocated.
*
* @api
*/ */
Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size, Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
tprio_t prio, tfunc_t pf, void *arg) { tprio_t prio, tfunc_t pf, void *arg) {
@ -219,6 +227,8 @@ Thread *chThdCreateFromHeap(MemoryHeap *heapp, size_t size,
* @return The pointer to the @p Thread structure allocated for * @return The pointer to the @p Thread structure allocated for
* the thread into the working space area. * the thread into the working space area.
* @retval NULL if the memory pool is empty. * @retval NULL if the memory pool is empty.
*
* @api
*/ */
Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio, Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
tfunc_t pf, void *arg) { tfunc_t pf, void *arg) {
@ -246,6 +256,8 @@ Thread *chThdCreateFromMemoryPool(MemoryPool *mp, tprio_t prio,
* *
* @param[in] newprio the new priority level of the running thread * @param[in] newprio the new priority level of the running thread
* @return The old priority level. * @return The old priority level.
*
* @api
*/ */
tprio_t chThdSetPriority(tprio_t newprio) { tprio_t chThdSetPriority(tprio_t newprio) {
tprio_t oldprio; tprio_t oldprio;
@ -278,6 +290,8 @@ tprio_t chThdSetPriority(tprio_t newprio) {
* *
* @param[in] tp pointer to the thread * @param[in] tp pointer to the thread
* @return The pointer to the thread. * @return The pointer to the thread.
*
* @api
*/ */
Thread *chThdResume(Thread *tp) { Thread *chThdResume(Thread *tp) {
@ -299,6 +313,8 @@ Thread *chThdResume(Thread *tp) {
* condition. * condition.
* *
* @param[in] tp pointer to the thread * @param[in] tp pointer to the thread
*
* @api
*/ */
void chThdTerminate(Thread *tp) { void chThdTerminate(Thread *tp) {
@ -318,6 +334,8 @@ void chThdTerminate(Thread *tp) {
* interpreted as a normal time specification not as an * interpreted as a normal time specification not as an
* immediate timeout specification. * immediate timeout specification.
* . * .
*
* @api
*/ */
void chThdSleep(systime_t time) { void chThdSleep(systime_t time) {
@ -333,6 +351,8 @@ void chThdSleep(systime_t time) {
* specified value. * specified value.
* *
* @param[in] time absolute system time * @param[in] time absolute system time
*
* @api
*/ */
void chThdSleepUntil(systime_t time) { void chThdSleepUntil(systime_t time) {
@ -346,6 +366,8 @@ void chThdSleepUntil(systime_t time) {
* @brief Yields the time slot. * @brief Yields the time slot.
* @details Yields the CPU control to the next thread in the ready list with * @details Yields the CPU control to the next thread in the ready list with
* equal priority, if any. * equal priority, if any.
*
* @api
*/ */
void chThdYield(void) { void chThdYield(void) {
@ -360,9 +382,13 @@ void chThdYield(void) {
* specified exit status code, other threads can retrieve the * specified exit status code, other threads can retrieve the
* exit status code by invoking the function @p chThdWait(). * exit status code by invoking the function @p chThdWait().
* @post Eventual code after this function will never be executed, * @post Eventual code after this function will never be executed,
* this function never returns. * this function never returns. The compiler has no way to
* know this so do not assume that the compiler would remove
* the dead code.
* *
* @param[in] msg thread exit code * @param[in] msg thread exit code
*
* @api
*/ */
void chThdExit(msg_t msg) { void chThdExit(msg_t msg) {
Thread *tp = currp; Thread *tp = currp;
@ -391,6 +417,8 @@ void chThdExit(msg_t msg) {
* @param[in] tp pointer to the thread * @param[in] tp pointer to the thread
* @return The same thread pointer passed as parameter * @return The same thread pointer passed as parameter
* representing the new reference. * representing the new reference.
*
* @api
*/ */
Thread *chThdAddRef(Thread *tp) { Thread *chThdAddRef(Thread *tp) {
@ -411,6 +439,8 @@ Thread *chThdAddRef(Thread *tp) {
* @note Static threads are not affected. * @note Static threads are not affected.
* *
* @param[in] tp pointer to the thread * @param[in] tp pointer to the thread
*
* @api
*/ */
void chThdRelease(Thread *tp) { void chThdRelease(Thread *tp) {
trefs_t refs; trefs_t refs;
@ -469,6 +499,8 @@ void chThdRelease(Thread *tp) {
* *
* @param[in] tp pointer to the thread * @param[in] tp pointer to the thread
* @return The exit code from the terminated thread. * @return The exit code from the terminated thread.
*
* @api
*/ */
msg_t chThdWait(Thread *tp) { msg_t chThdWait(Thread *tp) {
msg_t msg; msg_t msg;

View File

@ -36,6 +36,8 @@ VTList vtlist;
/** /**
* @brief Virtual Timers initialization. * @brief Virtual Timers initialization.
* @note Internal use only. * @note Internal use only.
*
* @notapi
*/ */
void vt_init(void) { void vt_init(void) {
@ -58,6 +60,8 @@ void vt_init(void) {
* be disposed or reused. * be disposed or reused.
* @param[in] par a parameter that will be passed to the callback * @param[in] par a parameter that will be passed to the callback
* function * function
*
* @iclass
*/ */
void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) { void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) {
VirtualTimer *p; VirtualTimer *p;
@ -85,6 +89,8 @@ void chVTSetI(VirtualTimer *vtp, systime_t time, vtfunc_t vtfunc, void *par) {
* @note The timer MUST be active when this function is invoked. * @note The timer MUST be active when this function is invoked.
* *
* @param[in] vtp the @p VirtualTimer structure pointer * @param[in] vtp the @p VirtualTimer structure pointer
*
* @iclass
*/ */
void chVTResetI(VirtualTimer *vtp) { void chVTResetI(VirtualTimer *vtp) {
@ -110,6 +116,8 @@ void chVTResetI(VirtualTimer *vtp) {
* @param[in] end the end of the time window (non inclusive) * @param[in] end the end of the time window (non inclusive)
* @retval TRUE current time within the specified time window. * @retval TRUE current time within the specified time window.
* @retval FALSE current time not within the specified time window. * @retval FALSE current time not within the specified time window.
*
* @api
*/ */
bool_t chTimeIsWithin(systime_t start, systime_t end) { bool_t chTimeIsWithin(systime_t start, systime_t end) {

View File

@ -111,9 +111,15 @@
- OPT: Removed an unused field in the VTList structure. - OPT: Removed an unused field in the VTList structure.
- OPT: Speed optimizations of the STM32 SPI driver, improved latency. - OPT: Speed optimizations of the STM32 SPI driver, improved latency.
- OPT: Speed optimizations of the STM32 ADC driver. - OPT: Speed optimizations of the STM32 ADC driver.
- CHANGE: The mailboxes macros chMBSize(), chMBGetEmpty(), chMBGetFull(),
chMBPeek() have been renamed to chMBSizeI(), chMBGetEmptyI(),
chMBGetFullI(), chMBPeekI().
- CHANGE: The queue APIs chQSize(), chQSpace(), chIQIsEmpty(), chIQIsFull(),
chOQIsEmpty(), chOQIsFull() have been renamed to chQSizeI(), chQSpaceI(),
chIQIsEmptyI(), chIQIsFullI(), chOQIsEmptyI(), chOQIsFullI().
- CHANGE: The event APIs chEvtPend() and chEvtClear() have been renamed - CHANGE: The event APIs chEvtPend() and chEvtClear() have been renamed
to chEvtAddFlags() and chEvtClearFlags() for consistency and correct to chEvtAddFlags() and chEvtClearFlags() for consistency and correct
English. English. Changed the macro chEvtIsListening() in chEvtIsListeningI().
- CHANGE: Added a parameter to the UART driver callbacks, the pointer to the - CHANGE: Added a parameter to the UART driver callbacks, the pointer to the
driver itself. driver itself.
- CHANGE: In the UART driver now an error does not automatically brings the - CHANGE: In the UART driver now an error does not automatically brings the

View File

@ -94,11 +94,11 @@ static void evt1_execute(void) {
chEvtInit(&es1); chEvtInit(&es1);
chEvtRegisterMask(&es1, &el1, 1); chEvtRegisterMask(&es1, &el1, 1);
chEvtRegisterMask(&es1, &el2, 2); chEvtRegisterMask(&es1, &el2, 2);
test_assert(1, chEvtIsListening(&es1), "no listener"); test_assert(1, chEvtIsListeningI(&es1), "no listener");
chEvtUnregister(&es1, &el1); chEvtUnregister(&es1, &el1);
test_assert(2, chEvtIsListening(&es1), "no listener"); test_assert(2, chEvtIsListeningI(&es1), "no listener");
chEvtUnregister(&es1, &el2); chEvtUnregister(&es1, &el2);
test_assert(3, !chEvtIsListening(&es1), "stuck listener"); test_assert(3, !chEvtIsListeningI(&es1), "stuck listener");
/* /*
* Testing chEvtDispatch(). * Testing chEvtDispatch().
@ -220,8 +220,8 @@ static void evt2_execute(void) {
test_wait_threads(); test_wait_threads();
chEvtUnregister(&es1, &el1); chEvtUnregister(&es1, &el1);
chEvtUnregister(&es2, &el2); chEvtUnregister(&es2, &el2);
test_assert(14, !chEvtIsListening(&es1), "stuck listener"); test_assert(14, !chEvtIsListeningI(&es1), "stuck listener");
test_assert(15, !chEvtIsListening(&es2), "stuck listener"); test_assert(15, !chEvtIsListeningI(&es2), "stuck listener");
} }
ROMCONST struct testcase testevt2 = { ROMCONST struct testcase testevt2 = {

View File

@ -83,7 +83,7 @@ static void mbox1_execute(void) {
/* /*
* Testing initial space. * Testing initial space.
*/ */
test_assert(1, chMBGetEmpty(&mb1) == MB_SIZE, "wrong size"); test_assert(1, chMBGetEmptyI(&mb1) == MB_SIZE, "wrong size");
/* /*
* Testing enqueuing and backward circularity. * Testing enqueuing and backward circularity.
@ -104,8 +104,8 @@ static void mbox1_execute(void) {
/* /*
* Testing final conditions. * Testing final conditions.
*/ */
test_assert(5, chMBGetEmpty(&mb1) == 0, "still empty"); test_assert(5, chMBGetEmptyI(&mb1) == 0, "still empty");
test_assert(6, chMBGetFull(&mb1) == MB_SIZE, "not full"); test_assert(6, chMBGetFullI(&mb1) == MB_SIZE, "not full");
test_assert(7, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); test_assert(7, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
/* /*
@ -137,8 +137,8 @@ static void mbox1_execute(void) {
/* /*
* Testing final conditions. * Testing final conditions.
*/ */
test_assert(15, chMBGetEmpty(&mb1) == MB_SIZE, "not empty"); test_assert(15, chMBGetEmptyI(&mb1) == MB_SIZE, "not empty");
test_assert(16, chMBGetFull(&mb1) == 0, "still full"); test_assert(16, chMBGetFullI(&mb1) == 0, "still full");
test_assert(17, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned"); test_assert(17, mb1.mb_rdptr == mb1.mb_wrptr, "pointers not aligned");
/* /*
@ -149,8 +149,8 @@ static void mbox1_execute(void) {
/* /*
* Re-testing final conditions. * Re-testing final conditions.
*/ */
test_assert(18, chMBGetEmpty(&mb1) == MB_SIZE, "not empty"); test_assert(18, chMBGetEmptyI(&mb1) == MB_SIZE, "not empty");
test_assert(19, chMBGetFull(&mb1) == 0, "still full"); test_assert(19, chMBGetFullI(&mb1) == 0, "still full");
test_assert(20, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base"); test_assert(20, mb1.mb_buffer == mb1.mb_wrptr, "write pointer not aligned to base");
test_assert(21, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base"); test_assert(21, mb1.mb_buffer == mb1.mb_rdptr, "read pointer not aligned to base");
} }

View File

@ -86,18 +86,18 @@ static void queues1_execute(void) {
size_t n; size_t n;
/* Initial empty state */ /* Initial empty state */
test_assert(1, chIQIsEmpty(&iq), "not empty"); test_assert(1, chIQIsEmptyI(&iq), "not empty");
/* Queue filling */ /* Queue filling */
for (i = 0; i < TEST_QUEUES_SIZE; i++) for (i = 0; i < TEST_QUEUES_SIZE; i++)
chIQPutI(&iq, 'A' + i); chIQPutI(&iq, 'A' + i);
test_assert(2, chIQIsFull(&iq), "still has space"); test_assert(2, chIQIsFullI(&iq), "still has space");
test_assert(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL"); test_assert(3, chIQPutI(&iq, 0) == Q_FULL, "failed to report Q_FULL");
/* Queue emptying */ /* Queue emptying */
for (i = 0; i < TEST_QUEUES_SIZE; i++) for (i = 0; i < TEST_QUEUES_SIZE; i++)
test_emit_token(chIQGet(&iq)); test_emit_token(chIQGet(&iq));
test_assert(4, chIQIsEmpty(&iq), "still full"); test_assert(4, chIQIsEmptyI(&iq), "still full");
test_assert_sequence(5, "ABCD"); test_assert_sequence(5, "ABCD");
/* Queue filling again */ /* Queue filling again */
@ -107,7 +107,7 @@ static void queues1_execute(void) {
/* Reading the whole thing */ /* Reading the whole thing */
n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE);
test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size");
test_assert(7, chIQIsEmpty(&iq), "still full"); test_assert(7, chIQIsEmptyI(&iq), "still full");
/* Queue filling again */ /* Queue filling again */
for (i = 0; i < TEST_QUEUES_SIZE; i++) for (i = 0; i < TEST_QUEUES_SIZE; i++)
@ -118,12 +118,12 @@ static void queues1_execute(void) {
test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); test_assert(8, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); n = chIQReadTimeout(&iq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
test_assert(10, chIQIsEmpty(&iq), "still full"); test_assert(10, chIQIsEmptyI(&iq), "still full");
/* Testing reset */ /* Testing reset */
chIQPutI(&iq, 0); chIQPutI(&iq, 0);
chIQResetI(&iq); chIQResetI(&iq);
test_assert(11, chIQIsEmpty(&iq), "still full"); test_assert(11, chIQIsEmptyI(&iq), "still full");
/* Timeout */ /* Timeout */
test_assert(12, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return"); test_assert(12, chIQGetTimeout(&iq, 10) == Q_TIMEOUT, "wrong timeout return");
@ -155,35 +155,35 @@ static void queues2_execute(void) {
size_t n; size_t n;
/* Initial empty state */ /* Initial empty state */
test_assert(1, chOQIsEmpty(&oq), "not empty"); test_assert(1, chOQIsEmptyI(&oq), "not empty");
/* Queue filling */ /* Queue filling */
for (i = 0; i < TEST_QUEUES_SIZE; i++) for (i = 0; i < TEST_QUEUES_SIZE; i++)
chOQPut(&oq, 'A' + i); chOQPut(&oq, 'A' + i);
test_assert(2, chOQIsFull(&oq), "still has space"); test_assert(2, chOQIsFullI(&oq), "still has space");
/* Queue emptying */ /* Queue emptying */
for (i = 0; i < TEST_QUEUES_SIZE; i++) for (i = 0; i < TEST_QUEUES_SIZE; i++)
test_emit_token(chOQGetI(&oq)); test_emit_token(chOQGetI(&oq));
test_assert(3, chOQIsEmpty(&oq), "still full"); test_assert(3, chOQIsEmptyI(&oq), "still full");
test_assert_sequence(4, "ABCD"); test_assert_sequence(4, "ABCD");
test_assert(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY"); test_assert(5, chOQGetI(&oq) == Q_EMPTY, "failed to report Q_EMPTY");
/* Writing the whole thing */ /* Writing the whole thing */
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE); n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE * 2, TIME_IMMEDIATE);
test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size"); test_assert(6, n == TEST_QUEUES_SIZE, "wrong returned size");
test_assert(7, chOQIsFull(&oq), "not full"); test_assert(7, chOQIsFullI(&oq), "not full");
/* Testing reset */ /* Testing reset */
chOQResetI(&oq); chOQResetI(&oq);
test_assert(8, chOQIsEmpty(&oq), "still full"); test_assert(8, chOQIsEmptyI(&oq), "still full");
/* Partial writes */ /* Partial writes */
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); test_assert(9, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE); n = chOQWriteTimeout(&oq, wa[1], TEST_QUEUES_SIZE / 2, TIME_IMMEDIATE);
test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size"); test_assert(10, n == TEST_QUEUES_SIZE / 2, "wrong returned size");
test_assert(11, chOQIsFull(&oq), "not full"); test_assert(11, chOQIsFullI(&oq), "not full");
/* Timeout */ /* Timeout */
test_assert(12, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return"); test_assert(12, chOQPutTimeout(&oq, 0, 10) == Q_TIMEOUT, "wrong timeout return");