Professional Documents
Culture Documents
4GHz band
//Data is packed into RAWDATA reading for sending out of USB
void nRFscanChannels(void) {
unsigned char curChannel;
unsigned char numberOfChannels = 126; //there ae 126, 0 to 125
unsigned int i,j;
unsigned char curConfig;
unsigned char curCE;
//get current values that are changed so they can be restored later
curConfig = nrf24l01_get_config();
curCE = nrf24l01_ce_pin_active();
curChannel = nrf24l01_get_rf_ch();
//clear RAWDATA
for (i = 0; i < RAWDATASIZE; i++){
RAWDATA[i] = 0;
}
nrf24l01_clear_ce();
for (j = 0; j < 40; j++) {
USBDeviceTasks(); // USB Tasks
BlinkUSBStatus();
}
}
//restore values
nrf24l01_set_config(curConfig);
nrf24l01_set_rf_ch(curChannel);
if(curCE){
nrf24l01_set_ce();
} else
{nrf24l01_clear_ce();
}
Delay10uS(20); //may not be needed
}// scanning all channels in the 2.4GHz band
//Data is packed into RAWDATA reading for sending out of USB
void nRFscanChannels(void) {
unsigned char curChannel;
unsigned char numberOfChannels = 126; //there ae 126, 0 to 125
unsigned int i,j;
unsigned char curConfig;
unsigned char curCE;
//get current values that are changed so they can be restored later
curConfig = nrf24l01_get_config();
curCE = nrf24l01_ce_pin_active();
curChannel = nrf24l01_get_rf_ch();
//clear RAWDATA
for (i = 0; i < RAWDATASIZE; i++){
RAWDATA[i] = 0;
}
nrf24l01_clear_ce();
for (j = 0; j < 40; j++) {
USBDeviceTasks(); // USB Tasks
BlinkUSBStatus();
}
}
//restore values
nrf24l01_set_config(curConfig);
nrf24l01_set_rf_ch(curChannel);
if(curCE){
nrf24l01_set_ce();
} else
{nrf24l01_clear_ce();
}
Delay10uS(20); //may not be needed
}