PL1167_nRF24.h 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*
  2. * PL1167_nRF24.h
  3. *
  4. * Created on: 29 May 2015
  5. * Author: henryk
  6. */
  7. #ifdef ARDUINO
  8. #include "Arduino.h"
  9. #endif
  10. #include "RF24.h"
  11. // #define DEBUG_PRINTF
  12. #ifndef PL1167_NRF24_H_
  13. #define PL1167_NRF24_H_
  14. class PL1167_nRF24 {
  15. public:
  16. PL1167_nRF24(RF24& radio);
  17. int open();
  18. int setPreambleLength(uint8_t preambleLength);
  19. int setSyncword(uint16_t syncword0, uint16_t syncword3);
  20. int setTrailerLength(uint8_t trailerLength);
  21. int setCRC(bool crc);
  22. int setMaxPacketLength(uint8_t maxPacketLength);
  23. int writeFIFO(const uint8_t data[], size_t data_length);
  24. int transmit(uint8_t channel);
  25. int receive(uint8_t channel);
  26. int readFIFO(uint8_t data[], size_t &data_length);
  27. private:
  28. RF24 &_radio;
  29. const uint8_t* _syncwordBytes = nullptr;
  30. uint8_t _syncwordLength = 4;
  31. uint8_t _maxPacketLength = 8;
  32. uint8_t _channel = 0;
  33. uint8_t _nrf_pipe[5];
  34. uint8_t _nrf_pipe_length;
  35. uint8_t _packet_length = 0;
  36. uint8_t _receive_length = 0;
  37. uint8_t _preamble = 0;
  38. uint8_t _packet[32];
  39. bool _received = false;
  40. int recalc_parameters();
  41. int internal_receive();
  42. };
  43. #endif /* PL1167_NRF24_H_ */