📄 mac_rx_engine.c
字号:
mlmeOrphanIndication(pMDI->srcAddr.Extended, pMDI->securityUse, pMDI->aclEntry);
mrxpReleasePacket(pPacket);
}
}
break;
#endif
#if MAC_OPT_FFD
case CMD_PAN_ID_CONFLICT_NOTIFICATION:
// The PAN Coordinator has received a PAN ID conflict notification command from a device on its own PAN
if ((GET_MF(MF_PAN_COORDINATOR)) && (pMDI->srcPanId == mpib.macPANId)) {
// Clean up before making the call to the higher layer
cleanUpAfterSwitch = FALSE;
mschRemoveTask(pTask->priority, 0);
mrxpReleasePacket(pPacket);
mlmeSyncLossIndication(PAN_ID_CONFLICT);
}
break;
#endif
default:
break;
}
// Clean up (used when there are no calls to the upper layer
if (cleanUpAfterSwitch) {
mschRemoveTask(pTask->priority, MSCH_KEEP_TASK_IN_PROGRESS_BM);
mrxpReleasePacket(pPacket);
}
} // mrxProcessMacCommand
//-------------------------------------------------------------------------------------------------------
// void mrxCommStatusIndication(MAC_TASK_INFO *pTask)
//
// DESCRIPTION:
// This task is responsible for generating mlme-comm-status.indication upon security failures.
//
// TASK DATA:
// A pointer to the MAC_RX_PACKET to be processed
//-------------------------------------------------------------------------------------------------------
void mrxCommStatusIndication(MAC_TASK_INFO *pTask) {
MAC_RX_PACKET *pPacket = (MAC_RX_PACKET*) pTask->taskData;
MCPS_DATA_INDICATION *pMDI = &pPacket->mdi;
/// ENABLE_FIFOP_INT();
mlmeCommStatusIndication(pMDI->srcPanId, pMDI->srcAddrMode, &pMDI->srcAddr, pMDI->dstAddrMode, &pMDI->dstAddr, pPacket->securityStatus);
mschRemoveTask(pTask->priority, 0);
mrxpReleasePacket(pPacket);
} //mrxCommStatusIndication
//-------------------------------------------------------------------------------------------------------
// void mrxHandleFifoUnderAndOverflow(void)
//
// DESCRIPTION:
// Flushes the RX FIFO if an overflow has occurred (FIFOP and FIFO are both low, when the polarity
// of FIFOP has been switched). This function is called by the reception routine in the final stage.
//-------------------------------------------------------------------------------------------------------
void mrxHandleFifoUnderAndOverflow(void) {
//if (CC2420_RXFIFO_OVERFLOW() || mrxInfo.handleFifoUnderflow) {
// DISABLE_GLOBAL_INT();
// FASTSPI_STROBE(CC2420_SFLUSHRX);
// FASTSPI_STROBE(CC2420_SFLUSHRX); // Flush
// ENABLE_GLOBAL_INT();
//} --li
} // mrxHandleFifoUnderAndOverflow
//-------------------------------------------------------------------------------------------------------
// void mrxSetFifopThreshold(UINT8 count)
//
// DESCRIPTION:
// Adjusts the FIFOP threshold so that when the FIFOP pin changes when the number of bytes in the RX
// FIFO exceeds "count".
//
// ARGUMENTS:
// UINT8 count
// The new FIFOP threshold
//-------------------------------------------------------------------------------------------------------
void mrxSetFifopThreshold(UINT8 count) {
//WORD regValue;
//
//// Invert the FIFOP pin
//regValue = 0x0200;
//
//// Set the BCN_ACCEPT bit during active and passive scan
//if (macInfo.state == MAC_STATE_ACTIVE_OR_PASSIVE_SCAN) regValue |= 0x0800;
//
//// Add the byte count
//regValue |= count;
//
//DISABLE_GLOBAL_INT();
//FASTSPI_SETREG(CC2420_IOCFG0, regValue);
//ENABLE_GLOBAL_INT(); --li
} // mrxSetFifopThreshold
//-------------------------------------------------------------------------------------------------------
// SIGNAL(SIG_INTERRUPT0)
//
// DESCRIPTION:
// FIFOP interrupt:
// This interrupt is triggered when the number of bytes in the CC2420 RX FIFO exceeds a configurable
// threshold (IOCFG0.FIFOP_THRESHOLD). The callback timer is disabled during the execution of this
// interrupt. To avoid a long burst of FIFOP interrupts, the interrupt uses timer 1 to turn it back
// on a short while after it has returned. It will thereby allow for callbacks and task execution in
// between.
//-------------------------------------------------------------------------------------------------------
//SIGNAL(SIG_INTERRUPT0) {
// BYTE reservedTask;
// BYTE dstAddrMode;
// BYTE srcAddrMode;
// BYTE nextState;
// BYTE readLength;
// UINT16 timer1compC;
// ZBOOL createProcessTask;
// void *pProcessTask;
// WORD processTaskData;
//
//#if ((MAC_OPT_SECURITY) || (MAC_OPT_ACL_SIZE>0))
// BYTE n;
// ZBOOL aclEntryFound;
//#endif
//
// //Disable compc on timer 1 so we prevent double fifop interupts.
// DISABLE_T1_COMPC_INT();
// // Copy the pointer for fast access
// MAC_RX_PACKET *pPacket = mrxInfo.pMrxPacket;
// MCPS_DATA_INDICATION *pMDI = &pPacket->mdi;
//
// // Turn off the main MAC interrupts
// DISABLE_FIFOP_INT();
// DISABLE_T1_COMPA_INT();
// ENABLE_GLOBAL_INT();
//
// switch (mrxInfo.state) {
// case MRX_STATE_LEN_FCF_SEQ:
//
// // Reserve task
// reservedTask = mschReserveTask();
//
// // Keep RX on while receiving
// mrxAutoIncrOnCounter();
//
// if ((macInfo.state != MAC_STATE_ENERGY_SCAN) && (reservedTask != NO_TASK)) {
// mrxInfo.taskNumber = reservedTask;
//
// // Reserve packet
// pPacket = mrxpReservePacket();
// if (pPacket) {
// mrxInfo.pMrxPacket = pPacket;
// pMDI = &pPacket->mdi;
//
// // By default, report that the received packet is not found in ACL
// // This value may be overridden at a later stage
// pMDI->aclEntry = 0x08;
//
// // By default, report successful securityStatus
// pPacket->securityStatus = SUCCESS;
//
// // Read the packet length, the frame control field and the sequence number
// msupReadFifo(&mrxInfo.length, 4);
// mrxInfo.length &= 0x7F;
//#if MAC_OPT_SECURITY
// // Store the unmodified PSDU length, later to be used
// // for security purposes
// mrxSecurityInfo.securitySetup.clearTextLength = mrxInfo.length;
//#endif
// mrxInfo.length -= 5; // 3 for FCF and SN + 2 for FCS
//
// // Get the time stamp (do it now to make sure that it is not overwritten by the acknowledgment)
// DISABLE_GLOBAL_INT();
// pPacket->timeStamp = mtimInfo.captureTime >> 4;
// ENABLE_GLOBAL_INT();
//
// // Set default security values
// if ((BYTE) mrxInfo.frameControlField & SECURITY_ENABLED_BM) {
// pMDI->securityUse = TRUE;
// } else {
// pMDI->securityUse = FALSE;
// }
//
// // Set default MSDU length
// pMDI->msduLength = 0;
//
// // This packet will be acknowledged if the ack request bit is set
// pPacket->flags &= ~MRXP_FLAG_SACKPEND_ISSUED_BM;
// if ((BYTE) mrxInfo.frameControlField & ACK_REQ_BM) {
//
// // Acknowledge with the pending flag set if there is at least one packet in the pending queue
// DISABLE_GLOBAL_INT();
//#if MAC_OPT_FFD
//
// if ((SFD_IS_ACTIVE()) && ((mscInfo.scanStatus == MSC_STATUS_FINISHED) || (mscInfo.scanStatus == MSC_STATUS_ORPHAN_REALIGNED) || (mscInfo.scanType == ORPHAN_SCAN))){
//
//#if MAC_OPT_TRANSMIT_POWER
// msupSetTransmitPower();//If changed set the transmit power
//#endif
// if (miqInfo.firstIndirectPacket != NO_PACKET) {
// FASTSPI_STROBE(CC2420_SACKPEND);
// pPacket->flags |= MRXP_FLAG_SACKPEND_ISSUED_BM;
// } else {
// FASTSPI_STROBE(CC2420_SACK);
// }
// }
//#else
// if ((SFD_IS_ACTIVE()) && ((mscInfo.scanStatus == MSC_STATUS_FINISHED) || (mscInfo.scanStatus == MSC_STATUS_ORPHAN_REALIGNED) || (mscInfo.scanType == ORPHAN_SCAN))){
// FASTSPI_STROBE(CC2420_SACK);
// }
//#endif
// ENABLE_GLOBAL_INT();
// }
//
//
// // Set the destination address mode and length (of the fields)
// dstAddrMode = BF(mrxInfo.frameControlField, DEST_ADDR_MODE_BM, DEST_ADDR_MODE_IDX);
// pMDI->dstAddrMode = dstAddrMode;
// if (dstAddrMode) {
// switch (dstAddrMode) {
// case AM_SHORT_16: mrxInfo.dstAddrLength = 4; break;
// case AM_EXTENDED_64: mrxInfo.dstAddrLength = 10; break;
// }
// mrxInfo.pDstAddrStoragePtr = (BYTE*) &pMDI->dstPanId;
// } else {
// mrxInfo.dstAddrLength = 0;
// }
//
// // Set the source address mode and length (of the fields)
// srcAddrMode = BF(mrxInfo.frameControlField, SRC_ADDR_MODE_BM, SRC_ADDR_MODE_IDX);
// pMDI->srcAddrMode = srcAddrMode;
// if (srcAddrMode) {
// switch (srcAddrMode) {
// case AM_SHORT_16: mrxInfo.srcAddrLength = 4; break;
// case AM_EXTENDED_64: mrxInfo.srcAddrLength = 10; break;
// }
// mrxInfo.pSrcAddrStoragePtr = (BYTE*) &pMDI->srcPanId;
// if (mrxInfo.frameControlField & INTRA_PAN_BM) {
// mrxInfo.srcAddrLength -= 2;
// mrxInfo.pSrcAddrStoragePtr += 2;
// }
// } else {
// mrxInfo.srcAddrLength = 0;
// }
//
// // Set the next state
// if ((mrxInfo.dstAddrLength + mrxInfo.srcAddrLength) > mrxInfo.length) {
// nextState = MRX_STATE_DISCARD_REMAINING;
// if (mrxInfo.length < 2) mrxSetFifopThreshold(mrxInfo.length + 1);
// } else if (mrxInfo.dstAddrLength) {
// nextState = MRX_STATE_DEST_ADDR;
// } else if (mrxInfo.srcAddrLength) {
// nextState = MRX_STATE_SRC_ADDR;
// } else if (mrxInfo.length) {
// nextState = MRX_STATE_SECURITY_INIT;
// if (mrxInfo.length == 1) mrxSetFifopThreshold(0);
// } else {
// nextState = MRX_STATE_FCS;
// mrxSetFifopThreshold(1);
// }
// mrxInfo.state = nextState;
// break;
// }
// }
//
// // This packet will be discarded because
// // - There was no available task to handle the packet processing
// // - There was no packet structure to store the incoming data
// // - We're performing an energy detection scan, where all incoming packets are discarded
// mrxInfo.state = MRX_STATE_DISCARD_ALL;
// mschReleaseTask(reservedTask);
// break;
//
// case MRX_STATE_DEST_ADDR:
// readLength = MIN(4, mrxInfo.dstAddrLength);
// msupReadFifo(mrxInfo.pDstAddrStoragePtr, readLength);
// mrxInfo.dstAddrLength -= readLength;
// mrxInfo.length -= readLength;
// if (mrxInfo.dstAddrLength) {
// mrxInfo.pDstAddrStoragePtr += readLength;
// break;
// } else if (pMDI->srcAddrMode) {
// pMDI->srcPanId = pMDI->dstPanId;
// nextState = MRX_STATE_SRC_ADDR;
// } else if (mrxInfo.length) {
// nextState = MRX_STATE_SECURITY_INIT;
// if (mrxInfo.length == 1) mrxSetFifopThreshold(0);
// } else {
// nextState = MRX_STATE_FCS;
// mrxSetFifopThreshold(1);
// }
// mrxInfo.state = nextState;
// break;
//
// case MRX_STATE_SRC_ADDR:
// readLength = MIN(4, mrxInfo.srcAddrLength);
// msupReadFifo(mrxInfo.pSrcAddrStoragePtr, readLength);
// mrxInfo.srcAddrLength -= readLength;
// mrxInfo.length -= readLength;
// if (mrxInfo.srcAddrLength) {
// mrxInfo.pSrcAddrStoragePtr += readLength;
// break;
// } else if (mrxInfo.length) {
// nextState = MRX_STATE_SECURITY_INIT;
// if (mrxInfo.length == 1) mrxSetFifopThreshold(0);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -