From 5f926a60d2c80ed00665d6a09690b90ce531d8a2 Mon Sep 17 00:00:00 2001 From: Peter Wu Date: Wed, 10 Jun 2015 22:17:49 +0200 Subject: Add include guards, fix compilation with arduino-makefile Include guards are needed because files are concatenated. https://github.com/Lekensteyn/arduino-makefile (forked from https://github.com/tomswartz07/arduino-makefile) --- .gitignore | 1 + Venus_Skeleton/Makefile | 43 +++++++++++-------------------------- Venus_Skeleton/calibration_wall-e.h | 6 +++++- Venus_Skeleton/comm.h | 5 +++++ Venus_Skeleton/dataTypes.h | 5 +++++ 5 files changed, 28 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index 4fe7862..492658d 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ .*.sw? __pycache__/ *.py[oc] +bin/ diff --git a/Venus_Skeleton/Makefile b/Venus_Skeleton/Makefile index c2c5198..f150b58 100644 --- a/Venus_Skeleton/Makefile +++ b/Venus_Skeleton/Makefile @@ -1,35 +1,16 @@ -#CC = /usr/share/arduino/hardware/tools/avr/bin/avr-gcc -CC = avr-gcc -WFLAGS = -Wall -Wextra -Wno-attributes -WFLAGS += -fdiagnostics-color=auto -EXTRA_CFLAGS = $(shell cat .syntastic_c_config) -O2 $(CFLAGS) -MY_SOURCES = Venus_Skeleton.ino comm.cpp -MY_OBJECTS = $(patsubst %.cpp,%.o,$(patsubst %.ino,%.o,$(MY_SOURCES))) -LIBS_SOURCES = $(wildcard libs/*/*.cpp) -LIBS_OBJECTS = $(patsubst %.cpp,%.o,$(LIBS_SOURCES)) -SOURCES = $(MY_SOURCES) $(LIBS_SOURCES) -OBJECTS = $(MY_OBJECTS) $(LIBS_OBJECTS) -PROGRAM ?= main +PROJECT = Venus_Skeleton +ARDUINO_MODEL = uno +#PORT = /dev/ttyACM* +ARDUINO = 163 +#ARDUINO_DIR = /usr/share/arduino +#ARDUINO_VARIANT = $(ARDUINO_DIR)/hardware/arduino/avr/variants/standard -_V_0 = @ -_V = $(_V_$(V)) +ARDUINO_LIBS = Serial Servo Wire +USER_LIBDIR = ./libs +USER_LIBS = HMC5883L IRremote TrueRandom -.PHONY: main clean check -check: - rm -f $(MY_OBJECTS) - $(MAKE) $(MY_OBJECTS) -# Note: does not compile due to link errors. -$(PROGRAM): $(OBJECTS) - $(_V)$(CC) $(WFLAGS) $(EXTRA_CFLAGS) $(OBJECTS) -o $@ +CEXTRA = -fdiagnostics-color=auto +#CEXTRA += -Wall -Wextra -Wno-attributes -clean: - $(_V)rm -f $(PROGRAM) $(OBJECTS) - -# Not my code... -libs/%.o: libs/%.cpp - $(_V)$(CC) -w $(EXTRA_CFLAGS) -c -o $@ $< -%.o: %.cpp - $(_V)$(CC) $(WFLAGS) $(EXTRA_CFLAGS) -c -o $@ $< -%.o: %.ino - $(_V)$(CC) $(WFLAGS) $(EXTRA_CFLAGS) -c -x c++ -o $@ $< +include ~/Arduino/arduino-makefile/Makefile diff --git a/Venus_Skeleton/calibration_wall-e.h b/Venus_Skeleton/calibration_wall-e.h index 16e0ebe..c859a84 100644 --- a/Venus_Skeleton/calibration_wall-e.h +++ b/Venus_Skeleton/calibration_wall-e.h @@ -1,3 +1,5 @@ +#ifndef CALIBRATION_WALL_E_H +#define CALIBRATION_WALL_E_H // WALLY configuration file #define calObstacleTurretMaxDist 50 @@ -27,4 +29,6 @@ #define CAL_TURRET_TO_CENTER_DIST 6 -#define CAL_SAMPLE_TURRET_MAX_DIST 27 \ No newline at end of file +#define CAL_SAMPLE_TURRET_MAX_DIST 27 + +#endif /* !CALIBRATION_WALL_E_H */ diff --git a/Venus_Skeleton/comm.h b/Venus_Skeleton/comm.h index 26e8d7b..bca5aab 100644 --- a/Venus_Skeleton/comm.h +++ b/Venus_Skeleton/comm.h @@ -1,3 +1,6 @@ +#ifndef COMM_H +#define COMM_H + typedef enum { RESET1 = 0x81, RESET2 = 0x82, @@ -40,3 +43,5 @@ static inline void serial_print_debug(long n) { static inline void serial_print_debug(float n) { serial_print_debug(String(n)); } + +#endif /* !COMM_H */ diff --git a/Venus_Skeleton/dataTypes.h b/Venus_Skeleton/dataTypes.h index f19eaf5..2f2aa69 100644 --- a/Venus_Skeleton/dataTypes.h +++ b/Venus_Skeleton/dataTypes.h @@ -1,3 +1,6 @@ +#ifndef DATATYPES_H +#define DATATYPES_H + // **************** // ** Data types ** // **************** @@ -63,3 +66,5 @@ typedef enum { OPMODE_LABSEQUENCE, OPMODE_ERROR } opmode_t; + +#endif /* !DATATYPES_H */ -- cgit v1.2.1