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

📄 ia443x_demo.lst

📁 silicon wireless开发套件F920+Si4432原理图,源码
💻 LST
📖 第 1 页 / 共 5 页
字号:
 791   4                                      }                               
 792   3                                      DemoStates = sDemoRxStartReceive;
 793   3                                      return;
 794   3                              }
 795   2      
 796   2                              //check what kind of packet received
 797   2                              if( fWaitForPacketOrAck == PING_PACKET )                        
 798   2                              {//simple packet received -> send an ACK 
C51 COMPILER V8.00   IA443X_DEMO                                                           11/17/2008 10:50:31 PAGE 14  

 799   3                                      if( (RxTxBuffer[1] == MenuItems.name.self_id) && (RxTxBuffer[4] == PING_PACKET) )
 800   3                                      {//if the packet is sent to this device, then send ACK
 801   4                                              //report the result
 802   4      
 803   4                                              DemoPingReceived();
 804   4                                              //set ACK packet
 805   4                                              memcpy(&string[0],&RxTxBuffer[0],4);
 806   4                                              RxTxBuffer[0] = MenuItems.name.self_id;
 807   4                                              RxTxBuffer[1] = MenuItems.name.dest_id;
 808   4                                              RxTxBuffer[2] = string[2];
 809   4                                              RxTxBuffer[3] = string[3];
 810   4                                              RxTxBuffer[4] = ACK_PACKET;
 811   4                                              MessageBuffer.header = HeaderBuffer;
 812   4                                              MessageBuffer.length = 5;
 813   4                                              MessageBuffer.payload = &RxTxBuffer[0];
 814   4                                              //send the packet
 815   4                                              LED_TX = 1;
 816   4                                              RFTransmit(&MessageBuffer);
 817   4                                              //set flag ->ACK packet has sent
 818   4                                              fPacketSent = ACK_PACKET;
 819   4                                              //next state
 820   4                                              DemoStates = sDemoWaitForSendPacket;    
 821   4                                      }
 822   3                                      else
 823   3                                      {//the packet is not PING or sent to another device, so discard it -> goto RX state: 
 824   4                                       //wait for push button or another PING packet
 825   4                                              //goto RX state: wait for push button or another packet
 826   4                                              DemoStates = sDemoStartReceive;
 827   4                                      }
 828   3                                      return;
 829   3                              }
 830   2                              if( fWaitForPacketOrAck == ACK_PACKET )
 831   2                              {//a packet received, check the content of it
 832   3                                      if( (RxTxBuffer[1] == MenuItems.name.self_id) && (RxTxBuffer[4] == ACK_PACKET) )
 833   3                                      {//ACK packet received -> calculate the PER and print the result        
 834   4                                              //report the result
 835   4                                              DemoAckReceived(TRUE);
 836   4                                      }
 837   3                                      else
 838   3                                      {//no ACK received -> calculate the PER and print the result
 839   4                                              //report the result
 840   4                                              DemoAckReceived(FALSE);
 841   4                                      }
 842   3                                      //goto RX state: wait for push button or another PING packet
 843   3                                      DemoStates = sDemoStartReceive;
 844   3                                      return;
 845   3                              }
 846   2                      break;
 847   2      
 848   2                      case sDemoSendPing:
 849   2                              //set the payload of PING message
 850   2                              RxTxBuffer[0] = MenuItems.name.self_id;                         //source address field
 851   2                              RxTxBuffer[1] = MenuItems.name.dest_id;                         //destination address field
 852   2                              RxTxBuffer[2] = (uint8)(NmbrOfSentPackets >> 8);                //16bit packet ID (incremented after every
 853   2                              RxTxBuffer[3] = (uint8)(NmbrOfSentPackets & 0x00FF);    //              PING packet transmission
 854   2                              RxTxBuffer[4] = PING_PACKET;                                                                    //packet type field
 855   2                              //set the PING message
 856   2                              MessageBuffer.header = HeaderBuffer;
 857   2                              MessageBuffer.length = 5;                                                               
 858   2                              MessageBuffer.payload = &RxTxBuffer[0];
 859   2                              //start sending the PING packet
 860   2                              LED_TX = 1;
