分享51单片机调试cc1100完整程序
#include <reg52.h>#include <intrins.h>
#include "CC1100.h"
#include"uart.h"
void Delay(unsigned int s)
{
unsigned int i;
for(i=0; i<s; i++);
for(i=0; i<s; i++);
}
void main(void)
{
INT8U leng =8;// 预计接受8 bytes
INT8U tf =0;
INT8U TxBuf={0}; // 8字节, 如果需要更长的数据包,请正确设置
INT8U RxBuf={0};
INT8U i=0;
CpuInit();
UART_Init();
UART_Send_Str("mcu初始化完毕...\n");
POWER_UP_RESET_CC1100();
halRfWriteRfSettings();//配置cc1100寄存器
halSpiWriteBurstReg(CCxxx0_PATABLE, PaTabel, 8);
UART_Send_Str("rfcc1100初始化完毕...\n");
TxBuf = '0' ;
TxBuf = '0' ;
halRfSendPacket(TxBuf,8); // Transmit Tx buffer data
Delay(6000);
while(1)
{
setRxMode();
if(KEY1 ==0 )
{
while(KEY1 ==0);
TxBuf = 'o' ;
tf = 1 ;
}
if(KEY2 ==0 )
{
while(KEY2 ==0);
TxBuf = 'k' ;
tf = 1 ;
}
if (tf==1)
{
halRfSendPacket(TxBuf,8); // Transmit Tx buffer data
TxBuf = 0xff;//清除
TxBuf = 0xff;
tf=0;
Delay(500);
UART_Send_Str("按键按下,已发送.....\n");
setRxMode();
}
if(halRfReceivePacket(RxBuf,&leng))
{
for(i=0;i<8;i++)
{
UART_Send_Byte(RxBuf);
}
UART_Send_Str("成功接收到数据.....\n");
}
}
} 点击此处下载 ourdev_674469VF9NFH.rar(文件大小:438K) (原文件名:51test1100.rar)
页:
[1]