📄 basicdriver_1.c
字号:
}
}
MRF24J40_NewOption:
input = ConsoleGet();
ConsolePut(input);
if(PrintMenus)
{
nl();
}
switch(input)
{
case 'a':
case 'A':
if( PrintMenus )
{
PrintHeader((rom char *)"Settings");
c(" (a) Set the Operating Channel\r\n");
// c(" (b) Set the Output Power\r\n");
// c(" (c) Set Hardware CRC checking\r\n");
// c(" (d) Configure External Power Amplifier and Low Noise Amplifier\r\n");
// c(" (e) Set Transmission Delay Between Packets\r\n");
// c(" (f) Set the Number of Averaged RSSI Samples\r\n");
// c(" (g) Turbo Mode Configuration\r\n");
c(">>");
}
input = ConsoleInput();
switch(input)
{
case 'a':
case 'A':
MRF24J40_Channel_submenu:
if(PrintMenus)
{
PrintHeader((rom char *)"Set the Operating Channel");
c(" (a) Channel 11\r\n");
c(" (b) Channel 12\r\n");
c(" (c) Channel 13\r\n");
c(" (d) Channel 14\r\n");
c(" (e) Channel 15\r\n");
c(" (f) Channel 16\r\n");
c(" (g) Channel 17\r\n");
c(" (h) Channel 18\r\n");
c(" (i) Channel 19\r\n");
c(" (j) Channel 20\r\n");
c(" (k) Channel 21\r\n");
c(" (l) Channel 22\r\n");
c(" (m) Channel 23\r\n");
c(" (n) Channel 24\r\n");
c(" (o) Channel 25\r\n");
c(" (p) Channel 26\r\n");
c(" (~) Reset Device\r\n");
c(">>");
}
input = ConsoleInput();
if((input<0x61) || (input>0x70))
{
if(input == '~')
{
if(PrintMenus)
{
c("Device Reset\r\n");
}
{WORD i; for(i=0;i<30000;i++){}}
Reset();
}
if(PrintMenus)
{
c("Incorrect Menu Choice: ");
ConsolePut(input);
nl();nl();
}
goto MRF24J40_Channel_submenu;
}
else
{
BYTE var;
var = ((input-0x61)<<4);
PrintChar(var);
SetChannel(var);
if(PrintMenus)
{
c("Channel successfully changed\r\n");
PrintChar(var);
}
goto MRF24J40_SubMenu;
}
break;
case 'b':
case 'B':
MRF24J40_output_power_submenu:
if(PrintMenus)
{
PrintHeader((rom char *)"Set Output Power");
c(" (a) 0 dB\r\n");
c(" (b) -1.25 dB\r\n");
c(" (c) -2.5 dB\r\n");
c(" (d) -3.75 dB\r\n");
c(" (e) -5 dB\r\n");
c(" (f) -6.25 dB\r\n");
c(" (g) -7.5 dB\r\n");
c(" (h) -8.75 dB\r\n");
c(" ...\r\n");
c(" (z) -31.25 dB\r\n");
c(" (0) -32.5 dB\r\n");
c(" (1) -33.75 dB\r\n");
c(" (2) -35 dB\r\n");
c(" (3) -36.25 dB\r\n");
c(" (4) -37.5 dB\r\n");
c(" (5) -38.75 dB\r\n");
c(">>");
}
input = ConsoleInput();
if((input>=0x61) && (input<=0x7A))
{
power = ((input-0x61)<<3);
PHYSetLongRAMAddr(RFCTRL3,power);
if(PrintMenus)
{
c("Output power successfully changed\r\n");
}
goto MRF24J40_SubMenu;
}
else if((input>=0x30) && (input<=0x35))
{
power = ((input-0x30+0x1A)<<3);
PHYSetLongRAMAddr(RFCTRL3,power);
if(PrintMenus)
{
c("Output power successfully changed\r\n");
}
goto MRF24J40_SubMenu;
}
else
{
if(input == '~')
{
if(PrintMenus)
{
c("Device Reset\r\n");
}
{WORD i; for(i=0;i<30000;i++){}}
Reset();
}
if(PrintMenus)
{
c("Incorrect Menu Choice: ");
ConsolePut(input);
nl();nl();
}
goto MRF24J40_output_power_submenu;
}
break;
case 'c':
case 'C':
MRF24J40_CRC_Checking_submenu:
if( PrintMenus )
{
PrintHeader((rom char *)"Hardware CRC checking");
c(" (a) Disable CRC Checking\r\n");
c(" (b) Enable CRC Checking\r\n");
c(">>");
}
input = ConsoleInput();
switch(input)
{
case 'a':
PHYSetShortRAMAddr(WRITE_RXMCR,0xA3);
AutoCRC = FALSE;
if(PrintMenus)
{
c("Automatic CRC is disabled\r\n");
}
break;
case 'b':
PHYSetShortRAMAddr(WRITE_RXMCR,0x23);
AutoCRC = TRUE;
if(PrintMenus)
{
c("Automatic CRC is enabled\r\n");
}
break;
default:
c("Incorrect Menu Choice: ");
ConsolePut(input);
goto MRF24J40_CRC_Checking_submenu;
}
goto MRF24J40_SubMenu;
case 'd':
case 'D':
PHYSetShortRAMAddr(WRITE_GPIO, 0b00001100); //RX
PHYSetShortRAMAddr(WRITE_GPIODIR, 0b00001111);
UseExternal = TRUE;
if(PrintMenus)
{
c("Set device to use External LNA/PA\r\nDevice reset required to remove this feature.\r\n\r\n");
}
PHYSetShortRAMAddr(WRITE_GPIO, 0b00001100); //RX
Delay100TCYx(4);
c("Using external LNA\r\n");
goto MRF24J40_SubMenu;
case 'e':
case 'E':
MRF24J40_Transmission_Delay_submenu:
if(PrintMenus)
{
PrintHeader((rom char *)"Transmission Delay Between Packets");
c(" (0) no delay\r\n");
c(" (1) 1 unit of delay\r\n");
c(" (2) 4 units of delay\r\n");
c(" ...\r\n");
c(" (9) 81 units of delay\r\n");
c(" (a) 100 units of delay\r\n");
c(" (b) 121 units of delay\r\n");
c(" ...\r\n");
c(" (z) 1225 units of delay (approx 1 sec)\r\n");
c(">>");
}
input = ConsoleInput();
if(input<0x30)
{
if(PrintMenus)
{
c("Incorrect Menu Choice: ");
ConsolePut(input);
nl(); nl();
}
goto MRF24J40_Transmission_Delay_submenu;
}
input -= 0x30;
if(input>9)
{
input-=0x21;
}
packetDelay = input;
goto MRF24J40_SubMenu;
case 'f':
case 'F':
if( PrintMenus )
{
PrintHeader((rom char *)"RSSI Sample Number");
c(" Please enter 2 decimal digits (1-49)\r\n");
c(" i.e. - enter 05 for 5 samples\r\n");
c(">>");
}
_sampleRSSILoop1:
numRSSISamples = 0;
while(!ConsoleIsGetReady()){}
input = ConsoleGet();
switch(input)
{
case '4':
numRSSISamples += 10;
//fall through
case '3':
numRSSISamples += 10;
//fall through
case '2':
numRSSISamples += 10;
//fall through
case '1':
numRSSISamples += 10;
//fall through
case '0':
break;
default:
goto _sampleRSSILoop1;
}
ConsolePut(input);
_sampleRSSILoop2:
while(!ConsoleIsGetReady()){}
input = ConsoleGet();
switch(input)
{
case '9':
numRSSISamples += 1;
//fall through
case '8':
numRSSISamples += 1;
//fall through
case '7':
numRSSISamples += 1;
//fall through
case '6':
numRSSISamples += 1;
//fall through
case '5':
numRSSISamples += 1;
//fall through
case '4':
numRSSISamples += 1;
//fall through
case '3':
numRSSISamples += 1;
//fall through
case '2':
numRSSISamples += 1;
//fall through
case '1':
numRSSISamples += 1;
//fall through
case '0':
break;
default:
goto _sampleRSSILoop2;
}
ConsolePut(input);
if(numRSSISamples == 0)
{
if(PrintMenus)
{
c("\r\n\r\ndivide by 0 not allowed. setting number of samples to 1.\r\n");
}
numRSSISamples = 1;
}
c("\r\n\r\n");
goto MRF24J40_SubMenu;
case 'g':
case 'G':
MRF24J40_Turbo_Mode_submenu:
if( PrintMenus )
{
PrintHeader((rom char *)"Turbo Mode");
c(" (a) Enable Turbo Mode\r\n");
c(" (b) Disable Turbo Mode\r\n");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -