OT_WEAK void radio_init( ) { /// Transceiver implementation dependent //vlFILE* fp; /// Set SPIRIT1-dependent initialization defaults //rfctl.flags = RADIO_FLAG_XOON; rfctl.flags = 0; rfctl.nextcal = 0; /// Set universal Radio module initialization defaults //radio.state = RADIO_Idle; //radio.evtdone = &otutils_sig2_null; /// Initialize the bus between SPIRIT1 and MCU, and load defaults. /// SPIRIT1 starts-up in Idle (READY), so we set the state and flags /// to match that. Then, init the bus and send RADIO to sleep. /// SPIRIT1 can do SPI in Sleep. spirit1_init_bus(); spirit1_load_defaults(); /// Do this workaround (SPIRIT1 Errata DocID023165 R5, section 1.2) to fix /// the shutdown current issue for input voltages <= 2.6V. For input /// voltages > 2.6V, it does not hurt anything. spirit1_write(RFREG(PM_TEST), 0xCA); spirit1_write(RFREG(TEST_SELECT), 0x04); spirit1_write(RFREG(TEST_SELECT), 0x00); /// Done with the radio init //spirit1drv_smart_standby(); radio_sleep(); /// Initialize RM2 elements such as channels, link-params, etc. rm2_init(); }
void spirit1_clockout_off() { /// This is the reverse of spirit1_clockout_on(), described above. #if (BOARD_FEATURE_RFXTALOUT) spirit1.clkreq = False; spirit1_write(RFREG(GPIO3_CONF), RFGPO(GND)); spirit1_write(RFREG(MCU_CK_CONF), 0); spirit1drv_smart_standby(); #endif }
/** Special Functions <BR> * ========================================================================<BR> * Notably, these two control the clock-out feature of the SPIRIT1, which is * handy if you have a 48MHz crystal and you want to drive an otherwise * crystal-less MCU for USB. */ void spirit1_clockout_on(ot_u8 clk_param) { /// Set the SPIRIT1 to idle, then configure the driver so it never goes into sleep /// or standby, and finally configure the SPIRIT1 to output the clock. #if (BOARD_FEATURE_RFXTALOUT) spirit1drv_smart_ready(); spirit1.clkreq = True; spirit1_write(RFREG(MCU_CK_CONF), clk_param); spirit1_write(RFREG(GPIO3_CONF), (_GPIO_SELECT(RFGPO_MCU_CLK) | _GPIO_MODE_HIDRIVE)); #endif }
void spirit1_wfe_aes() { // Kill any interrupts and activate the WFE event source (always pin 2) EXTI->IMR &= (RFI_SOURCE2 | RFI_SOURCE1 | RFI_SOURCE0); EXTI->EMR |= RFI_SOURCE2; // read-out all IRQ_STATUS bits to clear { ot_u8 cmd[2]; cmd[0] = 1; cmd[1] = RFREG(IRQ_STATUS3); spirit1_spibus_io(2, 4, (ot_u8*)cmd); } // write AES to IRQ MASK spirit1_write(0x40, RFREG(IRQ_MASK3)); }