diff --git a/globals.h b/globals.h index b75f43f9..717ef618 100644 --- a/globals.h +++ b/globals.h @@ -41,6 +41,16 @@ const int map_page_size = 288; #define SERIAL_BUFFER_THRESHOLD 32 // When the serial buffer is filled to greater than this threshold value, the serial processing operations will be performed more urgently in order to avoid it overflowing. Serial buffer is 64 bytes long, so the threshold is set at half this as a reasonable figure +//These are for the direct port manipulation of the injectors and coils +volatile byte *inj1_pin_port; +volatile byte inj1_pin_mask; +volatile byte *inj2_pin_port; +volatile byte inj2_pin_mask; +volatile byte *inj3_pin_port; +volatile byte inj3_pin_mask; +volatile byte *inj4_pin_port; +volatile byte inj4_pin_mask; + //The status struct contains the current values for all 'live' variables //In current version this is 64 bytes struct statuses { diff --git a/speeduino.ino b/speeduino.ino index 2a6c5c4e..6be80dfb 100644 --- a/speeduino.ino +++ b/speeduino.ino @@ -868,11 +868,15 @@ void loop() //NOTE: squirt status is changed as per http://www.msextra.com/doc/ms1extra/COM_RS232.htm#Acmd void openInjector1() { digitalWrite(pinInjector1, HIGH); BIT_SET(currentStatus.squirt, 0); } void closeInjector1() { digitalWrite(pinInjector1, LOW); BIT_CLEAR(currentStatus.squirt, 0); } +//void openInjector1() { *inj1_pin_port |= (inj1_pin_mask); ; BIT_SET(currentStatus.squirt, 0); } +//void closeInjector1() { *inj1_pin_port &= ~(inj1_pin_mask); BIT_CLEAR(currentStatus.squirt, 0); } void beginCoil1Charge() { digitalWrite(pinCoil1, coilHIGH); BIT_SET(currentStatus.spark, 0); digitalWrite(pinTachOut, LOW); } void endCoil1Charge() { digitalWrite(pinCoil1, coilLOW); BIT_CLEAR(currentStatus.spark, 0); } void openInjector2() { digitalWrite(pinInjector2, HIGH); BIT_SET(currentStatus.squirt, 1); } //Sets the relevant pin HIGH and changes the current status bit for injector 2 (2nd bit of currentStatus.squirt) void closeInjector2() { digitalWrite(pinInjector2, LOW); BIT_CLEAR(currentStatus.squirt, 1); } +//void openInjector2() { *inj2_pin_port |= (inj2_pin_mask); ; BIT_SET(currentStatus.squirt, 0); } +//void closeInjector2() { *inj2_pin_port &= ~(inj2_pin_mask); BIT_CLEAR(currentStatus.squirt, 0); } void beginCoil2Charge() { digitalWrite(pinCoil2, coilHIGH); BIT_SET(currentStatus.spark, 1); digitalWrite(pinTachOut, LOW); } void endCoil2Charge() { digitalWrite(pinCoil2, coilLOW); BIT_CLEAR(currentStatus.spark, 1);} diff --git a/utils.ino b/utils.ino index 3ee0ea81..7375256a 100644 --- a/utils.ino +++ b/utils.ino @@ -237,6 +237,15 @@ void setPinMapping(byte boardID) pinMode(pinIdle1, OUTPUT); pinMode(pinIdle2, OUTPUT); pinMode(pinFuelPump, OUTPUT); + + inj1_pin_port = portOutputRegister(digitalPinToPort(pinInjector1)); + inj1_pin_mask = digitalPinToBitMask(pinInjector1); + inj2_pin_port = portOutputRegister(digitalPinToPort(pinInjector2)); + inj2_pin_mask = digitalPinToBitMask(pinInjector2); + inj3_pin_port = portOutputRegister(digitalPinToPort(pinInjector3)); + inj3_pin_mask = digitalPinToBitMask(pinInjector3); + inj4_pin_port = portOutputRegister(digitalPinToPort(pinInjector4)); + inj4_pin_mask = digitalPinToBitMask(pinInjector4); //And for inputs pinMode(pinMAP, INPUT);