void check_maca(void) { safe_irq_disable(MACA); static volatile uint32_t last_time; static volatile uint32_t last_entry; volatile uint32_t i; #if DEBUG_MACA volatile uint32_t count; #endif /* if *MACA_CLK == last_time */ /* try waiting for one clock period */ /* since maybe check_maca is getting called quickly */ for(i=0; (i < 1024) && (*MACA_CLK == last_time); i++) { continue; } if(*MACA_CLK == last_time) { PRINTF("check maca: maca_clk stopped, restarting\n"); /* clock isn't running */ ResumeMACASync(); *INTFRC = (1<<INT_NUM_MACA); } else { if((last_time > (*MACA_SFTCLK + RECV_SOFTIMEOUT)) && (last_time > (*MACA_CPLCLK + CPL_TIMEOUT))) { PRINTF("check maca: complete clocks expired\n"); /* all complete clocks have expired */ /* check that maca entry is changing */ /* if not, do call the isr to restart the cycle */ if(last_entry == maca_entry) { PRINTF("check maca: forcing isr\n"); *INTFRC = (1<<INT_NUM_MACA); } } } last_entry = maca_entry; last_time = *MACA_CLK; #if DEBUG_MACA if((count = count_packets()) != NUM_PACKETS) { PRINTF("check maca: count_packets %d\n", count); Print_Packets("check_maca"); #if PACKET_STATS for(i=0; i<NUM_PACKETS; i++) { printf("packet 0x%lx seen %d post_tx %d get_free %d rxd %d\n", (uint32_t) &packet_pool[i], packet_pool[i].seen, packet_pool[i].post_tx, packet_pool[i].get_free, packet_pool[i].rxd); } #endif if(bit_is_set(*NIPEND, INT_NUM_MACA)) { *INTFRC = (1 << INT_NUM_MACA); } } #endif /* DEBUG_MACA */ irq_restore(); }
void maca_init(void) { reset_maca(); radio_init(); flyback_init(); init_phy(); free_head = 0; tx_head = 0; rx_head = 0; rx_end = 0; tx_end = 0; dma_tx = 0; dma_rx = 0; free_all_packets(); #if DEBUG_MACA Print_Packets("maca_init"); #endif /* initial radio command */ /* nop, promiscuous, no cca */ *MACA_CONTROL = (1 << PRM) | (NO_CCA << MODE); enable_irq(MACA); *INTFRC = (1 << INT_NUM_MACA); }
void maca_init(void) { reset_maca(); radio_init(); flyback_init(); init_phy(); set_channel(0); /* things get weird if you never set a channel */ set_power(0); /* set the power too --- who knows what happens if you don't */ free_head = 0; tx_head = 0; rx_head = 0; rx_end = 0; tx_end = 0; dma_tx = 0; dma_rx = 0; free_all_packets(); #if DEBUG_MACA Print_Packets("maca_init"); #endif /* initial radio command */ /* nop, promiscuous, no cca */ *MACA_CONTROL = (prm_mode << PRM) | (NO_CCA << MACA_MODE); enable_irq(MACA); *INTFRC = (1 << INT_NUM_MACA); }