金牌会员
- 积分
- 1986
- 威望
- 1222
- 贡献
- 504
- 兑换币
- 410
- 注册时间
- 2013-10-4
- 在线时间
- 130 小时
|
刘旺小盆友 发表于 2014-4-26 19:07
大哥,# include "common.h"???
头文件“sbq.h”/*********************************************************************/
# ifndef _SBQ_H_
# define _SBQ_H_
//extern s16 pulse;
unsigned short CRC_CHECK(unsigned char *Buf, unsigned char CRC_CNT);
void OutPut_Data(void);
void sbq(void);
#endif
/********************************************************************/
运行文件“sbq.c”
/********************************************************************/
/*************************虚拟示波器底层驱动*********************************/
# include "common.h" //根据你的底层需要,看是否需要添加
# include "uart.h"
# include "sbq.h"
extern u16 ADresult;
float OutData[4] = { 0 };
/*配合串口示波器的校验协议*/
unsigned short CRC_CHECK(unsigned char *Buf, unsigned char CRC_CNT)
{
unsigned short CRC_Temp;
unsigned char i,j;
CRC_Temp = 0xffff;
for (i=0;i<CRC_CNT; i++){
CRC_Temp ^= Buf;
for (j=0;j<8;j++) {
if (CRC_Temp & 0x01)
CRC_Temp = (CRC_Temp >>1 ) ^ 0xa001;
else
CRC_Temp = CRC_Temp >> 1;
}
}
return(CRC_Temp);
}
/* 配合串口示波器的输出协议*/
void OutPut_Data(void)
{
int temp[4] = {0};
unsigned int temp1[4] = {0};
unsigned char databuf[10] = {0};
unsigned char i;
unsigned short CRC16 = 0;
for(i=0;i<4;i++)
{
temp = (int)OutData;
temp1 = (unsigned int)temp;
}
for(i=0;i<4;i++)
{
databuf[i*2] = (unsigned char)(temp1%256);
databuf[i*2+1] = (unsigned char)(temp1/256);
}
CRC16 = CRC_CHECK(databuf,8);
databuf[8] = CRC16%256;
databuf[9] = CRC16/256;
for(i=0;i<10;i++)
uart_putchar(UART3,databuf);
}
void sbq(void)
{
OutData[0]=ADresult;
OutData[1]=100;
// OutData[2]=(float)475;
// OutData[3]=(float)pulse ;
OutPut_Data();
}
/********************************************************************/
|
|