Final 350 project

Dependencies:   uzair Camera_LS_Y201 F7_Ethernet LCD_DISCO_F746NG NetworkAPI SDFileSystem mbed

Committer:
shoaib_ahmed
Date:
Mon Jul 31 09:16:35 2017 +0000
Revision:
0:791a779d6220
final project;

Who changed what in which revision?

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