void cc110x_switch_to_pwd(void) { DEBUG("[cc110x_ng] switching to powerdown\n"); cc110x_wakeup_from_rx(); cc110x_strobe(CC1100_SPWD); radio_state = RADIO_PWD; }
static void reset(void) { cc110x_wakeup_from_rx(); #ifdef MODULE_CC110x_SPI cc110x_spi_select(); #endif cc110x_strobe(CC1100_SRES); hwtimer_wait(RTIMER_TICKS(100)); }
void cc110x_wakeup_from_rx(void) { if(radio_state != RADIO_RX) { return; } DEBUG("CC1100 going to idle\n"); cc110x_strobe(CC1100_SIDLE); radio_state = RADIO_IDLE; }
static void finish(void) { // back to idle cc110x_strobe(RF_SIDLE); radio_state = RADIO_IDLE; restore_conf(); /* Have to put radio back to WOR/RX if old radio state * was WOR/RX, otherwise no action is necessary */ if ((old_radio_state == RADIO_WOR) || (old_radio_state == RADIO_RX)) { cc110x_switch_to_rx(); } radio_release(); // restoreIRQ(cpsr); }
void cc110x_rx_handler(void) { uint8_t res = 0; // Possible packet received, RX -> IDLE (0.1 us) rflags.CAA = 0; rflags.MAN_WOR = 0; cc110x_statistic.packets_in++; res = receive_packet((uint8_t*)&(cc110x_rx_buffer[rx_buffer_next].packet), sizeof(cc110x_packet_t)); if (res) { // If we are sending a burst, don't accept packets. // Only ACKs are processed (for stopping the burst). // Same if state machine is in TX lock. if (radio_state == RADIO_SEND_BURST || rflags.TX) { cc110x_statistic.packets_in_while_tx++; return; } cc110x_rx_buffer[rx_buffer_next].rssi = rflags._RSSI; cc110x_rx_buffer[rx_buffer_next].lqi = rflags._LQI; cc110x_strobe(CC1100_SFRX); // ...for flushing the RX FIFO // Valid packet. After a wake-up, the radio should be in IDLE. // So put CC1100 to RX for WOR_TIMEOUT (have to manually put // the radio back to sleep/WOR). //cc110x_spi_write_reg(CC1100_MCSM0, 0x08); // Turn off FS-Autocal cc110x_write_reg(CC1100_MCSM2, 0x07); // Configure RX_TIME (until end of packet) cc110x_strobe(CC1100_SRX); hwtimer_wait(IDLE_TO_RX_TIME); radio_state = RADIO_RX; #ifdef DBG_IGNORE if (is_ignored(cc110x_rx_buffer[rx_buffer_next].packet.phy_src)) { LED_RED_TOGGLE; return; } #endif /* notify transceiver thread if any */ if (transceiver_pid) { msg_t m; m.type = (uint16_t) RCV_PKT_CC1100; m.content.value = rx_buffer_next; msg_send_int(&m, transceiver_pid); } /* shift to next buffer element */ if (++rx_buffer_next == RX_BUF_SIZE) { rx_buffer_next = 0; } return; } else { // No ACK received so TOF is unpredictable rflags.TOF = 0; // CRC false or RX buffer full -> clear RX FIFO in both cases cc110x_strobe(CC1100_SIDLE); // Switch to IDLE (should already be)... cc110x_strobe(CC1100_SFRX); // ...for flushing the RX FIFO // If packet interrupted this nodes send call, // don't change anything after this point. if (radio_state == RADIO_AIR_FREE_WAITING) { cc110x_strobe(CC1100_SRX); hwtimer_wait(IDLE_TO_RX_TIME); return; } // If currently sending, exit here (don't go to RX/WOR) if (radio_state == RADIO_SEND_BURST) { cc110x_statistic.packets_in_while_tx++; return; } // No valid packet, so go back to RX/WOR as soon as possible cc110x_switch_to_rx(); } }
void cc110x_switch_to_rx(void) { radio_state = RADIO_RX; cc110x_strobe(CC1100_SRX); }
void cc110x_rx_handler(void *args) { uint8_t res = 0; /* Possible packet received, RX -> IDLE (0.1 us) */ cc110x_statistic.packets_in++; res = receive_packet((uint8_t *)&(cc110x_rx_buffer[rx_buffer_next].packet), sizeof(cc110x_packet_t)); if (res) { /* If we are sending a burst, don't accept packets. * Only ACKs are processed (for stopping the burst). * Same if state machine is in TX lock. */ if (radio_state == RADIO_SEND_BURST) { cc110x_statistic.packets_in_while_tx++; return; } cc110x_rx_buffer[rx_buffer_next].rssi = rflags._RSSI; cc110x_rx_buffer[rx_buffer_next].lqi = rflags._LQI; cc110x_strobe(CC1100_SFRX); /* ...for flushing the RX FIFO */ /* Valid packet. After a wake-up, the radio should be in IDLE. * So put CC110x to RX for WOR_TIMEOUT (have to manually put * the radio back to sleep/WOR). */ cc110x_write_reg(CC1100_MCSM2, 0x07); /* Configure RX_TIME (until end of packet) */ cc110x_strobe(CC1100_SRX); hwtimer_wait(IDLE_TO_RX_TIME); radio_state = RADIO_RX; #ifdef MODULE_TRANSCEIVER /* notify transceiver thread if any */ if (transceiver_pid != KERNEL_PID_UNDEF) { msg_t m; m.type = (uint16_t) RCV_PKT_CC1100; m.content.value = rx_buffer_next; msg_send_int(&m, transceiver_pid); } #endif #ifdef MODULE_NETDEV_BASE if (cc110x_recv_cb != NULL) { cc110x_packet_t p = cc110x_rx_buffer[rx_buffer_next].packet; cc110x_recv_cb(&cc110x_dev, &p.phy_src, sizeof(uint8_t), &p.address, sizeof(uint8_t), p.data, p.length - CC1100_HEADER_LENGTH); } #endif /* shift to next buffer element */ if (++rx_buffer_next == RX_BUF_SIZE) { rx_buffer_next = 0; } return; } else { /* CRC false or RX buffer full -> clear RX FIFO in both cases */ cc110x_strobe(CC1100_SIDLE); /* Switch to IDLE (should already be)... */ cc110x_strobe(CC1100_SFRX); /* ...for flushing the RX FIFO */ /* If currently sending, exit here (don't go to RX/WOR) */ if (radio_state == RADIO_SEND_BURST) { cc110x_statistic.packets_in_while_tx++; return; } /* No valid packet, so go back to RX/WOR as soon as possible */ cc110x_switch_to_rx(); } }
static void broadcast_code(void) { // MCSM1[TXOFF_MODE]=01 meaning after tx radio will go back to FSTXON state cc110x_writeburst_reg(RF_TXFIFOWR, gate_toggle_code, sizeof(gate_toggle_code)); cc110x_strobe(RF_STX); }