/** \brief The program starts executing here. */ int mote_main(void) { // initialize board board_init(); // switch radio LED on leds_radio_on(); // prepare bsp_timer bsp_timer_set_callback(bsp_timer_cb_compare); // prepare radiotimer radiotimer_setOverflowCb(radiotimer_cb_overflow); radiotimer_setCompareCb(radiotimer_cb_compare); // kick off first bsp_timer compare bsp_timer_scheduleIn(BSP_TIMER_PERIOD); // start periodic radiotimer overflow radiotimer_start(RADIOTIMER_OVERFLOW_PERIOD); // kick off first radiotimer compare app_vars.radiotimer_num_compares_left = RADIOTIMER_NUM_COMPARES-1; app_vars.radiotimer_last_compare_val = RADIOTIMER_COMPARE_PERIOD; radiotimer_schedule(app_vars.radiotimer_last_compare_val); while (1) { board_sleep(); } }
void radio_txEnable() { // change state radio_vars.state = RADIOSTATE_ENABLING_TX; // wiggle debug pin debugpins_radio_set(); leds_radio_on(); // change state radio_vars.state = RADIOSTATE_TX_ENABLED; }
void radio_txEnable() { // change state radio_vars.state = RADIOSTATE_ENABLING_TX; // wiggle debug pin debugpins_radio_set(); leds_radio_on(); // I don't fully understand how the CC2420_STXCA the can be used here. // change state radio_vars.state = RADIOSTATE_TX_ENABLED; }
void radio_rxEnable() { // change state radio_vars.state = RADIOSTATE_ENABLING_RX; //enable radio interrupts // do nothing as we do not want to receive anything yet. // wiggle debug pin debugpins_radio_set(); leds_radio_on(); // change state radio_vars.state = RADIOSTATE_LISTENING; }
void radio_txEnable() { // change state radio_vars.state = RADIOSTATE_ENABLING_TX; // wiggle debug pin debugpins_radio_set(); leds_radio_on(); //do nothing -- radio is activated by the strobe on rx or tx //radio_rfOn(); // change state radio_vars.state = RADIOSTATE_TX_ENABLED; }
void radio_txEnable() { // change state radio_vars.state = RADIOSTATE_ENABLING_TX; // wiggle debug pin debugpins_radio_set(); leds_radio_on(); // turn on radio's PLL radio_spiWriteReg(RG_TRX_STATE, CMD_PLL_ON); while((radio_spiReadReg(RG_TRX_STATUS) & 0x1F) != PLL_ON); // busy wait until done // change state radio_vars.state = RADIOSTATE_TX_ENABLED; }
void radio_rxEnable() { // change state radio_vars.state = RADIOSTATE_ENABLING_RX; // put radio in reception mode radio_spiWriteReg(RG_TRX_STATE, CMD_RX_ON); // wiggle debug pin debugpins_radio_set(); leds_radio_on(); // busy wait until radio really listening while((radio_spiReadReg(RG_TRX_STATUS) & 0x1F) != RX_ON); // change state radio_vars.state = RADIOSTATE_LISTENING; }
void radio_rxEnable() { // change state radio_vars.state = RADIOSTATE_ENABLING_RX; // put radio in reception mode radio_spiStrobe(CC2420_SRXON, &radio_vars.radioStatusByte); radio_spiStrobe(CC2420_SFLUSHRX, &radio_vars.radioStatusByte); // wiggle debug pin debugpins_radio_set(); leds_radio_on(); // busy wait until radio really listening while (radio_vars.radioStatusByte.rssi_valid==0) { radio_spiStrobe(CC2420_SNOP, &radio_vars.radioStatusByte); } // change state radio_vars.state = RADIOSTATE_LISTENING; }
/** \brief The program starts executing here. */ int mote_main(void) { // initialize board board_init(); // prepare radiotimer radiotimer_setOverflowCb(cb_overflow); radiotimer_setCompareCb(cb_compare); // kick off first compare app_vars.num_compares_left = RADIOTIMER_NUM_COMPARES-1; app_vars.last_compare_val = RADIOTIMER_COMPARE_PERIOD; // start periodic overflow radiotimer_start(RADIOTIMER_OVERFLOW_PERIOD); leds_radio_on(); radiotimer_schedule(app_vars.last_compare_val); while (1) { board_sleep(); } }
void leds_all_on() { leds_error_on(); leds_sync_on(); leds_radio_on(); }
void board_init() { uint16_t i,j; //enable all port clocks. SIM_SCGC5 |= (SIM_SCGC5_PORTA_MASK | SIM_SCGC5_PORTB_MASK | SIM_SCGC5_PORTC_MASK | SIM_SCGC5_PORTD_MASK | SIM_SCGC5_PORTE_MASK ); //init all pins for the radio //SLPTR #ifdef TOWER_K20 PORTB_PCR3 = PORT_PCR_MUX(1);// -- PTB3 used as gpio for slptr GPIOB_PDDR |= RADIO_SLPTR_MASK; //set as output //RADIO RST -- TODO in the TWR change it to another pin! this is one of the leds. PORTC_PCR9 = PORT_PCR_MUX(1);// -- PTC9 used as gpio for radio rst GPIOC_PDDR |= RADIO_RST_MASK; //set as output #elif OPENMOTE_K20 PORTD_PCR4 = PORT_PCR_MUX(1);// -- PTD4 used as gpio for slptr GPIOD_PDDR |= RADIO_SLPTR_MASK; //set as output //RADIO RST PORTD_PCR5 = PORT_PCR_MUX(1);// -- PTD5 used as gpio for radio rst GPIOD_PDDR |= RADIO_RST_MASK; //set as output #endif PORT_PIN_RADIO_RESET_LOW();//activate the radio. PORT_PIN_RADIO_SLP_TR_CNTL_LOW(); //ptc5 .. ptc5 is pin 62, irq A enable_irq(RADIO_EXTERNAL_PORT_IRQ_NUM);//enable the irq. The function is mapped to the vector at position 105 (see manual page 69). The vector is in isr.h //external port radio_isr. PORTC_PCR5 = PORT_PCR_MUX(1);// -- PTC5 used as gpio for radio isr through llwu GPIOC_PDDR &= ~1<<RADIO_ISR_PIN; //set as input ==0 PORTC_PCR5 |= PORT_PCR_IRQC(0x09); //9 interrupt on raising edge. page 249 of the manual. PORTC_PCR5 |= PORT_PCR_ISF_MASK; //clear any pending interrupt. llwu_init();//low leakage unit init - to recover from deep sleep debugpins_init(); leds_init(); bsp_timer_init(); uart_init(); radiotimer_init(); spi_init(); radio_init(); leds_all_off(); leds_sync_on(); leds_radio_on(); leds_debug_on(); leds_error_on(); leds_all_off(); debugpins_fsm_clr(); }