Skip to content

Commit 6d8a6e3

Browse files
authored
Merge pull request speeduino#1332 from adbancroft/micros_safe
Remove micros_safe() - it's never used/defined
2 parents 4c677f5 + 24ec6d6 commit 6d8a6e3

File tree

11 files changed

+10
-45
lines changed

11 files changed

+10
-45
lines changed

speeduino/board_avr2560.cpp

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -116,23 +116,6 @@ uint16_t freeRam(void)
116116

117117
void doSystemReset(void) { return; }
118118
void jumpToBootloader(void) { return; }
119-
#if defined(TIMER5_MICROS)
120-
//This is used by the fast version of micros(). We just need to increment the timer overflow counter
121-
ISR(TIMER5_OVF_vect)
122-
{
123-
++timer5_overflow_count;
124-
}
125-
126-
static inline unsigned long micros_safe(void)
127-
{
128-
unsigned long newMicros;
129-
noInterrupts();
130-
newMicros = (((timer5_overflow_count << 16) + TCNT5) * 4);
131-
interrupts();
132-
133-
return newMicros;
134-
}
135-
#endif //TIMER5_MICROS
136119

137120
uint8_t getSystemTemp()
138121
{

speeduino/board_avr2560.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,6 @@
3232
void jumpToBootloader(void);
3333
uint8_t getSystemTemp();
3434

35-
#if defined(TIMER5_MICROS)
36-
/*#define micros() (((timer5_overflow_count << 16) + TCNT5) * 4) */ //Fast version of micros() that uses the 4uS tick of timer5. See timers.ino for the overflow ISR of timer5
37-
#define millis() (ms_counter) //Replaces the standard millis() function with this macro. It is both faster and more accurate. See timers.ino for its counter increment.
38-
static inline unsigned long micros_safe(); //A version of micros() that is interrupt safe
39-
#else
40-
#define micros_safe() micros() //If the timer5 method is not used, the micros_safe() macro is simply an alias for the normal micros()
41-
#endif
4235
#define pinIsReserved(pin) ( ((pin) == 0) ) //Forbidden pins like USB on other boards
4336

4437
/*

speeduino/board_same51.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,6 @@
3737
void jumpToBootloader();
3838
uint8_t getSystemTemp();
3939

40-
#if defined(TIMER5_MICROS)
41-
/*#define micros() (((timer5_overflow_count << 16) + TCNT5) * 4) */ //Fast version of micros() that uses the 4uS tick of timer5. See timers.ino for the overflow ISR of timer5
42-
#define millis() (ms_counter) //Replaces the standard millis() function with this macro. It is both faster and more accurate. See timers.ino for its counter increment.
43-
static inline unsigned long micros_safe(); //A version of micros() that is interrupt safe
44-
#else
45-
#define micros_safe() micros() //If the timer5 method is not used, the micros_safe() macro is simply an alias for the normal micros()
46-
#endif
4740
#define pinIsReserved(pin) ( ((pin) == 0) ) //Forbidden pins like USB on other boards
4841

4942
//Additional analog pins (These won't work without other changes)

speeduino/board_stm32_official.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@
3535
#define COMPARE_TYPE uint16_t
3636
#define SERIAL_BUFFER_SIZE 517 //Size of the serial buffer used by new comms protocol. For SD transfers this must be at least 512 + 1 (flag) + 4 (sector)
3737
#define FPU_MAX_SIZE 32 //Size of the FPU buffer. 0 means no FPU.
38-
#define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
3938
#define TIMER_RESOLUTION 4
4039

4140
//Select one for EEPROM,the default is EEPROM emulation on internal flash.

speeduino/board_teensy35.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@
3030
#define RTC_LIB_H "TimeLib.h"
3131
#define SD_CONFIG SdioConfig(FIFO_SDIO) //Set Teensy to use SDIO in FIFO mode. This is the fastest SD mode on Teensy as it offloads most of the writes
3232

33-
#define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
3433
#define PWM_FAN_AVAILABLE
3534
#define pinIsReserved(pin) ( ((pin) == 0) || ((pin) == 1) || ((pin) == 3) || ((pin) == 4) ) //Forbidden pins like USB
3635

speeduino/board_teensy41.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929
#define RTC_LIB_H "TimeLib.h"
3030
#define SD_CONFIG SdioConfig(FIFO_SDIO) //Set Teensy to use SDIO in FIFO mode. This is the fastest SD mode on Teensy as it offloads most of the writes
3131

32-
#define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
3332
//#define PWM_FAN_AVAILABLE
3433
#define pinIsReserved(pin) ( ((pin) == 0) || ((pin) == 42) || ((pin) == 43) || ((pin) == 44) || ((pin) == 45) || ((pin) == 46) || ((pin) == 47) || pinIsSerial((pin)) ) //Forbidden pins like USB
3534

speeduino/board_template.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#define BOARD_MAX_DIGITAL_PINS 52 //Pretty sure this isn't right
1313
#define EEPROM_LIB_H <EEPROM.h> //The name of the file that provides the EEPROM class
1414
typedef int eeprom_address_t;
15-
#define micros_safe() micros() //timer5 method is not used on anything but AVR, the micros_safe() macro is simply an alias for the normal micros()
1615
void initBoard();
1716
uint16_t freeRam();
1817
void doSystemReset();

speeduino/corrections.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ uint16_t correctionAccel(void)
298298
if( BIT_CHECK(currentStatus.engine, BIT_ENGINE_ACC) || BIT_CHECK(currentStatus.engine, BIT_ENGINE_DCC))
299299
{
300300
//If it is currently running, check whether it should still be running or whether it's reached it's end time
301-
if( micros_safe() >= currentStatus.AEEndTime )
301+
if( micros() >= currentStatus.AEEndTime )
302302
{
303303
//Time to turn enrichment off
304304
BIT_CLEAR(currentStatus.engine, BIT_ENGINE_ACC);
@@ -346,7 +346,7 @@ uint16_t correctionAccel(void)
346346
if (abs(currentStatus.mapDOT) > configPage2.maeThresh)
347347
{
348348
activateMAPDOT = abs(currentStatus.mapDOT);
349-
currentStatus.AEEndTime = micros_safe() + ((unsigned long)configPage2.aeTime * 10000); //Set the time in the future where the enrichment will be turned off. taeTime is stored as mS / 10, so multiply it by 100 to get it in uS
349+
currentStatus.AEEndTime = micros() + ((unsigned long)configPage2.aeTime * 10000); //Set the time in the future where the enrichment will be turned off. taeTime is stored as mS / 10, so multiply it by 100 to get it in uS
350350
//Check if the MAP rate of change is negative or positive. Negative means decelarion.
351351
if (currentStatus.mapDOT < 0)
352352
{
@@ -412,7 +412,7 @@ uint16_t correctionAccel(void)
412412
if (abs(currentStatus.tpsDOT) > configPage2.taeThresh)
413413
{
414414
activateTPSDOT = abs(currentStatus.tpsDOT);
415-
currentStatus.AEEndTime = micros_safe() + ((unsigned long)configPage2.aeTime * 10000); //Set the time in the future where the enrichment will be turned off. taeTime is stored as mS / 10, so multiply it by 100 to get it in uS
415+
currentStatus.AEEndTime = micros() + ((unsigned long)configPage2.aeTime * 10000); //Set the time in the future where the enrichment will be turned off. taeTime is stored as mS / 10, so multiply it by 100 to get it in uS
416416
//Check if the TPS rate of change is negative or positive. Negative means decelarion.
417417
if (currentStatus.tpsDOT < 0)
418418
{

speeduino/idle.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -230,13 +230,13 @@ static inline byte checkForStepping(void)
230230
timeCheck = iacCoolTime_uS;
231231
}
232232

233-
if(micros_safe() > (idleStepper.stepStartTime + timeCheck) )
233+
if(micros() > (idleStepper.stepStartTime + timeCheck) )
234234
{
235235
if(idleStepper.stepperStatus == STEPPING)
236236
{
237237
//Means we're currently in a step, but it needs to be turned off
238238
digitalWrite(pinStepperStep, LOW); //Turn off the step
239-
idleStepper.stepStartTime = micros_safe();
239+
idleStepper.stepStartTime = micros();
240240

241241
//Set status to COOLING. In next cycle, status will be set to SOFF and set stepper power OFF based on given settings
242242
idleStepper.stepperStatus = COOLING; //'Cooling' is the time the stepper needs to sit in LOW state before the next step can be made
@@ -290,7 +290,7 @@ static inline void doStep(void)
290290

291291
digitalWrite(pinStepperEnable, LOW); //Enable the DRV8825
292292
digitalWrite(pinStepperStep, HIGH);
293-
idleStepper.stepStartTime = micros_safe();
293+
idleStepper.stepStartTime = micros();
294294
idleStepper.stepperStatus = STEPPING;
295295
idleOn = true;
296296

@@ -314,7 +314,7 @@ static inline byte isStepperHomed(void)
314314
digitalWrite(pinStepperDir, STEPPER_LESS_AIR_DIRECTION() ); //homing the stepper closes off the air bleed
315315
digitalWrite(pinStepperEnable, LOW); //Enable the DRV8825
316316
digitalWrite(pinStepperStep, HIGH);
317-
idleStepper.stepStartTime = micros_safe();
317+
idleStepper.stepStartTime = micros();
318318
idleStepper.stepperStatus = STEPPING;
319319
completedHomeSteps++;
320320
idleOn = true;

speeduino/init.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ void initialiseAll(void)
292292
}
293293

294294
//Initial values for loop times
295-
currentLoopTime = micros_safe();
295+
currentLoopTime = micros();
296296
mainLoopCount = 0;
297297

298298
if(configPage2.divider == 0) { currentStatus.nSquirts = 2; } //Safety check.

0 commit comments

Comments
 (0)