基于STC89C52的控制NRF24L01的程序,这个是发送程序,改一下,可以作为接收程序.doc
文本预览下载声明
这是init.c文件
#include comm.h
#define uchar unsigned char
#define uint unsigned int
uchar xdata date_time[6];
uchar xdata i2c_buf[8];
uchar xdata result;
uchar xdata re_buf[16];
uchar xdata re_cnt;
uchar check_sum;
uchar flag_init;
uchar xdata flag_end;
uchar xdata flag_uart_busy;
uint r_cnt;
uchar flag_ex0_isr;
//uchar xdata year ,month ,day0;
uchar xdata c_year,c_month,c_day0;
uchar xdata tx_buf1[20];
uchar xdata tx_buf2[20];
uchar xdata tx_buf3[20];
uchar xdata tx_buf4[20];
uint run_cnt;
/*
================================================================================
* Name : DelayMs( )
* Description : delay some times
* Input : None
* Output : None
* Note : None
================================================================================
*/
void init_uart(void)
{
uchar i;
TMOD|=0x20;
TH1=0Xfd;
TL1=0Xfd;
SCON=0X50;
TR1=1;
ES=1;
IT0 =1; //低电平触发外部中断
EX0 =1; //允许外部中断
//-----------------------------------------
for(i=0;i20;i++)
{
tx_buf1[i]=1;
tx_buf2[i]=2;
tx_buf3[i]=2;
tx_buf4[i]=2;
}
}
/*
================================================================================
* Name : DelayMs( )
* Description : delay some times
* Input : None
* Output : None
* Note : None
================================================================================
*/
////////////////////////////////////////////////////////////////////////////////////////////////
void send_one_byte(unsigned char tad )
{
uchar temp;
if(ES==1)
{
ES=0;
temp=1;
}
TI=0;
SBUF=tad; //发送数据 os_wait2(K_TMO,1);
while(TI==0);
TI=0;
flag_uart_busy=1;
if(temp==1)
{
ES=1;
}
}
/*
================================================================================
* Name : DelayMs( )
* Description : delay some times
* Input : None
* Output : None
* Note : None
================================================================================
*/
void job0(void) // _TASK_ 0
{
uchar temp;
显示全部