From 4dd9b2a4a5ad0cc4fd88c9232d74c9779ce6c52d Mon Sep 17 00:00:00 2001 From: Fredrik Johansson Date: Sat, 14 Feb 2015 14:11:43 +0100 Subject: [PATCH] Add scope guards to header files --- comms.h | 5 +++++ corrections.h | 5 +++++ fastAnalog.h | 4 ++++ globals.h | 4 ++++ math.h | 4 ++++ scheduler.h | 4 ++++ storage.h | 3 +++ table.h | 4 ++++ testing.h | 5 ++++- timers.h | 4 +++- utils.h | 5 +++++ 11 files changed, 45 insertions(+), 2 deletions(-) diff --git a/comms.h b/comms.h index b685f1c8..a0f93c62 100644 --- a/comms.h +++ b/comms.h @@ -1,3 +1,6 @@ +#ifndef COMMS_H +#define COMMS_H + #define vePage 1 #define ignPage 2 #define afrPage 3 @@ -12,3 +15,5 @@ void sendPage(); void receiveCalibration(byte tableID); void sendToothLog(bool useChar); void testComm(); + +#endif // COMMS_H diff --git a/corrections.h b/corrections.h index 3e24b0a7..0fd54ba8 100644 --- a/corrections.h +++ b/corrections.h @@ -2,6 +2,9 @@ All functions in the gamma file return */ +#ifndef CORRECTIONS_H +#define CORRECTIONS_H + //static byte numCorrections = 2; byte correctionsTotal(); @@ -10,3 +13,5 @@ byte correctionASE(); //After Start Enrichment byte correctionAccel(); //Acceleration Enrichment byte correctionsFloodClear(); //Check for flood clear on cranking byte correctionsAFRClosedLoop(); //Closed loop AFR adjustment + +#endif // CORRECTIONS_H diff --git a/fastAnalog.h b/fastAnalog.h index af6fbb1d..b1b0ef98 100644 --- a/fastAnalog.h +++ b/fastAnalog.h @@ -1,3 +1,6 @@ +#ifndef FASTANALOG_H +#define FASTANALOG_H + #ifndef cbi #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #endif @@ -5,4 +8,5 @@ #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit)) #endif +#endif // FASTANALOG_H diff --git a/globals.h b/globals.h index 7ba915aa..81a8b0bc 100644 --- a/globals.h +++ b/globals.h @@ -1,3 +1,5 @@ +#ifndef GLOBALS_H +#define GLOBALS_H #include const byte ms_version = 20; @@ -270,3 +272,5 @@ struct config3 { #define pinCLT A3 //CLS sensor pin #define pinO2 A4 //O2 Sensor pin */ + +#endif // GLOBALS_H diff --git a/math.h b/math.h index fe25096f..316ac604 100644 --- a/math.h +++ b/math.h @@ -1,3 +1,5 @@ +#ifndef MATH_H +#define MATH_H //Replace the standard arduino map() function to use the div function instead int fastMap(int x, int in_min, int in_max, int out_min, int out_max) @@ -49,3 +51,5 @@ int divs100(int n) { return q + ((r + 28) >> 7); // return q + (r > 99); } + +#endif // MATH_H diff --git a/scheduler.h b/scheduler.h index 4d3e9eb1..d6257c08 100644 --- a/scheduler.h +++ b/scheduler.h @@ -22,6 +22,8 @@ See page 136 of the processors datasheet: http://www.atmel.com/Images/doc2549.pd 256 prescale gives overflow every 1048576uS (This means maximum wait time is 1.0485 seconds) */ +#ifndef SCHEDULER_H +#define SCHEDULER_H #include #include @@ -54,3 +56,5 @@ Schedule ignitionSchedule1; Schedule ignitionSchedule2; Schedule ignitionSchedule3; Schedule ignitionSchedule4; + +#endif // SCHEDULER_H diff --git a/storage.h b/storage.h index 1100d271..499d46fc 100644 --- a/storage.h +++ b/storage.h @@ -1,3 +1,5 @@ +#ifndef STORAGE_H +#define STORAGE_H #include void writeConfig(); @@ -59,3 +61,4 @@ Current layout of EEPROM data (Version 2) is as follows (All sizes are in bytes) #define EEPROM_CALIBRATION_IAT 3071 #define EEPROM_CALIBRATION_CLT 3583 +#endif // STORAGE_H diff --git a/table.h b/table.h index 66166f48..8170abc4 100644 --- a/table.h +++ b/table.h @@ -1,6 +1,8 @@ /* This file is used for everything related to maps/tables including their definition, functions etc */ +#ifndef TABLE_H +#define TABLE_H #include /* @@ -46,3 +48,5 @@ Eg: 2x2 table */ int get3DTableValue(struct table3D, int, int); int table2D_getValue(struct table2D, int); + +#endif // TABLE_H diff --git a/testing.h b/testing.h index 2f9633eb..53b64731 100644 --- a/testing.h +++ b/testing.h @@ -1,7 +1,8 @@ /* This file has a few functions that are helpful for testing such as creating dummy maps and faking interrupts */ - +#ifndef TESTING_H +#define TESTING_H /* Aim is to create an 8x8 table that looks like the below: MAP @@ -105,3 +106,5 @@ void dummyIgnitionTable(struct table3D *mySparkTable) for (byte x = 0; x< mySparkTable->xSize; x++) { mySparkTable->values[7][x] = tempRow8[x]; } } + +#endif // TESTING_H diff --git a/timers.h b/timers.h index 5660c312..9ceb8fbf 100644 --- a/timers.h +++ b/timers.h @@ -16,6 +16,8 @@ We're after a 1ms interval so we'll need 131 intervals to reach this ( 1ms / 0.0 Hence we will preload the timer with 131 cycles to leave 125 until overflow (1ms). */ +#ifndef TIMERS_H +#define TIMERS_H volatile int loop250ms; volatile int loopSec; @@ -24,4 +26,4 @@ volatile unsigned long targetOverdwellTime; void initialiseTimers(); - +#endif TIMERS_H diff --git a/utils.h b/utils.h index b44b3968..49746fae 100644 --- a/utils.h +++ b/utils.h @@ -1,6 +1,9 @@ /* These are some utility functions and variables used through the main code */ +#ifndef UTILS_H +#define UTILS_H + #include #define MS_IN_MINUTE 60000 #define US_IN_MINUTE 60000000 @@ -10,3 +13,5 @@ int AIRDEN(); unsigned int PW(); unsigned int PW_SD(); unsigned int PW_AN(); + +#endif // UTILS_H