Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
Solve the pgmspace.h problem centrally.
Browse files Browse the repository at this point in the history
We previously put replacements for the von Neuman architecture
into arduino.h already, now let's complete this by having only
one #include <avr/pgmspace.h> in arduino.h. Almost all sources
include arduino.h anyways, so this is mostly a code reduction.
  • Loading branch information
Traumflug committed Aug 12, 2015
1 parent 52f5a56 commit ce40b67
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 21 deletions.
10 changes: 8 additions & 2 deletions arduino.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,20 @@
For the AVR definitions, see /usr/lib/avr/include/avr/pgmspace.h on Linux.
*/
#ifndef __AVR__
#ifdef __AVR__

#include <avr/pgmspace.h>

#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
Expand Down
9 changes: 0 additions & 9 deletions dda.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,6 @@
#endif
#endif

#ifndef SIMULATOR
#include <avr/pgmspace.h>
#else
#define PROGMEM
#endif

/*
types
*/

// Enum to denote an axis
enum axis_e { X = 0, Y, Z, E, AXIS_COUNT };
Expand Down
1 change: 0 additions & 1 deletion heater.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

#include <stdlib.h>
#include <avr/eeprom.h>
#include <avr/pgmspace.h>

#include "arduino.h"
#include "debug.h"
Expand Down
3 changes: 0 additions & 3 deletions serial.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@

#include "config_wrapper.h"
#include <stdint.h>
#ifdef __AVR__
#include <avr/pgmspace.h>
#endif
#include "simulator.h"

#ifdef USB_SERIAL
Expand Down
3 changes: 0 additions & 3 deletions sersendf.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
*/

#include <stdarg.h>
#ifndef SIMULATOR
#include <avr/pgmspace.h>
#endif

#include "serial.h"
#include "sermsg.h"
Expand Down
4 changes: 1 addition & 3 deletions sersendf.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
#ifndef _SERSENDF_H
#define _SERSENDF_H

#ifndef SIMULATOR
#include <avr/pgmspace.h>
#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)));

Expand Down

0 comments on commit ce40b67

Please sign in to comment.