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
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) *********************************/
|