/*---------------------------------------------------------------------------*/ void profile_init(void) { timetable_init(); timetable_clear(&profile_begin_timetable); timetable_clear(&profile_end_timetable); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(cc2420_process, ev, data) { int len; PROCESS_BEGIN(); PRINTF("cc2420_process: started\n"); while(1) { PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); #if CC2420_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(cc2420_timetable, "poll"); #endif /* CC2420_TIMETABLE_PROFILING */ PRINTF("cc2420_process: calling receiver callback\n"); packetbuf_clear(); packetbuf_set_attr(PACKETBUF_ATTR_TIMESTAMP, last_packet_timestamp); len = cc2420_read(packetbuf_dataptr(), PACKETBUF_SIZE); packetbuf_set_datalen(len); NETSTACK_RDC.input(); #if CC2420_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(cc2420_timetable, "end"); timetable_aggregate_compute_detailed(&aggregate_time, &cc2420_timetable); timetable_clear(&cc2420_timetable); #endif /* CC2420_TIMETABLE_PROFILING */ } PROCESS_END(); }
/*---------------------------------------------------------------------------*/ PROCESS_THREAD(cc2420_process, ev, data) { PROCESS_BEGIN(); PRINTF("cc2420_process: started\n"); while(1) { PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); #if CC2420_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(cc2420_timetable, "poll"); #endif /* CC2420_TIMETABLE_PROFILING */ if(receiver_callback != NULL) { PRINTF("cc2420_process: calling receiver callback\n"); receiver_callback(&cc2420_driver); #if CC2420_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(cc2420_timetable, "end"); timetable_aggregate_compute_detailed(&aggregate_time, &cc2420_timetable); timetable_clear(&cc2420_timetable); #endif /* CC2420_TIMETABLE_PROFILING */ } else { PRINTF("cc2420_process not receiving function\n"); flushrx(); } } PROCESS_END(); }
/* Process to handle input packets * Receive interrupts cause this process to be polled * It calls the core MAC layer which calls rf230_read to get the packet */ PROCESS_THREAD(nrf24l01_process, ev, data) { PROCESS_BEGIN(); while(1) { PROCESS_YIELD_UNTIL(ev == PROCESS_EVENT_POLL); #if RF230_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(rf230_timetable, "poll"); #endif /* RF230_TIMETABLE_PROFILING */ if(receiver_callback != NULL) { receiver_callback(&nrf24l01_driver); #if RF230_TIMETABLE_PROFILING TIMETABLE_TIMESTAMP(rf230_timetable, "end"); timetable_aggregate_compute_detailed(&aggregate_time, &rf230_timetable); timetable_clear(&rf230_timetable); #endif /* RF230_TIMETABLE_PROFILING */ } else { PRINTF("nrf24l01_process not receiving function\n"); //flushrx(); } } PROCESS_END(); }
/*---------------------------------------------------------------------------*/ void profile_episode_start(void) { struct timetable_timestamp *e; timetable_clear(&profile_begin_timetable); timetable_clear(&profile_end_timetable); episode_start_time = clock_time(); e = timetable_entry(&profile_begin_timetable, PROFILE_TIMETABLE_SIZE - 1); if(e != NULL) { e->id = NULL; } e = timetable_entry(&profile_end_timetable, PROFILE_TIMETABLE_SIZE - 1); if(e != NULL) { e->id = NULL; } }
/*---------------------------------------------------------------------------*/ void timetable_init(void) { char dummy1, dummy2; #define temp_size 4 TIMETABLE_STATIC(temp); timetable_clear(&temp); /* Measure the time for taking a timestamp. */ TIMETABLE_TIMESTAMP(temp, &dummy1); TIMETABLE_TIMESTAMP(temp, &dummy2); timetable_timestamp_time = timetable_timediff(&temp, &dummy1, &dummy2); }
/* * Interrupt leaves frame intact in FIFO. */ static volatile rtimer_clock_t interrupt_time; static volatile int interrupt_time_set; #if CC2420_TIMETABLE_PROFILING #define cc2420_timetable_size 16 TIMETABLE(cc2420_timetable); TIMETABLE_AGGREGATE(aggregate_time, 10); #endif /* CC2420_TIMETABLE_PROFILING */ int cc2420_interrupt(void) { interrupt_time = timesynch_time(); interrupt_time_set = 1; CLEAR_FIFOP_INT(); process_poll(&cc2420_process); #if CC2420_TIMETABLE_PROFILING timetable_clear(&cc2420_timetable); TIMETABLE_TIMESTAMP(cc2420_timetable, "interrupt"); #endif /* CC2420_TIMETABLE_PROFILING */ return 1; }
/* * Interrupt leaves frame intact in FIFO. */ #if CC2420_TIMETABLE_PROFILING #define cc2420_timetable_size 16 TIMETABLE(cc2420_timetable); TIMETABLE_AGGREGATE(aggregate_time, 10); #endif /* CC2420_TIMETABLE_PROFILING */ int cc2420_interrupt(void) { CC2420_CLEAR_FIFOP_INT(); process_poll(&cc2420_process); #if CC2420_TIMETABLE_PROFILING timetable_clear(&cc2420_timetable); TIMETABLE_TIMESTAMP(cc2420_timetable, "interrupt"); #endif /* CC2420_TIMETABLE_PROFILING */ pending++; cc2420_packets_seen++; return 1; }
/* * Interrupt leaves frame intact in FIFO. */ #if CC2420_TIMETABLE_PROFILING #define cc2420_timetable_size 16 TIMETABLE(cc2420_timetable); TIMETABLE_AGGREGATE(aggregate_time, 10); #endif /* CC2420_TIMETABLE_PROFILING */ int cc2420_interrupt(void) { //printf("Enter cc2420 interrupt.\n"); CC2420_CLEAR_FIFOP_INT(); process_poll(&cc2420_process); #if CC2420_TIMETABLE_PROFILING timetable_clear(&cc2420_timetable); TIMETABLE_TIMESTAMP(cc2420_timetable, "interrupt"); #endif /* CC2420_TIMETABLE_PROFILING */ last_packet_timestamp = cc2420_sfd_start_time; //printf("Radio rec time = %u\n",cc2420_sfd_start_time); pending++; cc2420_packets_seen++; return 1; }
void nrf24l01_interrupt(void) { #if RF230_CONF_TIMESTAMPS interrupt_time = timesynch_time(); interrupt_time_set = 1; #endif /* RF230_CONF_TIMESTAMPS */ isr_event_write.isr_type= ISR_RX_DR; process_poll(&nrf24l01_process); #if RF230_TIMETABLE_PROFILING timetable_clear(&rf230_timetable); TIMETABLE_TIMESTAMP(rf230_timetable, "interrupt"); #endif /* RF230_TIMETABLE_PROFILING */ return; }
nRF24L01_ISR() { #if RF230_CONF_TIMESTAMPS interrupt_time = timesynch_time(); interrupt_time_set = 1; #endif /* RF230_CONF_TIMESTAMPS */ volatile uint8_t status; status = spi_register_read(NOP); //PRINTF("ISR: status=0x%x\r\n", status); //Rx FIFO data ready if(status & (1 << MASK_RX_DR)) { uint8_t rx_pipe_no = (status & 0x07); if(rx_pipe_no < 6) { status_rx_dr_handler(rx_pipe_no); } sbi(status, MASK_RX_DR); } //Tx FIFO data has been sent successfully else if(status & (1 << MASK_TX_DS)) { status_tx_ds_handler(); sbi(status, MASK_TX_DS); //clear intertupt } //Re transmit is up to the max counter, //Note: // 1. If you don't clear this interrupt, no data can be transmitted any more // 2. The package lost counter(PLOS_CNT) is incremented at each MAX_RT interrupt else if(status & (1 << MASK_MAX_RT)) { status_max_rt_handler(); sbi(status, MASK_MAX_RT); //clear the interrupt } else {} //clean interrupts SPI_WRITE_REG(WRITE_REG+STATUS, status); #if RF230_TIMETABLE_PROFILING timetable_clear(&rf230_timetable); TIMETABLE_TIMESTAMP(rf230_timetable, "interrupt"); #endif /* RF230_TIMETABLE_PROFILING */ }
/*---------------------------------------------------------------------------*/ const struct mac_driver * xmac_init(const struct radio_driver *d) { #if WITH_TIMETABLE timetable_clear(&xmac_timetable); #endif radio_is_on = 0; waiting_for_packet = 0; PT_INIT(&pt); rtimer_set(&rt, RTIMER_NOW() + xmac_config.off_time, 1, TC(powercycle), NULL); xmac_is_on = 1; radio = d; radio->set_receive_function(input_packet); BB_SET("xmac.state_addr", (int) &waiting_for_packet); BB_SET(XMAC_RECEIVER, 0); BB_SET(XMAC_STROBES, 0); BB_SET(XMAC_SEND_WITH_ACK, 0); BB_SET(XMAC_SEND_WITH_NOACK, 0); return &xmac_driver; }