From ce40b678f65678621bcc7941e63a201a4e670bde Mon Sep 17 00:00:00 2001 From: Markus Hitter Date: Sun, 12 Jul 2015 22:57:19 +0200 Subject: [PATCH] Solve the pgmspace.h problem centrally. We previously put replacements for the von Neuman architecture into arduino.h already, now let's complete this by having only one #include in arduino.h. Almost all sources include arduino.h anyways, so this is mostly a code reduction. --- arduino.h | 10 ++++++++-- dda.h | 9 --------- heater.c | 1 - serial.h | 3 --- sersendf.c | 3 --- sersendf.h | 4 +--- 6 files changed, 9 insertions(+), 21 deletions(-) diff --git a/arduino.h b/arduino.h index 9756525..4224266 100644 --- a/arduino.h +++ b/arduino.h @@ -71,14 +71,20 @@ For the AVR definitions, see /usr/lib/avr/include/avr/pgmspace.h on Linux. */ -#ifndef __AVR__ +#ifdef __AVR__ + + #include + +#else + #define PROGMEM #define PGM_P const char * #define PSTR(s) ((const PROGMEM char *)(s)) #define pgm_read_byte(x) (*((uint8_t *)(x))) #define pgm_read_word(x) (*((uint16_t *)(x))) #define pgm_read_dword(x) (*((uint32_t *)(x))) -#endif /* ! __AVR__ */ + +#endif /* __AVR__, ! __AVR__ */ /* ports and functions diff --git a/dda.h b/dda.h index 8008741..a1a45db 100644 --- a/dda.h +++ b/dda.h @@ -11,15 +11,6 @@ #endif #endif -#ifndef SIMULATOR - #include -#else - #define PROGMEM -#endif - -/* - types -*/ // Enum to denote an axis enum axis_e { X = 0, Y, Z, E, AXIS_COUNT }; diff --git a/heater.c b/heater.c index dc5a787..3eec957 100644 --- a/heater.c +++ b/heater.c @@ -6,7 +6,6 @@ #include #include -#include #include "arduino.h" #include "debug.h" diff --git a/serial.h b/serial.h index f9ea9f7..bda9b78 100644 --- a/serial.h +++ b/serial.h @@ -3,9 +3,6 @@ #include "config_wrapper.h" #include -#ifdef __AVR__ -#include -#endif #include "simulator.h" #ifdef USB_SERIAL diff --git a/sersendf.c b/sersendf.c index a0e24cf..46af1d9 100644 --- a/sersendf.c +++ b/sersendf.c @@ -5,9 +5,6 @@ */ #include -#ifndef SIMULATOR -#include -#endif #include "serial.h" #include "sermsg.h" diff --git a/sersendf.h b/sersendf.h index 74a2ef4..1ac2f90 100644 --- a/sersendf.h +++ b/sersendf.h @@ -1,11 +1,9 @@ #ifndef _SERSENDF_H #define _SERSENDF_H -#ifndef SIMULATOR -#include -#endif #include "arduino.h" + void sersendf(char *format, ...) __attribute__ ((format (printf, 1, 2))); void sersendf_P(PGM_P format_P, ...) __attribute__ ((format (printf, 1, 2)));