/*---------------------------------------------------------------------------*/ int cc2420_rssi(void) { int rssi; int radio_was_off = 0; if(locked) { return 0; } GET_LOCK(); if(!receive_on) { radio_was_off = 1; cc2420_on(); } BUSYWAIT_UNTIL(status() & BV(CC2420_RSSI_VALID), RTIMER_SECOND / 100); rssi = (int)((signed char)getreg(CC2420_RSSI)); if(radio_was_off) { cc2420_off(); } RELEASE_LOCK(); return rssi; }
/*---------------------------------------------------------------------------*/ static int cc2420_cca(void) { int cca; int radio_was_off = 0; /* If the radio is locked by an underlying thread (because we are being invoked through an interrupt), we preted that the coast is clear (i.e., no packet is currently being transmitted by a neighbor). */ if(locked) { return 1; } if(!receive_on) { radio_was_off = 1; cc2420_on(); } while(!(status() & BV(CC2420_RSSI_VALID))) { /* printf("cc2420_rssi: RSSI not valid.\n"); */ } cca = CCA_IS_1; if(radio_was_off) { cc2420_off(); } return cca; }
/*---------------------------------------------------------------------------*/ static int cc2420_cca(void) { int cca; int radio_was_off = 0; /* If the radio is locked by an underlying thread (because we are being invoked through an interrupt), we preted that the coast is clear (i.e., no packet is currently being transmitted by a neighbor). */ if(locked) { return 1; } GET_LOCK(); if(!receive_on) { radio_was_off = 1; cc2420_on(); } /* Make sure that the radio really got turned on. */ if(!receive_on) { RELEASE_LOCK(); if(radio_was_off) { cc2420_off(); } return 1; } BUSYWAIT_UNTIL(status() & BV(CC2420_RSSI_VALID), RTIMER_SECOND / 100); cca = CC2420_CCA_IS_1; if(radio_was_off) { cc2420_off(); } RELEASE_LOCK(); return cca; }
/*---------------------------------------------------------------------------*/ int cc2420_rssi(void) { int rssi; int radio_was_off = 0; if(!receive_on) { radio_was_off = 1; cc2420_on(); } while(!(status() & BV(CC2420_RSSI_VALID))) { /* printf("cc2420_rssi: RSSI not valid.\n");*/ } rssi = (int)((signed char)getreg(CC2420_RSSI)); if(radio_was_off) { cc2420_off(); } return rssi; }