C51 COMPILER V8.00   IA443X_DEMO                                                           11/17/2008 10:50:31 PAGE 15  

 861   2                              RFTransmit(&MessageBuffer);
 862   2                              //set flag ->PING packet sent
 863   2                              fPacketSent = PING_PACKET;
 864   2                              //next state
 865   2                              DemoStates = sDemoWaitForSendPacket;
 866   2                      break;
 867   2      
 868   2                      case sDemoWaitForSendPacket:
 869   2                              if( fChangeDemoStates == TRUE )
 870   2                              {
 871   3                                      fChangeDemoStates = FALSE;
 872   3                                      DemoStates = NewDemoStates;
 873   3                              }
 874   2      
 875   2                      break;
 876   2      
 877   2                      case sDemoPacketSent:
 878   2                              //check what kind of packet has sent
 879   2                              LED_TX = 0;
 880   2                              if( MenuItems.name.demo_mode == DEMO_MODE_TX )
 881   2                              {
 882   3                                      //stop the RF stack
 883   3                                      RFIdle();
 884   3                                      MenuReportSentPackets( NmbrOfSentPackets );
 885   3                                      DemoStates = sDemoTxStartTransmit;
 886   3                                      return;
 887   3                              }
 888   2                              if( fPacketSent == PING_PACKET )
 889   2                              {//PING packet sent -> goto RX state immediatelly: wait for ACK
 890   3                                      //stop the RF stack
 891   3                                      RFIdle();
 892   3                                      //set flags -> wait for simple packet and not for ACK
 893   3                                      fWaitForPacketOrAck = ACK_PACKET;
 894   3                                      //start receiving
 895   3                                      RFReceive(&RxCommand);
 896   3                                      //start timeout (~300ms)
 897   3                                      LongDelay = 3;
 898   3                                      DemoTimer.U16 = 65530;
 899   3                                      StartTmr3(TMR3_12, DemoTimer, FALSE);
 900   3                                      //next state
 901   3                                      DemoStates = sDemoWaitForAck;
 902   3                              }
 903   2                              if( fPacketSent == ACK_PACKET )
 904   2                              {//ACK packet sent -> goto RX state: wait for push button or another PING packet
 905   3                                      //stop the RF stack
 906   3                                      RFIdle();
 907   3                                      //report that ACK sent correctly
 908   3                                      DemoAckSent(TRUE);      
 909   3                                      //next state
 910   3                                      DemoStates = sDemoStartReceive;
 911   3                              }
 912   2                      break;
 913   2                      
 914   2                      case sDemoTxError:
 915   2                              //error occured during packet transmission
 916   2                              LED_TX = 0;
 917   2                              if( fPacketSent == PING_PACKET)
 918   2                              {//ping packet didn't send, because error occured
 919   3                                      PerformMenu( sMenuPingTxError );
 920   3                                      if( MenuItems.name.demo_mode == DEMO_MODE_TX )
 921   3                                      {
 922   4                                              RFIdle();
C51 COMPILER V8.00   IA443X_DEMO                                                           11/17/2008 10:50:31 PAGE 16  

 923   4                                              DemoStates = sDemoTxStartTransmit;
 924   4                                              return;
 925   4                                      }
 926   3                                      else
 927   3                                      {
 928   4                                              DemoStates = sDemoStartReceive;
 929   4                                      }
 930   3                              }
 931   2                              if( fPacketSent == ACK_PACKET ) 
 932   2                              {//ACK packet didn't send, because error occured
 933   3                              }
 934   2                      break;
 935   2      
 936   2                      case sDemoWaitForAck:
 937   2                              if( fChangeDemoStates == TRUE )
 938   2                              {
 939   3                                      fChangeDemoStates = FALSE;
 940   3                                      DemoStates = NewDemoStates;
 941   3                                      return;
 942   3                              }
 943   2                              if( Tmr3Expired() == TRUE )
 944   2                              {//ACK didn't receive within timeout
 945   3                                      if( --LongDelay == 0 )
 946   3                                      {
 947   4                                              //stop timer & RF Stack
 948   4                                              StopTmr3();
 949   4                                              RFIdle();
 950   4                                              //report that timeout occured and ACK didn't receive
 951   4                                              DemoAckReceived(FALSE);
 952   4                                              //goto RX state: wait for push button or another PING packet
 953   4                                              DemoStates = sDemoStartReceive;
 954   4                                              return;
 955   4                                      }
 956   3                                      else
 957   3                                      {//restart timer
 958   4                                              DemoTimer.U16 = 65530;
 959   4                                              StartTmr3(TMR3_12, DemoTimer, FALSE);
 960   4                                      }
 961   3                              }
 962   2                      break;          
 963   2      
 964   2                      case sDemoDoNothing:
 965   2                      break;
 966   2      
 967   2                      default:
 968   2                      break;
 969   2              }
 970   1      }
 971          
 972          /*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 973            +
 974            + FUNCTION NAME:  void DemoAckSent(uint8 success)
 975            +
 976            + DESCRIPTION:    the function is called if the ACK packet sent correctly
 977            +                                     or there was a problem to send it. It reports the result
 978            +                                     on the LCD and to the UART.
 979            +
 980            +     INPUT:                  success - status of the ACK transmition (TRUE/FALSE)
 981            +
 982            + RETURN:         None
 983            +
 984            + NOTES:          
C51 COMPILER V8.00   IA443X_DEMO                                                           11/17/2008 10:50:31 PAGE 17  

 985            +
 986            ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

⌨️ 快捷键说明

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