⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 basicdriver_signal_strength.c

📁 这是一个自动测量zigbee发射信号强度的原代码,可以直接运行,不用修改,测试已成功
💻 C
📖 第 1 页 / 共 5 页
字号:

                        PHYSetShortRAMAddr(WRITE_TXNMTRIG,0b00000001);  //transmit packet without ACK requested 

                        blah++;
                        if((blah % 100) == 0 )
                        {
                            for(j = 0; j < 0xFFFF; j++) {}
                        }
                        if(blah == 1000)
                        {
                            break;
                        }
                    }
                }
                RA1 = 0;
                StartSendingPER = 0;
                c("Completed sending 1000 packets\r\n");
                if( UseExternal)
                {
                    PHYSetShortRAMAddr(WRITE_GPIO, 0b00001100); //RX
                    Delay100TCYx(4);
                    c("Using external LNA\r\n");   
                }
                goto MRF24J40_SubMenu;                       
            }  
        }
    }
    
MRF24J40_NewOption:        
    input = ConsoleGet();
    ConsolePut(input);
    if(PrintMenus)
    {
        nl();
    }

    switch(input)
    {
        case '1':
   //     case '1':
            if( PrintMenus )
            {
                PrintHeader((rom char *)" ");
//                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(">>");
                
                
                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;
             
             
             
            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':

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -