Hi, I would like to reuse some chunks of code from PER TEST software (www.ti.com/.../swru296b.pdf) but some points are unclear to me
File cc120x_per_test_api.c
Receiver code includes this block
/* The RX FIFO is not empty, process contents */ cc120xSpiReadRxFifo(&rxLength, 1); /* Check that the packet length just read + status bytes(2B) + length byte match the RXBYTES */ /* If these are not equal: * - Packet is not like expected */ if(rxBytes != (rxLength+3)) { /* This is a fault FIFO condition -> clean FIFO and register a sync detection */ /* IDLE -> FLUSH RX FIFO -> RX */ perCC120xRxIdle(); perCC120xEnterRx(); /* Report that a sync was detected */ rxData_tmp.rssi = perCC120xRead8BitRssi(); return;
Questions:
1. if(rxBytes != (rxLength+3))
Is this checking have the same meaning as below from cc120x_easy_link_rx.c:
// Read marcstate to check for RX FIFO error cc120xSpiReadReg(CC120X_MARCSTATE, &marcStatus, 1); // Mask out marcstate bits and check if we have a RX FIFO error if((marcStatus & 0x1F) == RX_FIFO_ERROR){
So is it just another way of RX FIFO error checking?
2. Comment below mentions FLUSH RX FIFO. But I do not see explicit function like trxSpiCmdStrobe(CC120X_SFRX) inside perCC120xRxIdle()and perCC120xEnterRx():
/* This is a fault FIFO condition -> clean FIFO and register a sync detection */ /* IDLE -> FLUSH RX FIFO -> RX */ perCC120xRxIdle(); perCC120xEnterRx(); /******************************************************************************* * @fn perCC120xRxIdle * * @brief Radio state is switched from RX to IDLE * * input parameters * * @param none * * output parameters * * @return void */ static void perCC120xRxIdle(void) { /* Disable pin interrupt */ trxDisableInt(); /* Strobe IDLE */ trxSpiCmdStrobe(CC120X_SIDLE); /* Wait until chip is in IDLE */ while(trxSpiCmdStrobe(CC120X_SNOP) & 0xF0); /* Clear pin interrupt flag */ trxClearIntFlag(); return; } /******************************************************************************* * @fn perCC120xIdleRx * * @brief Radio state is switched from Idle to RX. Function assumes that * radio is in IDLE when called. * * input parameters * * @param none * * output parameters * * @return void */ static void perCC120xIdleRx(void) { trxClearIntFlag(); trxSpiCmdStrobe(CC120X_SRX); trxEnableInt(); return; } /*******************************************************************************
How FIFO cleaning is implemented here?