this a test code modified to cr20A

Dependencies:   fsl_phy_mcr20a fsl_smac mbed-rtos mbed

Fork of mcr20_connectivity_test by Freescale

Committer:
andreikovacs
Date:
Fri Jul 24 11:57:20 2015 +0000
Revision:
2:aaffc5d91884
Parent:
1:1eb1eccc81c2
Child:
3:b9e209eca377
Added gSmacSupported to allow SMAC state machine reset.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
andreikovacs 0:4eb2240dbd22 1 /*!
andreikovacs 0:4eb2240dbd22 2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
andreikovacs 0:4eb2240dbd22 3 * All rights reserved.
andreikovacs 0:4eb2240dbd22 4 *
andreikovacs 0:4eb2240dbd22 5 * \file Connectivity_TestApp.c
andreikovacs 0:4eb2240dbd22 6 *
andreikovacs 0:4eb2240dbd22 7 * Redistribution and use in source and binary forms, with or without modification,
andreikovacs 0:4eb2240dbd22 8 * are permitted provided that the following conditions are met:
andreikovacs 0:4eb2240dbd22 9 *
andreikovacs 0:4eb2240dbd22 10 * o Redistributions of source code must retain the above copyright notice, this list
andreikovacs 0:4eb2240dbd22 11 * of conditions and the following disclaimer.
andreikovacs 0:4eb2240dbd22 12 *
andreikovacs 0:4eb2240dbd22 13 * o Redistributions in binary form must reproduce the above copyright notice, this
andreikovacs 0:4eb2240dbd22 14 * list of conditions and the following disclaimer in the documentation and/or
andreikovacs 0:4eb2240dbd22 15 * other materials provided with the distribution.
andreikovacs 0:4eb2240dbd22 16 *
andreikovacs 0:4eb2240dbd22 17 * o Neither the name of Freescale Semiconductor, Inc. nor the names of its
andreikovacs 0:4eb2240dbd22 18 * contributors may be used to endorse or promote products derived from this
andreikovacs 0:4eb2240dbd22 19 * software without specific prior written permission.
andreikovacs 0:4eb2240dbd22 20 *
andreikovacs 0:4eb2240dbd22 21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
andreikovacs 0:4eb2240dbd22 22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
andreikovacs 0:4eb2240dbd22 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
andreikovacs 0:4eb2240dbd22 24 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
andreikovacs 0:4eb2240dbd22 25 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
andreikovacs 0:4eb2240dbd22 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
andreikovacs 0:4eb2240dbd22 27 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
andreikovacs 0:4eb2240dbd22 28 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
andreikovacs 0:4eb2240dbd22 29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
andreikovacs 0:4eb2240dbd22 30 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
andreikovacs 0:4eb2240dbd22 31 */
andreikovacs 0:4eb2240dbd22 32
andreikovacs 0:4eb2240dbd22 33 /************************************************************************************
andreikovacs 0:4eb2240dbd22 34 *************************************************************************************
andreikovacs 0:4eb2240dbd22 35 * Include
andreikovacs 0:4eb2240dbd22 36 *************************************************************************************
andreikovacs 0:4eb2240dbd22 37 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 38
andreikovacs 0:4eb2240dbd22 39 #include "Application_Interface.h"
andreikovacs 0:4eb2240dbd22 40 #include "Connectivity_Test_Platform.h"
andreikovacs 0:4eb2240dbd22 41 /************************************************************************************
andreikovacs 0:4eb2240dbd22 42 *************************************************************************************
andreikovacs 0:4eb2240dbd22 43 * Private type definitions
andreikovacs 0:4eb2240dbd22 44 *************************************************************************************
andreikovacs 0:4eb2240dbd22 45 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 46
andreikovacs 0:4eb2240dbd22 47 /************************************************************************************
andreikovacs 0:4eb2240dbd22 48 *************************************************************************************
andreikovacs 0:4eb2240dbd22 49 * Macros
andreikovacs 0:4eb2240dbd22 50 *************************************************************************************
andreikovacs 0:4eb2240dbd22 51 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 52 #define gPrbs9BufferLength_c ( 65 )
andreikovacs 0:4eb2240dbd22 53 #define gContTxModSelectPN9_c ( 2 )
andreikovacs 0:4eb2240dbd22 54 #define gContTxModSelectOnes_c ( 1 )
andreikovacs 0:4eb2240dbd22 55 #define gContTxModSelectZeros_c ( 0 )
andreikovacs 2:aaffc5d91884 56 #define SelfNotificationEvent() \
andreikovacs 2:aaffc5d91884 57 do \
andreikovacs 2:aaffc5d91884 58 { \
andreikovacs 2:aaffc5d91884 59 gTaskEventFlags |= gCTSelf_EVENT_c; \
andreikovacs 2:aaffc5d91884 60 mainTask->signal_set(gEventsAny_c); \
andreikovacs 2:aaffc5d91884 61 }while(0);
andreikovacs 1:1eb1eccc81c2 62 #define ResetMCU() NVIC_SystemReset()
andreikovacs 0:4eb2240dbd22 63
andreikovacs 0:4eb2240dbd22 64 #define gUART_RX_EVENT_c (1<<0)
andreikovacs 0:4eb2240dbd22 65 #define gMcps_Cnf_EVENT_c (1<<1)
andreikovacs 0:4eb2240dbd22 66 #define gMcps_Ind_EVENT_c (1<<2)
andreikovacs 0:4eb2240dbd22 67 #define gMlme_EdCnf_EVENT_c (1<<3)
andreikovacs 0:4eb2240dbd22 68 #define gMlme_CcaCnf_EVENT_c (1<<4)
andreikovacs 0:4eb2240dbd22 69 #define gMlme_TimeoutInd_EVENT_c (1<<5)
andreikovacs 0:4eb2240dbd22 70 #define gRangeTest_EVENT_c (1<<6)
andreikovacs 0:4eb2240dbd22 71 #define gCTSelf_EVENT_c (1<<7)
andreikovacs 0:4eb2240dbd22 72 #define gTimePassed_EVENT_c (1<<8)
andreikovacs 0:4eb2240dbd22 73
andreikovacs 2:aaffc5d91884 74 #define gEventsAny_c (1<<9)
andreikovacs 0:4eb2240dbd22 75
andreikovacs 0:4eb2240dbd22 76 #define Delay_ms(a)
andreikovacs 0:4eb2240dbd22 77 #define FlaggedDelay_ms(a) TMR_StartSingleShotTimer(AppDelayTmr, a, DelayTimeElapsed, NULL)
andreikovacs 0:4eb2240dbd22 78
andreikovacs 0:4eb2240dbd22 79 #ifdef gPHY_802_15_4g_d
andreikovacs 0:4eb2240dbd22 80 #define GetTimestampUS() PhyTime_GetTimestampUs()
andreikovacs 0:4eb2240dbd22 81 #define GetTransmissionTime(payload, bitrate) ((((gPhyFSKPreambleLength_c + \
andreikovacs 0:4eb2240dbd22 82 gPhyMRFSKPHRLength_c + gPhyMRFSKSFDLength_c + \
andreikovacs 0:4eb2240dbd22 83 sizeof(smacHeader_t) + payload + gPhyFCSSize_c )*8000 )/ bitrate))
andreikovacs 0:4eb2240dbd22 84 #else
andreikovacs 0:4eb2240dbd22 85 #define GetTimestampUS() (16*PhyTime_GetTimestamp())
andreikovacs 0:4eb2240dbd22 86 #define GetTransmissionTime(payload, bitrate) (((6 + sizeof(smacHeader_t) + payload + 2)*32))
andreikovacs 0:4eb2240dbd22 87 //bitrate is fixed for 2.4 GHz
andreikovacs 0:4eb2240dbd22 88 #define crtBitrate (0)
andreikovacs 0:4eb2240dbd22 89 #endif
andreikovacs 0:4eb2240dbd22 90 /************************************************************************************
andreikovacs 0:4eb2240dbd22 91 *************************************************************************************
andreikovacs 0:4eb2240dbd22 92 * Public memory declarations
andreikovacs 0:4eb2240dbd22 93 *************************************************************************************
andreikovacs 0:4eb2240dbd22 94 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 95
andreikovacs 0:4eb2240dbd22 96 uint32_t gTaskEventFlags;
andreikovacs 0:4eb2240dbd22 97
andreikovacs 0:4eb2240dbd22 98 /*smac related variables*/
andreikovacs 0:4eb2240dbd22 99 bool_t bTxDone;
andreikovacs 0:4eb2240dbd22 100 bool_t bRxDone;
andreikovacs 0:4eb2240dbd22 101 bool_t bScanDone;
andreikovacs 0:4eb2240dbd22 102 bool_t gCCaGotResult;
andreikovacs 0:4eb2240dbd22 103 bool_t gIsChannelIdle;
andreikovacs 0:4eb2240dbd22 104 bool_t bEdDone;
andreikovacs 0:4eb2240dbd22 105 bool_t failedPRBS9;
andreikovacs 0:4eb2240dbd22 106 uint8_t u8LastRxRssiValue;
andreikovacs 0:4eb2240dbd22 107 bool_t evTestParameters;
andreikovacs 0:4eb2240dbd22 108 uint8_t au8ScanResults[129];
andreikovacs 0:4eb2240dbd22 109
andreikovacs 0:4eb2240dbd22 110 /*serial manager related variables*/
andreikovacs 0:4eb2240dbd22 111 uint8_t gu8UartData;
andreikovacs 0:4eb2240dbd22 112 bool_t evDataFromUART;
andreikovacs 0:4eb2240dbd22 113 uint8_t mAppSer;
andreikovacs 0:4eb2240dbd22 114
andreikovacs 0:4eb2240dbd22 115 /*connectivity test state machine variables*/
andreikovacs 0:4eb2240dbd22 116 operationModes_t testOpMode;
andreikovacs 0:4eb2240dbd22 117 operationModes_t prevOpMode;
andreikovacs 0:4eb2240dbd22 118
andreikovacs 0:4eb2240dbd22 119 channels_t testChannel;
andreikovacs 0:4eb2240dbd22 120 uint8_t testPower;
andreikovacs 0:4eb2240dbd22 121 uint8_t testPayloadLen;
andreikovacs 0:4eb2240dbd22 122 uint8_t contTxModBitValue;
andreikovacs 0:4eb2240dbd22 123 uint8_t ccaThresh;
andreikovacs 0:4eb2240dbd22 124 bool_t shortCutsEnabled;
andreikovacs 0:4eb2240dbd22 125 ConnectivityStates_t connState;
andreikovacs 0:4eb2240dbd22 126 ContinuousTxRxTestStates_t cTxRxState;
andreikovacs 0:4eb2240dbd22 127 PerTxStates_t perTxState;
andreikovacs 0:4eb2240dbd22 128 PerRxStates_t perRxState;
andreikovacs 0:4eb2240dbd22 129 RangeTxStates_t rangeTxState;
andreikovacs 0:4eb2240dbd22 130 RangeRxStates_t rangeRxState;
andreikovacs 0:4eb2240dbd22 131 EditRegsStates_t eRState;
andreikovacs 0:4eb2240dbd22 132 oRStates_t oRState;
andreikovacs 0:4eb2240dbd22 133 rRStates_t rRState;
andreikovacs 0:4eb2240dbd22 134 dRStates_t dRState;
andreikovacs 0:4eb2240dbd22 135 CSenseTCtrlStates_t cstcState;
andreikovacs 0:4eb2240dbd22 136 uint8_t ChannelToScan;
andreikovacs 0:4eb2240dbd22 137 smacTestMode_t contTestRunning;
andreikovacs 0:4eb2240dbd22 138
andreikovacs 0:4eb2240dbd22 139 /*asp related variables*/
andreikovacs 0:4eb2240dbd22 140 AppToAspMessage_t aspTestRequestMsg;
andreikovacs 0:4eb2240dbd22 141
andreikovacs 0:4eb2240dbd22 142 extern uint8_t u8Prbs9Buffer[gPrbs9BufferLength_c];
andreikovacs 0:4eb2240dbd22 143
andreikovacs 0:4eb2240dbd22 144 Serial uart(USBTX,USBRX);
andreikovacs 0:4eb2240dbd22 145 Thread *mainTask;
andreikovacs 0:4eb2240dbd22 146
andreikovacs 0:4eb2240dbd22 147 /************************************************************************************
andreikovacs 0:4eb2240dbd22 148 *************************************************************************************
andreikovacs 0:4eb2240dbd22 149 * Private memory declarations
andreikovacs 0:4eb2240dbd22 150 *************************************************************************************
andreikovacs 0:4eb2240dbd22 151 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 152 static uint8_t gau8RxDataBuffer[gMaxSmacSDULength_c + sizeof(txPacket_t)];
andreikovacs 0:4eb2240dbd22 153 static uint8_t gau8TxDataBuffer[gMaxSmacSDULength_c + sizeof(rxPacket_t)];
andreikovacs 0:4eb2240dbd22 154
andreikovacs 0:4eb2240dbd22 155 static txPacket_t * gAppTxPacket;
andreikovacs 0:4eb2240dbd22 156 static rxPacket_t * gAppRxPacket;
andreikovacs 0:4eb2240dbd22 157
andreikovacs 0:4eb2240dbd22 158 static uint8_t timePassed;
andreikovacs 0:4eb2240dbd22 159 Timeout RangeTestTmr;
andreikovacs 0:4eb2240dbd22 160 Timer AppDelayTmr;
andreikovacs 0:4eb2240dbd22 161 /************************************************************************************
andreikovacs 0:4eb2240dbd22 162 *************************************************************************************
andreikovacs 0:4eb2240dbd22 163 * Private prototypes
andreikovacs 0:4eb2240dbd22 164 *************************************************************************************
andreikovacs 0:4eb2240dbd22 165 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 166 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 167 extern void StoreTrimValueToFlash (uint32_t trimValue, CalibrationOptionSelect_t option);
andreikovacs 0:4eb2240dbd22 168 #endif
andreikovacs 0:4eb2240dbd22 169
andreikovacs 0:4eb2240dbd22 170 /*platform independent functions*/
andreikovacs 0:4eb2240dbd22 171 static void SerialUIStateMachine(void);
andreikovacs 0:4eb2240dbd22 172 static bool_t SerialContinuousTxRxTest(void);
andreikovacs 0:4eb2240dbd22 173 static bool_t PacketErrorRateTx(void);
andreikovacs 0:4eb2240dbd22 174 static bool_t PacketErrorRateRx(void);
andreikovacs 0:4eb2240dbd22 175 static void SetRadioRxOnNoTimeOut(void);
andreikovacs 0:4eb2240dbd22 176 static void HandleEvents(int32_t evSignals);
andreikovacs 0:4eb2240dbd22 177 static void PrintTestParameters(bool_t bEraseLine);
andreikovacs 0:4eb2240dbd22 178
andreikovacs 0:4eb2240dbd22 179 static void PrintPerRxFinalLine(uint16_t u16Received, uint16_t u16Total);
andreikovacs 0:4eb2240dbd22 180 extern uint32_t HexString2Dec(uint8_t * au8String);
andreikovacs 0:4eb2240dbd22 181 static bool_t stringComp(uint8_t * au8leftString, uint8_t * au8RightString, uint8_t bytesToCompare);
andreikovacs 0:4eb2240dbd22 182 /********************************/
andreikovacs 0:4eb2240dbd22 183
andreikovacs 0:4eb2240dbd22 184 static void RangeTest_Timer_CallBack ();
andreikovacs 0:4eb2240dbd22 185 static bool_t RangeTx(void);
andreikovacs 0:4eb2240dbd22 186 static bool_t RangeRx(void);
andreikovacs 0:4eb2240dbd22 187
andreikovacs 0:4eb2240dbd22 188 static bool_t EditRegisters(void);
andreikovacs 0:4eb2240dbd22 189 #if CT_Feature_Direct_Registers || CT_Feature_Indirect_Registers
andreikovacs 0:4eb2240dbd22 190 bool_t OverrideRegisters(void);
andreikovacs 0:4eb2240dbd22 191 bool_t ReadRegisters(void);
andreikovacs 0:4eb2240dbd22 192 bool_t DumpRegisters(void);
andreikovacs 0:4eb2240dbd22 193 bool_t bIsRegisterDirect = TRUE;
andreikovacs 0:4eb2240dbd22 194 #endif
andreikovacs 0:4eb2240dbd22 195
andreikovacs 0:4eb2240dbd22 196 static bool_t CSenseAndTCtrl(void);
andreikovacs 0:4eb2240dbd22 197 static void TransmissionControlHandler(void);
andreikovacs 0:4eb2240dbd22 198 static void CarrierSenseHandler(void);
andreikovacs 0:4eb2240dbd22 199 static smacErrors_t TestMode ( smacTestMode_t mode);
andreikovacs 0:4eb2240dbd22 200 static void PacketHandler_Prbs9(void);
andreikovacs 0:4eb2240dbd22 201 static void DelayTimeElapsed();
andreikovacs 0:4eb2240dbd22 202 static void IncrementChannelOnEdEvent();
andreikovacs 0:4eb2240dbd22 203 extern void ReadRFRegs(registerAddressSize_t, registerAddressSize_t);
andreikovacs 0:4eb2240dbd22 204 extern void PrintTestParameters(bool_t bEraseLine);
andreikovacs 0:4eb2240dbd22 205
andreikovacs 0:4eb2240dbd22 206 /*************************************/
andreikovacs 0:4eb2240dbd22 207 /************************************************************************************
andreikovacs 0:4eb2240dbd22 208 *************************************************************************************
andreikovacs 0:4eb2240dbd22 209 * Public functions
andreikovacs 0:4eb2240dbd22 210 *************************************************************************************
andreikovacs 0:4eb2240dbd22 211 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 212 void InitProject(void);
andreikovacs 0:4eb2240dbd22 213 void InitSmac(void);
andreikovacs 0:4eb2240dbd22 214 void main_task(void const *argument);
andreikovacs 2:aaffc5d91884 215 void UartRxCallBack(void);
andreikovacs 0:4eb2240dbd22 216 void PrintMenu(char * const pu8Menu[], uint8_t port);
andreikovacs 0:4eb2240dbd22 217
andreikovacs 0:4eb2240dbd22 218 /************************************************************************************
andreikovacs 0:4eb2240dbd22 219 *
andreikovacs 0:4eb2240dbd22 220 * InitProject
andreikovacs 0:4eb2240dbd22 221 *
andreikovacs 0:4eb2240dbd22 222 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 223 void InitProject(void)
andreikovacs 0:4eb2240dbd22 224 {
andreikovacs 0:4eb2240dbd22 225 /*Global Data init*/
andreikovacs 0:4eb2240dbd22 226 testPayloadLen = gMaxSmacSDULength_c;
andreikovacs 0:4eb2240dbd22 227
andreikovacs 0:4eb2240dbd22 228 testOpMode = gDefaultOperationMode_c;
andreikovacs 0:4eb2240dbd22 229 testChannel = gDefaultChannelNumber_c;
andreikovacs 0:4eb2240dbd22 230 testPower = gDefaultOutputPower_c;
andreikovacs 0:4eb2240dbd22 231 testPayloadLen = gDefaultPayload_c;
andreikovacs 0:4eb2240dbd22 232 contTestRunning = gTestModeForceIdle_c;
andreikovacs 0:4eb2240dbd22 233 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 234 connState = gConnInitState_c;
andreikovacs 0:4eb2240dbd22 235 cTxRxState = gCTxRxStateInit_c;
andreikovacs 0:4eb2240dbd22 236 perTxState = gPerTxStateInit_c;
andreikovacs 0:4eb2240dbd22 237 perRxState = gPerRxStateInit_c;
andreikovacs 0:4eb2240dbd22 238 rangeTxState = gRangeTxStateInit_c;
andreikovacs 0:4eb2240dbd22 239 rangeRxState = gRangeRxStateInit_c;
andreikovacs 0:4eb2240dbd22 240 prevOpMode = gDefaultOperationMode_c;
andreikovacs 0:4eb2240dbd22 241 oRState = gORStateInit_c;
andreikovacs 0:4eb2240dbd22 242 rRState = gRRStateInit_c;
andreikovacs 0:4eb2240dbd22 243 dRState = gDRStateInit_c;
andreikovacs 0:4eb2240dbd22 244 ccaThresh = gDefaultCCAThreshold_c;
andreikovacs 0:4eb2240dbd22 245 bEdDone = FALSE;
andreikovacs 0:4eb2240dbd22 246 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 247
andreikovacs 0:4eb2240dbd22 248 InitProject_custom();
andreikovacs 0:4eb2240dbd22 249 }
andreikovacs 0:4eb2240dbd22 250
andreikovacs 0:4eb2240dbd22 251 /************************************************************************************
andreikovacs 0:4eb2240dbd22 252 *************************************************************************************
andreikovacs 0:4eb2240dbd22 253 * SAP functions
andreikovacs 0:4eb2240dbd22 254 *************************************************************************************
andreikovacs 0:4eb2240dbd22 255 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 256
andreikovacs 0:4eb2240dbd22 257 //(Management) Sap handler for managing timeout indication and ED confirm
andreikovacs 0:4eb2240dbd22 258 smacErrors_t smacToAppMlmeSap(smacToAppMlmeMessage_t* pMsg, instanceId_t instance)
andreikovacs 0:4eb2240dbd22 259 {
andreikovacs 0:4eb2240dbd22 260 switch(pMsg->msgType)
andreikovacs 0:4eb2240dbd22 261 {
andreikovacs 0:4eb2240dbd22 262 case gMlmeEdCnf_c:
andreikovacs 0:4eb2240dbd22 263 au8ScanResults[pMsg->msgData.edCnf.scannedChannel] = pMsg->msgData.edCnf.energyLeveldB;
andreikovacs 0:4eb2240dbd22 264 gTaskEventFlags |= gMlme_EdCnf_EVENT_c;
andreikovacs 2:aaffc5d91884 265 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 266 break;
andreikovacs 0:4eb2240dbd22 267 case gMlmeCcaCnf_c:
andreikovacs 0:4eb2240dbd22 268 gTaskEventFlags |= gMlme_CcaCnf_EVENT_c;
andreikovacs 2:aaffc5d91884 269 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 270 if(pMsg->msgData.ccaCnf.status == gErrorNoError_c)
andreikovacs 0:4eb2240dbd22 271 gIsChannelIdle = TRUE;
andreikovacs 0:4eb2240dbd22 272 else
andreikovacs 0:4eb2240dbd22 273 gIsChannelIdle = FALSE;
andreikovacs 0:4eb2240dbd22 274 break;
andreikovacs 0:4eb2240dbd22 275 case gMlmeTimeoutInd_c:
andreikovacs 0:4eb2240dbd22 276 gTaskEventFlags |= gMlme_TimeoutInd_EVENT_c;
andreikovacs 2:aaffc5d91884 277 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 278 break;
andreikovacs 0:4eb2240dbd22 279 default:
andreikovacs 0:4eb2240dbd22 280 break;
andreikovacs 0:4eb2240dbd22 281 }
andreikovacs 0:4eb2240dbd22 282 MEM_BufferFree(pMsg);
andreikovacs 0:4eb2240dbd22 283 return gErrorNoError_c;
andreikovacs 0:4eb2240dbd22 284 }
andreikovacs 0:4eb2240dbd22 285 //(Data) Sap handler for managing data confirm and data indication
andreikovacs 0:4eb2240dbd22 286 smacErrors_t smacToAppMcpsSap(smacToAppDataMessage_t* pMsg, instanceId_t instance)
andreikovacs 0:4eb2240dbd22 287 {
andreikovacs 0:4eb2240dbd22 288 switch(pMsg->msgType)
andreikovacs 0:4eb2240dbd22 289 {
andreikovacs 0:4eb2240dbd22 290 case gMcpsDataInd_c:
andreikovacs 0:4eb2240dbd22 291 if(pMsg->msgData.dataInd.pRxPacket->rxStatus == rxSuccessStatus_c)
andreikovacs 0:4eb2240dbd22 292 {
andreikovacs 0:4eb2240dbd22 293 u8LastRxRssiValue = pMsg->msgData.dataInd.u8LastRxRssi;
andreikovacs 0:4eb2240dbd22 294 gTaskEventFlags |= gMcps_Ind_EVENT_c;
andreikovacs 2:aaffc5d91884 295 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 296 }
andreikovacs 0:4eb2240dbd22 297 break;
andreikovacs 0:4eb2240dbd22 298 case gMcpsDataCnf_c:
andreikovacs 0:4eb2240dbd22 299 if(pMsg->msgData.dataCnf.status == gErrorNoError_c)
andreikovacs 0:4eb2240dbd22 300 {
andreikovacs 0:4eb2240dbd22 301 gTaskEventFlags |= gMcps_Cnf_EVENT_c;
andreikovacs 2:aaffc5d91884 302 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 303 }
andreikovacs 0:4eb2240dbd22 304 break;
andreikovacs 0:4eb2240dbd22 305 default:
andreikovacs 0:4eb2240dbd22 306 break;
andreikovacs 0:4eb2240dbd22 307 }
andreikovacs 0:4eb2240dbd22 308
andreikovacs 0:4eb2240dbd22 309 MEM_BufferFree(pMsg);
andreikovacs 0:4eb2240dbd22 310 return gErrorNoError_c;
andreikovacs 0:4eb2240dbd22 311 }
andreikovacs 0:4eb2240dbd22 312
andreikovacs 0:4eb2240dbd22 313 static void HandleEvents(int32_t evSignals)
andreikovacs 0:4eb2240dbd22 314 {
andreikovacs 0:4eb2240dbd22 315 if(evSignals & gUART_RX_EVENT_c)
andreikovacs 0:4eb2240dbd22 316 {
andreikovacs 0:4eb2240dbd22 317 if(shortCutsEnabled)
andreikovacs 0:4eb2240dbd22 318 {
andreikovacs 0:4eb2240dbd22 319 ShortCutsParser(gu8UartData);
andreikovacs 0:4eb2240dbd22 320 }
andreikovacs 0:4eb2240dbd22 321 else
andreikovacs 0:4eb2240dbd22 322 {
andreikovacs 0:4eb2240dbd22 323 evDataFromUART = TRUE;
andreikovacs 0:4eb2240dbd22 324 }
andreikovacs 0:4eb2240dbd22 325 }
andreikovacs 0:4eb2240dbd22 326 if(evSignals & gMcps_Cnf_EVENT_c)
andreikovacs 0:4eb2240dbd22 327 {
andreikovacs 0:4eb2240dbd22 328 bTxDone = TRUE;
andreikovacs 0:4eb2240dbd22 329 }
andreikovacs 0:4eb2240dbd22 330 if(evSignals & gMcps_Ind_EVENT_c)
andreikovacs 0:4eb2240dbd22 331 {
andreikovacs 0:4eb2240dbd22 332 bRxDone = TRUE;
andreikovacs 0:4eb2240dbd22 333 }
andreikovacs 0:4eb2240dbd22 334 if(evSignals & gMlme_TimeoutInd_EVENT_c)
andreikovacs 0:4eb2240dbd22 335 {
andreikovacs 0:4eb2240dbd22 336 }
andreikovacs 0:4eb2240dbd22 337 if(evSignals & gRangeTest_EVENT_c)
andreikovacs 0:4eb2240dbd22 338 {
andreikovacs 0:4eb2240dbd22 339 bRxDone=TRUE;
andreikovacs 0:4eb2240dbd22 340 }
andreikovacs 0:4eb2240dbd22 341 if(evSignals & gMlme_EdCnf_EVENT_c)
andreikovacs 0:4eb2240dbd22 342 {
andreikovacs 0:4eb2240dbd22 343 if (cTxRxState == gCTxRxStateRunnigScanTest_c)
andreikovacs 0:4eb2240dbd22 344 {
andreikovacs 0:4eb2240dbd22 345 IncrementChannelOnEdEvent();
andreikovacs 0:4eb2240dbd22 346 }
andreikovacs 0:4eb2240dbd22 347 if (cTxRxState == gCTxRxStateRunnigEdTest_c)
andreikovacs 0:4eb2240dbd22 348 {
andreikovacs 0:4eb2240dbd22 349 cTxRxState = gCTxRxStateRunningEdTestGotResult_c;
andreikovacs 0:4eb2240dbd22 350 }
andreikovacs 0:4eb2240dbd22 351 if (connState == gConnCSenseAndTCtrl_c)
andreikovacs 0:4eb2240dbd22 352 {
andreikovacs 0:4eb2240dbd22 353 bScanDone = TRUE;
andreikovacs 0:4eb2240dbd22 354 }
andreikovacs 0:4eb2240dbd22 355 bEdDone = TRUE;
andreikovacs 0:4eb2240dbd22 356 }
andreikovacs 0:4eb2240dbd22 357 if(evSignals & gMlme_CcaCnf_EVENT_c)
andreikovacs 0:4eb2240dbd22 358 {
andreikovacs 0:4eb2240dbd22 359 gCCaGotResult = TRUE;
andreikovacs 0:4eb2240dbd22 360 uart.printf("Channel %d is", (uint32_t)testChannel);
andreikovacs 0:4eb2240dbd22 361 if(gIsChannelIdle)
andreikovacs 0:4eb2240dbd22 362 uart.printf("Idle\r\n");
andreikovacs 0:4eb2240dbd22 363 else
andreikovacs 0:4eb2240dbd22 364 uart.printf("Busy\r\n");
andreikovacs 0:4eb2240dbd22 365 }
andreikovacs 0:4eb2240dbd22 366 if(evSignals & gCTSelf_EVENT_c)
andreikovacs 0:4eb2240dbd22 367 {
andreikovacs 0:4eb2240dbd22 368 }
andreikovacs 0:4eb2240dbd22 369 }
andreikovacs 0:4eb2240dbd22 370
andreikovacs 0:4eb2240dbd22 371
andreikovacs 0:4eb2240dbd22 372 /*************************************************************************/
andreikovacs 0:4eb2240dbd22 373 /*Main Task: Application entry point*/
andreikovacs 0:4eb2240dbd22 374 /*************************************************************************/
andreikovacs 0:4eb2240dbd22 375 void main_task(void const *argument)
andreikovacs 0:4eb2240dbd22 376 {
andreikovacs 0:4eb2240dbd22 377 static bool_t bIsInitialized = FALSE;
andreikovacs 0:4eb2240dbd22 378 static bool_t bUserInteraction = FALSE;
andreikovacs 0:4eb2240dbd22 379 //Initialize Memory Manager, Timer Manager and LEDs.
andreikovacs 0:4eb2240dbd22 380 if( !bIsInitialized )
andreikovacs 0:4eb2240dbd22 381 {
andreikovacs 0:4eb2240dbd22 382
andreikovacs 0:4eb2240dbd22 383 MEM_Init();
andreikovacs 0:4eb2240dbd22 384 //initialize PHY
andreikovacs 0:4eb2240dbd22 385 Phy_Init();
andreikovacs 0:4eb2240dbd22 386
andreikovacs 0:4eb2240dbd22 387 InitApp();
andreikovacs 0:4eb2240dbd22 388
andreikovacs 2:aaffc5d91884 389 uart.attach(&UartRxCallBack);
andreikovacs 2:aaffc5d91884 390
andreikovacs 0:4eb2240dbd22 391 /*Prints the Welcome screens in the terminal*/
andreikovacs 0:4eb2240dbd22 392 PrintMenu(cu8FreescaleLogo, mAppSer);
andreikovacs 0:4eb2240dbd22 393
andreikovacs 0:4eb2240dbd22 394 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 395 bIsInitialized = TRUE;
andreikovacs 0:4eb2240dbd22 396 }
andreikovacs 0:4eb2240dbd22 397 if(!bUserInteraction)
andreikovacs 0:4eb2240dbd22 398 {
andreikovacs 0:4eb2240dbd22 399 while(1)
andreikovacs 2:aaffc5d91884 400 {
andreikovacs 2:aaffc5d91884 401 Thread::signal_wait(gEventsAny_c);
andreikovacs 2:aaffc5d91884 402 if(gu8UartData == '\r')
andreikovacs 0:4eb2240dbd22 403 {
andreikovacs 2:aaffc5d91884 404 SelfNotificationEvent();
andreikovacs 2:aaffc5d91884 405 bUserInteraction = TRUE;
andreikovacs 2:aaffc5d91884 406 break;
andreikovacs 2:aaffc5d91884 407 }
andreikovacs 2:aaffc5d91884 408 else
andreikovacs 2:aaffc5d91884 409 {
andreikovacs 2:aaffc5d91884 410 PrintMenu(cu8FreescaleLogo, mAppSer);
andreikovacs 0:4eb2240dbd22 411 }
andreikovacs 0:4eb2240dbd22 412 }
andreikovacs 0:4eb2240dbd22 413 }
andreikovacs 0:4eb2240dbd22 414 if(bUserInteraction)
andreikovacs 0:4eb2240dbd22 415 {
andreikovacs 0:4eb2240dbd22 416 while(1)
andreikovacs 0:4eb2240dbd22 417 {
andreikovacs 2:aaffc5d91884 418 Thread::signal_wait(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 419 HandleEvents(gTaskEventFlags);
andreikovacs 0:4eb2240dbd22 420 SerialUIStateMachine();
andreikovacs 0:4eb2240dbd22 421 }
andreikovacs 0:4eb2240dbd22 422 }
andreikovacs 0:4eb2240dbd22 423 }
andreikovacs 0:4eb2240dbd22 424
andreikovacs 0:4eb2240dbd22 425 /*************************************************************************/
andreikovacs 0:4eb2240dbd22 426 /*InitApp: Initializes application mdoules and data*/
andreikovacs 0:4eb2240dbd22 427 /*************************************************************************/
andreikovacs 0:4eb2240dbd22 428 void InitApp()
andreikovacs 0:4eb2240dbd22 429 {
andreikovacs 0:4eb2240dbd22 430
andreikovacs 0:4eb2240dbd22 431 gAppTxPacket = (txPacket_t*)gau8TxDataBuffer; //Map TX packet to buffer
andreikovacs 0:4eb2240dbd22 432 gAppRxPacket = (rxPacket_t*)gau8RxDataBuffer; //Map Rx packet to buffer
andreikovacs 0:4eb2240dbd22 433 gAppRxPacket->u8MaxDataLength = gMaxSmacSDULength_c;
andreikovacs 0:4eb2240dbd22 434
andreikovacs 0:4eb2240dbd22 435 uart.baud(115200);
andreikovacs 0:4eb2240dbd22 436
andreikovacs 0:4eb2240dbd22 437 //Initialise SMAC
andreikovacs 0:4eb2240dbd22 438 InitSmac();
andreikovacs 0:4eb2240dbd22 439 //Tell SMAC who to call when it needs to pass a message to the application thread.
andreikovacs 0:4eb2240dbd22 440 Smac_RegisterSapHandlers((SMAC_APP_MCPS_SapHandler_t)smacToAppMcpsSap,(SMAC_APP_MLME_SapHandler_t)smacToAppMlmeSap,0);
andreikovacs 0:4eb2240dbd22 441
andreikovacs 0:4eb2240dbd22 442 InitProject();
andreikovacs 0:4eb2240dbd22 443
andreikovacs 0:4eb2240dbd22 444 InitApp_custom();
andreikovacs 0:4eb2240dbd22 445
andreikovacs 0:4eb2240dbd22 446 ASP_Init(0, mAppSer);
andreikovacs 0:4eb2240dbd22 447
andreikovacs 0:4eb2240dbd22 448 SMACFillHeader(&(gAppTxPacket->smacHeader), gBroadcastAddress_c); //@CMA, Conn Test. Start with broadcast address default
andreikovacs 0:4eb2240dbd22 449 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 450 (void)MLMESetChannelRequest(testChannel); //@CMA, Conn Test. Start Foperation at default channel
andreikovacs 0:4eb2240dbd22 451 }
andreikovacs 0:4eb2240dbd22 452
andreikovacs 0:4eb2240dbd22 453 /************************************************************************************
andreikovacs 0:4eb2240dbd22 454 *
andreikovacs 0:4eb2240dbd22 455 * Connectivity Test State Machine
andreikovacs 0:4eb2240dbd22 456 *
andreikovacs 0:4eb2240dbd22 457 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 458 void SerialUIStateMachine(void)
andreikovacs 0:4eb2240dbd22 459 {
andreikovacs 0:4eb2240dbd22 460 if((gConnSelectTest_c == connState) && evTestParameters)
andreikovacs 0:4eb2240dbd22 461 {
andreikovacs 0:4eb2240dbd22 462 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 463 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 464 #endif
andreikovacs 0:4eb2240dbd22 465 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 466 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 467 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 468 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 469 }
andreikovacs 0:4eb2240dbd22 470 switch(connState)
andreikovacs 0:4eb2240dbd22 471 {
andreikovacs 0:4eb2240dbd22 472 case gConnIdleState_c:
andreikovacs 0:4eb2240dbd22 473 PrintMenu(cu8MainMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 474 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 475 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 476 connState = gConnSelectTest_c;
andreikovacs 0:4eb2240dbd22 477 break;
andreikovacs 0:4eb2240dbd22 478 case gConnSelectTest_c:
andreikovacs 0:4eb2240dbd22 479 if(evDataFromUART){
andreikovacs 0:4eb2240dbd22 480 if('1' == gu8UartData)
andreikovacs 0:4eb2240dbd22 481 {
andreikovacs 0:4eb2240dbd22 482 cTxRxState = gCTxRxStateInit_c;
andreikovacs 0:4eb2240dbd22 483 connState = gConnContinuousTxRxState_c;
andreikovacs 0:4eb2240dbd22 484 }
andreikovacs 0:4eb2240dbd22 485 else if('2' == gu8UartData)
andreikovacs 0:4eb2240dbd22 486 {
andreikovacs 0:4eb2240dbd22 487 perTxState = gPerTxStateInit_c;
andreikovacs 0:4eb2240dbd22 488 perRxState = gPerRxStateInit_c;
andreikovacs 0:4eb2240dbd22 489 connState = gConnPerState_c;
andreikovacs 0:4eb2240dbd22 490 }
andreikovacs 0:4eb2240dbd22 491 else if('3' == gu8UartData)
andreikovacs 0:4eb2240dbd22 492 {
andreikovacs 0:4eb2240dbd22 493 rangeTxState = gRangeTxStateInit_c;
andreikovacs 0:4eb2240dbd22 494 rangeRxState = gRangeRxStateInit_c;
andreikovacs 0:4eb2240dbd22 495 connState = gConnRangeState_c;
andreikovacs 0:4eb2240dbd22 496 }
andreikovacs 0:4eb2240dbd22 497 else if('4' == gu8UartData)
andreikovacs 0:4eb2240dbd22 498 {
andreikovacs 0:4eb2240dbd22 499 cstcState = gCsTcStateInit_c;
andreikovacs 0:4eb2240dbd22 500 connState = gConnCSenseAndTCtrl_c;
andreikovacs 0:4eb2240dbd22 501 }
andreikovacs 0:4eb2240dbd22 502 #if CT_Feature_Direct_Registers || CT_Feature_Indirect_Registers
andreikovacs 0:4eb2240dbd22 503 else if('5' == gu8UartData)
andreikovacs 0:4eb2240dbd22 504 {
andreikovacs 0:4eb2240dbd22 505 eRState = gERStateInit_c;
andreikovacs 0:4eb2240dbd22 506 connState = gConnRegEditState_c;
andreikovacs 0:4eb2240dbd22 507 }
andreikovacs 0:4eb2240dbd22 508 #endif
andreikovacs 0:4eb2240dbd22 509 #if CT_Feature_Bitrate_Select
andreikovacs 0:4eb2240dbd22 510 else if('6' == gu8UartData)
andreikovacs 0:4eb2240dbd22 511 {
andreikovacs 0:4eb2240dbd22 512 bsState = gBSStateInit_c;
andreikovacs 0:4eb2240dbd22 513 connState = gConnBitrateSelectState_c;
andreikovacs 0:4eb2240dbd22 514 }
andreikovacs 0:4eb2240dbd22 515 #endif
andreikovacs 0:4eb2240dbd22 516 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 517 else if('7' == gu8UartData)
andreikovacs 0:4eb2240dbd22 518 {
andreikovacs 0:4eb2240dbd22 519 connState = gConnEDMeasCalib_c;
andreikovacs 0:4eb2240dbd22 520 edCalState= gEdCalStateInit_c;
andreikovacs 0:4eb2240dbd22 521 }
andreikovacs 0:4eb2240dbd22 522 #endif
andreikovacs 0:4eb2240dbd22 523 else if('!' == gu8UartData)
andreikovacs 0:4eb2240dbd22 524 {
andreikovacs 0:4eb2240dbd22 525 ResetMCU();
andreikovacs 0:4eb2240dbd22 526 }
andreikovacs 0:4eb2240dbd22 527 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 528 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 529 }
andreikovacs 0:4eb2240dbd22 530 break;
andreikovacs 0:4eb2240dbd22 531 case gConnContinuousTxRxState_c:
andreikovacs 0:4eb2240dbd22 532 if(SerialContinuousTxRxTest())
andreikovacs 0:4eb2240dbd22 533 {
andreikovacs 0:4eb2240dbd22 534 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 535 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 536 }
andreikovacs 0:4eb2240dbd22 537 break;
andreikovacs 0:4eb2240dbd22 538 case gConnPerState_c:
andreikovacs 0:4eb2240dbd22 539 if(mTxOperation_c == testOpMode)
andreikovacs 0:4eb2240dbd22 540 {
andreikovacs 0:4eb2240dbd22 541 if(PacketErrorRateTx())
andreikovacs 0:4eb2240dbd22 542 {
andreikovacs 0:4eb2240dbd22 543 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 544 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 545 }
andreikovacs 0:4eb2240dbd22 546 }
andreikovacs 0:4eb2240dbd22 547 else
andreikovacs 0:4eb2240dbd22 548 {
andreikovacs 0:4eb2240dbd22 549 if(PacketErrorRateRx())
andreikovacs 0:4eb2240dbd22 550 {
andreikovacs 0:4eb2240dbd22 551 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 552 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 553 }
andreikovacs 0:4eb2240dbd22 554 }
andreikovacs 0:4eb2240dbd22 555 break;
andreikovacs 0:4eb2240dbd22 556 case gConnRangeState_c:
andreikovacs 0:4eb2240dbd22 557 if(mTxOperation_c == testOpMode)
andreikovacs 0:4eb2240dbd22 558 {
andreikovacs 0:4eb2240dbd22 559 if(RangeTx())
andreikovacs 0:4eb2240dbd22 560 {
andreikovacs 0:4eb2240dbd22 561 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 562 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 563 }
andreikovacs 0:4eb2240dbd22 564 }
andreikovacs 0:4eb2240dbd22 565 else
andreikovacs 0:4eb2240dbd22 566 {
andreikovacs 0:4eb2240dbd22 567 if(RangeRx())
andreikovacs 0:4eb2240dbd22 568 {
andreikovacs 0:4eb2240dbd22 569 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 570 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 571 }
andreikovacs 0:4eb2240dbd22 572 }
andreikovacs 0:4eb2240dbd22 573 break;
andreikovacs 0:4eb2240dbd22 574 case gConnRegEditState_c:
andreikovacs 0:4eb2240dbd22 575 if(EditRegisters())
andreikovacs 0:4eb2240dbd22 576 {
andreikovacs 0:4eb2240dbd22 577 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 578 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 579 }
andreikovacs 0:4eb2240dbd22 580 break;
andreikovacs 0:4eb2240dbd22 581 #if CT_Feature_Bitrate_Select
andreikovacs 0:4eb2240dbd22 582 case gConnBitrateSelectState_c:
andreikovacs 0:4eb2240dbd22 583 if(Bitrate_Select())
andreikovacs 0:4eb2240dbd22 584 {
andreikovacs 0:4eb2240dbd22 585 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 586 }
andreikovacs 0:4eb2240dbd22 587 break;
andreikovacs 0:4eb2240dbd22 588 #endif
andreikovacs 0:4eb2240dbd22 589 case gConnCSenseAndTCtrl_c:
andreikovacs 0:4eb2240dbd22 590 if(CSenseAndTCtrl())
andreikovacs 0:4eb2240dbd22 591 {
andreikovacs 0:4eb2240dbd22 592 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 593 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 594 }
andreikovacs 0:4eb2240dbd22 595 break;
andreikovacs 0:4eb2240dbd22 596 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 597 case gConnEDMeasCalib_c:
andreikovacs 0:4eb2240dbd22 598 if(EDCalibrationMeasurement())
andreikovacs 0:4eb2240dbd22 599 {
andreikovacs 0:4eb2240dbd22 600 connState = gConnIdleState_c;
andreikovacs 0:4eb2240dbd22 601 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 602 }
andreikovacs 0:4eb2240dbd22 603 break;
andreikovacs 0:4eb2240dbd22 604 #endif
andreikovacs 0:4eb2240dbd22 605 default:
andreikovacs 0:4eb2240dbd22 606 break;
andreikovacs 0:4eb2240dbd22 607
andreikovacs 0:4eb2240dbd22 608 }
andreikovacs 0:4eb2240dbd22 609 if(prevOpMode != testOpMode)
andreikovacs 0:4eb2240dbd22 610 {
andreikovacs 0:4eb2240dbd22 611 perTxState = gPerTxStateInit_c;
andreikovacs 0:4eb2240dbd22 612 perRxState = gPerRxStateInit_c;
andreikovacs 0:4eb2240dbd22 613 rangeTxState = gRangeTxStateInit_c;
andreikovacs 0:4eb2240dbd22 614 rangeRxState = gRangeRxStateInit_c;
andreikovacs 0:4eb2240dbd22 615 prevOpMode = testOpMode;
andreikovacs 0:4eb2240dbd22 616 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 617 }
andreikovacs 0:4eb2240dbd22 618 }
andreikovacs 0:4eb2240dbd22 619
andreikovacs 0:4eb2240dbd22 620 /************************************************************************************
andreikovacs 0:4eb2240dbd22 621 *
andreikovacs 0:4eb2240dbd22 622 * Continuous Tests State Machine
andreikovacs 0:4eb2240dbd22 623 *
andreikovacs 0:4eb2240dbd22 624 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 625 bool_t SerialContinuousTxRxTest(void)
andreikovacs 0:4eb2240dbd22 626 {
andreikovacs 0:4eb2240dbd22 627 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 628 uint8_t u8Index, u8TempEnergyValue, u8TempScanValue;
andreikovacs 0:4eb2240dbd22 629
andreikovacs 0:4eb2240dbd22 630 if(evTestParameters)
andreikovacs 0:4eb2240dbd22 631 {
andreikovacs 0:4eb2240dbd22 632 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 633 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 634 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 635 #endif
andreikovacs 0:4eb2240dbd22 636 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 637 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 638
andreikovacs 0:4eb2240dbd22 639 if(gTestModePRBS9_c == contTestRunning)
andreikovacs 0:4eb2240dbd22 640 {
andreikovacs 0:4eb2240dbd22 641 cTxRxState = gCTxRxStateRunningPRBS9Test_c;
andreikovacs 0:4eb2240dbd22 642 }
andreikovacs 0:4eb2240dbd22 643 (void)TestMode(contTestRunning);
andreikovacs 0:4eb2240dbd22 644
andreikovacs 0:4eb2240dbd22 645 if(gCTxRxStateSelectTest_c == cTxRxState)
andreikovacs 0:4eb2240dbd22 646 {
andreikovacs 0:4eb2240dbd22 647 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 648 }
andreikovacs 0:4eb2240dbd22 649 else
andreikovacs 0:4eb2240dbd22 650 {
andreikovacs 0:4eb2240dbd22 651 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 652 uart.printf("\r\n");
andreikovacs 0:4eb2240dbd22 653 }
andreikovacs 0:4eb2240dbd22 654
andreikovacs 0:4eb2240dbd22 655 if(gCTxRxStateRunnigRxTest_c == cTxRxState)
andreikovacs 0:4eb2240dbd22 656 {
andreikovacs 0:4eb2240dbd22 657 bRxDone = FALSE;
andreikovacs 0:4eb2240dbd22 658 gAppRxPacket->u8MaxDataLength = gMaxSmacSDULength_c;
andreikovacs 0:4eb2240dbd22 659 (void)MLMERXEnableRequest(gAppRxPacket, 0);
andreikovacs 0:4eb2240dbd22 660 }
andreikovacs 0:4eb2240dbd22 661 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 662 }
andreikovacs 0:4eb2240dbd22 663
andreikovacs 0:4eb2240dbd22 664 switch(cTxRxState)
andreikovacs 0:4eb2240dbd22 665 {
andreikovacs 0:4eb2240dbd22 666 case gCTxRxStateIdle_c:
andreikovacs 0:4eb2240dbd22 667 if((evDataFromUART) && ('\r' == gu8UartData))
andreikovacs 0:4eb2240dbd22 668 {
andreikovacs 0:4eb2240dbd22 669 cTxRxState = gCTxRxStateInit_c;
andreikovacs 0:4eb2240dbd22 670 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 671 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 672 }
andreikovacs 0:4eb2240dbd22 673 break;
andreikovacs 0:4eb2240dbd22 674 case gCTxRxStateInit_c:
andreikovacs 0:4eb2240dbd22 675 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 676 PrintMenu(cu8ContinuousTestMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 677 //Phy in StandBy, smacstate in Idle.
andreikovacs 0:4eb2240dbd22 678 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 679 while(MLMESetChannelRequest(testChannel));
andreikovacs 0:4eb2240dbd22 680 uart.printf(cu8ContinuousTestTags[contTestRunning]);
andreikovacs 0:4eb2240dbd22 681 if(contTestRunning == gTestModeContinuousTxModulated_c)
andreikovacs 0:4eb2240dbd22 682 {
andreikovacs 0:4eb2240dbd22 683 uart.printf(cu8TxModTestTags[contTxModBitValue]);
andreikovacs 0:4eb2240dbd22 684 }
andreikovacs 0:4eb2240dbd22 685 (void)TestMode(contTestRunning);
andreikovacs 0:4eb2240dbd22 686 uart.printf("\r\n\r\n");
andreikovacs 0:4eb2240dbd22 687 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 688 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 689 cTxRxState = gCTxRxStateSelectTest_c;
andreikovacs 0:4eb2240dbd22 690 break;
andreikovacs 0:4eb2240dbd22 691 case gCTxRxStateSelectTest_c:
andreikovacs 0:4eb2240dbd22 692 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 693 {
andreikovacs 0:4eb2240dbd22 694 if('1' == gu8UartData)
andreikovacs 0:4eb2240dbd22 695 {
andreikovacs 0:4eb2240dbd22 696 contTestRunning = gTestModeForceIdle_c;
andreikovacs 0:4eb2240dbd22 697 cTxRxState = gCTxRxStateInit_c;
andreikovacs 0:4eb2240dbd22 698 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 699 }
andreikovacs 0:4eb2240dbd22 700 else if('2' == gu8UartData)
andreikovacs 0:4eb2240dbd22 701 {
andreikovacs 0:4eb2240dbd22 702 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 703 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 704 contTestRunning = gTestModePRBS9_c;
andreikovacs 0:4eb2240dbd22 705 MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 706 uart.printf("\f\r\nPress [p] to stop the Continuous PRBS9 test\r\n");
andreikovacs 0:4eb2240dbd22 707 (void)TestMode(contTestRunning);
andreikovacs 0:4eb2240dbd22 708 cTxRxState = gCTxRxStateRunningPRBS9Test_c;
andreikovacs 0:4eb2240dbd22 709 }
andreikovacs 0:4eb2240dbd22 710 else if('3' == gu8UartData)
andreikovacs 0:4eb2240dbd22 711 {
andreikovacs 0:4eb2240dbd22 712 contTestRunning = gTestModeContinuousTxModulated_c;
andreikovacs 0:4eb2240dbd22 713 cTxRxState = gCTxRxStateRunningTXModSelectOpt;
andreikovacs 0:4eb2240dbd22 714 // uart.printf( "\f\r\n To use this mode shunt pins 3-4 on J18");
andreikovacs 0:4eb2240dbd22 715 uart.printf("\f\r\nPress 2 for PN9, 1 to modulate values of 1 and 0 to modulate values of 0");
andreikovacs 0:4eb2240dbd22 716
andreikovacs 0:4eb2240dbd22 717 }
andreikovacs 0:4eb2240dbd22 718 else if('4' == gu8UartData)
andreikovacs 0:4eb2240dbd22 719 {
andreikovacs 0:4eb2240dbd22 720 if(gTestModeContinuousTxUnmodulated_c != contTestRunning)
andreikovacs 0:4eb2240dbd22 721 {
andreikovacs 0:4eb2240dbd22 722 contTestRunning = gTestModeContinuousTxUnmodulated_c;
andreikovacs 0:4eb2240dbd22 723 cTxRxState = gCTxRxStateInit_c;
andreikovacs 0:4eb2240dbd22 724 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 725 }
andreikovacs 0:4eb2240dbd22 726 }
andreikovacs 0:4eb2240dbd22 727 else if('5' == gu8UartData)
andreikovacs 0:4eb2240dbd22 728 {
andreikovacs 0:4eb2240dbd22 729 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 730 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 731 MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 732 contTestRunning = gTestModeForceIdle_c;
andreikovacs 0:4eb2240dbd22 733 uart.printf("\f\r\nPress [p] to stop receiving broadcast packets \r\n");
andreikovacs 0:4eb2240dbd22 734 bRxDone = FALSE;
andreikovacs 0:4eb2240dbd22 735 gAppRxPacket->u8MaxDataLength = gMaxSmacSDULength_c;
andreikovacs 0:4eb2240dbd22 736 (void)MLMERXEnableRequest(gAppRxPacket, 0);
andreikovacs 0:4eb2240dbd22 737 cTxRxState = gCTxRxStateRunnigRxTest_c;
andreikovacs 0:4eb2240dbd22 738 }
andreikovacs 0:4eb2240dbd22 739 else if('6' == gu8UartData)
andreikovacs 0:4eb2240dbd22 740 {
andreikovacs 0:4eb2240dbd22 741 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 742 contTestRunning = gTestModeForceIdle_c;
andreikovacs 0:4eb2240dbd22 743 uart.printf("\f\r\nPress [p] to stop the Continuous ED test\r\n");
andreikovacs 0:4eb2240dbd22 744 cTxRxState = gCTxRxStateRunnigEdTest_c;
andreikovacs 0:4eb2240dbd22 745 Thread::wait(200);
andreikovacs 0:4eb2240dbd22 746 }
andreikovacs 0:4eb2240dbd22 747 else if('7' == gu8UartData)
andreikovacs 0:4eb2240dbd22 748 {
andreikovacs 0:4eb2240dbd22 749 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 750 contTestRunning = gTestModeForceIdle_c;
andreikovacs 0:4eb2240dbd22 751 ChannelToScan= gDefaultChannelNumber_c;
andreikovacs 0:4eb2240dbd22 752 uart.printf("\f\r\nPress [p] to stop the Continuous SCAN test\r\n");
andreikovacs 0:4eb2240dbd22 753 bScanDone = FALSE;
andreikovacs 0:4eb2240dbd22 754 cTxRxState = gCTxRxStateRunnigScanTest_c;
andreikovacs 0:4eb2240dbd22 755 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 756 }
andreikovacs 0:4eb2240dbd22 757 else if('8' == gu8UartData)
andreikovacs 0:4eb2240dbd22 758 {
andreikovacs 0:4eb2240dbd22 759 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 760 uart.printf("\f\r\nPress [p] to stop the Continuous CCA test\r\n");
andreikovacs 0:4eb2240dbd22 761 contTestRunning = gTestModeForceIdle_c;
andreikovacs 0:4eb2240dbd22 762 cTxRxState = gCTxRxStateRunnigCcaTest_c;
andreikovacs 0:4eb2240dbd22 763 Thread::wait(100);
andreikovacs 0:4eb2240dbd22 764 MLMECcaRequest();
andreikovacs 0:4eb2240dbd22 765 }
andreikovacs 0:4eb2240dbd22 766 #if CT_Feature_BER_Test
andreikovacs 0:4eb2240dbd22 767 else if ('9' == gu8UartData)
andreikovacs 0:4eb2240dbd22 768 {
andreikovacs 0:4eb2240dbd22 769 uart.printf( "\f\r\nPress [p] to stop the Continuous BER test\r\n");
andreikovacs 0:4eb2240dbd22 770 contTestRunning = gTestModeContinuousRxBER_c;
andreikovacs 0:4eb2240dbd22 771 cTxRxState = gCTxRxStateInit_c;
andreikovacs 0:4eb2240dbd22 772 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 773 }
andreikovacs 0:4eb2240dbd22 774 #endif
andreikovacs 0:4eb2240dbd22 775 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 776 {
andreikovacs 0:4eb2240dbd22 777 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 778 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 779 AppDelayTmr.stop();
andreikovacs 0:4eb2240dbd22 780 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 781 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 782 }
andreikovacs 0:4eb2240dbd22 783 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 784 }
andreikovacs 0:4eb2240dbd22 785 break;
andreikovacs 0:4eb2240dbd22 786 case gCTxRxStateRunningTXModSelectOpt:
andreikovacs 0:4eb2240dbd22 787 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 788 {
andreikovacs 0:4eb2240dbd22 789 if(gu8UartData == '2')
andreikovacs 0:4eb2240dbd22 790 contTxModBitValue = gContTxModSelectPN9_c;
andreikovacs 0:4eb2240dbd22 791 else
andreikovacs 0:4eb2240dbd22 792 if(gu8UartData == '1')
andreikovacs 0:4eb2240dbd22 793 contTxModBitValue = gContTxModSelectOnes_c;
andreikovacs 0:4eb2240dbd22 794 else
andreikovacs 0:4eb2240dbd22 795 if(gu8UartData == '0')
andreikovacs 0:4eb2240dbd22 796 contTxModBitValue = gContTxModSelectZeros_c;
andreikovacs 0:4eb2240dbd22 797
andreikovacs 0:4eb2240dbd22 798 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 799 cTxRxState = gCTxRxStateInit_c;
andreikovacs 0:4eb2240dbd22 800 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 801 }
andreikovacs 0:4eb2240dbd22 802 break;
andreikovacs 0:4eb2240dbd22 803 case gCTxRxStateRunningPRBS9Test_c:
andreikovacs 0:4eb2240dbd22 804 if(bTxDone || failedPRBS9)
andreikovacs 0:4eb2240dbd22 805 {
andreikovacs 0:4eb2240dbd22 806 failedPRBS9 = FALSE;
andreikovacs 0:4eb2240dbd22 807 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 808 PacketHandler_Prbs9();
andreikovacs 0:4eb2240dbd22 809 }
andreikovacs 0:4eb2240dbd22 810 if(evDataFromUART && 'p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 811 {
andreikovacs 0:4eb2240dbd22 812 contTestRunning = gTestModeForceIdle_c;
andreikovacs 0:4eb2240dbd22 813 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 814 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 815 AppDelayTmr.stop();
andreikovacs 0:4eb2240dbd22 816 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 817 uart.printf("\r\n\r\n Press [enter] to go back to the Continuous test menu ");
andreikovacs 0:4eb2240dbd22 818 cTxRxState = gCTxRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 819 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 820 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 821 }
andreikovacs 0:4eb2240dbd22 822 break;
andreikovacs 0:4eb2240dbd22 823 case gCTxRxStateRunnigRxTest_c:
andreikovacs 0:4eb2240dbd22 824 if(bRxDone)
andreikovacs 0:4eb2240dbd22 825 {
andreikovacs 0:4eb2240dbd22 826 if (gAppRxPacket->rxStatus == rxSuccessStatus_c)
andreikovacs 0:4eb2240dbd22 827 {
andreikovacs 0:4eb2240dbd22 828 uart.printf("New Packet: ");
andreikovacs 0:4eb2240dbd22 829 for(u8Index = 0; u8Index < (gAppRxPacket->u8DataLength); u8Index++){
andreikovacs 0:4eb2240dbd22 830 uart.printf( (const char *)(&(gAppRxPacket->smacPdu.smacPdu[u8Index])));
andreikovacs 0:4eb2240dbd22 831 }
andreikovacs 0:4eb2240dbd22 832 uart.printf(" \r\n");
andreikovacs 0:4eb2240dbd22 833 }
andreikovacs 0:4eb2240dbd22 834 bRxDone = FALSE;
andreikovacs 0:4eb2240dbd22 835 gAppRxPacket->u8MaxDataLength = gMaxSmacSDULength_c;
andreikovacs 0:4eb2240dbd22 836 (void)MLMERXEnableRequest(gAppRxPacket, 0);
andreikovacs 0:4eb2240dbd22 837 }
andreikovacs 0:4eb2240dbd22 838 if((evDataFromUART) && ('p' == gu8UartData))
andreikovacs 0:4eb2240dbd22 839 {
andreikovacs 0:4eb2240dbd22 840 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 841 (void)TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 842 uart.printf("\r\n\r\n Press [enter] to go back to the Continuous test menu ");
andreikovacs 0:4eb2240dbd22 843 cTxRxState = gCTxRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 844 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 845 }
andreikovacs 0:4eb2240dbd22 846 break;
andreikovacs 0:4eb2240dbd22 847 case gCTxRxStateRunnigEdTest_c:
andreikovacs 0:4eb2240dbd22 848 if(timePassed)
andreikovacs 0:4eb2240dbd22 849 {
andreikovacs 0:4eb2240dbd22 850 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 851 Thread::wait(100);
andreikovacs 0:4eb2240dbd22 852 MLMEScanRequest(testChannel);
andreikovacs 0:4eb2240dbd22 853 }
andreikovacs 0:4eb2240dbd22 854 if((evDataFromUART) && ('p' == gu8UartData))
andreikovacs 0:4eb2240dbd22 855 {
andreikovacs 0:4eb2240dbd22 856 uart.printf("\r\n\r\n Press [enter] to go back to the Continuous test menu ");
andreikovacs 0:4eb2240dbd22 857 cTxRxState = gCTxRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 858 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 859 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 860 AppDelayTmr.stop();
andreikovacs 0:4eb2240dbd22 861 }
andreikovacs 0:4eb2240dbd22 862
andreikovacs 0:4eb2240dbd22 863 break;
andreikovacs 0:4eb2240dbd22 864 case gCTxRxStateRunningEdTestGotResult_c:
andreikovacs 0:4eb2240dbd22 865 uart.printf("Energy on the Channel %d : ", (uint32_t)testChannel);
andreikovacs 0:4eb2240dbd22 866 u8TempEnergyValue = au8ScanResults[testChannel];
andreikovacs 0:4eb2240dbd22 867 if(u8TempEnergyValue != 0)
andreikovacs 0:4eb2240dbd22 868 uart.printf( "-");
andreikovacs 0:4eb2240dbd22 869 uart.printf("%d dBm\r\n ",(uint32_t)u8TempEnergyValue);
andreikovacs 0:4eb2240dbd22 870 cTxRxState = gCTxRxStateRunnigEdTest_c;
andreikovacs 0:4eb2240dbd22 871 break;
andreikovacs 0:4eb2240dbd22 872 case gCTxRxStateRunnigCcaTest_c:
andreikovacs 0:4eb2240dbd22 873 if(timePassed && gCCaGotResult)
andreikovacs 0:4eb2240dbd22 874 {
andreikovacs 0:4eb2240dbd22 875 gCCaGotResult = FALSE;
andreikovacs 0:4eb2240dbd22 876 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 877 MLMECcaRequest();
andreikovacs 0:4eb2240dbd22 878 Thread::wait(100);
andreikovacs 0:4eb2240dbd22 879 }
andreikovacs 0:4eb2240dbd22 880 if((evDataFromUART) && ('p' == gu8UartData))
andreikovacs 0:4eb2240dbd22 881 {
andreikovacs 0:4eb2240dbd22 882 uart.printf("\r\n\r\n Press [enter] to go back to the Continuous test menu ");
andreikovacs 0:4eb2240dbd22 883 cTxRxState = gCTxRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 884 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 885 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 886 AppDelayTmr.stop();
andreikovacs 0:4eb2240dbd22 887 }
andreikovacs 0:4eb2240dbd22 888 break;
andreikovacs 0:4eb2240dbd22 889 case gCTxRxStateRunnigScanTest_c:
andreikovacs 0:4eb2240dbd22 890 if(bScanDone && timePassed)
andreikovacs 0:4eb2240dbd22 891 {
andreikovacs 0:4eb2240dbd22 892 //Enters here until all channels have been scanned. Then starts to print.
andreikovacs 0:4eb2240dbd22 893 uart.printf("Results : ");
andreikovacs 0:4eb2240dbd22 894 for(u8Index = gMinChannel_c; u8Index <= gMaxChannel_c ; u8Index++)
andreikovacs 0:4eb2240dbd22 895 {
andreikovacs 0:4eb2240dbd22 896 u8TempScanValue= au8ScanResults[u8Index];
andreikovacs 0:4eb2240dbd22 897 if(u8TempScanValue != 0)
andreikovacs 0:4eb2240dbd22 898 uart.printf("-");
andreikovacs 0:4eb2240dbd22 899 uart.printf("%d, ", (uint32_t) u8TempScanValue);
andreikovacs 0:4eb2240dbd22 900 }
andreikovacs 0:4eb2240dbd22 901 uart.printf("\b \r\n");
andreikovacs 0:4eb2240dbd22 902 bScanDone = FALSE;
andreikovacs 0:4eb2240dbd22 903 ChannelToScan = gDefaultChannelNumber_c; // Restart channel count
andreikovacs 0:4eb2240dbd22 904 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 905 }
andreikovacs 0:4eb2240dbd22 906
andreikovacs 0:4eb2240dbd22 907 if((evDataFromUART) && ('p' == gu8UartData))
andreikovacs 0:4eb2240dbd22 908 {
andreikovacs 0:4eb2240dbd22 909 uart.printf("\r\n\r\n Press [enter] to go back to the Continuous test menu ");
andreikovacs 0:4eb2240dbd22 910 cTxRxState = gCTxRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 911 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 912 }
andreikovacs 0:4eb2240dbd22 913 else
andreikovacs 0:4eb2240dbd22 914 {
andreikovacs 0:4eb2240dbd22 915 if(ChannelToScan == gDefaultChannelNumber_c)
andreikovacs 0:4eb2240dbd22 916 {
andreikovacs 0:4eb2240dbd22 917 smacErrors_t err = MLMEScanRequest((channels_t)ChannelToScan);
andreikovacs 0:4eb2240dbd22 918 if(err == gErrorNoError_c)
andreikovacs 0:4eb2240dbd22 919 ChannelToScan++;
andreikovacs 0:4eb2240dbd22 920 }
andreikovacs 0:4eb2240dbd22 921 //Each of the other channels is scanned after SMAC notifies us that
andreikovacs 0:4eb2240dbd22 922 //it has obtained the energy value on the currently scanned channel
andreikovacs 0:4eb2240dbd22 923 //(channel scanning is performed asynchronously). See IncrementChannelOnEdEvent().
andreikovacs 0:4eb2240dbd22 924 }
andreikovacs 0:4eb2240dbd22 925 break;
andreikovacs 0:4eb2240dbd22 926 default:
andreikovacs 0:4eb2240dbd22 927 break;
andreikovacs 0:4eb2240dbd22 928 }
andreikovacs 0:4eb2240dbd22 929 return bBackFlag;
andreikovacs 0:4eb2240dbd22 930 }
andreikovacs 0:4eb2240dbd22 931
andreikovacs 0:4eb2240dbd22 932 /************************************************************************************
andreikovacs 0:4eb2240dbd22 933 *
andreikovacs 0:4eb2240dbd22 934 * PER Handler for board that is performing TX
andreikovacs 0:4eb2240dbd22 935 *
andreikovacs 0:4eb2240dbd22 936 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 937 bool_t PacketErrorRateTx(void)
andreikovacs 0:4eb2240dbd22 938 {
andreikovacs 0:4eb2240dbd22 939 const uint16_t u16TotalPacketsOptions[] = {1,25,100,500,1000,2000,5000,10000,65535};
andreikovacs 0:4eb2240dbd22 940 static uint16_t u16TotalPackets;
andreikovacs 0:4eb2240dbd22 941 static uint16_t u16SentPackets;
andreikovacs 0:4eb2240dbd22 942 static uint32_t miliSecDelay;
andreikovacs 0:4eb2240dbd22 943 static uint32_t u32MinDelay = 4;
andreikovacs 0:4eb2240dbd22 944 uint8_t u8Index;
andreikovacs 0:4eb2240dbd22 945 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 946
andreikovacs 0:4eb2240dbd22 947 if(evTestParameters)
andreikovacs 0:4eb2240dbd22 948 {
andreikovacs 0:4eb2240dbd22 949 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 950 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 951 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 952 #endif
andreikovacs 0:4eb2240dbd22 953 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 954 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 955 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 956 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 957 }
andreikovacs 0:4eb2240dbd22 958
andreikovacs 0:4eb2240dbd22 959 switch(perTxState)
andreikovacs 0:4eb2240dbd22 960 {
andreikovacs 0:4eb2240dbd22 961 case gPerTxStateInit_c:
andreikovacs 0:4eb2240dbd22 962 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 963 PrintMenu(cu8PerTxTestMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 964 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 965 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 966 perTxState = gPerTxStateSelectPacketNum_c;
andreikovacs 0:4eb2240dbd22 967 miliSecDelay = 0;
andreikovacs 0:4eb2240dbd22 968 u32MinDelay = 4;
andreikovacs 0:4eb2240dbd22 969 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 970 break;
andreikovacs 0:4eb2240dbd22 971 case gPerTxStateSelectPacketNum_c:
andreikovacs 0:4eb2240dbd22 972 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 973 {
andreikovacs 0:4eb2240dbd22 974 if((gu8UartData >= '0') && (gu8UartData <= '8'))
andreikovacs 0:4eb2240dbd22 975 {
andreikovacs 0:4eb2240dbd22 976 u16TotalPackets = u16TotalPacketsOptions[gu8UartData - '0'];
andreikovacs 0:4eb2240dbd22 977 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 978 u32MinDelay += (GetTransmissionTime(testPayloadLen, crtBitrate) / 1000);
andreikovacs 0:4eb2240dbd22 979 uart.printf("\r\n\r\n Please type TX interval in miliseconds ( > %d ms ) and press [ENTER]\r\n", u32MinDelay);
andreikovacs 0:4eb2240dbd22 980 perTxState = gPerTxStateInputPacketDelay_c;
andreikovacs 0:4eb2240dbd22 981 }
andreikovacs 0:4eb2240dbd22 982 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 983 {
andreikovacs 0:4eb2240dbd22 984 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 985 }
andreikovacs 0:4eb2240dbd22 986 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 987 }
andreikovacs 0:4eb2240dbd22 988 break;
andreikovacs 0:4eb2240dbd22 989 case gPerTxStateInputPacketDelay_c:
andreikovacs 0:4eb2240dbd22 990 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 991 {
andreikovacs 0:4eb2240dbd22 992 if(gu8UartData == '\r')
andreikovacs 0:4eb2240dbd22 993 {
andreikovacs 0:4eb2240dbd22 994 if(miliSecDelay < u32MinDelay)
andreikovacs 0:4eb2240dbd22 995 {
andreikovacs 0:4eb2240dbd22 996 uart.printf("\r\n\tError: TX Interval too small\r\n");
andreikovacs 0:4eb2240dbd22 997 perTxState = gPerTxStateInit_c;
andreikovacs 0:4eb2240dbd22 998 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 999 }
andreikovacs 0:4eb2240dbd22 1000 else
andreikovacs 0:4eb2240dbd22 1001 {
andreikovacs 0:4eb2240dbd22 1002 perTxState = gPerTxStateStartTest_c;
andreikovacs 0:4eb2240dbd22 1003 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1004 }
andreikovacs 0:4eb2240dbd22 1005 }
andreikovacs 0:4eb2240dbd22 1006 else if((gu8UartData >= '0') && (gu8UartData <='9'))
andreikovacs 0:4eb2240dbd22 1007 {
andreikovacs 0:4eb2240dbd22 1008 miliSecDelay = miliSecDelay*10 + (gu8UartData - '0');
andreikovacs 0:4eb2240dbd22 1009 uart.printf("%d", (uint32_t)(gu8UartData - '0'));
andreikovacs 0:4eb2240dbd22 1010 }
andreikovacs 0:4eb2240dbd22 1011 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1012 {
andreikovacs 0:4eb2240dbd22 1013 perTxState = gPerTxStateInit_c;
andreikovacs 0:4eb2240dbd22 1014 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1015 }
andreikovacs 0:4eb2240dbd22 1016 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1017 }
andreikovacs 0:4eb2240dbd22 1018 break;
andreikovacs 0:4eb2240dbd22 1019 case gPerTxStateStartTest_c:
andreikovacs 0:4eb2240dbd22 1020 gAppTxPacket->u8DataLength = testPayloadLen;
andreikovacs 0:4eb2240dbd22 1021 u16SentPackets = 0;
andreikovacs 0:4eb2240dbd22 1022
andreikovacs 0:4eb2240dbd22 1023 gAppTxPacket->smacPdu.smacPdu[0] = (u16TotalPackets >> 8);
andreikovacs 0:4eb2240dbd22 1024 gAppTxPacket->smacPdu.smacPdu[1] = (uint8_t)u16TotalPackets;
andreikovacs 0:4eb2240dbd22 1025 gAppTxPacket->smacPdu.smacPdu[2] = ((u16SentPackets+1) >> 8);
andreikovacs 0:4eb2240dbd22 1026 gAppTxPacket->smacPdu.smacPdu[3] = (uint8_t)(u16SentPackets+1);
andreikovacs 0:4eb2240dbd22 1027 FLib_MemCpy(&(gAppTxPacket->smacPdu.smacPdu[4]), (void*)"SMAC PER Demo",13);
andreikovacs 0:4eb2240dbd22 1028 if(17 < testPayloadLen)
andreikovacs 0:4eb2240dbd22 1029 {
andreikovacs 0:4eb2240dbd22 1030 for(u8Index=17;u8Index<testPayloadLen;u8Index++)
andreikovacs 0:4eb2240dbd22 1031 {
andreikovacs 0:4eb2240dbd22 1032 gAppTxPacket->smacPdu.smacPdu[u8Index] = (u8Index%10)+'0';
andreikovacs 0:4eb2240dbd22 1033 }
andreikovacs 0:4eb2240dbd22 1034 }
andreikovacs 0:4eb2240dbd22 1035 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 1036 (void)MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 1037 u16SentPackets++;
andreikovacs 0:4eb2240dbd22 1038 uart.printf("\f\r\n Running PER Tx, Sending %d Packets",(uint32_t)u16TotalPackets);
andreikovacs 0:4eb2240dbd22 1039 perTxState = gPerTxStateRunningTest_c;
andreikovacs 0:4eb2240dbd22 1040 Thread::wait(miliSecDelay);
andreikovacs 0:4eb2240dbd22 1041 break;
andreikovacs 0:4eb2240dbd22 1042 case gPerTxStateRunningTest_c:
andreikovacs 0:4eb2240dbd22 1043 if(bTxDone && timePassed)
andreikovacs 0:4eb2240dbd22 1044 {
andreikovacs 0:4eb2240dbd22 1045 uart.printf("\r\n Packet %d ",(uint32_t)u16SentPackets);
andreikovacs 0:4eb2240dbd22 1046 if(u16SentPackets == u16TotalPackets)
andreikovacs 0:4eb2240dbd22 1047 {
andreikovacs 0:4eb2240dbd22 1048 uart.printf("\r\n\r\nSending last %d frames \r\n",(uint32_t)mTotalFinalFrames_c);
andreikovacs 0:4eb2240dbd22 1049 FLib_MemCpy(&(gAppTxPacket->smacPdu.smacPdu[4]), (void *)"DONE",4);
andreikovacs 0:4eb2240dbd22 1050 gAppTxPacket->u8DataLength = 8;
andreikovacs 0:4eb2240dbd22 1051 u16SentPackets = 0;
andreikovacs 0:4eb2240dbd22 1052 u16TotalPackets = mTotalFinalFrames_c;
andreikovacs 0:4eb2240dbd22 1053 gAppTxPacket->u8DataLength = 8;
andreikovacs 0:4eb2240dbd22 1054 perTxState = gPerTxStateSendingLastFrames_c;
andreikovacs 0:4eb2240dbd22 1055 }
andreikovacs 0:4eb2240dbd22 1056 else
andreikovacs 0:4eb2240dbd22 1057 {
andreikovacs 0:4eb2240dbd22 1058 gAppTxPacket->smacPdu.smacPdu[2] = ((u16SentPackets+1) >> 8);
andreikovacs 0:4eb2240dbd22 1059 gAppTxPacket->smacPdu.smacPdu[3] = (uint8_t)(u16SentPackets+1);
andreikovacs 0:4eb2240dbd22 1060 gAppTxPacket->u8DataLength = testPayloadLen;
andreikovacs 0:4eb2240dbd22 1061 }
andreikovacs 0:4eb2240dbd22 1062 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 1063 (void)MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 1064 u16SentPackets++;
andreikovacs 0:4eb2240dbd22 1065 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 1066 Thread::wait(miliSecDelay);
andreikovacs 0:4eb2240dbd22 1067 }
andreikovacs 0:4eb2240dbd22 1068 if(evDataFromUART && gu8UartData == ' ')
andreikovacs 0:4eb2240dbd22 1069 {
andreikovacs 0:4eb2240dbd22 1070 uart.printf("\r\n\r\n-Test interrupted by user. Press [ENTER] to continue\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1071 perTxState = gPerTxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1072 }
andreikovacs 0:4eb2240dbd22 1073 break;
andreikovacs 0:4eb2240dbd22 1074 case gPerTxStateSendingLastFrames_c:
andreikovacs 0:4eb2240dbd22 1075 if(bTxDone && timePassed)
andreikovacs 0:4eb2240dbd22 1076 {
andreikovacs 0:4eb2240dbd22 1077 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 1078 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 1079 uart.printf("\r\n Final Packet %d",(uint32_t)u16SentPackets);
andreikovacs 0:4eb2240dbd22 1080 if(u16SentPackets == u16TotalPackets)
andreikovacs 0:4eb2240dbd22 1081 {
andreikovacs 0:4eb2240dbd22 1082 uart.printf( "\r\n PER Tx DONE \r\n");
andreikovacs 0:4eb2240dbd22 1083 uart.printf( "\r\n\r\n Press [enter] to go back to the PER Tx test menu ");
andreikovacs 0:4eb2240dbd22 1084 perTxState = gPerTxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1085 AppDelayTmr.stop();
andreikovacs 0:4eb2240dbd22 1086 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 1087 }
andreikovacs 0:4eb2240dbd22 1088 else
andreikovacs 0:4eb2240dbd22 1089 {
andreikovacs 0:4eb2240dbd22 1090 gAppTxPacket->u8DataLength = 8;
andreikovacs 0:4eb2240dbd22 1091 (void)MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 1092 u16SentPackets++;
andreikovacs 0:4eb2240dbd22 1093 Thread::wait(miliSecDelay);
andreikovacs 0:4eb2240dbd22 1094 }
andreikovacs 0:4eb2240dbd22 1095 }
andreikovacs 0:4eb2240dbd22 1096 if(evDataFromUART && gu8UartData == ' ')
andreikovacs 0:4eb2240dbd22 1097 {
andreikovacs 0:4eb2240dbd22 1098 uart.printf("\r\n\r\n-Test interrupted by user. Press [ENTER] to continue\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1099 perTxState = gPerTxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1100 }
andreikovacs 0:4eb2240dbd22 1101 break;
andreikovacs 0:4eb2240dbd22 1102 case gPerTxStateIdle_c:
andreikovacs 0:4eb2240dbd22 1103 if((evDataFromUART) && ('\r' == gu8UartData))
andreikovacs 0:4eb2240dbd22 1104 {
andreikovacs 0:4eb2240dbd22 1105 perTxState = gPerTxStateInit_c;
andreikovacs 0:4eb2240dbd22 1106 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1107 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1108 }
andreikovacs 0:4eb2240dbd22 1109 break;
andreikovacs 0:4eb2240dbd22 1110 default:
andreikovacs 0:4eb2240dbd22 1111 break;
andreikovacs 0:4eb2240dbd22 1112 }
andreikovacs 0:4eb2240dbd22 1113
andreikovacs 0:4eb2240dbd22 1114 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1115 }
andreikovacs 0:4eb2240dbd22 1116
andreikovacs 0:4eb2240dbd22 1117 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1118 *
andreikovacs 0:4eb2240dbd22 1119 * PER Handler for board that is performing RX
andreikovacs 0:4eb2240dbd22 1120 *
andreikovacs 0:4eb2240dbd22 1121 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1122 bool_t PacketErrorRateRx(void)
andreikovacs 0:4eb2240dbd22 1123 {
andreikovacs 0:4eb2240dbd22 1124 static uint16_t u16ReceivedPackets;
andreikovacs 0:4eb2240dbd22 1125 static uint16_t u16PacketsIndex;
andreikovacs 0:4eb2240dbd22 1126 static uint16_t u16TotalPackets;
andreikovacs 0:4eb2240dbd22 1127 static uint16_t u16FinalPacketsCount;
andreikovacs 0:4eb2240dbd22 1128 static uint32_t u32RssiSum;
andreikovacs 0:4eb2240dbd22 1129 static uint8_t u8AverageRssi;
andreikovacs 0:4eb2240dbd22 1130 uint8_t u8TempRssivalue;
andreikovacs 0:4eb2240dbd22 1131
andreikovacs 0:4eb2240dbd22 1132 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1133 if(evTestParameters)
andreikovacs 0:4eb2240dbd22 1134 {
andreikovacs 0:4eb2240dbd22 1135 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 1136 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 1137 #endif
andreikovacs 0:4eb2240dbd22 1138 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 1139 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 1140 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 1141 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 1142 }
andreikovacs 0:4eb2240dbd22 1143 switch(perRxState)
andreikovacs 0:4eb2240dbd22 1144 {
andreikovacs 0:4eb2240dbd22 1145 case gPerRxStateInit_c:
andreikovacs 0:4eb2240dbd22 1146 u16TotalPackets = 0;
andreikovacs 0:4eb2240dbd22 1147 u16ReceivedPackets = 0;
andreikovacs 0:4eb2240dbd22 1148 u16PacketsIndex = 0;
andreikovacs 0:4eb2240dbd22 1149 u32RssiSum = 0;
andreikovacs 0:4eb2240dbd22 1150 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 1151 PrintMenu(cu8PerRxTestMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 1152 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 1153 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 1154 perRxState = gPerRxWaitStartTest_c;
andreikovacs 0:4eb2240dbd22 1155 break;
andreikovacs 0:4eb2240dbd22 1156 case gPerRxWaitStartTest_c:
andreikovacs 0:4eb2240dbd22 1157 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1158 {
andreikovacs 0:4eb2240dbd22 1159 if(' ' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1160 {
andreikovacs 0:4eb2240dbd22 1161 uart.printf("\f\n\rPER Test Rx Running\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1162 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1163 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 1164 perRxState = gPerRxStateStartTest_c;
andreikovacs 0:4eb2240dbd22 1165 }
andreikovacs 0:4eb2240dbd22 1166 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1167 {
andreikovacs 0:4eb2240dbd22 1168 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1169 }
andreikovacs 0:4eb2240dbd22 1170 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1171 }
andreikovacs 0:4eb2240dbd22 1172 break;
andreikovacs 0:4eb2240dbd22 1173 case gPerRxStateStartTest_c:
andreikovacs 0:4eb2240dbd22 1174 if(bRxDone)
andreikovacs 0:4eb2240dbd22 1175 {
andreikovacs 0:4eb2240dbd22 1176 if (gAppRxPacket->rxStatus == rxSuccessStatus_c)
andreikovacs 0:4eb2240dbd22 1177 {
andreikovacs 0:4eb2240dbd22 1178 if(stringComp((uint8_t*)"SMAC PER Demo",&gAppRxPacket->smacPdu.smacPdu[4],13))
andreikovacs 0:4eb2240dbd22 1179 {
andreikovacs 0:4eb2240dbd22 1180 u16TotalPackets = ((uint16_t)gAppRxPacket->smacPdu.smacPdu[0] <<8) + gAppRxPacket->smacPdu.smacPdu[1];
andreikovacs 0:4eb2240dbd22 1181 u16PacketsIndex = ((uint16_t)gAppRxPacket->smacPdu.smacPdu[2] <<8) + gAppRxPacket->smacPdu.smacPdu[3];
andreikovacs 0:4eb2240dbd22 1182 u16ReceivedPackets++;
andreikovacs 0:4eb2240dbd22 1183 u8TempRssivalue= u8LastRxRssiValue; //@CMA, Conn Test. New line
andreikovacs 0:4eb2240dbd22 1184 u32RssiSum += u8TempRssivalue;
andreikovacs 0:4eb2240dbd22 1185 u8AverageRssi = (uint8_t)(u32RssiSum/u16ReceivedPackets);
andreikovacs 0:4eb2240dbd22 1186 uart.printf("Packet %d . Packet index: %d . Rssi during RX: - %d\r\n",(uint32_t)u16ReceivedPackets, (uint32_t)u16PacketsIndex, (uint32_t)u8LastRxRssiValue);
andreikovacs 0:4eb2240dbd22 1187 if(u16PacketsIndex == u16TotalPackets)
andreikovacs 0:4eb2240dbd22 1188 {
andreikovacs 0:4eb2240dbd22 1189 u16FinalPacketsCount = 0;
andreikovacs 0:4eb2240dbd22 1190 perRxState = gPerRxStateReceivingLastFrames_c;
andreikovacs 0:4eb2240dbd22 1191 }
andreikovacs 0:4eb2240dbd22 1192 }
andreikovacs 0:4eb2240dbd22 1193 else if(stringComp((uint8_t*)"DONE",&gAppRxPacket->smacPdu.smacPdu[4],4))
andreikovacs 0:4eb2240dbd22 1194 {
andreikovacs 0:4eb2240dbd22 1195 u16FinalPacketsCount = 0;
andreikovacs 0:4eb2240dbd22 1196 perRxState = gPerRxStateReceivingLastFrames_c;
andreikovacs 0:4eb2240dbd22 1197 }
andreikovacs 0:4eb2240dbd22 1198 }
andreikovacs 0:4eb2240dbd22 1199 else
andreikovacs 0:4eb2240dbd22 1200 {
andreikovacs 0:4eb2240dbd22 1201 if(u16TotalPackets)
andreikovacs 0:4eb2240dbd22 1202 {
andreikovacs 0:4eb2240dbd22 1203 u16PacketsIndex++;
andreikovacs 0:4eb2240dbd22 1204 if(u16PacketsIndex == u16TotalPackets)
andreikovacs 0:4eb2240dbd22 1205 {
andreikovacs 0:4eb2240dbd22 1206 u16FinalPacketsCount = 0;
andreikovacs 0:4eb2240dbd22 1207 perRxState = gPerRxStateReceivingLastFrames_c;
andreikovacs 0:4eb2240dbd22 1208 }
andreikovacs 0:4eb2240dbd22 1209 }
andreikovacs 0:4eb2240dbd22 1210 }
andreikovacs 0:4eb2240dbd22 1211
andreikovacs 0:4eb2240dbd22 1212 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1213 }
andreikovacs 0:4eb2240dbd22 1214 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1215 {
andreikovacs 0:4eb2240dbd22 1216 if(' ' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1217 {
andreikovacs 0:4eb2240dbd22 1218 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 1219 uart.printf("\r\nAverage Rssi during PER: -");
andreikovacs 0:4eb2240dbd22 1220 uart.printf("%d",(uint32_t)u8AverageRssi);
andreikovacs 0:4eb2240dbd22 1221 uart.printf(" dBm\r\n");
andreikovacs 0:4eb2240dbd22 1222 uart.printf( "\n\rPER Test Rx Stopped\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1223 PrintPerRxFinalLine(u16ReceivedPackets,u16TotalPackets);
andreikovacs 0:4eb2240dbd22 1224 perRxState = gPerRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1225 }
andreikovacs 0:4eb2240dbd22 1226 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1227 }
andreikovacs 0:4eb2240dbd22 1228 break;
andreikovacs 0:4eb2240dbd22 1229 case gPerRxStateReceivingLastFrames_c:
andreikovacs 0:4eb2240dbd22 1230 if(bRxDone)
andreikovacs 0:4eb2240dbd22 1231 {
andreikovacs 0:4eb2240dbd22 1232 u16FinalPacketsCount++;
andreikovacs 0:4eb2240dbd22 1233 if(mTotalFinalFrames_c == u16FinalPacketsCount)
andreikovacs 0:4eb2240dbd22 1234 {
andreikovacs 0:4eb2240dbd22 1235 uart.printf("\r\nAverage Rssi during PER: -");
andreikovacs 0:4eb2240dbd22 1236 uart.printf("%d",(uint32_t)u8AverageRssi);
andreikovacs 0:4eb2240dbd22 1237 uart.printf(" dBm\r\n");
andreikovacs 0:4eb2240dbd22 1238 uart.printf( "\n\rPER Test Finished\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1239 PrintPerRxFinalLine(u16ReceivedPackets,u16TotalPackets);
andreikovacs 0:4eb2240dbd22 1240 perRxState = gPerRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1241 }
andreikovacs 0:4eb2240dbd22 1242 else
andreikovacs 0:4eb2240dbd22 1243 {
andreikovacs 0:4eb2240dbd22 1244 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1245 }
andreikovacs 0:4eb2240dbd22 1246 }
andreikovacs 0:4eb2240dbd22 1247 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1248 {
andreikovacs 0:4eb2240dbd22 1249 if(' ' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1250 {
andreikovacs 0:4eb2240dbd22 1251 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 1252 uart.printf("\r\nAverage Rssi during PER: -");
andreikovacs 0:4eb2240dbd22 1253 uart.printf("%d",(uint32_t)u8AverageRssi);
andreikovacs 0:4eb2240dbd22 1254 uart.printf(" dBm\r\n");
andreikovacs 0:4eb2240dbd22 1255 uart.printf( "\n\rPER Test Rx Stopped\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1256 PrintPerRxFinalLine(u16ReceivedPackets,u16TotalPackets);
andreikovacs 0:4eb2240dbd22 1257 perRxState = gPerRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1258 }
andreikovacs 0:4eb2240dbd22 1259 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1260 }
andreikovacs 0:4eb2240dbd22 1261 break;
andreikovacs 0:4eb2240dbd22 1262 case gPerRxStateIdle_c:
andreikovacs 0:4eb2240dbd22 1263 if((evDataFromUART) && ('\r' == gu8UartData))
andreikovacs 0:4eb2240dbd22 1264 {
andreikovacs 0:4eb2240dbd22 1265 perRxState = gPerRxStateInit_c;
andreikovacs 0:4eb2240dbd22 1266 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1267 }
andreikovacs 0:4eb2240dbd22 1268 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1269 break;
andreikovacs 0:4eb2240dbd22 1270 default:
andreikovacs 0:4eb2240dbd22 1271 break;
andreikovacs 0:4eb2240dbd22 1272 }
andreikovacs 0:4eb2240dbd22 1273 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1274 }
andreikovacs 0:4eb2240dbd22 1275
andreikovacs 0:4eb2240dbd22 1276 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1277 *
andreikovacs 0:4eb2240dbd22 1278 * Range Test Handler for board that is performing TX
andreikovacs 0:4eb2240dbd22 1279 *
andreikovacs 0:4eb2240dbd22 1280 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1281 bool_t RangeTx(void)
andreikovacs 0:4eb2240dbd22 1282 {
andreikovacs 0:4eb2240dbd22 1283 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1284 static uint32_t u32RSSISum;
andreikovacs 0:4eb2240dbd22 1285 static uint16_t u16ReceivedPackets;
andreikovacs 0:4eb2240dbd22 1286 static uint16_t u16PacketsDropped;
andreikovacs 0:4eb2240dbd22 1287 uint8_t u8AverageRSSI;
andreikovacs 0:4eb2240dbd22 1288 uint8_t u8CurrentRSSI;
andreikovacs 0:4eb2240dbd22 1289
andreikovacs 0:4eb2240dbd22 1290 if(evTestParameters)
andreikovacs 0:4eb2240dbd22 1291 {
andreikovacs 0:4eb2240dbd22 1292 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 1293 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 1294 #endif
andreikovacs 0:4eb2240dbd22 1295 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 1296 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 1297 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 1298 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 1299 }
andreikovacs 0:4eb2240dbd22 1300
andreikovacs 0:4eb2240dbd22 1301 switch(rangeTxState)
andreikovacs 0:4eb2240dbd22 1302 {
andreikovacs 0:4eb2240dbd22 1303 case gRangeTxStateInit_c:
andreikovacs 0:4eb2240dbd22 1304 u32RSSISum = 0;
andreikovacs 0:4eb2240dbd22 1305 u16ReceivedPackets = 0;
andreikovacs 0:4eb2240dbd22 1306 u16PacketsDropped = 0;
andreikovacs 0:4eb2240dbd22 1307 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 1308 PrintMenu(cu8RangeTxTestMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 1309 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 1310 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 1311 rangeTxState = gRangeTxWaitStartTest_c;
andreikovacs 0:4eb2240dbd22 1312 break;
andreikovacs 0:4eb2240dbd22 1313 case gRangeTxWaitStartTest_c:
andreikovacs 0:4eb2240dbd22 1314 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1315 {
andreikovacs 0:4eb2240dbd22 1316 if(' ' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1317 {
andreikovacs 0:4eb2240dbd22 1318 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 1319 uart.printf( "\f\r\nRange Test Tx Running\r\n");
andreikovacs 0:4eb2240dbd22 1320 rangeTxState = gRangeTxStateStartTest_c;
andreikovacs 0:4eb2240dbd22 1321 Thread::wait(200);
andreikovacs 0:4eb2240dbd22 1322 }
andreikovacs 0:4eb2240dbd22 1323 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1324 {
andreikovacs 0:4eb2240dbd22 1325 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1326 }
andreikovacs 0:4eb2240dbd22 1327 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1328 }
andreikovacs 0:4eb2240dbd22 1329 break;
andreikovacs 0:4eb2240dbd22 1330 case gRangeTxStateStartTest_c:
andreikovacs 0:4eb2240dbd22 1331 if(!timePassed) //waiting 200 ms
andreikovacs 0:4eb2240dbd22 1332 break;
andreikovacs 0:4eb2240dbd22 1333 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 1334 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 1335 gAppTxPacket->u8DataLength = 16;
andreikovacs 0:4eb2240dbd22 1336 gAppTxPacket->smacPdu.smacPdu[0] = 0;
andreikovacs 0:4eb2240dbd22 1337 FLib_MemCpy(&(gAppTxPacket->smacPdu.smacPdu[1]), (void*)"SMAC Range Demo",15);
andreikovacs 0:4eb2240dbd22 1338 MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 1339 //RangeTestTmr.stop(); //@CMA, Conn Test. Stop Rx timer
andreikovacs 0:4eb2240dbd22 1340 (void)MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 1341 rangeTxState = gRangeTxStateRunningTest_c;
andreikovacs 0:4eb2240dbd22 1342 break;
andreikovacs 0:4eb2240dbd22 1343 case gRangeTxStateRunningTest_c:
andreikovacs 0:4eb2240dbd22 1344 if(bTxDone)
andreikovacs 0:4eb2240dbd22 1345 {
andreikovacs 0:4eb2240dbd22 1346 RangeTestTmr.attach_us(RangeTest_Timer_CallBack, 80000); //@CMA, Conn Test. Start Timer
andreikovacs 0:4eb2240dbd22 1347 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1348 rangeTxState = gRangeTxStatePrintTestResults_c;
andreikovacs 0:4eb2240dbd22 1349 }
andreikovacs 0:4eb2240dbd22 1350 break;
andreikovacs 0:4eb2240dbd22 1351 case gRangeTxStatePrintTestResults_c:
andreikovacs 0:4eb2240dbd22 1352 if(bRxDone)
andreikovacs 0:4eb2240dbd22 1353 {
andreikovacs 0:4eb2240dbd22 1354 if(gAppRxPacket->rxStatus == rxSuccessStatus_c)
andreikovacs 0:4eb2240dbd22 1355 {
andreikovacs 0:4eb2240dbd22 1356 if(stringComp((uint8_t*)"SMAC Range Demo",&gAppRxPacket->smacPdu.smacPdu[1],15))
andreikovacs 0:4eb2240dbd22 1357 {
andreikovacs 0:4eb2240dbd22 1358 u8CurrentRSSI = (gAppRxPacket->smacPdu.smacPdu[0]);
andreikovacs 0:4eb2240dbd22 1359 u32RSSISum += u8CurrentRSSI;
andreikovacs 0:4eb2240dbd22 1360 u16ReceivedPackets++;
andreikovacs 0:4eb2240dbd22 1361 u8AverageRSSI = (uint8_t)(u32RSSISum/u16ReceivedPackets);
andreikovacs 0:4eb2240dbd22 1362 uart.printf( "\r\n RSSI = -");
andreikovacs 0:4eb2240dbd22 1363 uart.printf("%d", (uint32_t)u8CurrentRSSI);
andreikovacs 0:4eb2240dbd22 1364 uart.printf(" dBm");
andreikovacs 0:4eb2240dbd22 1365 }
andreikovacs 0:4eb2240dbd22 1366 else
andreikovacs 0:4eb2240dbd22 1367 {
andreikovacs 0:4eb2240dbd22 1368 RangeTestTmr.attach_us(RangeTest_Timer_CallBack, 80000); //@CMA, Conn Test. Start Timer
andreikovacs 0:4eb2240dbd22 1369 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1370 }
andreikovacs 0:4eb2240dbd22 1371 }
andreikovacs 0:4eb2240dbd22 1372 else
andreikovacs 0:4eb2240dbd22 1373 {
andreikovacs 0:4eb2240dbd22 1374 u16PacketsDropped++;
andreikovacs 0:4eb2240dbd22 1375 uart.printf( "\r\nPacket Dropped");
andreikovacs 0:4eb2240dbd22 1376 bRxDone= FALSE; //@CMA, Conn Test. Added
andreikovacs 0:4eb2240dbd22 1377 }
andreikovacs 0:4eb2240dbd22 1378 if(evDataFromUART && (' ' == gu8UartData))
andreikovacs 0:4eb2240dbd22 1379 {
andreikovacs 0:4eb2240dbd22 1380 uart.printf( "\n\r\n\rRange Test Tx Stopped\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1381 u8AverageRSSI = (uint8_t)(u32RSSISum/u16ReceivedPackets);
andreikovacs 0:4eb2240dbd22 1382 uart.printf( "Average RSSI -");
andreikovacs 0:4eb2240dbd22 1383 uart.printf("%d", (uint32_t)u8AverageRSSI);
andreikovacs 0:4eb2240dbd22 1384 uart.printf(" dBm");
andreikovacs 0:4eb2240dbd22 1385 uart.printf( "\r\nPackets dropped ");
andreikovacs 0:4eb2240dbd22 1386 uart.printf("%d", (uint32_t)u16PacketsDropped);
andreikovacs 0:4eb2240dbd22 1387 uart.printf( "\r\n\r\n Press [enter] to go back to the Range Tx test menu");
andreikovacs 0:4eb2240dbd22 1388 rangeTxState = gRangeTxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1389 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 1390 AppDelayTmr.stop();
andreikovacs 0:4eb2240dbd22 1391 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 1392 }
andreikovacs 0:4eb2240dbd22 1393 else
andreikovacs 0:4eb2240dbd22 1394 {
andreikovacs 0:4eb2240dbd22 1395 rangeTxState = gRangeTxStateStartTest_c;
andreikovacs 0:4eb2240dbd22 1396 Thread::wait(200);
andreikovacs 0:4eb2240dbd22 1397 }
andreikovacs 0:4eb2240dbd22 1398 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1399 }
andreikovacs 0:4eb2240dbd22 1400
andreikovacs 0:4eb2240dbd22 1401 break;
andreikovacs 0:4eb2240dbd22 1402 case gRangeTxStateIdle_c:
andreikovacs 0:4eb2240dbd22 1403 if((evDataFromUART) && ('\r' == gu8UartData))
andreikovacs 0:4eb2240dbd22 1404 {
andreikovacs 0:4eb2240dbd22 1405 rangeTxState = gRangeTxStateInit_c;
andreikovacs 0:4eb2240dbd22 1406 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1407 }
andreikovacs 0:4eb2240dbd22 1408 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1409 break;
andreikovacs 0:4eb2240dbd22 1410 default:
andreikovacs 0:4eb2240dbd22 1411 break;
andreikovacs 0:4eb2240dbd22 1412 }
andreikovacs 0:4eb2240dbd22 1413 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1414 }
andreikovacs 0:4eb2240dbd22 1415
andreikovacs 0:4eb2240dbd22 1416 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1417 *
andreikovacs 0:4eb2240dbd22 1418 * Range Test Handler for board that is performing RX
andreikovacs 0:4eb2240dbd22 1419 *
andreikovacs 0:4eb2240dbd22 1420 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1421 bool_t RangeRx(void)
andreikovacs 0:4eb2240dbd22 1422 {
andreikovacs 0:4eb2240dbd22 1423 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1424 static uint32_t u32RSSISum;
andreikovacs 0:4eb2240dbd22 1425 static uint16_t u16ReceivedPackets;
andreikovacs 0:4eb2240dbd22 1426 uint8_t u8AverageRSSI, u8TempRSSIvalue;
andreikovacs 0:4eb2240dbd22 1427 uint8_t u8CurrentRSSI;
andreikovacs 0:4eb2240dbd22 1428
andreikovacs 0:4eb2240dbd22 1429 if(evTestParameters)
andreikovacs 0:4eb2240dbd22 1430 {
andreikovacs 0:4eb2240dbd22 1431 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 1432 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 1433 #endif
andreikovacs 0:4eb2240dbd22 1434 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 1435 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 1436 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 1437 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 1438 }
andreikovacs 0:4eb2240dbd22 1439
andreikovacs 0:4eb2240dbd22 1440 switch(rangeRxState)
andreikovacs 0:4eb2240dbd22 1441 {
andreikovacs 0:4eb2240dbd22 1442 case gRangeRxStateInit_c:
andreikovacs 0:4eb2240dbd22 1443 u32RSSISum = 0;
andreikovacs 0:4eb2240dbd22 1444 u16ReceivedPackets = 0;
andreikovacs 0:4eb2240dbd22 1445 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 1446 PrintMenu(cu8RangeRxTestMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 1447 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 1448 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 1449 rangeRxState = gRangeRxWaitStartTest_c;
andreikovacs 0:4eb2240dbd22 1450 break;
andreikovacs 0:4eb2240dbd22 1451 case gRangeRxWaitStartTest_c:
andreikovacs 0:4eb2240dbd22 1452 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1453 {
andreikovacs 0:4eb2240dbd22 1454 if(' ' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1455 {
andreikovacs 0:4eb2240dbd22 1456 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 1457 uart.printf( "\f\r\nRange Test Rx Running\r\n");
andreikovacs 0:4eb2240dbd22 1458 rangeRxState = gRangeRxStateStartTest_c;
andreikovacs 0:4eb2240dbd22 1459 }
andreikovacs 0:4eb2240dbd22 1460 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1461 {
andreikovacs 0:4eb2240dbd22 1462 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1463 }
andreikovacs 0:4eb2240dbd22 1464 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1465 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1466 }
andreikovacs 0:4eb2240dbd22 1467 break;
andreikovacs 0:4eb2240dbd22 1468 case gRangeRxStateStartTest_c:
andreikovacs 0:4eb2240dbd22 1469 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1470 rangeRxState = gRangeRxStateRunningTest_c;
andreikovacs 0:4eb2240dbd22 1471 break;
andreikovacs 0:4eb2240dbd22 1472 case gRangeRxStateRunningTest_c:
andreikovacs 0:4eb2240dbd22 1473 if(evDataFromUART && (' ' == gu8UartData))
andreikovacs 0:4eb2240dbd22 1474 {
andreikovacs 0:4eb2240dbd22 1475 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 1476 uart.printf( "\n\r\n\rRange Test Rx Stopped\r\n\r\n");
andreikovacs 0:4eb2240dbd22 1477 u8AverageRSSI = (uint8_t)(u32RSSISum/u16ReceivedPackets);
andreikovacs 0:4eb2240dbd22 1478 uart.printf( "Average RSSI ");
andreikovacs 0:4eb2240dbd22 1479 if(u8AverageRSSI != 0)
andreikovacs 0:4eb2240dbd22 1480 {
andreikovacs 0:4eb2240dbd22 1481 uart.printf("-");
andreikovacs 0:4eb2240dbd22 1482 }
andreikovacs 0:4eb2240dbd22 1483 uart.printf("%d", (uint32_t)u8AverageRSSI);
andreikovacs 0:4eb2240dbd22 1484 uart.printf(" dBm");
andreikovacs 0:4eb2240dbd22 1485 uart.printf( "\r\n\r\n Press [enter] to go back to the Range Rx test menu");
andreikovacs 0:4eb2240dbd22 1486 rangeRxState = gRangeRxStateIdle_c;
andreikovacs 0:4eb2240dbd22 1487 }
andreikovacs 0:4eb2240dbd22 1488 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1489 if(bRxDone)
andreikovacs 0:4eb2240dbd22 1490 {
andreikovacs 0:4eb2240dbd22 1491 if(gAppRxPacket->rxStatus == rxSuccessStatus_c)
andreikovacs 0:4eb2240dbd22 1492 {
andreikovacs 0:4eb2240dbd22 1493 if(stringComp((uint8_t*)"SMAC Range Demo",&gAppRxPacket->smacPdu.smacPdu[1],15))
andreikovacs 0:4eb2240dbd22 1494 {
andreikovacs 0:4eb2240dbd22 1495 bRxDone = FALSE;
andreikovacs 0:4eb2240dbd22 1496 Thread::wait(4);
andreikovacs 0:4eb2240dbd22 1497 }
andreikovacs 0:4eb2240dbd22 1498 else
andreikovacs 0:4eb2240dbd22 1499 {
andreikovacs 0:4eb2240dbd22 1500 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1501 }
andreikovacs 0:4eb2240dbd22 1502 }
andreikovacs 0:4eb2240dbd22 1503 else
andreikovacs 0:4eb2240dbd22 1504 {
andreikovacs 0:4eb2240dbd22 1505 SetRadioRxOnNoTimeOut();
andreikovacs 0:4eb2240dbd22 1506 }
andreikovacs 0:4eb2240dbd22 1507 }
andreikovacs 0:4eb2240dbd22 1508 if(timePassed)
andreikovacs 0:4eb2240dbd22 1509 {
andreikovacs 0:4eb2240dbd22 1510 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 1511 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 1512 u8TempRSSIvalue= u8LastRxRssiValue;
andreikovacs 0:4eb2240dbd22 1513 gAppTxPacket->smacPdu.smacPdu[0] = u8TempRSSIvalue;
andreikovacs 0:4eb2240dbd22 1514 FLib_MemCpy(&(gAppTxPacket->smacPdu.smacPdu[1]), (void *)"SMAC Range Demo",15);
andreikovacs 0:4eb2240dbd22 1515 gAppTxPacket->u8DataLength = 16;
andreikovacs 0:4eb2240dbd22 1516 (void)MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 1517 rangeRxState = gRangeRxStatePrintTestResults_c;
andreikovacs 0:4eb2240dbd22 1518 }
andreikovacs 0:4eb2240dbd22 1519 break;
andreikovacs 0:4eb2240dbd22 1520 case gRangeRxStatePrintTestResults_c:
andreikovacs 0:4eb2240dbd22 1521 if(bTxDone)
andreikovacs 0:4eb2240dbd22 1522 {
andreikovacs 0:4eb2240dbd22 1523 u8CurrentRSSI= u8LastRxRssiValue;
andreikovacs 0:4eb2240dbd22 1524 u32RSSISum += u8CurrentRSSI;
andreikovacs 0:4eb2240dbd22 1525 u16ReceivedPackets++;
andreikovacs 0:4eb2240dbd22 1526 u8AverageRSSI = (uint8_t)(u32RSSISum/u16ReceivedPackets);
andreikovacs 0:4eb2240dbd22 1527 uart.printf( "\r\n RSSI = -");
andreikovacs 0:4eb2240dbd22 1528 uart.printf("%d", (uint32_t)u8CurrentRSSI);
andreikovacs 0:4eb2240dbd22 1529 uart.printf(" dBm");
andreikovacs 0:4eb2240dbd22 1530 rangeRxState = gRangeRxStateStartTest_c;
andreikovacs 0:4eb2240dbd22 1531 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1532 }
andreikovacs 0:4eb2240dbd22 1533 break;
andreikovacs 0:4eb2240dbd22 1534 case gRangeRxStateIdle_c:
andreikovacs 0:4eb2240dbd22 1535 if((evDataFromUART) && ('\r' == gu8UartData))
andreikovacs 0:4eb2240dbd22 1536 {
andreikovacs 0:4eb2240dbd22 1537 rangeRxState = gRangeRxStateInit_c;
andreikovacs 0:4eb2240dbd22 1538 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1539 }
andreikovacs 0:4eb2240dbd22 1540 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1541 break;
andreikovacs 0:4eb2240dbd22 1542 default:
andreikovacs 0:4eb2240dbd22 1543 break;
andreikovacs 0:4eb2240dbd22 1544 }
andreikovacs 0:4eb2240dbd22 1545 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1546 }
andreikovacs 0:4eb2240dbd22 1547
andreikovacs 0:4eb2240dbd22 1548 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1549 *
andreikovacs 0:4eb2240dbd22 1550 * Handler for viewing/modifying XCVR registers
andreikovacs 0:4eb2240dbd22 1551 *
andreikovacs 0:4eb2240dbd22 1552 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1553 bool_t EditRegisters(void)
andreikovacs 0:4eb2240dbd22 1554 {
andreikovacs 0:4eb2240dbd22 1555 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1556 if(evTestParameters)
andreikovacs 0:4eb2240dbd22 1557 {
andreikovacs 0:4eb2240dbd22 1558 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 1559 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 1560 #endif
andreikovacs 0:4eb2240dbd22 1561 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 1562 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 1563 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 1564 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 1565 }
andreikovacs 0:4eb2240dbd22 1566
andreikovacs 0:4eb2240dbd22 1567 switch(eRState)
andreikovacs 0:4eb2240dbd22 1568 {
andreikovacs 0:4eb2240dbd22 1569 case gERStateInit_c:
andreikovacs 0:4eb2240dbd22 1570 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 1571 PrintMenu(cu8RadioRegistersEditMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 1572 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 1573 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 1574 eRState = gERWaitSelection_c;
andreikovacs 0:4eb2240dbd22 1575 break;
andreikovacs 0:4eb2240dbd22 1576 case gERWaitSelection_c:
andreikovacs 0:4eb2240dbd22 1577 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1578 {
andreikovacs 0:4eb2240dbd22 1579 #if CT_Feature_Direct_Registers
andreikovacs 0:4eb2240dbd22 1580 if('1' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1581 {
andreikovacs 0:4eb2240dbd22 1582 bIsRegisterDirect = TRUE;
andreikovacs 0:4eb2240dbd22 1583 oRState = gORStateInit_c;
andreikovacs 0:4eb2240dbd22 1584 eRState = gERStateOverrideReg_c;
andreikovacs 0:4eb2240dbd22 1585 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1586 }
andreikovacs 0:4eb2240dbd22 1587 else if('2' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1588 {
andreikovacs 0:4eb2240dbd22 1589 bIsRegisterDirect = TRUE;
andreikovacs 0:4eb2240dbd22 1590 rRState = gRRStateInit_c;
andreikovacs 0:4eb2240dbd22 1591 eRState = gERStateReadReg_c;
andreikovacs 0:4eb2240dbd22 1592 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1593 }
andreikovacs 0:4eb2240dbd22 1594 #if CT_Feature_Indirect_Registers
andreikovacs 0:4eb2240dbd22 1595 else if('3' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1596 {
andreikovacs 0:4eb2240dbd22 1597 bIsRegisterDirect = FALSE;
andreikovacs 0:4eb2240dbd22 1598 oRState = gORStateInit_c;
andreikovacs 0:4eb2240dbd22 1599 eRState = gERStateOverrideReg_c;
andreikovacs 0:4eb2240dbd22 1600 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1601 }
andreikovacs 0:4eb2240dbd22 1602 else if('4' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1603 {
andreikovacs 0:4eb2240dbd22 1604 bIsRegisterDirect = FALSE;
andreikovacs 0:4eb2240dbd22 1605 rRState = gRRStateInit_c;
andreikovacs 0:4eb2240dbd22 1606 eRState = gERStateReadReg_c;
andreikovacs 0:4eb2240dbd22 1607 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1608 }
andreikovacs 0:4eb2240dbd22 1609 else if('5' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1610 {
andreikovacs 0:4eb2240dbd22 1611 dRState = gDRStateInit_c;
andreikovacs 0:4eb2240dbd22 1612 eRState = gERStateDumpAllRegs_c;
andreikovacs 0:4eb2240dbd22 1613 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1614 }
andreikovacs 0:4eb2240dbd22 1615 #else
andreikovacs 0:4eb2240dbd22 1616 else if('3' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1617 {
andreikovacs 0:4eb2240dbd22 1618 dRState = gDRStateInit_c;
andreikovacs 0:4eb2240dbd22 1619 eRState = gERStateDumpAllRegs_c;
andreikovacs 0:4eb2240dbd22 1620 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1621 }
andreikovacs 0:4eb2240dbd22 1622 #endif
andreikovacs 0:4eb2240dbd22 1623 else
andreikovacs 0:4eb2240dbd22 1624 #endif
andreikovacs 0:4eb2240dbd22 1625 if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1626 {
andreikovacs 0:4eb2240dbd22 1627 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1628 }
andreikovacs 0:4eb2240dbd22 1629 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1630 }
andreikovacs 0:4eb2240dbd22 1631 break;
andreikovacs 0:4eb2240dbd22 1632 case gERStateOverrideReg_c:
andreikovacs 0:4eb2240dbd22 1633 if(OverrideRegisters())
andreikovacs 0:4eb2240dbd22 1634 {
andreikovacs 0:4eb2240dbd22 1635 eRState = gERStateInit_c;
andreikovacs 0:4eb2240dbd22 1636 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1637 }
andreikovacs 0:4eb2240dbd22 1638 break;
andreikovacs 0:4eb2240dbd22 1639 case gERStateReadReg_c:
andreikovacs 0:4eb2240dbd22 1640 if(ReadRegisters())
andreikovacs 0:4eb2240dbd22 1641 {
andreikovacs 0:4eb2240dbd22 1642 eRState = gERStateInit_c;
andreikovacs 0:4eb2240dbd22 1643 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1644 }
andreikovacs 0:4eb2240dbd22 1645 break;
andreikovacs 0:4eb2240dbd22 1646 case gERStateDumpAllRegs_c:
andreikovacs 0:4eb2240dbd22 1647 if(DumpRegisters()) {
andreikovacs 0:4eb2240dbd22 1648 eRState = gERStateInit_c;
andreikovacs 0:4eb2240dbd22 1649 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1650 }
andreikovacs 0:4eb2240dbd22 1651 break;
andreikovacs 0:4eb2240dbd22 1652 default:
andreikovacs 0:4eb2240dbd22 1653 break;
andreikovacs 0:4eb2240dbd22 1654 }
andreikovacs 0:4eb2240dbd22 1655 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1656 }
andreikovacs 0:4eb2240dbd22 1657
andreikovacs 0:4eb2240dbd22 1658 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1659 *
andreikovacs 0:4eb2240dbd22 1660 * Dump registers
andreikovacs 0:4eb2240dbd22 1661 *
andreikovacs 0:4eb2240dbd22 1662 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1663 bool_t DumpRegisters(void)
andreikovacs 0:4eb2240dbd22 1664 {
andreikovacs 0:4eb2240dbd22 1665 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1666
andreikovacs 0:4eb2240dbd22 1667 switch(dRState)
andreikovacs 0:4eb2240dbd22 1668 {
andreikovacs 0:4eb2240dbd22 1669 case gDRStateInit_c:
andreikovacs 0:4eb2240dbd22 1670 uart.printf( "\f\r\rDump Registers\r\n");
andreikovacs 0:4eb2240dbd22 1671 uart.printf( "\r\n-Press [space] to dump registers\r\n");
andreikovacs 0:4eb2240dbd22 1672 uart.printf( "\r\n-Press [p] Previous Menu\r\n");
andreikovacs 0:4eb2240dbd22 1673 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 1674 dRState = gDRStateDumpRegs_c;
andreikovacs 0:4eb2240dbd22 1675 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1676 break;
andreikovacs 0:4eb2240dbd22 1677 case gDRStateDumpRegs_c:
andreikovacs 0:4eb2240dbd22 1678 if(evDataFromUART){
andreikovacs 0:4eb2240dbd22 1679 if(gu8UartData == 'p')
andreikovacs 0:4eb2240dbd22 1680 {
andreikovacs 0:4eb2240dbd22 1681 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1682 }
andreikovacs 0:4eb2240dbd22 1683 else if (gu8UartData == ' ')
andreikovacs 0:4eb2240dbd22 1684 {
andreikovacs 0:4eb2240dbd22 1685 uart.printf( "\r\n -Dumping registers... \r\n");
andreikovacs 0:4eb2240dbd22 1686 const registerLimits_t* interval = registerIntervals;
andreikovacs 0:4eb2240dbd22 1687
andreikovacs 0:4eb2240dbd22 1688 while(!((*interval).regStart == 0 && (*interval).regEnd == 0))
andreikovacs 0:4eb2240dbd22 1689 {
andreikovacs 0:4eb2240dbd22 1690 uart.printf( "\r\n -Access type: ");
andreikovacs 0:4eb2240dbd22 1691 if( (*interval).bIsRegisterDirect )
andreikovacs 0:4eb2240dbd22 1692 uart.printf("direct\r\n");
andreikovacs 0:4eb2240dbd22 1693 else
andreikovacs 0:4eb2240dbd22 1694 uart.printf("indirect\r\n");
andreikovacs 0:4eb2240dbd22 1695 bIsRegisterDirect = (*interval).bIsRegisterDirect;
andreikovacs 0:4eb2240dbd22 1696 ReadRFRegs((*interval).regStart, (*interval).regEnd);
andreikovacs 0:4eb2240dbd22 1697 interval++;
andreikovacs 0:4eb2240dbd22 1698 }
andreikovacs 0:4eb2240dbd22 1699 dRState = gDRStateInit_c;
andreikovacs 0:4eb2240dbd22 1700 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1701 }
andreikovacs 0:4eb2240dbd22 1702 }
andreikovacs 0:4eb2240dbd22 1703 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1704 break;
andreikovacs 0:4eb2240dbd22 1705 default:
andreikovacs 0:4eb2240dbd22 1706 break;
andreikovacs 0:4eb2240dbd22 1707 }
andreikovacs 0:4eb2240dbd22 1708 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1709 }
andreikovacs 0:4eb2240dbd22 1710
andreikovacs 0:4eb2240dbd22 1711 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1712 *
andreikovacs 0:4eb2240dbd22 1713 * Read and print register values with addresses from u8RegStartAddress
andreikovacs 0:4eb2240dbd22 1714 * to u8RegStopAddress
andreikovacs 0:4eb2240dbd22 1715 *
andreikovacs 0:4eb2240dbd22 1716 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1717 void ReadRFRegs(registerAddressSize_t rasRegStartAddress, registerAddressSize_t rasRegStopAddress)
andreikovacs 0:4eb2240dbd22 1718 {
andreikovacs 0:4eb2240dbd22 1719
andreikovacs 0:4eb2240dbd22 1720 static uint16_t rasRegAddress;
andreikovacs 0:4eb2240dbd22 1721 registerSize_t rsRegValue;
andreikovacs 0:4eb2240dbd22 1722 uart.printf( " --------------------------------------- ");
andreikovacs 0:4eb2240dbd22 1723 for(rasRegAddress = rasRegStartAddress; rasRegAddress <= rasRegStopAddress; rasRegAddress+=(gRegisterSize_c))
andreikovacs 0:4eb2240dbd22 1724 {
andreikovacs 0:4eb2240dbd22 1725 uart.printf( "\r\n| Address : 0x");
andreikovacs 0:4eb2240dbd22 1726 uart.printf("%x", (uint8_t*)&rasRegAddress);
andreikovacs 0:4eb2240dbd22 1727 aspTestRequestMsg.msgType = aspMsgTypeXcvrReadReq_c;
andreikovacs 0:4eb2240dbd22 1728 aspTestRequestMsg.msgData.aspXcvrData.addr = (uint16_t)rasRegAddress;
andreikovacs 0:4eb2240dbd22 1729 aspTestRequestMsg.msgData.aspXcvrData.len = gRegisterSize_c;
andreikovacs 0:4eb2240dbd22 1730 aspTestRequestMsg.msgData.aspXcvrData.mode = !bIsRegisterDirect;
andreikovacs 0:4eb2240dbd22 1731
andreikovacs 0:4eb2240dbd22 1732 APP_ASP_SapHandler(&aspTestRequestMsg, 0);
andreikovacs 0:4eb2240dbd22 1733 rsRegValue = *((registerSize_t*)aspTestRequestMsg.msgData.aspXcvrData.data);
andreikovacs 0:4eb2240dbd22 1734 uart.printf( " Data value : 0x");
andreikovacs 0:4eb2240dbd22 1735 uart.printf("%x", (uint8_t*)&rsRegValue);
andreikovacs 0:4eb2240dbd22 1736 uart.printf( " |");
andreikovacs 0:4eb2240dbd22 1737 }
andreikovacs 0:4eb2240dbd22 1738 uart.printf( "\r\n --------------------------------------- \r\n");
andreikovacs 0:4eb2240dbd22 1739 }
andreikovacs 0:4eb2240dbd22 1740
andreikovacs 0:4eb2240dbd22 1741 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1742 *
andreikovacs 0:4eb2240dbd22 1743 * Read register
andreikovacs 0:4eb2240dbd22 1744 *
andreikovacs 0:4eb2240dbd22 1745 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1746 bool_t ReadRegisters(void)
andreikovacs 0:4eb2240dbd22 1747 {
andreikovacs 0:4eb2240dbd22 1748 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1749 static uint8_t au8RxString[5];
andreikovacs 0:4eb2240dbd22 1750 static uint8_t u8Index;
andreikovacs 0:4eb2240dbd22 1751 static registerAddressSize_t rasRegAddress;
andreikovacs 0:4eb2240dbd22 1752 static registerSize_t rsRegValue;
andreikovacs 0:4eb2240dbd22 1753 static char auxToPrint[2];
andreikovacs 0:4eb2240dbd22 1754
andreikovacs 0:4eb2240dbd22 1755 switch(rRState)
andreikovacs 0:4eb2240dbd22 1756 {
andreikovacs 0:4eb2240dbd22 1757 case gRRStateInit_c:
andreikovacs 0:4eb2240dbd22 1758 uart.printf( "\f\r\rRead Registers\r\n");
andreikovacs 0:4eb2240dbd22 1759 uart.printf( "\r\n-Press [p] Previous Menu\r\n");
andreikovacs 0:4eb2240dbd22 1760 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 1761 rRState = gRRStateStart_c;
andreikovacs 0:4eb2240dbd22 1762 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1763 break;
andreikovacs 0:4eb2240dbd22 1764 case gRRStateStart_c:
andreikovacs 0:4eb2240dbd22 1765 uart.printf( "\r\n -write the Register address in Hex and [enter]: 0x");
andreikovacs 0:4eb2240dbd22 1766 u8Index = 0;
andreikovacs 0:4eb2240dbd22 1767 rRState = gRRWaitForTheAddress_c;
andreikovacs 0:4eb2240dbd22 1768 break;
andreikovacs 0:4eb2240dbd22 1769 case gRRWaitForTheAddress_c:
andreikovacs 0:4eb2240dbd22 1770 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1771 {
andreikovacs 0:4eb2240dbd22 1772 if((!isAsciiHex(gu8UartData)) && ('\r' != gu8UartData))
andreikovacs 0:4eb2240dbd22 1773 {
andreikovacs 0:4eb2240dbd22 1774 if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1775 {
andreikovacs 0:4eb2240dbd22 1776 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1777 }
andreikovacs 0:4eb2240dbd22 1778 else
andreikovacs 0:4eb2240dbd22 1779 {
andreikovacs 0:4eb2240dbd22 1780 uart.printf( "\r\n -Invalid Character!! ");
andreikovacs 0:4eb2240dbd22 1781 rRState = gRRStateStart_c;
andreikovacs 0:4eb2240dbd22 1782 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1783 }
andreikovacs 0:4eb2240dbd22 1784 }
andreikovacs 0:4eb2240dbd22 1785 else if((gRegisterAddressASCII_c == u8Index) && ('\r' != gu8UartData))
andreikovacs 0:4eb2240dbd22 1786 {
andreikovacs 0:4eb2240dbd22 1787 uart.printf( "\r\n -Value out of Range!! ");
andreikovacs 0:4eb2240dbd22 1788 rRState = gRRStateStart_c;
andreikovacs 0:4eb2240dbd22 1789 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1790 }
andreikovacs 0:4eb2240dbd22 1791 else if(isAsciiHex(gu8UartData))
andreikovacs 0:4eb2240dbd22 1792 {
andreikovacs 0:4eb2240dbd22 1793 au8RxString[u8Index++] = gu8UartData;
andreikovacs 0:4eb2240dbd22 1794 auxToPrint[0] = gu8UartData;
andreikovacs 0:4eb2240dbd22 1795 auxToPrint[1] = '\0';
andreikovacs 0:4eb2240dbd22 1796 uart.printf( auxToPrint);
andreikovacs 0:4eb2240dbd22 1797 }
andreikovacs 0:4eb2240dbd22 1798 else
andreikovacs 0:4eb2240dbd22 1799 {
andreikovacs 0:4eb2240dbd22 1800 au8RxString[u8Index] = 0;
andreikovacs 0:4eb2240dbd22 1801 rasRegAddress = (registerAddressSize_t)HexString2Dec(au8RxString);
andreikovacs 0:4eb2240dbd22 1802 aspTestRequestMsg.msgType = aspMsgTypeXcvrReadReq_c;
andreikovacs 0:4eb2240dbd22 1803 aspTestRequestMsg.msgData.aspXcvrData.addr = (uint16_t)rasRegAddress;
andreikovacs 0:4eb2240dbd22 1804 aspTestRequestMsg.msgData.aspXcvrData.len = gRegisterSize_c;
andreikovacs 0:4eb2240dbd22 1805 aspTestRequestMsg.msgData.aspXcvrData.mode = !bIsRegisterDirect;
andreikovacs 0:4eb2240dbd22 1806 APP_ASP_SapHandler(&aspTestRequestMsg, 0);
andreikovacs 0:4eb2240dbd22 1807 rsRegValue = *((registerSize_t*)aspTestRequestMsg.msgData.aspXcvrData.data);
andreikovacs 0:4eb2240dbd22 1808
andreikovacs 0:4eb2240dbd22 1809 uart.printf( "\r\n -Register value : 0x");
andreikovacs 0:4eb2240dbd22 1810 uart.printf("%x", (uint8_t*)&rsRegValue);
andreikovacs 0:4eb2240dbd22 1811 uart.printf( "\r\n");
andreikovacs 0:4eb2240dbd22 1812
andreikovacs 0:4eb2240dbd22 1813 rRState = gRRStateStart_c;
andreikovacs 0:4eb2240dbd22 1814 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1815 }
andreikovacs 0:4eb2240dbd22 1816 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1817 }
andreikovacs 0:4eb2240dbd22 1818 break;
andreikovacs 0:4eb2240dbd22 1819 default:
andreikovacs 0:4eb2240dbd22 1820 break;
andreikovacs 0:4eb2240dbd22 1821 }
andreikovacs 0:4eb2240dbd22 1822 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1823 }
andreikovacs 0:4eb2240dbd22 1824
andreikovacs 0:4eb2240dbd22 1825 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1826 *
andreikovacs 0:4eb2240dbd22 1827 * Override Register
andreikovacs 0:4eb2240dbd22 1828 *
andreikovacs 0:4eb2240dbd22 1829 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1830 bool_t OverrideRegisters(void)
andreikovacs 0:4eb2240dbd22 1831 {
andreikovacs 0:4eb2240dbd22 1832 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1833 static uint8_t au8RxString[5];
andreikovacs 0:4eb2240dbd22 1834 static uint8_t u8Index;
andreikovacs 0:4eb2240dbd22 1835 static registerAddressSize_t rasRegAddress;
andreikovacs 0:4eb2240dbd22 1836 static registerSize_t rsRegValue;
andreikovacs 0:4eb2240dbd22 1837 static char auxToPrint[2];
andreikovacs 0:4eb2240dbd22 1838
andreikovacs 0:4eb2240dbd22 1839 switch(oRState)
andreikovacs 0:4eb2240dbd22 1840 {
andreikovacs 0:4eb2240dbd22 1841 case gORStateInit_c:
andreikovacs 0:4eb2240dbd22 1842 uart.printf("\f\r\nWrite Registers\r\n");
andreikovacs 0:4eb2240dbd22 1843 uart.printf("\r\n-Press [p] Previous Menu\r\n");
andreikovacs 0:4eb2240dbd22 1844 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 1845 oRState = gORStateStart_c;
andreikovacs 0:4eb2240dbd22 1846 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1847 break;
andreikovacs 0:4eb2240dbd22 1848 case gORStateStart_c:
andreikovacs 0:4eb2240dbd22 1849 uart.printf("\r\n -write the Register address in Hex and [enter]: 0x");
andreikovacs 0:4eb2240dbd22 1850 u8Index = 0;
andreikovacs 0:4eb2240dbd22 1851 oRState = gORWaitForTheAddress_c;
andreikovacs 0:4eb2240dbd22 1852 break;
andreikovacs 0:4eb2240dbd22 1853 case gORWaitForTheAddress_c:
andreikovacs 0:4eb2240dbd22 1854 if(evDataFromUART){
andreikovacs 0:4eb2240dbd22 1855 if((!isAsciiHex(gu8UartData)) && ('\r' != gu8UartData))
andreikovacs 0:4eb2240dbd22 1856 {
andreikovacs 0:4eb2240dbd22 1857 if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1858 {
andreikovacs 0:4eb2240dbd22 1859 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1860 }
andreikovacs 0:4eb2240dbd22 1861 else
andreikovacs 0:4eb2240dbd22 1862 {
andreikovacs 0:4eb2240dbd22 1863 uart.printf("\r\n -Invalid Character!! ");
andreikovacs 0:4eb2240dbd22 1864 oRState = gORStateStart_c;
andreikovacs 0:4eb2240dbd22 1865 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1866 }
andreikovacs 0:4eb2240dbd22 1867 }
andreikovacs 0:4eb2240dbd22 1868 else if((gRegisterAddressASCII_c == u8Index) && ('\r' != gu8UartData))
andreikovacs 0:4eb2240dbd22 1869 {
andreikovacs 0:4eb2240dbd22 1870 uart.printf("\r\n -Value out of Range!! ");
andreikovacs 0:4eb2240dbd22 1871 oRState = gORStateStart_c;
andreikovacs 0:4eb2240dbd22 1872 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1873 }
andreikovacs 0:4eb2240dbd22 1874 else if(isAsciiHex(gu8UartData))
andreikovacs 0:4eb2240dbd22 1875 {
andreikovacs 0:4eb2240dbd22 1876 au8RxString[u8Index++] = gu8UartData;
andreikovacs 0:4eb2240dbd22 1877 auxToPrint[0] = gu8UartData;
andreikovacs 0:4eb2240dbd22 1878 auxToPrint[1] = '\0';
andreikovacs 0:4eb2240dbd22 1879 uart.printf(auxToPrint);
andreikovacs 0:4eb2240dbd22 1880 }
andreikovacs 0:4eb2240dbd22 1881 else
andreikovacs 0:4eb2240dbd22 1882 {
andreikovacs 0:4eb2240dbd22 1883 au8RxString[u8Index] = 0;
andreikovacs 0:4eb2240dbd22 1884 rasRegAddress = (registerAddressSize_t)HexString2Dec(au8RxString);
andreikovacs 0:4eb2240dbd22 1885 uart.printf("\r\n -write the Register value to override in Hex and [enter]: 0x");
andreikovacs 0:4eb2240dbd22 1886 u8Index = 0;
andreikovacs 0:4eb2240dbd22 1887 oRState = gORWaitForTheValue_c;
andreikovacs 0:4eb2240dbd22 1888 }
andreikovacs 0:4eb2240dbd22 1889 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1890 }
andreikovacs 0:4eb2240dbd22 1891 break;
andreikovacs 0:4eb2240dbd22 1892 case gORWaitForTheValue_c:
andreikovacs 0:4eb2240dbd22 1893 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1894 {
andreikovacs 0:4eb2240dbd22 1895 if((!isAsciiHex(gu8UartData)) && ('\r' != gu8UartData))
andreikovacs 0:4eb2240dbd22 1896 {
andreikovacs 0:4eb2240dbd22 1897 if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1898 {
andreikovacs 0:4eb2240dbd22 1899 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 1900 }
andreikovacs 0:4eb2240dbd22 1901 else
andreikovacs 0:4eb2240dbd22 1902 {
andreikovacs 0:4eb2240dbd22 1903 uart.printf("\r\n -Invalid Character!! ");
andreikovacs 0:4eb2240dbd22 1904 oRState = gORStateStart_c;
andreikovacs 0:4eb2240dbd22 1905 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1906 }
andreikovacs 0:4eb2240dbd22 1907 }
andreikovacs 0:4eb2240dbd22 1908 else if((2 == u8Index) && ('\r' != gu8UartData))
andreikovacs 0:4eb2240dbd22 1909 {
andreikovacs 0:4eb2240dbd22 1910 uart.printf("\r\n -Value out of Range!! ");
andreikovacs 0:4eb2240dbd22 1911 oRState = gORStateStart_c;
andreikovacs 0:4eb2240dbd22 1912 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1913 }
andreikovacs 0:4eb2240dbd22 1914 else if(isAsciiHex(gu8UartData))
andreikovacs 0:4eb2240dbd22 1915 {
andreikovacs 0:4eb2240dbd22 1916 au8RxString[u8Index++] = gu8UartData;
andreikovacs 0:4eb2240dbd22 1917 auxToPrint[0] = gu8UartData;
andreikovacs 0:4eb2240dbd22 1918 auxToPrint[1] = '\0';
andreikovacs 0:4eb2240dbd22 1919 uart.printf(auxToPrint);
andreikovacs 0:4eb2240dbd22 1920 }
andreikovacs 0:4eb2240dbd22 1921 else
andreikovacs 0:4eb2240dbd22 1922 {
andreikovacs 0:4eb2240dbd22 1923 au8RxString[u8Index] = 0;
andreikovacs 0:4eb2240dbd22 1924 rsRegValue = (registerSize_t)HexString2Dec(au8RxString);
andreikovacs 0:4eb2240dbd22 1925 aspTestRequestMsg.msgType = aspMsgTypeXcvrWriteReq_c;
andreikovacs 0:4eb2240dbd22 1926 aspTestRequestMsg.msgData.aspXcvrData.addr = (uint16_t)rasRegAddress;
andreikovacs 0:4eb2240dbd22 1927 aspTestRequestMsg.msgData.aspXcvrData.len = gRegisterAddress_c;
andreikovacs 0:4eb2240dbd22 1928 aspTestRequestMsg.msgData.aspXcvrData.mode = !bIsRegisterDirect;
andreikovacs 0:4eb2240dbd22 1929 FLib_MemCpy(aspTestRequestMsg.msgData.aspXcvrData.data, &rsRegValue, gRegisterSize_c);
andreikovacs 0:4eb2240dbd22 1930 APP_ASP_SapHandler(&aspTestRequestMsg, 0);
andreikovacs 0:4eb2240dbd22 1931
andreikovacs 0:4eb2240dbd22 1932 uart.printf("\r\n Register overridden \r\n");
andreikovacs 0:4eb2240dbd22 1933 u8Index = 0;
andreikovacs 0:4eb2240dbd22 1934 oRState = gORStateStart_c;
andreikovacs 0:4eb2240dbd22 1935 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1936 }
andreikovacs 0:4eb2240dbd22 1937 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 1938 }
andreikovacs 0:4eb2240dbd22 1939 break;
andreikovacs 0:4eb2240dbd22 1940 default:
andreikovacs 0:4eb2240dbd22 1941 break;
andreikovacs 0:4eb2240dbd22 1942 }
andreikovacs 0:4eb2240dbd22 1943 return bBackFlag;
andreikovacs 0:4eb2240dbd22 1944 }
andreikovacs 0:4eb2240dbd22 1945
andreikovacs 0:4eb2240dbd22 1946 /************************************************************************************
andreikovacs 0:4eb2240dbd22 1947 *
andreikovacs 0:4eb2240dbd22 1948 * Handler for Carrier Sense Test and Transmission Control Test
andreikovacs 0:4eb2240dbd22 1949 *
andreikovacs 0:4eb2240dbd22 1950 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 1951 bool_t CSenseAndTCtrl(void)
andreikovacs 0:4eb2240dbd22 1952 {
andreikovacs 0:4eb2240dbd22 1953 bool_t bBackFlag = FALSE;
andreikovacs 0:4eb2240dbd22 1954 static uint8_t testSelector = 0;
andreikovacs 0:4eb2240dbd22 1955
andreikovacs 0:4eb2240dbd22 1956 if(evTestParameters){
andreikovacs 0:4eb2240dbd22 1957 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 1958 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 1959 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 1960 #endif
andreikovacs 0:4eb2240dbd22 1961 (void)MLMEPAOutputAdjust(testPower);
andreikovacs 0:4eb2240dbd22 1962 PrintTestParameters(TRUE);
andreikovacs 0:4eb2240dbd22 1963 evTestParameters = FALSE;
andreikovacs 0:4eb2240dbd22 1964 }
andreikovacs 0:4eb2240dbd22 1965
andreikovacs 0:4eb2240dbd22 1966 switch(cstcState)
andreikovacs 0:4eb2240dbd22 1967 {
andreikovacs 0:4eb2240dbd22 1968 case gCsTcStateInit_c:
andreikovacs 0:4eb2240dbd22 1969 TestMode(gTestModeForceIdle_c);
andreikovacs 0:4eb2240dbd22 1970 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 1971 PrintMenu(cu8RadioCSTCSelectMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 1972 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 1973 shortCutsEnabled = TRUE;
andreikovacs 0:4eb2240dbd22 1974 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 1975 bScanDone = FALSE;
andreikovacs 0:4eb2240dbd22 1976 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 1977
andreikovacs 0:4eb2240dbd22 1978 cstcState = gCsTcStateSelectTest_c;
andreikovacs 0:4eb2240dbd22 1979 break;
andreikovacs 0:4eb2240dbd22 1980 case gCsTcStateSelectTest_c:
andreikovacs 0:4eb2240dbd22 1981 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 1982 {
andreikovacs 0:4eb2240dbd22 1983 if('1' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1984 {
andreikovacs 0:4eb2240dbd22 1985 cstcState = gCsTcStateCarrierSenseStart_c;
andreikovacs 0:4eb2240dbd22 1986 testSelector = 1;
andreikovacs 0:4eb2240dbd22 1987 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1988 }
andreikovacs 0:4eb2240dbd22 1989 else if ('2' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1990 {
andreikovacs 0:4eb2240dbd22 1991 cstcState = gCsTcStateTransmissionControlStart_c;
andreikovacs 0:4eb2240dbd22 1992 testSelector = 2;
andreikovacs 0:4eb2240dbd22 1993 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 1994 }
andreikovacs 0:4eb2240dbd22 1995 else if( 'p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 1996 {
andreikovacs 0:4eb2240dbd22 1997 cstcState = gCsTcStateInit_c;
andreikovacs 0:4eb2240dbd22 1998 testSelector = 0;
andreikovacs 0:4eb2240dbd22 1999 bBackFlag = TRUE;
andreikovacs 0:4eb2240dbd22 2000 }
andreikovacs 0:4eb2240dbd22 2001 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 2002 }
andreikovacs 0:4eb2240dbd22 2003 break;
andreikovacs 0:4eb2240dbd22 2004 default:
andreikovacs 0:4eb2240dbd22 2005 if(testSelector == 1)
andreikovacs 0:4eb2240dbd22 2006 CarrierSenseHandler();
andreikovacs 0:4eb2240dbd22 2007 else if(testSelector == 2)
andreikovacs 0:4eb2240dbd22 2008 TransmissionControlHandler();
andreikovacs 0:4eb2240dbd22 2009 break;
andreikovacs 0:4eb2240dbd22 2010 }
andreikovacs 0:4eb2240dbd22 2011 return bBackFlag;
andreikovacs 0:4eb2240dbd22 2012 }
andreikovacs 0:4eb2240dbd22 2013
andreikovacs 0:4eb2240dbd22 2014 /************************************************************************************
andreikovacs 0:4eb2240dbd22 2015 *
andreikovacs 0:4eb2240dbd22 2016 * Handler for Transmission Control Test called by above function
andreikovacs 0:4eb2240dbd22 2017 *
andreikovacs 0:4eb2240dbd22 2018 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2019 void TransmissionControlHandler(void)
andreikovacs 0:4eb2240dbd22 2020 {
andreikovacs 0:4eb2240dbd22 2021 const uint16_t u16TotalPacketsOptions[] = {1,25,100,500,1000,2000,5000,10000,65535};
andreikovacs 0:4eb2240dbd22 2022 static uint16_t u16TotalPackets;
andreikovacs 0:4eb2240dbd22 2023 static uint16_t u16PacketCounter = 0;
andreikovacs 0:4eb2240dbd22 2024 static uint16_t miliSecDelay = 0;
andreikovacs 0:4eb2240dbd22 2025 static phyTime_t startTime;
andreikovacs 0:4eb2240dbd22 2026 int8_t fillIndex = 0;
andreikovacs 0:4eb2240dbd22 2027 uint8_t* smacPduPtr;
andreikovacs 0:4eb2240dbd22 2028 uint32_t totalTimeMs;
andreikovacs 0:4eb2240dbd22 2029
andreikovacs 0:4eb2240dbd22 2030 switch(cstcState)
andreikovacs 0:4eb2240dbd22 2031 {
andreikovacs 0:4eb2240dbd22 2032 case gCsTcStateTransmissionControlStart_c:
andreikovacs 0:4eb2240dbd22 2033 PrintMenu(cu8ShortCutsBar, mAppSer);
andreikovacs 0:4eb2240dbd22 2034 PrintMenu(cu8CsTcTestMenu, mAppSer);
andreikovacs 0:4eb2240dbd22 2035 PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 2036 miliSecDelay = 0;
andreikovacs 0:4eb2240dbd22 2037 u16TotalPackets = 0;
andreikovacs 0:4eb2240dbd22 2038 u16PacketCounter = 0;
andreikovacs 0:4eb2240dbd22 2039 fillIndex = testPayloadLen / gPrbs9BufferLength_c;
andreikovacs 0:4eb2240dbd22 2040
andreikovacs 0:4eb2240dbd22 2041 while(fillIndex > 0)
andreikovacs 0:4eb2240dbd22 2042 {
andreikovacs 0:4eb2240dbd22 2043 fillIndex--;
andreikovacs 0:4eb2240dbd22 2044 smacPduPtr = gAppTxPacket->smacPdu.smacPdu + fillIndex * gPrbs9BufferLength_c;
andreikovacs 0:4eb2240dbd22 2045 FLib_MemCpy(smacPduPtr, u8Prbs9Buffer, gPrbs9BufferLength_c);
andreikovacs 0:4eb2240dbd22 2046 }
andreikovacs 0:4eb2240dbd22 2047 smacPduPtr = gAppTxPacket->smacPdu.smacPdu + ((testPayloadLen / gPrbs9BufferLength_c)*gPrbs9BufferLength_c);
andreikovacs 0:4eb2240dbd22 2048 FLib_MemCpy(smacPduPtr, u8Prbs9Buffer, (testPayloadLen % gPrbs9BufferLength_c));
andreikovacs 0:4eb2240dbd22 2049
andreikovacs 0:4eb2240dbd22 2050 gAppTxPacket->u8DataLength = testPayloadLen;
andreikovacs 0:4eb2240dbd22 2051
andreikovacs 0:4eb2240dbd22 2052 cstcState = gCsTcStateTransmissionControlSelectNumOfPackets_c;
andreikovacs 0:4eb2240dbd22 2053 break;
andreikovacs 0:4eb2240dbd22 2054 case gCsTcStateTransmissionControlSelectNumOfPackets_c:
andreikovacs 0:4eb2240dbd22 2055 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 2056 {
andreikovacs 0:4eb2240dbd22 2057 if((gu8UartData >= '0') && (gu8UartData <= '8'))
andreikovacs 0:4eb2240dbd22 2058 {
andreikovacs 0:4eb2240dbd22 2059 u16TotalPackets = u16TotalPacketsOptions[gu8UartData - '0'];
andreikovacs 0:4eb2240dbd22 2060 cstcState = gCsTcStateTransmissionControlSelectInterpacketDelay_c;
andreikovacs 0:4eb2240dbd22 2061 uart.printf("\r\n\r\n Please type InterPacket delay in miliseconds and press [ENTER]");
andreikovacs 0:4eb2240dbd22 2062 uart.printf("\r\n(During test, exit by pressing [SPACE])\r\n\r\n");
andreikovacs 0:4eb2240dbd22 2063 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 2064 }
andreikovacs 0:4eb2240dbd22 2065 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 2066 {
andreikovacs 0:4eb2240dbd22 2067 cstcState = gCsTcStateInit_c;
andreikovacs 0:4eb2240dbd22 2068 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 2069 }
andreikovacs 0:4eb2240dbd22 2070 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 2071 }
andreikovacs 0:4eb2240dbd22 2072 break;
andreikovacs 0:4eb2240dbd22 2073 case gCsTcStateTransmissionControlSelectInterpacketDelay_c:
andreikovacs 0:4eb2240dbd22 2074 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 2075 {
andreikovacs 0:4eb2240dbd22 2076 if(gu8UartData == '\r' && miliSecDelay != 0)
andreikovacs 0:4eb2240dbd22 2077 {
andreikovacs 0:4eb2240dbd22 2078 cstcState = gCsTcStateTransmissionControlPerformingTest_c;
andreikovacs 0:4eb2240dbd22 2079 startTime = GetTimestampUS();
andreikovacs 0:4eb2240dbd22 2080 (void)MLMEScanRequest(testChannel);
andreikovacs 0:4eb2240dbd22 2081 }
andreikovacs 0:4eb2240dbd22 2082 else if((gu8UartData >= '0') && (gu8UartData <='9'))
andreikovacs 0:4eb2240dbd22 2083 {
andreikovacs 0:4eb2240dbd22 2084 miliSecDelay = miliSecDelay*10 + (gu8UartData - '0');
andreikovacs 0:4eb2240dbd22 2085 uart.printf("%d",(uint32_t)(gu8UartData - '0'));
andreikovacs 0:4eb2240dbd22 2086 }
andreikovacs 0:4eb2240dbd22 2087 else if('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 2088 {
andreikovacs 0:4eb2240dbd22 2089 cstcState = gCsTcStateInit_c;
andreikovacs 0:4eb2240dbd22 2090 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 2091 }
andreikovacs 0:4eb2240dbd22 2092 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 2093 }
andreikovacs 0:4eb2240dbd22 2094 break;
andreikovacs 0:4eb2240dbd22 2095 case gCsTcStateTransmissionControlPerformingTest_c:
andreikovacs 0:4eb2240dbd22 2096 if(bScanDone)
andreikovacs 0:4eb2240dbd22 2097 {
andreikovacs 0:4eb2240dbd22 2098 bScanDone = FALSE;
andreikovacs 0:4eb2240dbd22 2099 (void)MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 2100 }
andreikovacs 0:4eb2240dbd22 2101 if(bTxDone)
andreikovacs 0:4eb2240dbd22 2102 {
andreikovacs 0:4eb2240dbd22 2103 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 2104 u16PacketCounter++;
andreikovacs 0:4eb2240dbd22 2105 uart.printf("\r\n\tPacket number: ");
andreikovacs 0:4eb2240dbd22 2106 uart.printf("%d", (uint32_t)(u16PacketCounter));
andreikovacs 0:4eb2240dbd22 2107 uart.printf("; RSSI value: -");
andreikovacs 0:4eb2240dbd22 2108 uart.printf("%d",(uint32_t)au8ScanResults[testChannel]);
andreikovacs 0:4eb2240dbd22 2109 uart.printf(" dBm\r\n");
andreikovacs 0:4eb2240dbd22 2110 if(u16PacketCounter < u16TotalPackets)
andreikovacs 0:4eb2240dbd22 2111 {
andreikovacs 0:4eb2240dbd22 2112 totalTimeMs = (uint32_t)(GetTimestampUS() - startTime);
andreikovacs 0:4eb2240dbd22 2113 totalTimeMs -= GetTransmissionTime(testPayloadLen, crtBitrate);
andreikovacs 0:4eb2240dbd22 2114 totalTimeMs = (totalTimeMs % 1000 < 500) ? totalTimeMs/1000 : (totalTimeMs/1000)+1;
andreikovacs 0:4eb2240dbd22 2115 if(totalTimeMs > miliSecDelay)
andreikovacs 0:4eb2240dbd22 2116 {
andreikovacs 0:4eb2240dbd22 2117 uart.printf( " Overhead + Transmission + ED = ~");
andreikovacs 0:4eb2240dbd22 2118 uart.printf("%d", totalTimeMs);
andreikovacs 0:4eb2240dbd22 2119 uart.printf("ms\r\n Interpacket delay too small (Press [ENTER] to continue)\r\n");
andreikovacs 0:4eb2240dbd22 2120 cstcState = gCsTcStateTransmissionControlEndTest_c;
andreikovacs 0:4eb2240dbd22 2121 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 2122 break;
andreikovacs 0:4eb2240dbd22 2123 }
andreikovacs 0:4eb2240dbd22 2124 Thread::wait(miliSecDelay - totalTimeMs);
andreikovacs 0:4eb2240dbd22 2125 }
andreikovacs 0:4eb2240dbd22 2126 else
andreikovacs 0:4eb2240dbd22 2127 {
andreikovacs 0:4eb2240dbd22 2128 uart.printf("\r\n\r\nFinished transmitting ");
andreikovacs 0:4eb2240dbd22 2129 uart.printf("%d", (uint32_t)u16TotalPackets);
andreikovacs 0:4eb2240dbd22 2130 uart.printf(" packets!\r\n\r\n");
andreikovacs 0:4eb2240dbd22 2131 uart.printf("\r\n -Press [ENTER] to end Transmission Control Test");
andreikovacs 0:4eb2240dbd22 2132 cstcState = gCsTcStateTransmissionControlEndTest_c;
andreikovacs 0:4eb2240dbd22 2133 }
andreikovacs 0:4eb2240dbd22 2134 }
andreikovacs 0:4eb2240dbd22 2135 if(timePassed)
andreikovacs 0:4eb2240dbd22 2136 {
andreikovacs 0:4eb2240dbd22 2137 timePassed = FALSE;
andreikovacs 0:4eb2240dbd22 2138 startTime = GetTimestampUS();
andreikovacs 0:4eb2240dbd22 2139 (void)MLMEScanRequest(testChannel);
andreikovacs 0:4eb2240dbd22 2140 }
andreikovacs 0:4eb2240dbd22 2141 if(evDataFromUART && gu8UartData == ' ')
andreikovacs 0:4eb2240dbd22 2142 {
andreikovacs 0:4eb2240dbd22 2143 uart.printf("\r\n\r\n-Test interrupted by user. Press [ENTER] to continue\r\n\r\n");
andreikovacs 0:4eb2240dbd22 2144 cstcState = gCsTcStateTransmissionControlEndTest_c;
andreikovacs 0:4eb2240dbd22 2145 }
andreikovacs 0:4eb2240dbd22 2146 break;
andreikovacs 0:4eb2240dbd22 2147 case gCsTcStateTransmissionControlEndTest_c:
andreikovacs 0:4eb2240dbd22 2148 if(evDataFromUART && gu8UartData == '\r')
andreikovacs 0:4eb2240dbd22 2149 {
andreikovacs 0:4eb2240dbd22 2150 cstcState = gCsTcStateInit_c;
andreikovacs 0:4eb2240dbd22 2151 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 2152 }
andreikovacs 0:4eb2240dbd22 2153 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 2154 break;
andreikovacs 0:4eb2240dbd22 2155 }
andreikovacs 0:4eb2240dbd22 2156 }
andreikovacs 0:4eb2240dbd22 2157 /************************************************************************************
andreikovacs 0:4eb2240dbd22 2158 *
andreikovacs 0:4eb2240dbd22 2159 * Handler for Carrier Sense Test
andreikovacs 0:4eb2240dbd22 2160 *
andreikovacs 0:4eb2240dbd22 2161 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2162 void CarrierSenseHandler(void)
andreikovacs 0:4eb2240dbd22 2163 {
andreikovacs 0:4eb2240dbd22 2164 int8_t fillIndex = 0;
andreikovacs 0:4eb2240dbd22 2165 uint8_t* smacPduPtr;
andreikovacs 0:4eb2240dbd22 2166 switch(cstcState)
andreikovacs 0:4eb2240dbd22 2167 {
andreikovacs 0:4eb2240dbd22 2168 case gCsTcStateCarrierSenseStart_c:
andreikovacs 0:4eb2240dbd22 2169 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 2170 if( gMode1Bitrate_c == crtBitrate )
andreikovacs 0:4eb2240dbd22 2171 {
andreikovacs 0:4eb2240dbd22 2172 (void)MLMESetAdditionalRFOffset(gOffsetIncrement + 30);
andreikovacs 0:4eb2240dbd22 2173 }
andreikovacs 0:4eb2240dbd22 2174 else
andreikovacs 0:4eb2240dbd22 2175 {
andreikovacs 0:4eb2240dbd22 2176 (void)MLMESetAdditionalRFOffset(gOffsetIncrement + 60);
andreikovacs 0:4eb2240dbd22 2177 }
andreikovacs 0:4eb2240dbd22 2178 #endif
andreikovacs 0:4eb2240dbd22 2179 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 2180
andreikovacs 0:4eb2240dbd22 2181 uart.printf( "\r\n\r\n Press [SPACE] to begin/interrupt test");
andreikovacs 0:4eb2240dbd22 2182 uart.printf( "\r\n Press [p] to return to previous menu");
andreikovacs 0:4eb2240dbd22 2183 // PrintTestParameters(FALSE);
andreikovacs 0:4eb2240dbd22 2184 shortCutsEnabled = FALSE;
andreikovacs 0:4eb2240dbd22 2185 uart.printf("\r\n");
andreikovacs 0:4eb2240dbd22 2186
andreikovacs 0:4eb2240dbd22 2187 fillIndex = testPayloadLen / gPrbs9BufferLength_c;
andreikovacs 0:4eb2240dbd22 2188 while(fillIndex > 0)
andreikovacs 0:4eb2240dbd22 2189 {
andreikovacs 0:4eb2240dbd22 2190 fillIndex--;
andreikovacs 0:4eb2240dbd22 2191 smacPduPtr = gAppTxPacket->smacPdu.smacPdu + fillIndex * gPrbs9BufferLength_c;
andreikovacs 0:4eb2240dbd22 2192 FLib_MemCpy(smacPduPtr, u8Prbs9Buffer, gPrbs9BufferLength_c);
andreikovacs 0:4eb2240dbd22 2193 }
andreikovacs 0:4eb2240dbd22 2194 smacPduPtr = gAppTxPacket->smacPdu.smacPdu + ((testPayloadLen / gPrbs9BufferLength_c)*gPrbs9BufferLength_c);
andreikovacs 0:4eb2240dbd22 2195 FLib_MemCpy(smacPduPtr, u8Prbs9Buffer, (testPayloadLen % gPrbs9BufferLength_c));
andreikovacs 0:4eb2240dbd22 2196
andreikovacs 0:4eb2240dbd22 2197 gAppTxPacket->u8DataLength = testPayloadLen;
andreikovacs 0:4eb2240dbd22 2198
andreikovacs 0:4eb2240dbd22 2199 cstcState = gCsTcStateCarrierSenseSelectType_c;
andreikovacs 0:4eb2240dbd22 2200 break;
andreikovacs 0:4eb2240dbd22 2201 case gCsTcStateCarrierSenseSelectType_c:
andreikovacs 0:4eb2240dbd22 2202 if(evDataFromUART)
andreikovacs 0:4eb2240dbd22 2203 {
andreikovacs 0:4eb2240dbd22 2204 if(' ' == gu8UartData)
andreikovacs 0:4eb2240dbd22 2205 {
andreikovacs 0:4eb2240dbd22 2206 cstcState = gCsTcStateCarrierSensePerformingTest_c;
andreikovacs 0:4eb2240dbd22 2207 (void)MLMEScanRequest(testChannel);
andreikovacs 0:4eb2240dbd22 2208 }
andreikovacs 0:4eb2240dbd22 2209 else if ('p' == gu8UartData)
andreikovacs 0:4eb2240dbd22 2210 {
andreikovacs 0:4eb2240dbd22 2211 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 2212 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 2213 #endif
andreikovacs 0:4eb2240dbd22 2214 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 2215 cstcState = gCsTcStateInit_c;
andreikovacs 0:4eb2240dbd22 2216 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 2217 }
andreikovacs 0:4eb2240dbd22 2218 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 2219 }
andreikovacs 0:4eb2240dbd22 2220 break;
andreikovacs 0:4eb2240dbd22 2221 case gCsTcStateCarrierSensePerformingTest_c:
andreikovacs 0:4eb2240dbd22 2222 if(bScanDone)
andreikovacs 0:4eb2240dbd22 2223 {
andreikovacs 0:4eb2240dbd22 2224 bScanDone = FALSE;
andreikovacs 0:4eb2240dbd22 2225 uart.printf( "\r\n\tSampling done. RSSI value: -");
andreikovacs 0:4eb2240dbd22 2226 uart.printf("%d", (uint32_t) au8ScanResults[testChannel]);
andreikovacs 0:4eb2240dbd22 2227 uart.printf( "dBm");
andreikovacs 0:4eb2240dbd22 2228 if(au8ScanResults[testChannel] > ccaThresh)
andreikovacs 0:4eb2240dbd22 2229 {
andreikovacs 0:4eb2240dbd22 2230 (void)MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 2231 }
andreikovacs 0:4eb2240dbd22 2232 else
andreikovacs 0:4eb2240dbd22 2233 {
andreikovacs 0:4eb2240dbd22 2234 (void)MLMEScanRequest(testChannel);
andreikovacs 0:4eb2240dbd22 2235 }
andreikovacs 0:4eb2240dbd22 2236 }
andreikovacs 0:4eb2240dbd22 2237 if(bTxDone)
andreikovacs 0:4eb2240dbd22 2238 {
andreikovacs 0:4eb2240dbd22 2239 bTxDone = FALSE;
andreikovacs 0:4eb2240dbd22 2240
andreikovacs 0:4eb2240dbd22 2241 uart.printf("\r\n Transmission Performed\r\n");
andreikovacs 0:4eb2240dbd22 2242 uart.printf("\r\n -Press [ENTER] to end Carrier Sense Test");
andreikovacs 0:4eb2240dbd22 2243 cstcState = gCsTcStateCarrierSenseEndTest_c;
andreikovacs 0:4eb2240dbd22 2244 }
andreikovacs 0:4eb2240dbd22 2245 if(evDataFromUART && gu8UartData == ' ')
andreikovacs 0:4eb2240dbd22 2246 {
andreikovacs 0:4eb2240dbd22 2247 uart.printf("\r\n\r\n-Test interrupted by user. Press [ENTER] to continue\r\n\r\n");
andreikovacs 0:4eb2240dbd22 2248 cstcState = gCsTcStateCarrierSenseEndTest_c;
andreikovacs 0:4eb2240dbd22 2249 }
andreikovacs 0:4eb2240dbd22 2250 break;
andreikovacs 0:4eb2240dbd22 2251 case gCsTcStateCarrierSenseEndTest_c:
andreikovacs 0:4eb2240dbd22 2252 if(evDataFromUART && gu8UartData == '\r')
andreikovacs 0:4eb2240dbd22 2253 {
andreikovacs 0:4eb2240dbd22 2254 #if CT_Feature_Calibration
andreikovacs 0:4eb2240dbd22 2255 (void)MLMESetAdditionalRFOffset(gOffsetIncrement);
andreikovacs 0:4eb2240dbd22 2256 #endif
andreikovacs 0:4eb2240dbd22 2257 (void)MLMESetChannelRequest(testChannel);
andreikovacs 0:4eb2240dbd22 2258 cstcState = gCsTcStateInit_c;
andreikovacs 0:4eb2240dbd22 2259 SelfNotificationEvent();
andreikovacs 0:4eb2240dbd22 2260 }
andreikovacs 0:4eb2240dbd22 2261 evDataFromUART = FALSE;
andreikovacs 0:4eb2240dbd22 2262 break;
andreikovacs 0:4eb2240dbd22 2263 }
andreikovacs 0:4eb2240dbd22 2264 }
andreikovacs 0:4eb2240dbd22 2265
andreikovacs 0:4eb2240dbd22 2266 /************************************************************************************
andreikovacs 0:4eb2240dbd22 2267 *
andreikovacs 0:4eb2240dbd22 2268 * Auxiliary Functions
andreikovacs 0:4eb2240dbd22 2269 *
andreikovacs 0:4eb2240dbd22 2270 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2271
andreikovacs 0:4eb2240dbd22 2272 /**************************************************************************************/
andreikovacs 0:4eb2240dbd22 2273 void SetRadioRxOnNoTimeOut(void)
andreikovacs 0:4eb2240dbd22 2274 {
andreikovacs 0:4eb2240dbd22 2275 bRxDone = FALSE;
andreikovacs 0:4eb2240dbd22 2276 gAppRxPacket->u8MaxDataLength = gMaxSmacSDULength_c;
andreikovacs 0:4eb2240dbd22 2277 (void)MLMERXEnableRequest(gAppRxPacket, 0);
andreikovacs 0:4eb2240dbd22 2278 }
andreikovacs 0:4eb2240dbd22 2279
andreikovacs 0:4eb2240dbd22 2280 /**************************************************************************************/
andreikovacs 0:4eb2240dbd22 2281 void PrintPerRxFinalLine(uint16_t u16Received, uint16_t u16Total)
andreikovacs 0:4eb2240dbd22 2282 {
andreikovacs 0:4eb2240dbd22 2283 uart.printf("Received ");
andreikovacs 0:4eb2240dbd22 2284 uart.printf("%d",(uint32_t)u16Received);
andreikovacs 0:4eb2240dbd22 2285 uart.printf(" of ");
andreikovacs 0:4eb2240dbd22 2286 uart.printf("%d",(uint32_t)u16Total);
andreikovacs 0:4eb2240dbd22 2287 uart.printf(" packets transmitted \r\n");
andreikovacs 0:4eb2240dbd22 2288 uart.printf("\r\n Press [enter] to go back to the Per Rx test menu");
andreikovacs 0:4eb2240dbd22 2289 }
andreikovacs 0:4eb2240dbd22 2290
andreikovacs 0:4eb2240dbd22 2291 /************************************************************************************
andreikovacs 0:4eb2240dbd22 2292 *
andreikovacs 0:4eb2240dbd22 2293 *
andreikovacs 0:4eb2240dbd22 2294 * By employing this function, users can execute a test of the radio. Test mode
andreikovacs 0:4eb2240dbd22 2295 * implements the following:
andreikovacs 0:4eb2240dbd22 2296 * -PRBS9 Mode,
andreikovacs 0:4eb2240dbd22 2297 * -Force_idle,
andreikovacs 0:4eb2240dbd22 2298 * -Continuos TX without modulation,
andreikovacs 0:4eb2240dbd22 2299 * -Continuos TX with modulation.(0's,1's and PN patterns)
andreikovacs 0:4eb2240dbd22 2300 *
andreikovacs 0:4eb2240dbd22 2301 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2302 smacErrors_t TestMode
andreikovacs 0:4eb2240dbd22 2303 (
andreikovacs 0:4eb2240dbd22 2304 smacTestMode_t mode /*IN: The test mode to start.*/
andreikovacs 0:4eb2240dbd22 2305 )
andreikovacs 0:4eb2240dbd22 2306 {
andreikovacs 0:4eb2240dbd22 2307 aspTestRequestMsg.msgType = aspMsgTypeTelecTest_c;
andreikovacs 0:4eb2240dbd22 2308
andreikovacs 0:4eb2240dbd22 2309 #if(TRUE == smacParametersValidation_d)
andreikovacs 0:4eb2240dbd22 2310 if(gMaxTestMode_c <= mode)
andreikovacs 0:4eb2240dbd22 2311 {
andreikovacs 0:4eb2240dbd22 2312 return gErrorOutOfRange_c;
andreikovacs 0:4eb2240dbd22 2313 }
andreikovacs 0:4eb2240dbd22 2314 #endif
andreikovacs 0:4eb2240dbd22 2315
andreikovacs 0:4eb2240dbd22 2316 if(gTestModeForceIdle_c == mode)
andreikovacs 0:4eb2240dbd22 2317 {
andreikovacs 0:4eb2240dbd22 2318 aspTestRequestMsg.msgData.aspTelecTest.mode = gTestForceIdle_c;
andreikovacs 0:4eb2240dbd22 2319 }
andreikovacs 0:4eb2240dbd22 2320 else if(gTestModeContinuousTxModulated_c == mode)
andreikovacs 0:4eb2240dbd22 2321 {
andreikovacs 1:1eb1eccc81c2 2322 /*if(contTxModBitValue==gContTxModSelectOnes_c)
andreikovacs 0:4eb2240dbd22 2323 {
andreikovacs 0:4eb2240dbd22 2324 aspTestRequestMsg.msgData.aspTelecTest.mode = gTestContinuousTxModOne_c;
andreikovacs 0:4eb2240dbd22 2325 }
andreikovacs 0:4eb2240dbd22 2326 else if(contTxModBitValue == gContTxModSelectZeros_c)
andreikovacs 0:4eb2240dbd22 2327 {
andreikovacs 0:4eb2240dbd22 2328 aspTestRequestMsg.msgData.aspTelecTest.mode = gTestContinuousTxModZero_c;
andreikovacs 0:4eb2240dbd22 2329 }
andreikovacs 1:1eb1eccc81c2 2330 else */if(contTxModBitValue == gContTxModSelectPN9_c)
andreikovacs 0:4eb2240dbd22 2331 {
andreikovacs 0:4eb2240dbd22 2332 #ifdef gPHY_802_15_4g_d
andreikovacs 0:4eb2240dbd22 2333 aspTestRequestMsg.msgData.aspTelecTest.mode = gTestContinuousTxContPN9_c;
andreikovacs 0:4eb2240dbd22 2334 #else
andreikovacs 0:4eb2240dbd22 2335 aspTestRequestMsg.msgData.aspTelecTest.mode = gTestPulseTxPrbs9_c;
andreikovacs 0:4eb2240dbd22 2336 #endif
andreikovacs 0:4eb2240dbd22 2337 }
andreikovacs 0:4eb2240dbd22 2338 }
andreikovacs 0:4eb2240dbd22 2339 else if(gTestModeContinuousTxUnmodulated_c == mode)
andreikovacs 0:4eb2240dbd22 2340 {
andreikovacs 0:4eb2240dbd22 2341 aspTestRequestMsg.msgData.aspTelecTest.mode = gTestContinuousTxNoMod_c;
andreikovacs 0:4eb2240dbd22 2342 }
andreikovacs 0:4eb2240dbd22 2343 else if(gTestModeContinuousRxBER_c == mode)
andreikovacs 0:4eb2240dbd22 2344 {
andreikovacs 0:4eb2240dbd22 2345 aspTestRequestMsg.msgData.aspTelecTest.mode = gTestContinuousRx_c;
andreikovacs 0:4eb2240dbd22 2346 }
andreikovacs 0:4eb2240dbd22 2347 else if(gTestModePRBS9_c == mode)
andreikovacs 0:4eb2240dbd22 2348 {
andreikovacs 0:4eb2240dbd22 2349 /*Set Data Mode*/
andreikovacs 0:4eb2240dbd22 2350 gAppTxPacket->u8DataLength = gPrbs9BufferLength_c;
andreikovacs 0:4eb2240dbd22 2351 FLib_MemCpy(gAppTxPacket->smacPdu.smacPdu, u8Prbs9Buffer, gPrbs9BufferLength_c);
andreikovacs 0:4eb2240dbd22 2352 PacketHandler_Prbs9();
andreikovacs 0:4eb2240dbd22 2353 }
andreikovacs 0:4eb2240dbd22 2354 if(gTestModePRBS9_c != mode)
andreikovacs 0:4eb2240dbd22 2355 (void)APP_ASP_SapHandler(&aspTestRequestMsg, 0);
andreikovacs 0:4eb2240dbd22 2356
andreikovacs 0:4eb2240dbd22 2357 return gErrorNoError_c;
andreikovacs 0:4eb2240dbd22 2358 }
andreikovacs 0:4eb2240dbd22 2359
andreikovacs 0:4eb2240dbd22 2360 /************************************************************************************
andreikovacs 0:4eb2240dbd22 2361 * PacketHandler_Prbs9
andreikovacs 0:4eb2240dbd22 2362 *
andreikovacs 0:4eb2240dbd22 2363 * This function sends OTA the content of a PRBS9 polynomial of 65 bytes of payload.
andreikovacs 0:4eb2240dbd22 2364 *
andreikovacs 0:4eb2240dbd22 2365 *
andreikovacs 0:4eb2240dbd22 2366 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2367
andreikovacs 0:4eb2240dbd22 2368 void PacketHandler_Prbs9(void)
andreikovacs 0:4eb2240dbd22 2369 {
andreikovacs 0:4eb2240dbd22 2370 smacErrors_t err;
andreikovacs 0:4eb2240dbd22 2371 /*@CMA, Need to set Smac to Idle in order to get PRBS9 to work after a second try on the Conn Test menu*/
andreikovacs 0:4eb2240dbd22 2372 (void)MLMERXDisableRequest();
andreikovacs 0:4eb2240dbd22 2373 (void)MLMETXDisableRequest();
andreikovacs 0:4eb2240dbd22 2374 err = MCPSDataRequest(gAppTxPacket);
andreikovacs 0:4eb2240dbd22 2375 if(err != gErrorNoError_c)
andreikovacs 0:4eb2240dbd22 2376 {
andreikovacs 0:4eb2240dbd22 2377 failedPRBS9 = TRUE;
andreikovacs 0:4eb2240dbd22 2378 SelfNotificationEvent(); //in case data isn't sent, no confirm event will fire.
andreikovacs 0:4eb2240dbd22 2379 //this way we need to make sure the application will not freeze.
andreikovacs 0:4eb2240dbd22 2380 }
andreikovacs 0:4eb2240dbd22 2381 }
andreikovacs 0:4eb2240dbd22 2382
andreikovacs 0:4eb2240dbd22 2383 /*****************************************************************************
andreikovacs 0:4eb2240dbd22 2384 * UartRxCallBack function
andreikovacs 0:4eb2240dbd22 2385 *
andreikovacs 0:4eb2240dbd22 2386 * Interface assumptions:
andreikovacs 0:4eb2240dbd22 2387 * This callback is triggered when a new byte is received over the UART
andreikovacs 0:4eb2240dbd22 2388 *
andreikovacs 0:4eb2240dbd22 2389 * Return Value:
andreikovacs 0:4eb2240dbd22 2390 * None
andreikovacs 0:4eb2240dbd22 2391 *****************************************************************************/
andreikovacs 2:aaffc5d91884 2392 void UartRxCallBack(void)
andreikovacs 0:4eb2240dbd22 2393 {
andreikovacs 0:4eb2240dbd22 2394 gu8UartData = uart.getc();
andreikovacs 0:4eb2240dbd22 2395 gTaskEventFlags |= gUART_RX_EVENT_c;
andreikovacs 2:aaffc5d91884 2396 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 2397 }
andreikovacs 0:4eb2240dbd22 2398
andreikovacs 0:4eb2240dbd22 2399 /*@CMA, Conn Test. Range Test CallBack*/
andreikovacs 0:4eb2240dbd22 2400 void RangeTest_Timer_CallBack ()
andreikovacs 0:4eb2240dbd22 2401 {
andreikovacs 0:4eb2240dbd22 2402 gTaskEventFlags |= gRangeTest_EVENT_c;
andreikovacs 2:aaffc5d91884 2403 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 2404 }
andreikovacs 0:4eb2240dbd22 2405
andreikovacs 0:4eb2240dbd22 2406
andreikovacs 0:4eb2240dbd22 2407
andreikovacs 0:4eb2240dbd22 2408 /************************************************************************************
andreikovacs 0:4eb2240dbd22 2409 *
andreikovacs 0:4eb2240dbd22 2410 * Increments channel on the ED Confirm event and fires a new ED measurement request
andreikovacs 0:4eb2240dbd22 2411 *
andreikovacs 0:4eb2240dbd22 2412 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2413 void IncrementChannelOnEdEvent()
andreikovacs 0:4eb2240dbd22 2414 {
andreikovacs 0:4eb2240dbd22 2415 bScanDone = FALSE;
andreikovacs 0:4eb2240dbd22 2416 smacErrors_t err;
andreikovacs 0:4eb2240dbd22 2417 if (ChannelToScan <= gMaxChannel_c)
andreikovacs 0:4eb2240dbd22 2418 {
andreikovacs 0:4eb2240dbd22 2419 err = MLMEScanRequest((channels_t)ChannelToScan);
andreikovacs 0:4eb2240dbd22 2420 if(err == gErrorNoError_c)
andreikovacs 0:4eb2240dbd22 2421 ChannelToScan++; //Increment channel to scan
andreikovacs 0:4eb2240dbd22 2422 }
andreikovacs 0:4eb2240dbd22 2423 else
andreikovacs 0:4eb2240dbd22 2424 {
andreikovacs 0:4eb2240dbd22 2425 bScanDone = TRUE; //PRINT ALL CHANNEL RESULTS
andreikovacs 0:4eb2240dbd22 2426 Thread::wait(300); //Add delay between channel scanning series.
andreikovacs 0:4eb2240dbd22 2427 }
andreikovacs 0:4eb2240dbd22 2428 }
andreikovacs 0:4eb2240dbd22 2429
andreikovacs 0:4eb2240dbd22 2430 /***********************************************************************
andreikovacs 0:4eb2240dbd22 2431 *********************Utilities Software********************************
andreikovacs 0:4eb2240dbd22 2432 ************************************************************************/
andreikovacs 0:4eb2240dbd22 2433
andreikovacs 0:4eb2240dbd22 2434 bool_t stringComp(uint8_t * au8leftString, uint8_t * au8RightString, uint8_t bytesToCompare)
andreikovacs 0:4eb2240dbd22 2435 {
andreikovacs 0:4eb2240dbd22 2436 do
andreikovacs 0:4eb2240dbd22 2437 {
andreikovacs 0:4eb2240dbd22 2438 }while((*au8leftString++ == *au8RightString++) && --bytesToCompare);
andreikovacs 0:4eb2240dbd22 2439 return(0 == bytesToCompare);
andreikovacs 0:4eb2240dbd22 2440 }
andreikovacs 0:4eb2240dbd22 2441
andreikovacs 0:4eb2240dbd22 2442 uint32_t HexString2Dec(uint8_t* au8String)
andreikovacs 0:4eb2240dbd22 2443 {
andreikovacs 0:4eb2240dbd22 2444 uint8_t u8LocIndex=0;
andreikovacs 0:4eb2240dbd22 2445 uint8_t u8LocIndex2=0;
andreikovacs 0:4eb2240dbd22 2446 uint32_t u32DecValue = 0;
andreikovacs 0:4eb2240dbd22 2447
andreikovacs 0:4eb2240dbd22 2448 while(au8String[u8LocIndex]){
andreikovacs 0:4eb2240dbd22 2449 u8LocIndex++;
andreikovacs 0:4eb2240dbd22 2450 }
andreikovacs 0:4eb2240dbd22 2451
andreikovacs 0:4eb2240dbd22 2452 while(u8LocIndex--){
andreikovacs 0:4eb2240dbd22 2453 if((au8String[u8LocIndex] >= '0') && (au8String[u8LocIndex] <= '9'))
andreikovacs 0:4eb2240dbd22 2454 u32DecValue |= ((uint32_t)(au8String[u8LocIndex] - '0'))<<(u8LocIndex2*4);
andreikovacs 0:4eb2240dbd22 2455 else if((au8String[u8LocIndex] >= 'A') && (au8String[u8LocIndex] <= 'F')){
andreikovacs 0:4eb2240dbd22 2456 u32DecValue |= ((uint32_t)(au8String[u8LocIndex] - 'A' + 0x0A))<<(u8LocIndex2*4);
andreikovacs 0:4eb2240dbd22 2457 }else{
andreikovacs 0:4eb2240dbd22 2458 u32DecValue |= ((uint32_t)(au8String[u8LocIndex] - 'a' + 0x0A))<<(u8LocIndex2*4);
andreikovacs 0:4eb2240dbd22 2459 }
andreikovacs 0:4eb2240dbd22 2460 u8LocIndex2++;
andreikovacs 0:4eb2240dbd22 2461 }
andreikovacs 0:4eb2240dbd22 2462
andreikovacs 0:4eb2240dbd22 2463 return u32DecValue;
andreikovacs 0:4eb2240dbd22 2464 }
andreikovacs 0:4eb2240dbd22 2465
andreikovacs 0:4eb2240dbd22 2466 static void DelayTimeElapsed()
andreikovacs 0:4eb2240dbd22 2467 {
andreikovacs 0:4eb2240dbd22 2468 timePassed = TRUE;
andreikovacs 0:4eb2240dbd22 2469 gTaskEventFlags |= gTimePassed_EVENT_c;
andreikovacs 2:aaffc5d91884 2470 mainTask->signal_set(gEventsAny_c);
andreikovacs 0:4eb2240dbd22 2471 }
andreikovacs 0:4eb2240dbd22 2472
andreikovacs 0:4eb2240dbd22 2473 /***********************************************************************************
andreikovacs 0:4eb2240dbd22 2474 *
andreikovacs 0:4eb2240dbd22 2475 * PrintMenu
andreikovacs 0:4eb2240dbd22 2476 *
andreikovacs 0:4eb2240dbd22 2477 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2478 void PrintMenu(char * const pu8Menu[], uint8_t port)
andreikovacs 0:4eb2240dbd22 2479 {
andreikovacs 0:4eb2240dbd22 2480 uint8_t u8Index = 0;
andreikovacs 0:4eb2240dbd22 2481 (void)port;
andreikovacs 0:4eb2240dbd22 2482 while(pu8Menu[u8Index]){
andreikovacs 0:4eb2240dbd22 2483 uart.printf(pu8Menu[u8Index]);
andreikovacs 0:4eb2240dbd22 2484 u8Index++;
andreikovacs 0:4eb2240dbd22 2485 }
andreikovacs 0:4eb2240dbd22 2486 }
andreikovacs 0:4eb2240dbd22 2487
andreikovacs 0:4eb2240dbd22 2488 /***********************************************************************
andreikovacs 0:4eb2240dbd22 2489 ************************************************************************/
andreikovacs 0:4eb2240dbd22 2490
andreikovacs 0:4eb2240dbd22 2491 /************************************************************************************
andreikovacs 0:4eb2240dbd22 2492 *
andreikovacs 0:4eb2240dbd22 2493 * PrintTestParameters
andreikovacs 0:4eb2240dbd22 2494 *
andreikovacs 0:4eb2240dbd22 2495 ************************************************************************************/
andreikovacs 0:4eb2240dbd22 2496 void PrintTestParameters(bool_t bEraseLine)
andreikovacs 0:4eb2240dbd22 2497 {
andreikovacs 0:4eb2240dbd22 2498 uint8_t u8lineLen = 63;
andreikovacs 0:4eb2240dbd22 2499 uint8_t u8Index;
andreikovacs 0:4eb2240dbd22 2500
andreikovacs 0:4eb2240dbd22 2501 if(bEraseLine)
andreikovacs 0:4eb2240dbd22 2502 {
andreikovacs 0:4eb2240dbd22 2503 for(u8Index = 0;u8Index<u8lineLen;u8Index++)
andreikovacs 0:4eb2240dbd22 2504 {
andreikovacs 0:4eb2240dbd22 2505 uart.printf("\b");
andreikovacs 0:4eb2240dbd22 2506 }
andreikovacs 0:4eb2240dbd22 2507 }
andreikovacs 0:4eb2240dbd22 2508
andreikovacs 0:4eb2240dbd22 2509 uart.printf("Mode ");
andreikovacs 0:4eb2240dbd22 2510 if(mTxOperation_c == testOpMode)
andreikovacs 0:4eb2240dbd22 2511 {
andreikovacs 0:4eb2240dbd22 2512 uart.printf("Tx");
andreikovacs 0:4eb2240dbd22 2513 }
andreikovacs 0:4eb2240dbd22 2514 else
andreikovacs 0:4eb2240dbd22 2515 {
andreikovacs 0:4eb2240dbd22 2516 uart.printf("Rx");
andreikovacs 0:4eb2240dbd22 2517 }
andreikovacs 0:4eb2240dbd22 2518 uart.printf(", Channel ");
andreikovacs 0:4eb2240dbd22 2519 uart.printf("%d", (uint32_t)testChannel);
andreikovacs 0:4eb2240dbd22 2520 uart.printf(", Power ");
andreikovacs 0:4eb2240dbd22 2521 uart.printf("%d",(uint32_t)testPower);
andreikovacs 0:4eb2240dbd22 2522 uart.printf(", Payload ");
andreikovacs 0:4eb2240dbd22 2523 uart.printf("%d", (uint32_t)testPayloadLen);
andreikovacs 0:4eb2240dbd22 2524 uart.printf(", CCA Thresh ");
andreikovacs 0:4eb2240dbd22 2525 if(ccaThresh != 0)
andreikovacs 0:4eb2240dbd22 2526 {
andreikovacs 0:4eb2240dbd22 2527 uart.printf("-");
andreikovacs 0:4eb2240dbd22 2528 }
andreikovacs 0:4eb2240dbd22 2529 uart.printf("%d", (uint32_t)ccaThresh);
andreikovacs 0:4eb2240dbd22 2530 uart.printf("dBm");
andreikovacs 0:4eb2240dbd22 2531 uart.printf(" >");
andreikovacs 0:4eb2240dbd22 2532 }
andreikovacs 0:4eb2240dbd22 2533 /*****************************************************************************/
andreikovacs 0:4eb2240dbd22 2534
andreikovacs 0:4eb2240dbd22 2535 int main()
andreikovacs 0:4eb2240dbd22 2536 {
andreikovacs 0:4eb2240dbd22 2537 mainTask = new Thread(main_task);
andreikovacs 0:4eb2240dbd22 2538 while(1)
andreikovacs 0:4eb2240dbd22 2539 {
andreikovacs 0:4eb2240dbd22 2540
andreikovacs 0:4eb2240dbd22 2541 }
andreikovacs 0:4eb2240dbd22 2542 return 0;
andreikovacs 0:4eb2240dbd22 2543 }