Optimized High Speed NRF24L01+ Driver Class Documenation  V1.0
TMRh20 2014 - Optimized Fork of NRF24L01+ Driver
RF24_config.h
Go to the documentation of this file.
1 
2 /*
3  Copyright (C) 2011 J. Coliz <maniacbug@ymail.com>
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  version 2 as published by the Free Software Foundation.
8  */
9 
10  /* spaniakos <spaniakos@gmail.com>
11  Added __ARDUINO_X86__ support
12 */
13 
14 #ifndef __RF24_CONFIG_H__
15 #define __RF24_CONFIG_H__
16 
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  /**********************/
25  #define rf24_max(a,b) (a>b?a:b)
26  #define rf24_min(a,b) (a<b?a:b)
27 
28  #if defined SPI_HAS_TRANSACTION && !defined SPI_UART && !defined SOFTSPI
29  #define RF24_SPI_TRANSACTIONS
30  #endif
31 
32 
33 //ATXMega
34 #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.
35  #define XMEGA
36  #define XMEGA_D3
37  #include "utility/ATXMegaD3/RF24_arch_config.h"
38 #elif ( !defined (ARDUINO) ) // Any non-arduino device is handled via configure/Makefile
39 
40  // The configure script detects device and copies the correct includes.h file to /utility/includes.h
41  // This behavior can be overridden by calling configure with respective parameters
42  // The includes.h file defines either RF24_RPi, MRAA, LITTLEWIRE or RF24_SPIDEV and includes the correct RF24_arch_config.h file
43  #include "utility/includes.h"
44 
45 //ATTiny
46 #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__)
47  #define RF24_TINY
48  #include "utility/ATTiny/RF24_arch_config.h"
49 
50 
51 //LittleWire
52 #elif defined(LITTLEWIRE)
53 
54  #include "utility/LittleWire/RF24_arch_config.h"
55 
56 //Teensy
57 #elif defined (TEENSYDUINO)
58 
59  #include "utility/Teensy/RF24_arch_config.h"
60 //Everything else
61 #else
62 
63  #include <Arduino.h>
64 
65  // RF modules support 10 Mhz SPI bus speed
66  const uint32_t RF24_SPI_SPEED = 10000000;
67 
68 #if defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
69  #if defined SPI_UART
70  #include <SPI_UART.h>
71  #define _SPI uspi
72  #elif defined SOFTSPI
73  // change these pins to your liking
74  //
75  const uint8_t SOFT_SPI_MISO_PIN = 16;
76  const uint8_t SOFT_SPI_MOSI_PIN = 15;
77  const uint8_t SOFT_SPI_SCK_PIN = 14;
78  const uint8_t SPI_MODE = 0;
79  #define _SPI spi
80 
81  #else
82  #include <SPI.h>
83  #define _SPI SPI
84  #endif
85 #else
86  // Define _BV for non-Arduino platforms and for Arduino DUE
87  #include <stdint.h>
88  #include <stdio.h>
89  #include <string.h>
90 
91 
92  #if defined(__arm__) || defined (__ARDUINO_X86__)
93  #include <SPI.h>
94  #endif
95 
96 
97  #define _BV(x) (1<<(x))
98  #if !defined(__arm__) && !defined (__ARDUINO_X86__)
99  extern HardwareSPI SPI;
100  #endif
101 
102 
103  #define _SPI SPI
104 #endif
105 
106  #ifdef SERIAL_DEBUG
107  #define IF_SERIAL_DEBUG(x) ({x;})
108  #else
109  #define IF_SERIAL_DEBUG(x)
110  #if defined(RF24_TINY)
111  #define printf_P(...)
112  #endif
113  #endif
114 
115 #if defined (__ARDUINO_X86__)
116  #define printf_P printf
117  #define _BV(bit) (1<<(bit))
118 #endif
119 
120 // Progmem is Arduino-specific
121 // Arduino DUE is arm and does not include avr/pgmspace
122 #if defined (ARDUINO_ARCH_ESP8266)
123 
124  #define PSTR(x) (x)
125  #define printf Serial.printf
126  #define sprintf(...) os_sprintf( __VA_ARGS__ )
127  #define printf_P printf
128  #define strlen_P strlen
129  #define PROGMEM
130  #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
131  #define pgm_read_word(p) (*(p))
132  #define PRIPSTR "%s"
133 
134 #elif defined(ARDUINO) && ! defined(__arm__) && !defined (__ARDUINO_X86__) || defined(XMEGA)
135  #include <avr/pgmspace.h>
136  #define PRIPSTR "%S"
137 #else
138  #if ! defined(ARDUINO) // This doesn't work on Arduino DUE
139  typedef char const char;
140  #else // Fill in pgm_read_byte that is used, but missing from DUE
141  #define pgm_read_byte(addr) (*(const unsigned char *)(addr))
142  #endif
143 
144 
145  typedef uint16_t prog_uint16_t;
146  #define PSTR(x) (x)
147  #define printf_P printf
148  #define strlen_P strlen
149  #define PROGMEM
150  #define pgm_read_word(p) (*(p))
151 
152  #define PRIPSTR "%s"
153 
154 #endif
155 
156 #endif
157 
158 
159 
160 #endif // __RF24_CONFIG_H__
161 
uint16_t prog_uint16_t
SPI()