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 BayRF24::init(uint64_t address, uint8_t c = 0x71, rf24_pa_dbm_e pa_level = RF24_PA_HIGH, rf24_datarate_e rate = RF24_250KBPS) { _pipe = address; RF24::begin(); setChannel(c); setPayloadSize(32); enableDynamicPayloads(); setCRCLength (RF24_CRC_16); setDataRate(rate); setPALevel(pa_level); _pa_level = pa_level; //changed 0.1.2 - as we normally have a storage on board //User can call client.setRetries(15,15) after client.init setRetries(15, 8); setAutoAck(true); if (_powerdown) powerDown(); }
void EvHttpSyncClient::open(const std::string& sHost, int32_t nPort) { m_sHost = sHost; m_nPort = nPort; m_bOwnEventBase = false; if (!m_evbase) { FX_EVENT_BASE_NEW(m_evbase); m_bOwnEventBase = true; } m_pConn = evhttp_connection_base_new(m_evbase, NULL, m_sHost.c_str(), (unsigned short)m_nPort); if (!m_pConn) { FIRTEX_THROW_AND_LOG(NetworkException, "evhttp_connection_base_new FAILED"); } setTimeout(DEFAULT_TIMEOUT); setRetries(DEFAULT_MAX_RETRY); evhttp_connection_set_closecb(m_pConn, onCloseConnection, this); m_lastState = ST_OK; }