131 lines
3.5 KiB
C
Raw Normal View History

2019-10-24 17:37:35 +08:00
/*
*********************************************************************************************************
*
2019-10-24 18:03:30 +08:00
* :
* : bsp_msg.c
* : V1.0
* :
2019-10-24 17:37:35 +08:00
*
2019-10-24 18:03:30 +08:00
* :
*
* V1.0 2015-03-27 armfly
2019-10-24 17:37:35 +08:00
*
2019-10-24 18:03:30 +08:00
* Copyright (C), 2014-2015, www.armfly.com
2019-10-24 17:37:35 +08:00
*
*********************************************************************************************************
*/
#include "bsp.h"
MSG_FIFO_T g_tMsg;
/*
*********************************************************************************************************
2019-10-24 18:03:30 +08:00
* : bsp_InitMsg
* :
* :
* :
2019-10-24 17:37:35 +08:00
*********************************************************************************************************
*/
void bsp_InitMsg(void)
{
bsp_ClearMsg();
}
/*
*********************************************************************************************************
2019-10-24 18:03:30 +08:00
* : bsp_PutMsg
* : 1FIFO缓冲区
* : _MsgCode :
* _pMsgParam : . 0
* :
2019-10-24 17:37:35 +08:00
*********************************************************************************************************
*/
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;
2019-10-24 18:03:30 +08:00
if (++g_tMsg.Write >= MSG_FIFO_SIZE)
2019-10-24 17:37:35 +08:00
{
g_tMsg.Write = 0;
}
}
/*
*********************************************************************************************************
2019-10-24 18:03:30 +08:00
* : bsp_GetMsg
* : FIFO缓冲区读取一个键值
* :
* : 0 1
2019-10-24 17:37:35 +08:00
*********************************************************************************************************
*/
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;
}
2019-10-24 18:03:30 +08:00
2019-10-24 17:37:35 +08:00
_pMsg->MsgCode = p->MsgCode;
_pMsg->MsgParam = p->MsgParam;
return 1;
}
}
/*
*********************************************************************************************************
2019-10-24 18:03:30 +08:00
* : bsp_GetMsg2
* : FIFO缓冲区读取一个键值使22访
* :
* : 0 1
2019-10-24 17:37:35 +08:00
*********************************************************************************************************
*/
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;
}
2019-10-24 18:03:30 +08:00
2019-10-24 17:37:35 +08:00
_pMsg->MsgCode = p->MsgCode;
_pMsg->MsgParam = p->MsgParam;
return 1;
}
}
/*
*********************************************************************************************************
2019-10-24 18:03:30 +08:00
* : bsp_ClearMsg
* : FIFO缓冲区
*
* :
2019-10-24 17:37:35 +08:00
*********************************************************************************************************
*/
void bsp_ClearMsg(void)
{
g_tMsg.Read = g_tMsg.Write;
}
2019-10-24 18:03:30 +08:00
/***************************** 安富莱电子 www.armfly.com (END OF FILE) *********************************/