/* * ---------------------------------------------------------------------------- * “THE COFFEEWARE LICENSE” (Revision 1): * wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a coffee in return. * ----------------------------------------------------------------------------- * This library is based on this library: * https://github.com/aaronds/arduino-nrf24l01 * Which is based on this library: * http://www.tinkerer.eu/AVRLib/nRF24L01 * ----------------------------------------------------------------------------- */ #include "nrf24.h" uint8_t payload_len; /* init the hardware pins */ void nrf24_init() { nrf24_setupPins(); nrf24_ce_digitalWrite(LOW); nrf24_csn_digitalWrite(HIGH); } /* configure the module */ void nrf24_config(uint8_t channel, uint8_t pay_length) { /* Use static payload length ... */ payload_len = pay_length; // Set RF channel nrf24_configRegister(RF_CH,channel); // Set length of incoming payload nrf24_configRegister(RX_PW_P0, 0x00); // Auto-ACK pipe ... nrf24_configRegister(RX_PW_P1, payload_len); // Data payload pipe nrf24_configRegister(RX_PW_P2, 0x00); // Pipe not used nrf24_configRegister(RX_PW_P3, 0x00); // Pipe not used nrf24_configRegister(RX_PW_P4, 0x00); // Pipe not used nrf24_configRegister(RX_PW_P5, 0x00); // Pipe not used // 1 Mbps, TX gain: 0dbm nrf24_configRegister(RF_SETUP, (0<