uint8_t BayRF24::sendPayload(void) { if (_powerdown) powerUp(); else stopListening(); openWritingPipe (_pipe); uint8_t res; res = RF24::write(getPayload(), getPacketLength()); uint8_t curr_pa = 0; while (!res && curr_pa < 4) { setPALevel((rf24_pa_dbm_e) curr_pa); delayMicroseconds(random(2000)); res = RF24::write(getPayload(), getPacketLength()); curr_pa++; } if (_powerdown) powerDown(); else { txStandBy(); startListening(); } return !res; }
void ShieldGSM::verifyGSMOn() { Serial.println("Powering down..."); struct ATcommand powerDown[1] = {ATcommand("AT+CPOWD=1\r","NORMAL POWER DOWN")}; executeATCommands(powerDown,1); Serial.println("Rebooting..."); powerUp(); Serial.println("GSM Shield is on."); }
void Radio::stopListening(void) { if (read_register(FEATURE) & _BV(EN_ACK_PAY)) { _delay_us(155); flush_tx(); } write_register(CONFIG, (read_register(CONFIG)) & ~_BV(PRIM_RX)); // for 3 pins solution TX mode is only left with additional powerDown/powerUp cycle. powerDown(); powerUp(); }
void nRF24L01P::setTransmitMode(void) { if ( _NRF24L01P_MODE_POWER_DOWN == mode ) powerUp(); int config = getRegister(_NRF24L01P_REG_CONFIG); config &= ~_NRF24L01P_CONFIG_PRIM_RX; setRegister(_NRF24L01P_REG_CONFIG, config); mode = _NRF24L01P_MODE_TX; }
bool AS3935::setConfiguration(void) { reset(); wait_ms(5); setTuneCap( AS3935_TUN_CAP_VALUE); wait_ms(5); powerUp(); wait_ms(11); setMinimumLightnings(1); setNoiseFloor(2); if(getLightningDistanceKm()==-1) return false; //for tests return true; }
bool Radio::setup(void) { HalfDuplexSPI::setup(); csnHigh(); // Must allow the radio time to settle else configuration bits will not necessarily stick. // This is actually only required following power up but some settling time also appears to // be required after resets too. For full coverage, we'll always assume the worst. // Enabling 16b CRC is by far the most obvious case if the wrong timing is used - or skipped. // Technically we require 4.5ms + 14us as a worst case. We'll just call it 5ms for good measure. // WARNING: Delay is based on P-variant whereby non-P *may* require different timing. _delay_ms(5); // Reset CONFIG and enable 16-bit CRC. write_register(CONFIG, 0 | _BV(EN_CRC) | _BV(CRCO)); // Set 1500uS (minimum for 32B payload in ESB@250KBPS) timeouts, to make testing a little easier // WARNING: If this is ever lowered, either 250KBS mode with AA is broken or maximum packet // sizes must never be used. See documentation for a more complete explanation. setRetries(5, 15); uint8_t setup = read_register(RF_SETUP); // Then set the data rate to the slowest (and most reliable) speed supported by all // hardware. setDataRate(DataRate::RATE_1MBPS); write_register(FEATURE, 0); write_register(DYNPD, 0); // Reset current status // Notice reset and flush is the last thing we do write_register(STATUS, _BV(RX_DR) | _BV(TX_DS) | _BV(MAX_RT)); setChannel(76); // Flush buffers flush_rx(); flush_tx(); //Power up by default when setup() is called. powerUp(); // Enable PTX, do not write CE high so radio will remain in standby I mode ( 130us max to transition to RX or TX // instead of 1500us from powerUp ) PTX should use only 22uA of power. write_register(CONFIG, (read_register(CONFIG)) & ~_BV(PRIM_RX)); // If setup is 0 or ff then there was no response from module. return setup != 0 && setup != 0xff; }
void nRF24L01p::init(){ flushRX(); flushTX(); dynamicPayload(P0|P1); feature(DPL|DYN_ACK); writeReg(SETUP_RETR,0x2F); writeReg(STATUS,0x70); powerUp(); if(_prim_rx && _prim_tx){ enableRX(P1|P0); primPRX(); ceHigh(); }else if(_prim_rx && !_prim_tx){ enableRX(P1); primPRX(); ceHigh(); }else if(!_prim_rx && _prim_tx){ enableRX(P0); primPTX(); } _init=true; }
void BlueTooth::begin() { PIN_MODE_INPUT(HC05_STATUS); PIN_MODE_OUTPUT(HC05_ENABLE); PIN_MODE_OUTPUT(HC05_KEY); // no programming needed PIN_LOW(HC05_KEY); // enable the HC-05 powerUp(); bool connected = isConnected(); printf_P(PSTR("BlueTooth: ")); if(!connected) printf_P(PSTR("no ")); printf_P(PSTR("client connected\n")); m_lastConnectStatus = connected; }