From 53cb579400a76db6583ee973332c6c6d17a7f7d5 Mon Sep 17 00:00:00 2001 From: maniacbug Date: Sat, 10 Dec 2011 15:52:33 -0800 Subject: [PATCH] Moved environment-specific checking out to RF24_config.h --- RF24.cpp | 28 +---------------------- RF24.h | 3 +-- RF24_config.h | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+), 29 deletions(-) create mode 100644 RF24_config.h diff --git a/RF24.cpp b/RF24.cpp index c6edc1a..574910b 100644 --- a/RF24.cpp +++ b/RF24.cpp @@ -6,37 +6,11 @@ version 2 as published by the Free Software Foundation. */ -#if ARDUINO < 100 -#include -#else -#include -#endif - #include #include "nRF24L01.h" +#include "RF24_config.h" #include "RF24.h" -#undef SERIAL_DEBUG -#ifdef SERIAL_DEBUG -#define IF_SERIAL_DEBUG(x) ({x;}) -#else -#define IF_SERIAL_DEBUG(x) -#endif - -// Avoid spurious warnings -#if ! defined( NATIVE ) && defined( ARDUINO ) -#undef PROGMEM -#define PROGMEM __attribute__(( section(".progmem.data") )) -#undef PSTR -#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];})) -#endif - -#ifdef ARDUINO -#define PRIPSTR "%S" -#else -#define PRIPSTR "%s" -#endif - /****************************************************************************/ void RF24::csn(int mode) diff --git a/RF24.h b/RF24.h index 9af5844..7d041ce 100644 --- a/RF24.h +++ b/RF24.h @@ -9,8 +9,7 @@ #ifndef __RF24_H__ #define __RF24_H__ -#include -#include +#include typedef enum { RF24_PA_MIN = 0,RF24_PA_LOW, RF24_PA_HIGH, RF24_PA_MAX, RF24_PA_ERROR } rf24_pa_dbm_e ; typedef enum { RF24_1MBPS = 0, RF24_2MBPS, RF24_250KBPS } rf24_datarate_e; diff --git a/RF24_config.h b/RF24_config.h new file mode 100644 index 0000000..321a0fd --- /dev/null +++ b/RF24_config.h @@ -0,0 +1,61 @@ + +/* + Copyright (C) 2011 James Coliz, Jr. + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + */ + +#ifndef __RF24_CONFIG_H__ +#define __RF24_CONFIG_H__ + +#if ARDUINO < 100 +#include +#else +#include +#endif + +#include + +// Stuff that is normally provided by Arduino +#ifndef ARDUINO +#include +#include +#include +extern HardwareSPI SPI; +#define _BV(x) (1<<(x)) +#endif + +#undef SERIAL_DEBUG +#ifdef SERIAL_DEBUG +#define IF_SERIAL_DEBUG(x) ({x;}) +#else +#define IF_SERIAL_DEBUG(x) +#endif + +// Avoid spurious warnings +#if ! defined( NATIVE ) && defined( ARDUINO ) +#undef PROGMEM +#define PROGMEM __attribute__(( section(".progmem.data") )) +#undef PSTR +#define PSTR(s) (__extension__({static prog_char __c[] PROGMEM = (s); &__c[0];})) +#endif + +// Progmem is Arduino-specific +#ifdef ARDUINO +#include +#define PRIPSTR "%S" +#else +typedef char const prog_char; +typedef uint16_t prog_uint16_t; +#define PSTR(x) (x) +#define printf_P printf +#define strlen_P strlen +#define PROGMEM +#define pgm_read_word(p) (*(p)) +#define PRIPSTR "%s" +#endif + +#endif // __RF24_CONFIG_H__ +// vim:ai:cin:sts=2 sw=2 ft=cpp