/***********************************************************************************************************
/*函数:void nRF24L01_TxPacket(unsigned char * tx_buf)
/*功能:发送 tx_buf中数据
/**********************************************************************************************************/
void nRF24L01_TxPacket(unsigned char * tx_buf)
{
CE=0; //StandBy I模式
SPI_Write_Buf(WRITE_REG + RX_ADDR_P0, TX_ADDRESS, TX_ADR_WIDTH); // 装载接收端地址
SPI_Write_Buf(WR_TX_PLOAD, tx_buf, TX_PLOAD_WIDTH); // 装载数据
SPI_RW_Reg(WRITE_REG + CONFIG, 0x0e); // IRQ收发完成中断响应,16位CRC,主发送
CE=1; //置高CE,激发数据发送
inerDelay_us(10);
}
int_0(void) interrupt 0
{delay_1ms(15);
if(inter_0==0)
{uchar n=0,m=0,temp;
uchar scan[4]={0xfe,0xfd,0xfb,0xf7};
uchar table[4][4]={0x7e,0xbe,0xde,0xee,0x7d,0xbd,0xdd,0xed,0x7b,0xbb,0xdb,0xeb,0x77,0xb7,0xd7,0xe7};
uchar num[4][4]={12,1,4,7,0,2,5,8,13,3,6,9,11,10,15,14};
while(n<4)
{P1=scan[n];temp=P1;m=0;
while(m<4)
{if(temp==table[n][m])
goto next;
else
m++;
}
n++;
}
next: key=num[n][m];
mark=1;
}
P1=0XF0;
}
|