Optimized high speed nRF24L01+ driver class documentation
v1.4.10
TMRh20 2020 - Optimized fork of the nRF24L01+ driver
Main Page
Related Pages
Topics
Classes
Files
Examples
File List
File Members
Loading...
Searching...
No Matches
RF24_config.h
Go to the documentation of this file.
1
2
/*
3
Copyright (C)
4
2011 J. Coliz <maniacbug@ymail.com>
5
2015-2019 TMRh20
6
2015 spaniakos <spaniakos@gmail.com>
7
2015 nerdralph
8
2015 zador-blood-stained
9
2016 akatran
10
2017-2019 Avamander <avamander@gmail.com>
11
2019 IkpeohaGodson
12
2021 2bndy5
13
14
This program is free software; you can redistribute it and/or
15
modify it under the terms of the GNU General Public License
16
version 2 as published by the Free Software Foundation.
17
*/
18
19
#ifndef RF24_CONFIG_H_
20
#define RF24_CONFIG_H_
21
22
/*** USER DEFINES: ***/
23
#define FAILURE_HANDLING
24
//#define RF24_DEBUG
25
//#define MINIMAL
26
//#define SPI_UART // Requires library from https://github.com/TMRh20/Sketches/tree/master/SPI_UART
27
//#define SOFTSPI // Requires library from https://github.com/greiman/DigitalIO
28
34
#if !defined(RF24_POWERUP_DELAY)
35
#define RF24_POWERUP_DELAY 5000
36
#endif
37
38
/**********************/
39
#define rf24_max(a, b) ((a) > (b) ? (a) : (b))
40
#define rf24_min(a, b) ((a) < (b) ? (a) : (b))
41
43
#ifndef RF24_SPI_SPEED
44
#define RF24_SPI_SPEED 10000000
45
#endif
46
48
#define RF24_NO_FETCH_PIPE 0XFF
49
50
//ATXMega
51
#if defined(__AVR_ATxmega64D3__) || defined(__AVR_ATxmega128D3__) || defined(__AVR_ATxmega192D3__) || defined(__AVR_ATxmega256D3__) || defined(__AVR_ATxmega384D3__)
52
// In order to be available both in Windows and Linux this should take presence here.
53
#define XMEGA
54
#define XMEGA_D3
55
#include "utility/ATXMegaD3/RF24_arch_config.h"
56
57
// RaspberryPi rp2xxx-based devices (e.g. RPi Pico board)
58
#elif defined(PICO_BUILD) && !defined(ARDUINO)
59
#include "utility/rp2/RF24_arch_config.h"
60
#define sprintf_P sprintf
61
62
#elif (!defined(ARDUINO))
// Any non-arduino device is handled via configure/Makefile
63
// The configure script detects device and copies the correct includes.h file to /utility/includes.h
64
// This behavior can be overridden by calling configure with respective parameters
65
// The includes.h file defines either RF24_RPi, MRAA, LITTLEWIRE or RF24_SPIDEV and includes the correct RF24_arch_config.h file
66
#include "utility/includes.h"
67
68
#ifndef sprintf_P
69
#define sprintf_P sprintf
70
#endif
// sprintf_P
71
72
//ATTiny
73
#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__) || defined(__AVR_ATtinyX5__) || defined(__AVR_ATtinyX4__) || defined(__AVR_ATtinyX313__) || defined(__AVR_ATtinyX61__)
74
#define RF24_TINY
75
#include "utility/ATTiny/RF24_arch_config.h"
76
77
#elif defined(LITTLEWIRE)
//LittleWire
78
#include "utility/LittleWire/RF24_arch_config.h"
79
80
#elif defined(TEENSYDUINO)
//Teensy
81
#include "utility/Teensy/RF24_arch_config.h"
82
83
#else
//Everything else
84
#include <Arduino.h>
85
86
#ifdef NUM_DIGITAL_PINS
87
#if NUM_DIGITAL_PINS < 255
88
typedef
uint8_t
rf24_gpio_pin_t
;
89
#define RF24_PIN_INVALID 0xFF
90
#else
91
typedef
uint16_t
rf24_gpio_pin_t
;
92
#define RF24_PIN_INVALID 0xFFFF
93
#endif
94
#else
95
typedef
uint16_t
rf24_gpio_pin_t
;
96
#define RF24_PIN_INVALID 0xFFFF
97
#endif
98
99
#if defined(ARDUINO) && !defined(__arm__) && !defined(__ARDUINO_X86__)
100
#if defined SPI_UART
101
#include <SPI_UART.h>
102
#define _SPI uspi
103
#elif defined(SOFTSPI)
104
// change these pins to your liking
105
//
106
#ifndef SOFT_SPI_MISO_PIN
107
#define SOFT_SPI_MISO_PIN 9
108
#endif
// SOFT_SPI_MISO_PIN
109
110
#ifndef SOFT_SPI_MOSI_PIN
111
#define SOFT_SPI_MOSI_PIN 8
112
#endif
// SOFT_SPI_MOSI_PIN
113
114
#ifndef SOFT_SPI_SCK_PIN
115
#define SOFT_SPI_SCK_PIN 7
116
#endif
// SOFT_SPI_SCK_PIN
117
118
const
uint8_t SPI_MODE = 0;
119
#define _SPI spi
120
121
#elif defined(ARDUINO_SAM_DUE)
122
#include <SPI.h>
123
#define _SPI SPI
124
125
#else
// !defined (SPI_UART) && !defined (SOFTSPI)
126
#include <SPI.h>
127
#define _SPI SPIClass
128
#define RF24_SPI_PTR
129
#endif
// !defined (SPI_UART) && !defined (SOFTSPI)
130
131
#else
// !defined(ARDUINO) || defined (__arm__) || defined (__ARDUINO_X86__)
132
// Define _BV for non-Arduino platforms and for Arduino DUE
133
#include <stdint.h>
134
#include <stdio.h>
135
#include <string.h>
136
137
#if defined(__arm__) || defined(__ARDUINO_X86__)
138
#if defined(__arm__) && defined(SPI_UART)
139
#include <SPI_UART.h>
140
#define _SPI uspi
141
142
#else
// !defined (__arm__) || !defined (SPI_UART)
143
#include <SPI.h>
144
#define _SPI SPIClass
145
#define RF24_SPI_PTR
146
147
#endif
// !defined (__arm__) || !defined (SPI_UART)
148
#elif !defined(__arm__) && !defined(__ARDUINO_X86__)
149
// fallback to unofficially supported Hardware (courtesy of ManiacBug)
150
extern
HardwareSPI SPI;
151
#define _SPI HardwareSPI
152
#define RF24_SPI_PTR
153
154
#endif
// !defined(__arm__) && !defined (__ARDUINO_X86__)
155
156
#ifndef _BV
157
#define _BV(x) (1 << (x))
158
#endif
159
#endif
// defined (ARDUINO) && !defined (__arm__) && !defined (__ARDUINO_X86__)
160
161
#ifdef RF24_DEBUG
162
#define IF_RF24_DEBUG(x) ({ x; })
163
#else
164
#define IF_RF24_DEBUG(x)
165
#if defined(RF24_TINY)
166
#define printf_P(...)
167
#endif
// defined(RF24_TINY)
168
169
#endif
// RF24_DEBUG
170
171
#if defined(__ARDUINO_X86__)
172
#define printf_P printf
173
#define _BV(bit) (1 << (bit))
174
175
#endif
// defined (__ARDUINO_X86__)
176
177
// Progmem is Arduino-specific
178
#if defined(ARDUINO_ARCH_ESP8266) || defined(ESP32) || (defined(ARDUINO_ARCH_RP2040) && !defined(ARDUINO_ARCH_MBED))
179
#include <pgmspace.h>
180
#define PRIPSTR "%s"
181
#ifndef pgm_read_ptr
182
#define pgm_read_ptr(p) (*(void* const*)(p))
183
#endif
184
// Serial.printf() is no longer defined in the unifying Arduino/ArduinoCore-API repo
185
// Serial.printf() is defined if using the arduino-pico/esp32/8266 repo
186
#if defined(ARDUINO_ARCH_ESP32)
// do not `undef` when using the espressif SDK only
187
#undef printf_P
// needed for ESP32 core
188
#endif
189
#define printf_P Serial.printf
190
#elif defined(ARDUINO) && !defined(ESP_PLATFORM) && !defined(__arm__) && !defined(__ARDUINO_X86__) || defined(XMEGA)
191
#include <avr/pgmspace.h>
192
#define PRIPSTR "%S"
193
194
#else
// !defined (ARDUINO) || defined (ESP_PLATFORM) || defined (__arm__) || defined (__ARDUINO_X86__) && !defined (XMEGA)
195
#if !defined(ARDUINO)
// This doesn't work on Arduino DUE
196
typedef
char
const
char;
197
#else
// Fill in pgm_read_byte that is used
198
#if defined(ARDUINO_ARCH_AVR) || defined(ARDUINO_ARCH_SAMD) || defined(ARDUINO_SAM_DUE)
199
#include <avr/pgmspace.h>
// added to ArduinoCore-sam (Due core) in 2013
200
#endif
201
202
// Since the official arduino/ArduinoCore-samd repo switched to a unified API in 2016,
203
// Serial.printf() is no longer defined in the unifying Arduino/ArduinoCore-API repo
204
#if defined(ARDUINO_ARCH_SAMD) && defined(ARDUINO_SAMD_ADAFRUIT)
205
// it is defined if using the adafruit/ArduinoCore-samd repo
206
#define printf_P Serial.printf
207
#endif
// defined (ARDUINO_ARCH_SAMD)
208
209
#ifndef pgm_read_byte
210
#define pgm_read_byte(addr) (*(const unsigned char*)(addr))
211
#endif
212
#endif
// !defined (ARDUINO)
213
214
#ifndef prog_uint16_t
215
typedef
uint16_t
prog_uint16_t
;
216
#endif
217
#ifndef PSTR
218
#define PSTR(x) (x)
219
#endif
220
#ifndef printf_P
221
#define printf_P printf
222
#endif
223
#ifndef strlen_P
224
#define strlen_P strlen
225
#endif
226
#ifndef PROGMEM
227
#define PROGMEM
228
#endif
229
#ifndef pgm_read_word
230
#define pgm_read_word(p) (*(const unsigned short*)(p))
231
#endif
232
#if !defined pgm_read_ptr || defined ARDUINO_ARCH_MBED
233
#define pgm_read_ptr(p) (*(void* const*)(p))
234
#endif
235
#ifndef PRIPSTR
236
#define PRIPSTR "%s"
237
#endif
238
239
#endif
// !defined (ARDUINO) || defined (ESP_PLATFORM) || defined (__arm__) || defined (__ARDUINO_X86__) && !defined (XMEGA)
240
241
#endif
//Everything else
242
243
#if defined(SPI_HAS_TRANSACTION) && !defined(SPI_UART) && !defined(SOFTSPI)
244
#define RF24_SPI_TRANSACTIONS
245
#endif
// defined (SPI_HAS_TRANSACTION) && !defined (SPI_UART) && !defined (SOFTSPI)
246
247
#endif
// RF24_CONFIG_H_
prog_uint16_t
uint16_t prog_uint16_t
Definition
RF24_arch_config.h:53
rf24_gpio_pin_t
uint16_t rf24_gpio_pin_t
Definition
RF24_arch_config.h:54
Generated on Sun Oct 6 2024 for Optimized high speed nRF24L01+ driver class documentation by
1.12.0