/************************************************************************************************** * @fn macRadioTurnOnPower * * @brief Logic and sequence for powering up the radio. * * @param none * * @return none ************************************************************************************************** */ void macRadioTurnOnPower(void) { /* Enable RF error trap */ MAC_MCU_RFERR_ENABLE_INTERRUPT(); #if defined (HAL_PA_LNA) || defined (HAL_PA_LNA_CC2590) /* AGCCTRL1 for CC2590 or CC2591 */ AGCCTRL1 = 0x16; /* CC2591 PA/LNA control configuration * P0_7 -> HGM * P1_1 -> PA_EN * P1_4 -> EN */ /* P0_7 */ HAL_PA_LNA_RX_HGM(); /* P1_1 */ RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV; OBSSEL1 = OBSSEL1_OBS_CTRL0; /* P1_4 */ RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV; OBSSEL4 = OBSSEL4_OBS_CTRL4; #endif /* defined (HAL_PA_LNA) || defined (HAL_PA_LNA_CC2590) */ if (macChipVersion <= REV_B) { /* radio initializations for disappearing RAM; PG1.0 and before only */ MAC_RADIO_SET_PAN_ID(macPib.panId); MAC_RADIO_SET_SHORT_ADDR(macPib.shortAddress); MAC_RADIO_SET_IEEE_ADDR(macPib.extendedAddress.addr.extAddr); } }
/************************************************************************************************** * @fn macRadioTurnOnPower * * @brief Logic and sequence for powering up the radio. * * @param none * * @return none ************************************************************************************************** */ MAC_INTERNAL_API void macRadioTurnOnPower(void) { /* Enable RF error trap */ MAC_MCU_RFERR_ENABLE_INTERRUPT(); #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 /* table ID is referenced only when runtime configuratino is enabled */ if (macRadioDefsRefTableId & 0xf0) #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 */ #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \ defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 { /* either if compound statement or non-conditional compound statement */ /* (Re-)Configure PA and LNA control signals to RF frontend chips. * Note that The register values are not retained during sleep. */ /* P1_1 -> PAEN */ //RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV; //OBSSEL1 = OBSSEL_OBS_CTRL0; /* P1_4 -> EN (LNA control) */ //RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV; //OBSSEL4 = OBSSEL_OBS_CTRL1; /* P1_5 -> PAEN */ RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV; OBSSEL5 = OBSSEL_OBS_CTRL0; P1SEL &= ~0X10; P1DIR |= 0X10; P1_4 = 1; //P1_4 RXEN andy pa /* For any RX, change CCA settings for CC2591 compression workaround. * This will override LNA control if CC2591_COMPRESSION_WORKAROUND * flag is defined. */ COMPRESSION_WORKAROUND_ON(); } #endif /* defined MAC_RUNTIME_CC2591 || ... || defined HAL_PA_LNA_CC2590 */ if (macChipVersion <= REV_B) { /* radio initializations for disappearing RAM; PG1.0 and before only */ MAC_RADIO_SET_PAN_ID(macPib.panId); MAC_RADIO_SET_SHORT_ADDR(macPib.shortAddress); MAC_RADIO_SET_IEEE_ADDR(macPib.extendedAddress.addr.extAddr); } /* Turn on frame filtering */ MAC_RADIO_TURN_ON_RX_FRAME_FILTERING(); }
/************************************************************************************************** * @fn macRadioTurnOnPower * * @brief Logic and sequence for powering up the radio. * * @param none * * @return none ************************************************************************************************** */ MAC_INTERNAL_API void macRadioTurnOnPower(void) { /* Enable RF error trap */ MAC_MCU_RFERR_ENABLE_INTERRUPT(); #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \ defined MAC_RUNTIME_CC2592 /* table ID is referenced only when runtime configuratino is enabled */ if (macRadioDefsRefTableId & 0xf0) #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 */ #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \ defined MAC_RUNTIME_CC2592 || defined HAL_PA_LNA || \ defined HAL_PA_LNA_CC2590 || defined HAL_PA_LNA_CC2592 { /* either if compound statement or non-conditional compound statement */ /* (Re-)Configure PA and LNA control signals to RF frontend chips. * Note that The register values are not retained during sleep. */ /* PC3 -> PAEN */ RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV; OBSSEL3 = OBSSEL_OBS_CTRL0; /* PC2 -> EN (LNA control) */ RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV; OBSSEL2 = OBSSEL_OBS_CTRL1; } #endif /* defined MAC_RUNTIME_CC2591 || ... || defined HAL_PA_LNA_CC2592 */ if (macChipVersion <= REV_B) { /* radio initializations for disappearing RAM; PG1.0 and before only */ MAC_RADIO_SET_PAN_ID(macPib.panId); MAC_RADIO_SET_SHORT_ADDR(macPib.shortAddress); MAC_RADIO_SET_IEEE_ADDR(macPib.extendedAddress.addr.extAddr); } /* Turn on frame filtering */ MAC_RADIO_TURN_ON_RX_FRAME_FILTERING(); }
/************************************************************************************************** * @fn macRadioSetShortAddr * * @brief Set the short addrss on the radio. * * @param shortAddr - 16 bit short address * * @return none ************************************************************************************************** */ MAC_INTERNAL_API void macRadioSetShortAddr(uint16 shortAddr) { /* abstracted radio configuration */ MAC_RADIO_SET_SHORT_ADDR(shortAddr); }
static #endif /* USE_ICALL */ void macBackoffTimerEventHandler(void) { halIntState_t is; uint8 events; HAL_ENTER_CRITICAL_SECTION(is); events = macBackoffTimerEvents; macBackoffTimerEvents = 0; HAL_EXIT_CRITICAL_SECTION(is); if (events & MAC_BACKOFF_TIMER_EVENT_POWER_WAKEUP) { // Wakeup radio // Turning on radio domain before clock set up seems to cause // unexpected interrupt. // Hence interrupt shall be disabled here. MB_DisableInts(); // Enable clocks for all radio internal modules. // Use Non-Buff access for safety and check for sanity HWREG(RFC_PWR_NONBUF_BASE + RFC_PWR_O_PWMCLKEN) = 0x7FF; /* Setup mailbox */ macSetupMailbox(); #ifdef DEBUG_SW_TRACE /* re-enable RF trace output for FPGA */ MB_SendCommand( BUILD_DIRECT_PARAM_EXT_CMD( CMD_ENABLE_DEBUG, 0x1D40 ) ); /* or 0x1940 for less trace */ DBG_PRINT0(DBGSYS, "RF Trace Resumes..."); #endif /* DEBUG_SW_TRACE */ /* Start off CM0. Patch it. */ macSetupRfHal(); /* Restore states */ MAC_RADIO_SET_CHANNEL(macPhyChannel); MAC_RADIO_SET_PAN_COORDINATOR(macPanCoordinator); MAC_RADIO_SET_PAN_ID(pMacPib->panId); MAC_RADIO_SET_SHORT_ADDR(pMacPib->shortAddress); MAC_RADIO_SET_IEEE_ADDR(pMacPib->extendedAddress.addr.extAddr); #if !defined( USE_FPGA ) #ifdef USE_ICALL // Switch back to HFOSC. while (!ICall_pwrIsStableXOSCHF()); ICall_pwrSwitchXOSCHF(); #endif /* USE_ICALL */ #ifdef OSAL_PORT2TIRTOS // Switches back to HFOSC. while (!Power_isStableXOSC_HF()); Power_switchXOSC_HF(); #endif /* OSAL_PORT2TIRTOS */ #endif /* !defined( USE_FPGA ) */ /* Synchronize RAT timer */ macSyncStartRAT(macRATValue); /* Turn on autoack */ MAC_RADIO_TURN_ON_AUTO_ACK(); /* Initialize SRCEXTPENDEN and SRCSHORTPENDEN to zeros */ MAC_RADIO_SRC_MATCH_INIT_EXTPENDEN(); MAC_RADIO_SRC_MATCH_INIT_SHORTPENDEN(); /* Start 15.4 Radio */ macSetupRadio(); /* Restore timer comparators */ MAC_RADIO_BACKOFF_SET_PERIOD(macBackoffTimerRollover); MAC_RADIO_BACKOFF_SET_COMPARE(backoffTimerTrigger); #if 0 /* Following code should be disabled normally */ /* Code for wakeup lead time calibration */ { static uint32 macBackoffTimerMinMargin = 0xffffffffu; uint32 delta = macPrevPeriodRatCount + backoffTimerTrigger * MAC_BACKOFF_TO_RAT_RATIO - MAC_RAT_COUNT; if (delta < macBackoffTimerMinMargin) { macBackoffTimerMinMargin = delta; } } #endif } /* Note that MAC_BACKOFF_TIMER_EVENT_POWER_TIMER_EXP handling must always * occur after handling of MAC_BACKOFF_TIMER_EVENT_POWER_WAKEUP event * because the device might be waking up upon the timer event itself * in which case, radio has to be turned on before updating the RAT timer. */ if (events & MAC_BACKOFF_TIMER_EVENT_POWER_TIMER_EXP) { /* Update wakeup schedule, which most likely would vote not to enter * sleep state. */ HAL_ENTER_CRITICAL_SECTION(is); MAC_BACKOFF_TIMER_UPDATE_WAKEUP(); HAL_EXIT_CRITICAL_SECTION(is); } }
/************************************************************************************************** * @fn macRadioTurnOnPower * * @brief Logic and sequence for powering up the radio. * * @param none * * @return none ************************************************************************************************** */ MAC_INTERNAL_API void macRadioTurnOnPower(void) { /* Enable RF error trap */ MAC_MCU_RFERR_ENABLE_INTERRUPT(); #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \ defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 /* table ID is referenced only when runtime configuration is enabled */ if (macRadioDefsRefTableId & 0xf0) #endif /* defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 */ #if defined MAC_RUNTIME_CC2591 || defined MAC_RUNTIME_CC2590 || \ defined MAC_RUNTIME_SE2431L || defined MAC_RUNTIME_CC2592 || \ defined HAL_PA_LNA || defined HAL_PA_LNA_CC2590 || \ defined HAL_PA_LNA_SE2431L || defined HAL_PA_LNA_CC2592 { /* either if compound statement or non-conditional compound statement */ /* (Re-)Configure PA and LNA control signals to RF frontend chips. * Note that The register values are not retained during sleep. */ if (paLnaChip == PA_LNA_SE2431L) { /* CPS or P0_7 maps closely to the HGM line */ HAL_PA_LNA_RX_HGM(); /* EN or CSD line is controlled via software so setting it high here to start the SE2431L frontend */ HAL_PA_LNA_RX_CSD_HIGH(); /* CTX or P1_1 maps closely to PAEN */ RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV; OBSSEL1 = OBSSEL_OBS_CTRL0; } else if(paLnaChip == PA_LNA_CC2592) { /* P1_1 -> PAEN */ RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV; OBSSEL1 = OBSSEL_OBS_CTRL0; /* P1_0 -> EN (LNA control) */ RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV; OBSSEL0 = OBSSEL_OBS_CTRL1; } else { /* P1_1 -> PAEN */ RFC_OBS_CTRL0 = RFC_OBS_CTRL_PA_PD_INV; OBSSEL1 = OBSSEL_OBS_CTRL0; /* P1_4 -> EN (LNA control) */ RFC_OBS_CTRL1 = RFC_OBS_CTRL_LNAMIX_PD_INV; OBSSEL4 = OBSSEL_OBS_CTRL1; } /* For any RX, change CCA settings for CC2591 compression workaround. * This will override LNA control if CC2591_COMPRESSION_WORKAROUND * flag is defined. */ } #endif /* defined MAC_RUNTIME_CC2591 || ... || defined HAL_PA_LNA_SE2431L... */ if (macChipVersion <= REV_B) { /* radio initializations for disappearing RAM; PG1.0 and before only */ MAC_RADIO_SET_PAN_ID(macPib.panId); MAC_RADIO_SET_SHORT_ADDR(macPib.shortAddress); MAC_RADIO_SET_IEEE_ADDR(macPib.extendedAddress.addr.extAddr); } /* Turn on frame filtering */ MAC_RADIO_TURN_ON_RX_FRAME_FILTERING(); }