nRF24L01P::nRF24L01P(SPIPin mosi, SPIPin miso, SPIPin sck, int csn, int ce, int irq) : spi_(SS, mosi, miso, sck), nCS_(csn), ce_(ce) { //, nIRQ_(irq) { // SPI.begin(); // nCS_ = csn; // ce_ = ce; // pinMode(nCS_, OUTPUT); // pinMode(ce_, OUTPUT); mode = _NRF24L01P_MODE_UNKNOWN; disable(); // nCS_ = 1; // digitalWrite(nCS_, HIGH); nCS_.write(HIGH); // spi_.frequency(_NRF24L01P_SPI_MAX_DATA_RATE/5); // 2Mbit, 1/5th the maximum transfer rate for the SPI bus // spi_.format(8,0); // 8-bit, ClockPhase = 0, ClockPolarity = 0 // SPI.setClockDivider(SPI_CLOCK_DIV8); // SPI_CLOCK_DIV16 // SPI.setDataMode(SPI_MODE0); // delayMicroseconds(_NRF24L01P_TIMING_Tundef2pd_us); // Wait for Power-on reset _delay_us(_NRF24L01P_TIMING_Tundef2pd_us); setRegister(_NRF24L01P_REG_CONFIG, 0); // Power Down setRegister(_NRF24L01P_REG_STATUS, _NRF24L01P_STATUS_MAX_RT|_NRF24L01P_STATUS_TX_DS|_NRF24L01P_STATUS_RX_DR); // Clear any pending interrupts // // Setup default configuration // disableAllRxPipes(); setRfFrequency(); setRfOutputPower(); setAirDataRate(); setCrcWidth(); setTxAddress(); setRxAddress(); disableAutoAcknowledge(); disableAutoRetransmit(); setTransferSize(); mode = _NRF24L01P_MODE_POWER_DOWN; }
nRF24L01P::nRF24L01P(PinName mosi, PinName miso, PinName sck, PinName csn, PinName ce, PinName irq) : spi_(mosi, miso, sck), nCS_(csn), ce_(ce), nIRQ_(irq) { mode = _NRF24L01P_MODE_UNKNOWN; disable(); nCS_ = 1; // spi_.frequency(_NRF24L01P_SPI_MAX_DATA_RATE/5); // 2Mbit, 1/5th the maximum transfer rate for the SPI bus // spi_.format(8,0); // 8-bit, ClockPhase = 0, ClockPolarity = 0 wait_us(_NRF24L01P_TIMING_Tundef2pd_us); // Wait for Power-on reset setRegister(_NRF24L01P_REG_CONFIG, 0); // Power Down setRegister(_NRF24L01P_REG_STATUS, _NRF24L01P_STATUS_MAX_RT|_NRF24L01P_STATUS_TX_DS|_NRF24L01P_STATUS_RX_DR); // Clear any pending interrupts // // Setup default configuration // disableAllRxPipes(); setRfFrequency(); setRfOutputPower(); setAirDataRate(); setCrcWidth(); setTxAddress(); setRxAddress(); disableAutoAcknowledge(); disableAutoRetransmit(); setTransferSize(); mode = _NRF24L01P_MODE_POWER_DOWN; }
ChannelRfFrequency::ChannelRfFrequency(uint8_t channel, uint8_t frequency) : AntRequest(CHANNEL_RF_FREQUENCY) { setChannel(channel); setRfFrequency(frequency); }