Control a robot over the internet using UDP and a Wifly module (WiFi).

Dependencies:   Motor TextLCD WiflyInterface mbed-rtos mbed

Committer:
apatel336
Date:
Thu Oct 17 13:27:56 2013 +0000
Revision:
0:c0dc3a76f3d4
Initial Release

Who changed what in which revision?

UserRevisionLine numberNew contents of line
apatel336 0:c0dc3a76f3d4 1 /*----------------------------------------------------------------------------
apatel336 0:c0dc3a76f3d4 2 * RL-ARM - RTX
apatel336 0:c0dc3a76f3d4 3 *----------------------------------------------------------------------------
apatel336 0:c0dc3a76f3d4 4 * Name: RT_MAILBOX.C
apatel336 0:c0dc3a76f3d4 5 * Purpose: Implements waits and wake-ups for mailbox messages
apatel336 0:c0dc3a76f3d4 6 * Rev.: V4.60
apatel336 0:c0dc3a76f3d4 7 *----------------------------------------------------------------------------
apatel336 0:c0dc3a76f3d4 8 *
apatel336 0:c0dc3a76f3d4 9 * Copyright (c) 1999-2009 KEIL, 2009-2012 ARM Germany GmbH
apatel336 0:c0dc3a76f3d4 10 * All rights reserved.
apatel336 0:c0dc3a76f3d4 11 * Redistribution and use in source and binary forms, with or without
apatel336 0:c0dc3a76f3d4 12 * modification, are permitted provided that the following conditions are met:
apatel336 0:c0dc3a76f3d4 13 * - Redistributions of source code must retain the above copyright
apatel336 0:c0dc3a76f3d4 14 * notice, this list of conditions and the following disclaimer.
apatel336 0:c0dc3a76f3d4 15 * - Redistributions in binary form must reproduce the above copyright
apatel336 0:c0dc3a76f3d4 16 * notice, this list of conditions and the following disclaimer in the
apatel336 0:c0dc3a76f3d4 17 * documentation and/or other materials provided with the distribution.
apatel336 0:c0dc3a76f3d4 18 * - Neither the name of ARM nor the names of its contributors may be used
apatel336 0:c0dc3a76f3d4 19 * to endorse or promote products derived from this software without
apatel336 0:c0dc3a76f3d4 20 * specific prior written permission.
apatel336 0:c0dc3a76f3d4 21 *
apatel336 0:c0dc3a76f3d4 22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
apatel336 0:c0dc3a76f3d4 23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
apatel336 0:c0dc3a76f3d4 24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
apatel336 0:c0dc3a76f3d4 25 * ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
apatel336 0:c0dc3a76f3d4 26 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
apatel336 0:c0dc3a76f3d4 27 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
apatel336 0:c0dc3a76f3d4 28 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
apatel336 0:c0dc3a76f3d4 29 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
apatel336 0:c0dc3a76f3d4 30 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
apatel336 0:c0dc3a76f3d4 31 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
apatel336 0:c0dc3a76f3d4 32 * POSSIBILITY OF SUCH DAMAGE.
apatel336 0:c0dc3a76f3d4 33 *---------------------------------------------------------------------------*/
apatel336 0:c0dc3a76f3d4 34
apatel336 0:c0dc3a76f3d4 35 #include "rt_TypeDef.h"
apatel336 0:c0dc3a76f3d4 36 #include "RTX_Conf.h"
apatel336 0:c0dc3a76f3d4 37 #include "rt_System.h"
apatel336 0:c0dc3a76f3d4 38 #include "rt_List.h"
apatel336 0:c0dc3a76f3d4 39 #include "rt_Mailbox.h"
apatel336 0:c0dc3a76f3d4 40 #include "rt_MemBox.h"
apatel336 0:c0dc3a76f3d4 41 #include "rt_Task.h"
apatel336 0:c0dc3a76f3d4 42 #include "rt_HAL_CM.h"
apatel336 0:c0dc3a76f3d4 43
apatel336 0:c0dc3a76f3d4 44
apatel336 0:c0dc3a76f3d4 45 /*----------------------------------------------------------------------------
apatel336 0:c0dc3a76f3d4 46 * Functions
apatel336 0:c0dc3a76f3d4 47 *---------------------------------------------------------------------------*/
apatel336 0:c0dc3a76f3d4 48
apatel336 0:c0dc3a76f3d4 49
apatel336 0:c0dc3a76f3d4 50 /*--------------------------- rt_mbx_init -----------------------------------*/
apatel336 0:c0dc3a76f3d4 51
apatel336 0:c0dc3a76f3d4 52 void rt_mbx_init (OS_ID mailbox, U16 mbx_size) {
apatel336 0:c0dc3a76f3d4 53 /* Initialize a mailbox */
apatel336 0:c0dc3a76f3d4 54 P_MCB p_MCB = mailbox;
apatel336 0:c0dc3a76f3d4 55
apatel336 0:c0dc3a76f3d4 56 p_MCB->cb_type = MCB;
apatel336 0:c0dc3a76f3d4 57 p_MCB->state = 0;
apatel336 0:c0dc3a76f3d4 58 p_MCB->isr_st = 0;
apatel336 0:c0dc3a76f3d4 59 p_MCB->p_lnk = NULL;
apatel336 0:c0dc3a76f3d4 60 p_MCB->first = 0;
apatel336 0:c0dc3a76f3d4 61 p_MCB->last = 0;
apatel336 0:c0dc3a76f3d4 62 p_MCB->count = 0;
apatel336 0:c0dc3a76f3d4 63 p_MCB->size = (mbx_size + sizeof(void *) - sizeof(struct OS_MCB)) /
apatel336 0:c0dc3a76f3d4 64 (U32)sizeof (void *);
apatel336 0:c0dc3a76f3d4 65 }
apatel336 0:c0dc3a76f3d4 66
apatel336 0:c0dc3a76f3d4 67
apatel336 0:c0dc3a76f3d4 68 /*--------------------------- rt_mbx_send -----------------------------------*/
apatel336 0:c0dc3a76f3d4 69
apatel336 0:c0dc3a76f3d4 70 OS_RESULT rt_mbx_send (OS_ID mailbox, void *p_msg, U16 timeout) {
apatel336 0:c0dc3a76f3d4 71 /* Send message to a mailbox */
apatel336 0:c0dc3a76f3d4 72 P_MCB p_MCB = mailbox;
apatel336 0:c0dc3a76f3d4 73 P_TCB p_TCB;
apatel336 0:c0dc3a76f3d4 74
apatel336 0:c0dc3a76f3d4 75 if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 1)) {
apatel336 0:c0dc3a76f3d4 76 /* A task is waiting for message */
apatel336 0:c0dc3a76f3d4 77 p_TCB = rt_get_first ((P_XCB)p_MCB);
apatel336 0:c0dc3a76f3d4 78 #ifdef __CMSIS_RTOS
apatel336 0:c0dc3a76f3d4 79 rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg);
apatel336 0:c0dc3a76f3d4 80 #else
apatel336 0:c0dc3a76f3d4 81 *p_TCB->msg = p_msg;
apatel336 0:c0dc3a76f3d4 82 rt_ret_val (p_TCB, OS_R_MBX);
apatel336 0:c0dc3a76f3d4 83 #endif
apatel336 0:c0dc3a76f3d4 84 rt_rmv_dly (p_TCB);
apatel336 0:c0dc3a76f3d4 85 rt_dispatch (p_TCB);
apatel336 0:c0dc3a76f3d4 86 }
apatel336 0:c0dc3a76f3d4 87 else {
apatel336 0:c0dc3a76f3d4 88 /* Store message in mailbox queue */
apatel336 0:c0dc3a76f3d4 89 if (p_MCB->count == p_MCB->size) {
apatel336 0:c0dc3a76f3d4 90 /* No free message entry, wait for one. If message queue is full, */
apatel336 0:c0dc3a76f3d4 91 /* then no task is waiting for message. The 'p_MCB->p_lnk' list */
apatel336 0:c0dc3a76f3d4 92 /* pointer can now be reused for send message waits task list. */
apatel336 0:c0dc3a76f3d4 93 if (timeout == 0) {
apatel336 0:c0dc3a76f3d4 94 return (OS_R_TMO);
apatel336 0:c0dc3a76f3d4 95 }
apatel336 0:c0dc3a76f3d4 96 if (p_MCB->p_lnk != NULL) {
apatel336 0:c0dc3a76f3d4 97 rt_put_prio ((P_XCB)p_MCB, os_tsk.run);
apatel336 0:c0dc3a76f3d4 98 }
apatel336 0:c0dc3a76f3d4 99 else {
apatel336 0:c0dc3a76f3d4 100 p_MCB->p_lnk = os_tsk.run;
apatel336 0:c0dc3a76f3d4 101 os_tsk.run->p_lnk = NULL;
apatel336 0:c0dc3a76f3d4 102 os_tsk.run->p_rlnk = (P_TCB)p_MCB;
apatel336 0:c0dc3a76f3d4 103 /* Task is waiting to send a message */
apatel336 0:c0dc3a76f3d4 104 p_MCB->state = 2;
apatel336 0:c0dc3a76f3d4 105 }
apatel336 0:c0dc3a76f3d4 106 os_tsk.run->msg = p_msg;
apatel336 0:c0dc3a76f3d4 107 rt_block (timeout, WAIT_MBX);
apatel336 0:c0dc3a76f3d4 108 return (OS_R_TMO);
apatel336 0:c0dc3a76f3d4 109 }
apatel336 0:c0dc3a76f3d4 110 /* Yes, there is a free entry in a mailbox. */
apatel336 0:c0dc3a76f3d4 111 p_MCB->msg[p_MCB->first] = p_msg;
apatel336 0:c0dc3a76f3d4 112 rt_inc (&p_MCB->count);
apatel336 0:c0dc3a76f3d4 113 if (++p_MCB->first == p_MCB->size) {
apatel336 0:c0dc3a76f3d4 114 p_MCB->first = 0;
apatel336 0:c0dc3a76f3d4 115 }
apatel336 0:c0dc3a76f3d4 116 }
apatel336 0:c0dc3a76f3d4 117 return (OS_R_OK);
apatel336 0:c0dc3a76f3d4 118 }
apatel336 0:c0dc3a76f3d4 119
apatel336 0:c0dc3a76f3d4 120
apatel336 0:c0dc3a76f3d4 121 /*--------------------------- rt_mbx_wait -----------------------------------*/
apatel336 0:c0dc3a76f3d4 122
apatel336 0:c0dc3a76f3d4 123 OS_RESULT rt_mbx_wait (OS_ID mailbox, void **message, U16 timeout) {
apatel336 0:c0dc3a76f3d4 124 /* Receive a message; possibly wait for it */
apatel336 0:c0dc3a76f3d4 125 P_MCB p_MCB = mailbox;
apatel336 0:c0dc3a76f3d4 126 P_TCB p_TCB;
apatel336 0:c0dc3a76f3d4 127
apatel336 0:c0dc3a76f3d4 128 /* If a message is available in the fifo buffer */
apatel336 0:c0dc3a76f3d4 129 /* remove it from the fifo buffer and return. */
apatel336 0:c0dc3a76f3d4 130 if (p_MCB->count) {
apatel336 0:c0dc3a76f3d4 131 *message = p_MCB->msg[p_MCB->last];
apatel336 0:c0dc3a76f3d4 132 if (++p_MCB->last == p_MCB->size) {
apatel336 0:c0dc3a76f3d4 133 p_MCB->last = 0;
apatel336 0:c0dc3a76f3d4 134 }
apatel336 0:c0dc3a76f3d4 135 if ((p_MCB->p_lnk != NULL) && (p_MCB->state == 2)) {
apatel336 0:c0dc3a76f3d4 136 /* A task is waiting to send message */
apatel336 0:c0dc3a76f3d4 137 p_TCB = rt_get_first ((P_XCB)p_MCB);
apatel336 0:c0dc3a76f3d4 138 #ifdef __CMSIS_RTOS
apatel336 0:c0dc3a76f3d4 139 rt_ret_val(p_TCB, 0/*osOK*/);
apatel336 0:c0dc3a76f3d4 140 #else
apatel336 0:c0dc3a76f3d4 141 rt_ret_val(p_TCB, OS_R_OK);
apatel336 0:c0dc3a76f3d4 142 #endif
apatel336 0:c0dc3a76f3d4 143 p_MCB->msg[p_MCB->first] = p_TCB->msg;
apatel336 0:c0dc3a76f3d4 144 if (++p_MCB->first == p_MCB->size) {
apatel336 0:c0dc3a76f3d4 145 p_MCB->first = 0;
apatel336 0:c0dc3a76f3d4 146 }
apatel336 0:c0dc3a76f3d4 147 rt_rmv_dly (p_TCB);
apatel336 0:c0dc3a76f3d4 148 rt_dispatch (p_TCB);
apatel336 0:c0dc3a76f3d4 149 }
apatel336 0:c0dc3a76f3d4 150 else {
apatel336 0:c0dc3a76f3d4 151 rt_dec (&p_MCB->count);
apatel336 0:c0dc3a76f3d4 152 }
apatel336 0:c0dc3a76f3d4 153 return (OS_R_OK);
apatel336 0:c0dc3a76f3d4 154 }
apatel336 0:c0dc3a76f3d4 155 /* No message available: wait for one */
apatel336 0:c0dc3a76f3d4 156 if (timeout == 0) {
apatel336 0:c0dc3a76f3d4 157 return (OS_R_TMO);
apatel336 0:c0dc3a76f3d4 158 }
apatel336 0:c0dc3a76f3d4 159 if (p_MCB->p_lnk != NULL) {
apatel336 0:c0dc3a76f3d4 160 rt_put_prio ((P_XCB)p_MCB, os_tsk.run);
apatel336 0:c0dc3a76f3d4 161 }
apatel336 0:c0dc3a76f3d4 162 else {
apatel336 0:c0dc3a76f3d4 163 p_MCB->p_lnk = os_tsk.run;
apatel336 0:c0dc3a76f3d4 164 os_tsk.run->p_lnk = NULL;
apatel336 0:c0dc3a76f3d4 165 os_tsk.run->p_rlnk = (P_TCB)p_MCB;
apatel336 0:c0dc3a76f3d4 166 /* Task is waiting to receive a message */
apatel336 0:c0dc3a76f3d4 167 p_MCB->state = 1;
apatel336 0:c0dc3a76f3d4 168 }
apatel336 0:c0dc3a76f3d4 169 rt_block(timeout, WAIT_MBX);
apatel336 0:c0dc3a76f3d4 170 #ifndef __CMSIS_RTOS
apatel336 0:c0dc3a76f3d4 171 os_tsk.run->msg = message;
apatel336 0:c0dc3a76f3d4 172 #endif
apatel336 0:c0dc3a76f3d4 173 return (OS_R_TMO);
apatel336 0:c0dc3a76f3d4 174 }
apatel336 0:c0dc3a76f3d4 175
apatel336 0:c0dc3a76f3d4 176
apatel336 0:c0dc3a76f3d4 177 /*--------------------------- rt_mbx_check ----------------------------------*/
apatel336 0:c0dc3a76f3d4 178
apatel336 0:c0dc3a76f3d4 179 OS_RESULT rt_mbx_check (OS_ID mailbox) {
apatel336 0:c0dc3a76f3d4 180 /* Check for free space in a mailbox. Returns the number of messages */
apatel336 0:c0dc3a76f3d4 181 /* that can be stored to a mailbox. It returns 0 when mailbox is full. */
apatel336 0:c0dc3a76f3d4 182 P_MCB p_MCB = mailbox;
apatel336 0:c0dc3a76f3d4 183
apatel336 0:c0dc3a76f3d4 184 return (p_MCB->size - p_MCB->count);
apatel336 0:c0dc3a76f3d4 185 }
apatel336 0:c0dc3a76f3d4 186
apatel336 0:c0dc3a76f3d4 187
apatel336 0:c0dc3a76f3d4 188 /*--------------------------- isr_mbx_send ----------------------------------*/
apatel336 0:c0dc3a76f3d4 189
apatel336 0:c0dc3a76f3d4 190 void isr_mbx_send (OS_ID mailbox, void *p_msg) {
apatel336 0:c0dc3a76f3d4 191 /* Same function as "os_mbx_send", but to be called by ISRs. */
apatel336 0:c0dc3a76f3d4 192 P_MCB p_MCB = mailbox;
apatel336 0:c0dc3a76f3d4 193
apatel336 0:c0dc3a76f3d4 194 rt_psq_enq (p_MCB, (U32)p_msg);
apatel336 0:c0dc3a76f3d4 195 rt_psh_req ();
apatel336 0:c0dc3a76f3d4 196 }
apatel336 0:c0dc3a76f3d4 197
apatel336 0:c0dc3a76f3d4 198
apatel336 0:c0dc3a76f3d4 199 /*--------------------------- isr_mbx_receive -------------------------------*/
apatel336 0:c0dc3a76f3d4 200
apatel336 0:c0dc3a76f3d4 201 OS_RESULT isr_mbx_receive (OS_ID mailbox, void **message) {
apatel336 0:c0dc3a76f3d4 202 /* Receive a message in the interrupt function. The interrupt function */
apatel336 0:c0dc3a76f3d4 203 /* should not wait for a message since this would block the rtx os. */
apatel336 0:c0dc3a76f3d4 204 P_MCB p_MCB = mailbox;
apatel336 0:c0dc3a76f3d4 205
apatel336 0:c0dc3a76f3d4 206 if (p_MCB->count) {
apatel336 0:c0dc3a76f3d4 207 /* A message is available in the fifo buffer. */
apatel336 0:c0dc3a76f3d4 208 *message = p_MCB->msg[p_MCB->last];
apatel336 0:c0dc3a76f3d4 209 if (p_MCB->state == 2) {
apatel336 0:c0dc3a76f3d4 210 /* A task is locked waiting to send message */
apatel336 0:c0dc3a76f3d4 211 rt_psq_enq (p_MCB, 0);
apatel336 0:c0dc3a76f3d4 212 rt_psh_req ();
apatel336 0:c0dc3a76f3d4 213 }
apatel336 0:c0dc3a76f3d4 214 rt_dec (&p_MCB->count);
apatel336 0:c0dc3a76f3d4 215 if (++p_MCB->last == p_MCB->size) {
apatel336 0:c0dc3a76f3d4 216 p_MCB->last = 0;
apatel336 0:c0dc3a76f3d4 217 }
apatel336 0:c0dc3a76f3d4 218 return (OS_R_MBX);
apatel336 0:c0dc3a76f3d4 219 }
apatel336 0:c0dc3a76f3d4 220 return (OS_R_OK);
apatel336 0:c0dc3a76f3d4 221 }
apatel336 0:c0dc3a76f3d4 222
apatel336 0:c0dc3a76f3d4 223
apatel336 0:c0dc3a76f3d4 224 /*--------------------------- rt_mbx_psh ------------------------------------*/
apatel336 0:c0dc3a76f3d4 225
apatel336 0:c0dc3a76f3d4 226 void rt_mbx_psh (P_MCB p_CB, void *p_msg) {
apatel336 0:c0dc3a76f3d4 227 /* Store the message to the mailbox queue or pass it to task directly. */
apatel336 0:c0dc3a76f3d4 228 P_TCB p_TCB;
apatel336 0:c0dc3a76f3d4 229 void *mem;
apatel336 0:c0dc3a76f3d4 230
apatel336 0:c0dc3a76f3d4 231 if (p_CB->p_lnk != NULL) switch (p_CB->state) {
apatel336 0:c0dc3a76f3d4 232 #ifdef __CMSIS_RTOS
apatel336 0:c0dc3a76f3d4 233 case 3:
apatel336 0:c0dc3a76f3d4 234 /* Task is waiting to allocate memory, remove it from the waiting list */
apatel336 0:c0dc3a76f3d4 235 mem = rt_alloc_box(p_msg);
apatel336 0:c0dc3a76f3d4 236 if (mem == NULL) break;
apatel336 0:c0dc3a76f3d4 237 p_TCB = rt_get_first ((P_XCB)p_CB);
apatel336 0:c0dc3a76f3d4 238 rt_ret_val(p_TCB, (U32)mem);
apatel336 0:c0dc3a76f3d4 239 p_TCB->state = READY;
apatel336 0:c0dc3a76f3d4 240 rt_rmv_dly (p_TCB);
apatel336 0:c0dc3a76f3d4 241 rt_put_prio (&os_rdy, p_TCB);
apatel336 0:c0dc3a76f3d4 242 break;
apatel336 0:c0dc3a76f3d4 243 #endif
apatel336 0:c0dc3a76f3d4 244 case 2:
apatel336 0:c0dc3a76f3d4 245 /* Task is waiting to send a message, remove it from the waiting list */
apatel336 0:c0dc3a76f3d4 246 p_TCB = rt_get_first ((P_XCB)p_CB);
apatel336 0:c0dc3a76f3d4 247 #ifdef __CMSIS_RTOS
apatel336 0:c0dc3a76f3d4 248 rt_ret_val(p_TCB, 0/*osOK*/);
apatel336 0:c0dc3a76f3d4 249 #else
apatel336 0:c0dc3a76f3d4 250 rt_ret_val(p_TCB, OS_R_OK);
apatel336 0:c0dc3a76f3d4 251 #endif
apatel336 0:c0dc3a76f3d4 252 p_CB->msg[p_CB->first] = p_TCB->msg;
apatel336 0:c0dc3a76f3d4 253 rt_inc (&p_CB->count);
apatel336 0:c0dc3a76f3d4 254 if (++p_CB->first == p_CB->size) {
apatel336 0:c0dc3a76f3d4 255 p_CB->first = 0;
apatel336 0:c0dc3a76f3d4 256 }
apatel336 0:c0dc3a76f3d4 257 p_TCB->state = READY;
apatel336 0:c0dc3a76f3d4 258 rt_rmv_dly (p_TCB);
apatel336 0:c0dc3a76f3d4 259 rt_put_prio (&os_rdy, p_TCB);
apatel336 0:c0dc3a76f3d4 260 break;
apatel336 0:c0dc3a76f3d4 261 case 1:
apatel336 0:c0dc3a76f3d4 262 /* Task is waiting for a message, pass the message to the task directly */
apatel336 0:c0dc3a76f3d4 263 p_TCB = rt_get_first ((P_XCB)p_CB);
apatel336 0:c0dc3a76f3d4 264 #ifdef __CMSIS_RTOS
apatel336 0:c0dc3a76f3d4 265 rt_ret_val2(p_TCB, 0x10/*osEventMessage*/, (U32)p_msg);
apatel336 0:c0dc3a76f3d4 266 #else
apatel336 0:c0dc3a76f3d4 267 *p_TCB->msg = p_msg;
apatel336 0:c0dc3a76f3d4 268 rt_ret_val (p_TCB, OS_R_MBX);
apatel336 0:c0dc3a76f3d4 269 #endif
apatel336 0:c0dc3a76f3d4 270 p_TCB->state = READY;
apatel336 0:c0dc3a76f3d4 271 rt_rmv_dly (p_TCB);
apatel336 0:c0dc3a76f3d4 272 rt_put_prio (&os_rdy, p_TCB);
apatel336 0:c0dc3a76f3d4 273 break;
apatel336 0:c0dc3a76f3d4 274 } else {
apatel336 0:c0dc3a76f3d4 275 /* No task is waiting for a message, store it to the mailbox queue */
apatel336 0:c0dc3a76f3d4 276 if (p_CB->count < p_CB->size) {
apatel336 0:c0dc3a76f3d4 277 p_CB->msg[p_CB->first] = p_msg;
apatel336 0:c0dc3a76f3d4 278 rt_inc (&p_CB->count);
apatel336 0:c0dc3a76f3d4 279 if (++p_CB->first == p_CB->size) {
apatel336 0:c0dc3a76f3d4 280 p_CB->first = 0;
apatel336 0:c0dc3a76f3d4 281 }
apatel336 0:c0dc3a76f3d4 282 }
apatel336 0:c0dc3a76f3d4 283 else {
apatel336 0:c0dc3a76f3d4 284 os_error (OS_ERR_MBX_OVF);
apatel336 0:c0dc3a76f3d4 285 }
apatel336 0:c0dc3a76f3d4 286 }
apatel336 0:c0dc3a76f3d4 287 }
apatel336 0:c0dc3a76f3d4 288
apatel336 0:c0dc3a76f3d4 289 /*----------------------------------------------------------------------------
apatel336 0:c0dc3a76f3d4 290 * end of file
apatel336 0:c0dc3a76f3d4 291 *---------------------------------------------------------------------------*/
apatel336 0:c0dc3a76f3d4 292