📄 link.c
字号:
/*******************************************************************************************************
* *
* ********** *
* ************ *
* *** *** *
* *** +++ *** *
* *** + + *** This program lets the user test a simple rf link *
* *** + *
* *** + + *** *
* *** +++ *** Link.c *
* *** *** *
* ************ *
* ********** *
* *
*******************************************************************************************************
* Compiler: Keil C51 V7.50 *
* Target platform: Chipcon CCxxx0 (Silabs F320) *
* Author: SNA *
*******************************************************************************************************
* Revision history: See end of file *
******************************************************************************************************/
#include <Chipcon\srf04\regssrf04.h>
#include <Chipcon\srf04\halsrf04.h>
#include <Chipcon\srf04\ebsrf04.h>
#include <Link.h>
#include <LCD.h>
#include <stdio.h>
//-------------------------------------------------------------------------------------------------------
// Global Variables
BYTE xdata rxBuffer[11] ;
float re;
//-------------------------------------------------------------------------------------------------------
//-------------------------------------------------------------------------------------------------------
// void main(void)
//
// DESCRIPTION:
// This program shows how how to set up a link between two units.
//----------------------------------------------------------------------------------------------------
void main (void) {
unsigned char i;
UINT8 length;
char buf[13]=" ";
char Flag;
#ifdef STAND_ALONE
// Select the Internal Oscillator as Multiplier input source and disable the watchdog timer
// SYSCLK = 4X Clock Multiplier / 2
CLOCK_INIT();
#endif
// Set up the crossbar and I/O ports to communicate with the SmartRF04EB peripherals
IO_PORT_INIT();
halWait(50000);
SPI_INIT(SCLK_6_MHZ);
POWER_UP_RESET_CCxxx0();
halRfWriteRfSettings(&rfSettings);
halSpiWriteReg(CCxxx0_PATABLE, paTable);
halWait(30000);
LcmInit( );
LcmClearTXT();
LcmClearBMP();
PutBMP(logo);
halWait(500000);
halWait(500000);
Delay(100000);
LcmClearBMP();
PutBMP(bmp1);
// PutStr(0,2,"颈椎测量仪");
//PutStr(1,6,"mm");
// Infinite loop
while (TRUE) {
P_LED1=0;
length = sizeof(rxBuffer);
if (halRfReceivePacket(rxBuffer, &length)) {
//display rdata 计算算法
if (rxBuffer[3]>=0xf0)//判断符号位,为正,取反
{
rxBuffer[1]=~rxBuffer[1];
rxBuffer[2]=~rxBuffer[2];
rxBuffer[3]=~rxBuffer[3];
Flag=' ';
}
else
{
Flag='-';
}
P_LED1=1;
re=(rxBuffer[1]+rxBuffer[2]*256+rxBuffer[3]*65536)*0.00124015;
//display
for (i=5;i<13;i++) buf[i]=' ';
//i=sprintf (buf, "CH%c: %1.2f",rxBuffer[0]+0x30,re);
i=sprintf (buf, " %1.2f",re*0.1);
buf[0]=Flag;
buf[i]=' ';
buf[i+1]='\0';
//ReadStringUART(buf,7);
PutStr(3,4,buf);
halWait(5000);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -