Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RF_Stat RF_flushCmd(RF_Handle h, RF_CmdHandle ch, uint8_t mode)
- {
- return (abortCmd(h, ch, (mode | 0x2)));
- }
- static RF_Stat abortCmd(RF_Handle h, RF_CmdHandle ch, uint8_t type)
- {
- //Assert
- Assert_isTrue((h != NULL), NULL);
- // initialize local variables
- RF_Cmd* pCmdPend = Q_peek(&cmdQ.pPend);
- RF_CmdDirImm* pCmdDirImm = &cmdDirImm;
- bool bGraceful = type & 0x1;
- bool bFlushing = false;
- RF_Stat status = RF_StatInvalidParamsError;
- // Check if current command
- uint32_t key = Hwi_disable();
- if (ch == RF_CMDHANDLE_FLUSH_ALL)
- {
- ch = cmdQ.nSeqDone + 1;
- pCmdDirImm->flags = 0;
- }
- RF_Cmd* pCmd = &aCmdPool[ch%N_CMD_POOL];
- if (pCmd == cmdQ.pCurrCmd)
- {
- // Clear all pending commands
- if (type & 0x2)
- {
- pCmdPend = cmdQ.pPend;
- cmdQ.pPend = NULL;
- }
- // Flag that operation has been aborted.
- pCmd->flags |= (1 << bGraceful);
- uint32_t keySwi = Swi_disable();
- runDirImmCmd((bGraceful) ? CMDR_DIR_CMD(CMD_STOP) : CMDR_DIR_CMD(CMD_ABORT));
- Hwi_restore(key);
- // Call callbacks
- if (type & 0x2)
- {
- while (pCmdPend)
- {
- pCmdPend->flags |= RF_CMD_CANCELLED_FLAG;
- Q_push(&cmdQ.pDone, Q_pop(&pCmdPend));
- }
- }
- Swi_restore(keySwi);
- status = RF_StatSuccess;
- }
- else
- {
- if (pCmdPend == pCmd)
- {
- Clock_stop(Clock_handle(&clkPowerUp));
- if (type & 0x2)
- {
- cmdQ.pPend = NULL;
- }
- else
- {
- cmdQ.pPend = cmdQ.pPend->pNext;
- }
- Hwi_restore(key);
- do {
- // Call callbacks
- pCmdPend->flags |= RF_CMD_CANCELLED_FLAG;
- Q_push(&cmdQ.pDone, Q_pop(&pCmdPend));
- } while ((pCmdPend) && (type & 0x2));
- status = RF_StatSuccess;
- }
- else
- {
- while (pCmdPend)
- {
- if (pCmdPend->pNext == pCmd)
- {
- Clock_stop(Clock_handle(&clkPowerUp));
- RF_Cmd* pTemp = (RF_Cmd*)pCmdPend->pNext;
- pCmdPend->pNext = NULL;
- pCmdPend = pTemp;
- Hwi_restore(key);
- if (type & 0x2)
- {
- bFlushing = true;
- }
- else
- {
- pCmdPend->flags |= RF_CMD_CANCELLED_FLAG;
- Q_push(&cmdQ.pDone, Q_pop(&pCmdPend));
- }
- status = RF_StatSuccess;
- }
- if (bFlushing)
- {
- pCmdPend->flags |= RF_CMD_CANCELLED_FLAG;
- Q_push(&cmdQ.pDone, Q_pop(&pCmdPend));
- }
- else
- {
- pCmdPend = (RF_Cmd*)pCmdPend->pNext;
- }
- }
- if (status != RF_StatSuccess)
- {
- Hwi_restore(key);
- }
- }
- FsmNextState(fsmActiveState);
- Swi_or(Swi_handle(&swiFsm), Fsm_EventLastCommandDone);
- if (!bRadioActive)
- {
- FsmNextState(fsmPowerUpState);
- }
- }
- return(status);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement