You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

132 lines
3.2 KiB

5 months ago
/*
*********************************************************************************************************
*
* ģ : Ϣģ
* ļ : bsp_msg.c
* : V1.0
* ˵ : Ϣơ
*
* ޸ļ¼ :
* ˵
* V1.0 2015-03-27 armfly ʽ
*
* Copyright (C), 2014-2015, www.armfly.com
*
*********************************************************************************************************
*/
#include "bsp_msg.h"
MSG_FIFO_T g_tMsg;
/*
*********************************************************************************************************
* : bsp_InitMsg
* ˵: ʼϢ
* :
* ֵ:
*********************************************************************************************************
*/
void bsp_InitMsg(void)
{
bsp_ClearMsg();
}
/*
*********************************************************************************************************
* : bsp_PutMsg
* ˵: 1ϢѹϢFIFO
* : _MsgCode : Ϣ
* _pMsgParam : ϢһָijضĽ. 0
* ֵ:
*********************************************************************************************************
*/
void bsp_PutMsg(uint16_t _MsgCode, uint32_t _MsgParam)
{
g_tMsg.Buf[g_tMsg.Write].MsgCode = _MsgCode;
g_tMsg.Buf[g_tMsg.Write].MsgParam = _MsgParam;
if (++g_tMsg.Write >= MSG_FIFO_SIZE)
{
g_tMsg.Write = 0;
}
}
/*
*********************************************************************************************************
* : bsp_GetMsg
* ˵: ϢFIFOȡһֵ
* :
* ֵ: 0 ʾϢ 1ʾϢ
*********************************************************************************************************
*/
uint8_t bsp_GetMsg(MSG_T *_pMsg)
{
MSG_T *p;
if (g_tMsg.Read == g_tMsg.Write)
{
return 0;
}
else
{
p = &g_tMsg.Buf[g_tMsg.Read];
if (++g_tMsg.Read >= MSG_FIFO_SIZE)
{
g_tMsg.Read = 0;
}
_pMsg->MsgCode = p->MsgCode;
_pMsg->MsgParam = p->MsgParam;
return 1;
}
}
/*
*********************************************************************************************************
* : bsp_GetMsg2
* ˵: ϢFIFOȡһֵʹõ2ָ2ͬʱϢ
* :
* ֵ: 0 ʾϢ 1ʾϢ
*********************************************************************************************************
*/
uint8_t bsp_GetMsg2(MSG_T *_pMsg)
{
MSG_T *p;
if (g_tMsg.Read2 == g_tMsg.Write)
{
return 0;
}
else
{
p = &g_tMsg.Buf[g_tMsg.Read2];
if (++g_tMsg.Read2 >= MSG_FIFO_SIZE)
{
g_tMsg.Read2 = 0;
}
_pMsg->MsgCode = p->MsgCode;
_pMsg->MsgParam = p->MsgParam;
return 1;
}
}
/*
*********************************************************************************************************
* : bsp_ClearMsg
* ˵: ϢFIFO
* Σ
* ֵ:
*********************************************************************************************************
*/
void bsp_ClearMsg(void)
{
g_tMsg.Read = g_tMsg.Write;
}
/***************************** ���������� www.armfly.com (END OF FILE) *********************************/