You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
6.5 KiB

4 years ago
  1. /*
  2. Copyright (C)
  3. 2011 J. Coliz <maniacbug@ymail.com>
  4. 2015-2019 TMRh20
  5. 2015 spaniakos <spaniakos@gmail.com>
  6. 2015 nerdralph
  7. 2015 zador-blood-stained
  8. 2016 akatran
  9. 2017-2019 Avamander <avamander@gmail.com>
  10. 2019 IkpeohaGodson
  11. This program is free software; you can redistribute it and/or
  12. modify it under the terms of the GNU General Public License
  13. version 2 as published by the Free Software Foundation.
  14. */
  15. #ifndef __RF24_CONFIG_H__
  16. #define __RF24_CONFIG_H__
  17. /*** USER DEFINES: ***/
  18. #define FAILURE_HANDLING
  19. //#define SERIAL_DEBUG
  20. //#define MINIMAL
  21. //#define SPI_UART // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
  22. //#define SOFTSPI // Requires library from https://github.com/greiman/DigitalIO
  23. /**********************/
  24. #define rf24_max(a,b) (a>b?a:b)
  25. #define rf24_min(a,b) (a<b?a:b)
  26. #define RF24_SPI_SPEED 10000000
  27. //ATXMega
  28. #if defined (__AVR_ATxmega64D3__) || defined (__AVR_ATxmega128D3__) || defined (__AVR_ATxmega192D3__) || defined (__AVR_ATxmega256D3__) || defined (__AVR_ATxmega384D3__) // In order to be available both in Windows and Linux this should take presence here.
  29. #define XMEGA
  30. #define XMEGA_D3
  31. #include "utility/ATXMegaD3/RF24_arch_config.h"
  32. #elif ( !defined (ARDUINO) ) // Any non-arduino device is handled via configure/Makefile
  33. // The configure script detects device and copies the correct includes.h file to /utility/includes.h
  34. // This behavior can be overridden by calling configure with respective parameters
  35. // The includes.h file defines either RF24_RPi, MRAA, LITTLEWIRE or RF24_SPIDEV and includes the correct RF24_arch_config.h file
  36. #include "utility/includes.h"
  37. //ATTiny
  38. #elif defined (__AVR_ATtiny25__) || defined (__AVR_ATtiny45__) || defined (__AVR_ATtiny85__) || defined (__AVR_ATtiny24__) || defined (__AVR_ATtiny44__) || defined (__AVR_ATtiny84__) || defined (__AVR_ATtiny2313__) || defined (__AVR_ATtiny4313__) || defined (__AVR_ATtiny861__)
  39. #define RF24_TINY
  40. #include "utility/ATTiny/RF24_arch_config.h"
  41. #elif defined (LITTLEWIRE) //LittleWire
  42. #include "utility/LittleWire/RF24_arch_config.h"
  43. #elif defined (TEENSYDUINO) //Teensy
  44. #include "utility/Teensy/RF24_arch_config.h"
  45. #else //Everything else
  46. #include <Arduino.h>
  47. #if defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
  48. #if defined SPI_UART
  49. #include <SPI_UART.h>
  50. #define _SPI uspi
  51. #elif defined (SOFTSPI)
  52. // change these pins to your liking
  53. //
  54. #ifndef SOFT_SPI_MISO_PIN
  55. #define SOFT_SPI_MISO_PIN 9
  56. #endif // SOFT_SPI_MISO_PIN
  57. #ifndef SOFT_SPI_MOSI_PIN
  58. #define SOFT_SPI_MOSI_PIN 8
  59. #endif // SOFT_SPI_MOSI_PIN
  60. #ifndef SOFT_SPI_SCK_PIN
  61. #define SOFT_SPI_SCK_PIN 7
  62. #endif // SOFT_SPI_SCK_PIN
  63. const uint8_t SPI_MODE = 0;
  64. #define _SPI spi
  65. #else // !defined (SPI_UART) && !defined (SOFTSPI)
  66. #include <SPI.h>
  67. #define _SPI SPI
  68. #endif // !defined (SPI_UART) && !defined (SOFTSPI)
  69. #else // defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
  70. // Define _BV for non-Arduino platforms and for Arduino DUE
  71. #include <stdint.h>
  72. #include <stdio.h>
  73. #include <string.h>
  74. #if defined(__arm__) || defined (__ARDUINO_X86__)
  75. #if defined (__arm__) && defined (SPI_UART)
  76. #include <SPI_UART.h>
  77. #define _SPI uspi
  78. #else // !defined (__arm__) || !defined (SPI_UART)
  79. #include <SPI.h>
  80. #define _SPI SPI
  81. #endif // !defined (__arm__) || !defined (SPI_UART)
  82. #elif !defined(__arm__) && !defined (__ARDUINO_X86__)
  83. extern HardwareSPI SPI;
  84. #endif // !defined(__arm__) && !defined (__ARDUINO_X86__)
  85. #ifndef _BV
  86. #define _BV(x) (1<<(x))
  87. #endif
  88. #endif // defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
  89. #ifdef SERIAL_DEBUG
  90. #define IF_SERIAL_DEBUG(x) ({x;})
  91. #else
  92. #define IF_SERIAL_DEBUG(x)
  93. #if defined(RF24_TINY)
  94. #define printf_P(...)
  95. #endif // defined(RF24_TINY)
  96. #endif // SERIAL_DEBUG
  97. #if defined (__ARDUINO_X86__)
  98. #define printf_P printf
  99. #define _BV(bit) (1<<(bit))
  100. #endif // defined (__ARDUINO_X86__)
  101. // Progmem is Arduino-specific
  102. // Arduino DUE is arm and does not include avr/pgmspace
  103. #if defined (ARDUINO_ARCH_ESP8266) || defined (ESP32)
  104. #include <pgmspace.h>
  105. #define PRIPSTR "%s"
  106. #ifndef pgm_read_ptr
  107. #define pgm_read_ptr(p) (*(p))
  108. #endif
  109. #elif defined (ARDUINO) && !defined (ESP_PLATFORM) && ! defined (__arm__) && !defined (__ARDUINO_X86__) || defined (XMEGA)
  110. #include <avr/pgmspace.h>
  111. #define PRIPSTR "%S"
  112. #else // !defined (ARDUINO) || defined (ESP_PLATFORM) || defined (__arm__) || defined (__ARDUINO_X86__) && !defined (XMEGA)
  113. #if !defined (ARDUINO) // This doesn't work on Arduino DUE
  114. typedef char const char;
  115. #else // Fill in pgm_read_byte that is used, but missing from DUE
  116. #ifdef ARDUINO_ARCH_AVR
  117. #include <avr/pgmspace.h>
  118. #endif
  119. #ifndef pgm_read_byte
  120. #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
  121. #endif
  122. #endif // !defined (ARDUINO)
  123. #ifndef prog_uint16_t
  124. typedef uint16_t prog_uint16_t;
  125. #endif
  126. #ifndef PSTR
  127. #define PSTR(x) (x)
  128. #endif
  129. #ifndef printf_P
  130. #define printf_P printf
  131. #endif
  132. #ifndef strlen_P
  133. #define strlen_P strlen
  134. #endif
  135. #ifndef PROGMEM
  136. #define PROGMEM
  137. #endif
  138. #ifndef pgm_read_word
  139. #define pgm_read_word(p) (*(p))
  140. #endif
  141. #if !defined pgm_read_ptr || defined ARDUINO_ARCH_MBED
  142. #define pgm_read_ptr(p) (*(p))
  143. #endif
  144. #ifndef PRIPSTR
  145. #define PRIPSTR "%s"
  146. #endif
  147. #endif // !defined (ARDUINO) || defined (ESP_PLATFORM) || defined (__arm__) || defined (__ARDUINO_X86__) && !defined (XMEGA)
  148. #endif //Everything else
  149. #if defined (SPI_HAS_TRANSACTION) && !defined (SPI_UART) && !defined (SOFTSPI)
  150. #define RF24_SPI_TRANSACTIONS
  151. #endif // defined (SPI_HAS_TRANSACTION) && !defined (SPI_UART) && !defined (SOFTSPI)
  152. #endif // __RF24_CONFIG_H__