?? mbuf.c
字號:
/******************************************************************************
*
* (c) Freescale Inc. 2004 All rights reserved
*
* File Name : mBuf.c
* Description : Implementation of a buffering scheme based on mBUFs
*
* Version : 1.0
* Date : Jun/22/2004
*
******************************************************************************/
#include "mBuf.h"
#define MBUFS_NUM 2
MBUF mBufs [MBUFS_NUM]; /* The static array of MBufs buffers! */
MBUF mBufTx; /* MBUF buffer for transmissions */
/*****************************************************************************
* mBufInit ()
*
*****************************************************************************/
void mBufInit (void)
{
mBufs[0].status = 0x00;
mBufs[0].len = 0x0000;
mBufs[0].data = (void *)0x0000;
mBufs[0].working_ptr = (void *)0x0000;
mBufs[1].status = 0x00;
mBufs[1].len = 0x0000;
mBufs[1].data = (void *)0x0000;
mBufs[1].working_ptr = (void *)0x0000;
mBufTx.status = 0x00;
mBufTx.len = 0x00;
mBufTx.data = (void *)0x0000;
mBufTx.working_ptr = (void *)0x0000;
}
/******************************************************************************
*
*
******************************************************************************/
INT16 mENQUEUE (MBUF *m)
{
/* OS_ENTER_CRITICAL(); */
if (!(mBufs[0].status & MBUF_NOTEMPTY))
{
mBufs[0].data = m->data;
mBufs[0].working_ptr = m->working_ptr;
mBufs[0].len = m->len;
mBufs[0].status = m->status;
return 0;
}
if (!(mBufs[1].status & MBUF_NOTEMPTY))
{
mBufs[1].data = m->data;
mBufs[1].working_ptr = m->working_ptr;
mBufs[1].len = m->len;
mBufs[1].status = m->status;
return 0;
}
/* OS_EXIT_CRITICAL(); */
return (~0);
}
/******************************************************************************
*
*
******************************************************************************/
MBUF* mDEQUEUE (void)
{
/* OS_ENTER_CRITICAL(); */
if (mBufs[0].status & MBUF_NOTEMPTY)
{
return (MBUF *)&mBufs[0];
}
if (mBufs[1].status & MBUF_NOTEMPTY)
{
return (MBUF *)&mBufs[1];
}
return (MBUF *)0;
/* OS_EXIT_CRITICAL(); */
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -