diff --git a/RF24Network.cpp b/RF24Network.cpp index 955e020b..577c9999 100644 --- a/RF24Network.cpp +++ b/RF24Network.cpp @@ -330,7 +330,8 @@ bool RF24Network::write_to_pipe( uint16_t node, uint8_t pipe ) const char* RF24NetworkHeader::toString(void) const { static char buffer[45]; - snprintf_P(buffer,sizeof(buffer),PSTR("id %04x from 0%o to 0%o type %c"),id,from_node,to_node,type); + //snprintf_P(buffer,sizeof(buffer),PSTR("id %04x from 0%o to 0%o type %c"),id,from_node,to_node,type); + sprintf_P(buffer,PSTR("id %04x from 0%o to 0%o type %c"),id,from_node,to_node,type); return buffer; } diff --git a/RF24Network_config.h b/RF24Network_config.h index 85aee042..0f399967 100644 --- a/RF24Network_config.h +++ b/RF24Network_config.h @@ -25,47 +25,77 @@ /*************************************/ -// 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;}) + // Define _BV for non-Arduino platforms and for Arduino DUE +#if defined (ARDUINO) && !defined (__arm__) + #include #else -#define IF_SERIAL_DEBUG(x) -#if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__) -#define printf_P(...) -#endif + + #include + #include + #include + + + #if defined(__arm__) || defined (CORE_TEENSY) + #include + #endif + + #if !defined(CORE_TEENSY) + #define _BV(x) (1<<(x)) + #if !defined(__arm__) + extern HardwareSPI SPI; + #endif + #endif + + #endif + + #undef SERIAL_DEBUG + #ifdef SERIAL_DEBUG + #define IF_SERIAL_DEBUG(x) ({x;}) + #else + #define IF_SERIAL_DEBUG(x) + #if defined(__AVR_ATtiny84__) || defined(__AVR_ATtiny85__) + #define printf_P(...) + #endif + #endif + // Avoid spurious warnings -#if ! defined( NATIVE ) && defined( ARDUINO ) +// Arduino DUE is arm and uses traditional PROGMEM constructs +#if 1 +#if ! defined( NATIVE ) && defined( ARDUINO ) && ! defined(__arm__) && ! defined( CORE_TEENSY3 ) #undef PROGMEM #define PROGMEM __attribute__(( section(".progmem.data") )) #undef PSTR #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0];})) #endif +#endif // Progmem is Arduino-specific -#ifdef ARDUINO - -#include -#define PRIPSTR "%S" +// Arduino DUE is arm and does not include avr/pgmspace +#if defined(ARDUINO) && ! defined(__arm__) + #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" +#if ! defined(ARDUINO) // This doesn't work on Arduino DUE + typedef char const char; +#else // Fill in pgm_read_byte that is used, but missing from DUE + #define pgm_read_byte(addr) (*(const unsigned char *)(addr)) +#endif + + +#if !defined (CORE_TEENSY) + 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)) +#endif + + #define PRIPSTR "%s" + #endif #endif // __RF24_CONFIG_H__