|
本帖最后由 Am-PCB 于 2013-1-31 17:14 编辑
这是发射子函数
void sending()
{
//Wait for releasing the push button
//while( PB == 0 );
//disable the receiver chain (but keep the XTAL running to have shorter TX on time!)
SpiWriteRegister(0x07, 0x01); //write 0x01 to the Operating Function Control 1 register
//turn on the LED to show the packet transmission
//TX_LED = 1;
/*SET THE CONTENT OF THE PACKET*/
//set the length of the payload to 8bytes
SpiWriteRegister(0x3E, 8); //write 8 to the Transmit Packet Length register
//fill the payload into the transmit FIFO
SpiWriteRegister(0x7F, 0x42); //write 0x42 ('B') to the FIFO Access register
SpiWriteRegister(0x7F, 0x55); //write 0x55 ('U') to the FIFO Access register
SpiWriteRegister(0x7F, 0x54); //write 0x54 ('T') to the FIFO Access register
SpiWriteRegister(0x7F, 0x54); //write 0x54 ('T') to the FIFO Access register
SpiWriteRegister(0x7F, 0x4F); //write 0x4F ('O') to the FIFO Access register
SpiWriteRegister(0x7F, 0x4E); //write 0x4E ('N') to the FIFO Access register
SpiWriteRegister(0x7F, 0x31); //write 0x31 ('1') to the FIFO Access register
SpiWriteRegister(0x7F, 0x0D); //write 0x0D (CR) to the FIFO Access register
//Disable all other interrupts and enable the packet sent interrupt only.
//This will be used for indicating the successfull packet transmission for the MCU
SpiWriteRegister(0x05, 0x04); //write 0x04 to the Interrupt Enable 1 register
SpiWriteRegister(0x06, 0x00); //write 0x03 to the Interrupt Enable 2 register
//Read interrupt status regsiters. It clear all pending interrupts and the nIRQ pin goes back to high.
ItStatus1 = SpiReadRegister(0x03); //read the Interrupt Status1 register
ItStatus2 = SpiReadRegister(0x04); //read the Interrupt Status2 register
/*enable transmitter*/
//The radio forms the packet and send it automatically.
SpiWriteRegister(0x07, 0x09); //write 0x09 to the Operating Function Control 1 register
/*wait for the packet sent interrupt*/
//The MCU just needs to wait for the 'ipksent' interrupt.
while(NIRQ == 1); // 就是这个地方程序跳不过去,请求指导。
led1();
//read interrupt status registers to release the interrupt flags
ItStatus1 = SpiReadRegister(0x03); //read the Interrupt Status1 register
ItStatus2 = SpiReadRegister(0x04); //read the Interrupt Status2 register
//wait a bit for showing the LED a bit longer
for(delay = 0; delay < 10000;delay++);
//for(delay = 0; delay < 60000;delay++);
//Enable two interrupts:
// a) one which shows that a valid packet received: 'ipkval'
// b) second shows if the packet received with incorrect CRC: 'icrcerror'
SpiWriteRegister(0x05, 0x03); //write 0x03 to the Interrupt Enable 1 register
SpiWriteRegister(0x06, 0x00); //write 0x00 to the Interrupt Enable 2 register
//read interrupt status registers to release all pending interrupts
ItStatus1 = SpiReadRegister(0x03); //read the Interrupt Status1 register
ItStatus2 = SpiReadRegister(0x04); //read the Interrupt Status2 register
SpiWriteRegister(0x07, 0x05);
}
|
阿莫论坛20周年了!感谢大家的支持与爱护!!
你熬了10碗粥,别人一桶水倒进去,淘走90碗,剩下10碗给你,你看似没亏,其实你那10碗已经没有之前的裹腹了,人家的一桶水换90碗,继续卖。说白了,通货膨胀就是,你的钱是挣来的,他的钱是印来的,掺和在一起,你的钱就贬值了。
|