Skip to content

Commit

Permalink
Moved environment-specific checking out to RF24_config.h
Browse files Browse the repository at this point in the history
  • Loading branch information
maniacbug committed Dec 10, 2011
1 parent f393408 commit 53cb579
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 29 deletions.
28 changes: 1 addition & 27 deletions RF24.cpp
Expand Up @@ -6,37 +6,11 @@
version 2 as published by the Free Software Foundation.
*/

#if ARDUINO < 100
#include <WProgram.h>
#else
#include <Arduino.h>
#endif

#include <SPI.h>
#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)
Expand Down
3 changes: 1 addition & 2 deletions RF24.h
Expand Up @@ -9,8 +9,7 @@
#ifndef __RF24_H__
#define __RF24_H__

#include <stddef.h>
#include <avr/pgmspace.h>
#include <RF24_config.h>

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;
Expand Down
61 changes: 61 additions & 0 deletions RF24_config.h
@@ -0,0 +1,61 @@

/*
Copyright (C) 2011 James Coliz, Jr. <maniacbug@ymail.com>
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 <WProgram.h>
#else
#include <Arduino.h>
#endif

#include <stddef.h>

// Stuff that is normally provided by Arduino
#ifndef ARDUINO
#include <stdint.h>
#include <stdio.h>
#include <string.h>
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 <avr/pgmspace.h>
#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

0 comments on commit 53cb579

Please sign in to comment.