PJSC(Pump Jet Solenoid Controller)はArduinoを使用したバイク用燃料噴射コントローラです。このプロジェクトは、オープンソースECUプロジェクト『Speeduino』をベースにしています。
Speeduino Feb.2019 version.
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | |
| 2 | 2 | | | | |
| 3 | 3 | | --- | --- | |
| 4 | -| **Dev Status** |  | | |
| 5 | -| **Latest Release** | [](https://github.com/noisymime/speeduino/releases/tag/201808) | | |
| 4 | +| **Dev Status** |  | | |
| 5 | +| **Latest Release** | [](https://github.com/noisymime/speeduino/releases/tag/201810) | | |
| 6 | 6 | | **MISRA Status** | [](https://travis-ci.org/noisymime/speeduino/) | |
| 7 | 7 | | **Feature Bounties** | [](https://www.bountysource.com/teams/speeduino) |
| 8 | 8 |
| @@ -18,7 +18,7 @@ | ||
| 18 | 18 | |
| 19 | 19 | Q: Arduino ECU,pffft, heard THAT before. Does this one actually work? |
| 20 | 20 | |
| 21 | -A: Yep! 1, 2, 3, 4, 5, 6 and 8 cylinder engines have all run using Speeduino. At last count over 300 engines were running on this platform, but this figure is growing all the time. | |
| 21 | +A: Yep! 1, 2, 3, 4, 5, 6 and 8 cylinder engines have all run using Speeduino. At last count over 700 engines were running on this platform, but this figure is growing all the time. | |
| 22 | 22 | |
| 23 | 23 | ======================================================================== |
| 24 | 24 |
| @@ -30,7 +30,7 @@ | ||
| 30 | 30 | |
| 31 | 31 | Q: Target platform? |
| 32 | 32 | |
| 33 | -A: Arduino Mega (Or other ATmega1280 / ATmega2560 powered SKU) will be required. Standard arduino models are not suitable for multi-cylinder engines due to their lack of 16-bit timers. The shield board has been designed around the Mega and it is not expected that there will be a non-Mega variant. | |
| 33 | +A: Arduino Mega (or other ATmega2560 powered SKU) will be required. Standard arduino models are not suitable for multi-cylinder engines due to their lack of 16-bit timers. The shield board has been designed around the Mega and it is not expected that there will be a non-Mega variant. | |
| 34 | 34 | |
| 35 | 35 | ======================================================================== |
| 36 | 36 |
| @@ -30,7 +30,7 @@ | ||
| 30 | 30 | ;lib_deps = EEPROM |
| 31 | 31 | |
| 32 | 32 | [env:genericSTM32F103RB] |
| 33 | -platform = ststm32 | |
| 33 | +platform = ststm32@~4.5.0 | |
| 34 | 34 | framework = arduino |
| 35 | 35 | ; framework-arduinoststm32 |
| 36 | 36 | board = genericSTM32F103RB |
| @@ -37,6 +37,24 @@ | ||
| 37 | 37 | lib_deps = EEPROM |
| 38 | 38 | build_flags = -fpermissive -std=gnu++11 |
| 39 | 39 | |
| 40 | +[env:genericSTM32F103RB_STM32GENERIC] | |
| 41 | +;platform = ststm32@~4.5.0 | |
| 42 | +platform = ststm32 | |
| 43 | +framework = arduino | |
| 44 | +; framework-arduinoststm32 | |
| 45 | +board = genericSTM32F103RB | |
| 46 | +lib_deps = EEPROM, HardwareTimer, Flash_STM32 | |
| 47 | +build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DUSE_STM32GENERIC -DMENU_USB_SERIAL | |
| 48 | + | |
| 49 | +[env:black_F407VE] | |
| 50 | +;platform = ststm32@~4.5.0 | |
| 51 | +platform = ststm32 | |
| 52 | +framework = arduino | |
| 53 | +; framework-arduinoststm32 | |
| 54 | +board = black_F407VE | |
| 55 | +lib_deps = EEPROM | |
| 56 | +build_flags = -fpermissive -std=gnu++11 -UBOARD_NR_GPIO_PINS -DUSE_STM32GENERIC -DMENU_USB_SERIAL | |
| 57 | + | |
| 40 | 58 | [env:bluepill_f103c8] |
| 41 | 59 | platform = ststm32 |
| 42 | 60 | framework = arduino |
| @@ -44,8 +62,18 @@ | ||
| 44 | 62 | board = bluepill_f103c8 |
| 45 | 63 | lib_deps = EEPROM |
| 46 | 64 | ;build_flags = -fpermissive -std=gnu++11 -Os -ffunction-sections -fdata-sections -Wl,--gc-sections -Wl,-Map,output.map |
| 47 | -build_flags = -fpermissive -std=gnu++11 -Os | |
| 65 | +build_flags = -fpermissive -std=gnu++11 -Os -UBOARD_NR_GPIO_PINS | |
| 48 | 66 | |
| 67 | +;SAMD21 | |
| 68 | +[env:samd21] | |
| 69 | +platform = atmelsam | |
| 70 | +framework = arduino | |
| 71 | +board = zeroUSB | |
| 72 | +;lib_deps = EEPROM | |
| 73 | +build_flags = -fpermissive -std=gnu++11 | |
| 74 | +upload_protocol = sam-ba | |
| 75 | + | |
| 76 | + | |
| 49 | 77 | ;Support for the stm32f407 doesn't look ready in platformio yet |
| 50 | 78 | ;[env:genericSTM32F407VE] |
| 51 | 79 | ;platform = https://github.com/maichaell/platform-ststm32 |
| @@ -1,15 +1,15 @@ | ||
| 1 | -Part/Designator,Manufacture Part Number | |
| 2 | -R3,RC0805FR-071KL | |
| 3 | -R5,RC0805FR-071KL | |
| 4 | -R4,RC0805JR-0710KL | |
| 5 | -R6,RC0805JR-0710KL | |
| 6 | -R7,RC0805JR-0710KL | |
| 7 | -R9,RC0805JR-0710KL | |
| 8 | -R11,RC0805JR-0710KL | |
| 9 | -R13,RC0805JR-0710KL | |
| 10 | -MAX9926,MAX9926UAEE+T | |
| 11 | -C2,CC0805KRX7R9BB103 | |
| 12 | -C3,CC0805KKX7R7BB105 | |
| 13 | -C4,CC0805KRX7R9BB102 | |
| 14 | -C5,CC0805KRX7R9BB102 | |
| 1 | +Part/Designator,Manufacture Part Number | |
| 2 | +R3,RC0805FR-071KL | |
| 3 | +R5,RC0805FR-071KL | |
| 4 | +R4,RC0805JR-0710KL | |
| 5 | +R6,RC0805JR-0710KL | |
| 6 | +R7,RC0805JR-0710KL | |
| 7 | +R9,RC0805JR-0710KL | |
| 8 | +R11,RC0805JR-0710KL | |
| 9 | +R13,RC0805JR-0710KL | |
| 10 | +MAX9926,MAX9926UAEE+T | |
| 11 | +C2,CC0805KRX7R9BB103 | |
| 12 | +C3,CC0805KKX7R7BB105 | |
| 13 | +C4,CC0805KRX7R9BB102 | |
| 14 | +C5,CC0805KRX7R9BB102 | |
| 15 | 15 | C1,CC0805ZRY5V9BB104 |
| \ No newline at end of file |
| @@ -1,8 +1,8 @@ | ||
| 1 | -Part/Designator,Manufacture Part Number,Quantity | |
| 2 | -"R4,R6",RC0805FR-071KL,2 | |
| 3 | -"R7,R9,R11,R13",RC0805JR-0710KL,4 | |
| 4 | -MAX9926,MAX9926UAEE+T,1 | |
| 5 | -C2,CC0805KRX7R9BB103,1 | |
| 6 | -C3,CC0805KKX7R7BB105,1 | |
| 7 | -"C4,C5",CC0805KRX7R9BB102,2 | |
| 1 | +Part/Designator,Manufacture Part Number,Quantity | |
| 2 | +"R4,R6",RC0805FR-071KL,2 | |
| 3 | +"R7,R9,R11,R13",RC0805JR-0710KL,4 | |
| 4 | +MAX9926,MAX9926UAEE+T,1 | |
| 5 | +C2,CC0805KRX7R9BB103,1 | |
| 6 | +C3,CC0805KKX7R7BB105,1 | |
| 7 | +"C4,C5",CC0805KRX7R9BB102,2 | |
| 8 | 8 | C1,CC0805ZRY5V9BB104,1 |
| \ No newline at end of file |
| @@ -1,8 +1,8 @@ | ||
| 1 | -Part/Designator,Manufacture Part Number,Quantity | |
| 2 | -"R3,R5",RC0805FR-071KL,2 | |
| 3 | -"R4,R6,R7,R9,R11,R13",RC0805JR-0710KL,6 | |
| 4 | -MAX9926,MAX9926UAEE+T,1 | |
| 5 | -C2,CC0805KRX7R9BB103,1 | |
| 6 | -C3,CC0805KKX7R7BB105,1 | |
| 7 | -"C4,C5",CC0805KRX7R9BB102,2 | |
| 1 | +Part/Designator,Manufacture Part Number,Quantity | |
| 2 | +"R3,R5",RC0805FR-071KL,2 | |
| 3 | +"R4,R6,R7,R9,R11,R13",RC0805JR-0710KL,6 | |
| 4 | +MAX9926,MAX9926UAEE+T,1 | |
| 5 | +C2,CC0805KRX7R9BB103,1 | |
| 6 | +C3,CC0805KKX7R7BB105,1 | |
| 7 | +"C4,C5",CC0805KRX7R9BB102,2 | |
| 8 | 8 | C1,CC0805ZRY5V9BB104,1 |
| \ No newline at end of file |
| @@ -6,7 +6,7 @@ | ||
| 6 | 6 | MTversion = 2.25 |
| 7 | 7 | |
| 8 | 8 | queryCommand = "Q" |
| 9 | - signature = "speeduino 201810" | |
| 9 | + signature = "speeduino 201902" | |
| 10 | 10 | versionInfo = "S" ;This info is what is displayed to user |
| 11 | 11 | |
| 12 | 12 | [TunerStudio] |
| @@ -151,7 +151,8 @@ | ||
| 151 | 151 | |
| 152 | 152 | endianness = little |
| 153 | 153 | nPages = 10 |
| 154 | - pageSize = 288, 128, 288, 128, 288, 128, 240, 192, 192, 192 | |
| 154 | + ;pageSize = 288, 128, 288, 128, 288, 128, 240, 192, 192, 192 | |
| 155 | + pageSize = 128, 288, 288, 128, 288, 128, 240, 192, 192, 192 | |
| 155 | 156 | |
| 156 | 157 | ;burnCommand = "B" |
| 157 | 158 | ;pageActivate = "P\001", "P\002", "P\003", "P\004", "P\005", "P\006", "P\007", "P\010", "P\011", "P\012", "P\013" |
| @@ -181,7 +182,7 @@ | ||
| 181 | 182 | #define PIN_OUT16inv = "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" |
| 182 | 183 | #define PIN_16inv = "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" |
| 183 | 184 | |
| 184 | - #define ANALOG_PIN = "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A8", "A10", "A11", "A12", "A13", "A14", "A15", $PIN_16inv, $PIN_16inv, $PIN_16inv | |
| 185 | + #define ANALOG_PIN = "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", $PIN_16inv, $PIN_16inv, $PIN_16inv | |
| 185 | 186 | #define DIGITAL_PIN = "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID" |
| 186 | 187 | #define ANALOG_DIG_PIN_LIST = $DIGITAL_PIN, $ANALOG_PIN |
| 187 | 188 | #define tsCanId_list = "CAN ID 0", "CAN ID 1", "CAN ID 2", "CAN ID 3", "CAN ID 4", "CAN ID 5", "CAN ID 6", "CAN ID 7", "CAN ID 8", "CAN ID 9", "CAN ID 10","CAN ID 11","CAN ID 12","CAN ID 13","CAN ID 14","INVALID" |
| @@ -196,23 +197,13 @@ | ||
| 196 | 197 | #define CAN_ADDRESS_HEX_07XX = "0x700", "0x701", "0x702", "0x703", "0x704", "0x705", "0x706", "0x707", "0x708", "0x709", "0x70A", "0x70B", "0x70C", "0x70D", "0x70E", "0x70F", "0x710", "0x711", "0x712", "0x713", "0x714", "0x715", "0x716", "0x717", "0x718", "0x719", "0x71A", "0x71B", "0x71C", "0x71D", "0x71E", "0x71F", "0x720", "0x721", "0x722", "0x723", "0x724", "0x725", "0x726", "0x727", "0x728", "0x729", "0x72A", "0x72B", "0x72C", "0x72D", "0x72E", "0x72F", "0x730", "0x731", "0x732", "0x733", "0x734", "0x735", "0x736", "0x737", "0x738", "0x739", "0x73A", "0x73B", "0x73C", "0x73D", "0x73E", "0x73F", "0x740", "0x741", "0x742", "0x743", "0x744", "0x745", "0x746", "0x747", "0x748", "0x749", "0x74A", "0x74B", "0x74C", "0x74D", "0x74E", "0x74F", "0x750", "0x751", "0x752", "0x753", "0x754", "0x755", "0x756", "0x757", "0x758", "0x759", "0x75A", "0x75B", "0x75C", "0x75D", "0x75E", "0x75F" ,"0x760", "0x761", "0x762", "0x763", "0x764", "0x765", "0x766", "0x767", "0x768", "0x769", "0x76A", "0x76B", "0x76C", "0x76D", "0x76E", "0x76F", "0x770", "0x771", "0x772", "0x773", "0x774", "0x775", "0x776", "0x777", "0x778", "0x779", "0x77A", "0x77B", "0x77C", "0x77D", "0x77E", "0x77F", "0x780", "0x781", "0x782", "0x783", "0x784", "0x785", "0x786", "0x787", "0x788", "0x789", "0x78A", "0x78B", "0x78C", "0x78D", "0x78E", "0x78F" ,"0x790", "0x791", "0x792", "0x793", "0x794", "0x795", "0x796", "0x797", "0x798", "0x799", "0x79A", "0x79B", "0x79C", "0x79D", "0x79E", "0x79F", "0x7A0", "0x7A1", "0x7A2", "0x7A3", "0x7A4", "0x7A5", "0x7A6", "0x7A7", "0x7A8", "0x7A9", "0x7AA", "0x7AB", "0x7AC", "0x7AD", "0x7AE", "0x7AF", "0x7B0", "0x7B1", "0x7B2", "0x7B3", "0x7B4", "0x7B5", "0x7B6", "0x7B7", "0x7B8", "0x7B9", "0x7BA", "0x7BB", "0x7BC", "0x7BD", "0x7BE", "0x7BF" ,"0x7C0", "0x7C1", "0x7C2", "0x7C3", "0x7C4", "0x7C5", "0x7C6", "0x7C7", "0x7C8", "0x7C9", "0x7CA", "0x7CB", "0x7CC", "0x7CD", "0x7CE", "0x7CF", "0x7D0", "0x7D1", "0x7D2", "0x7D3", "0x7D4", "0x7D5", "0x7D6", "0x7D7", "0x7D8", "0x7D9", "0x7DA", "0x7DB", "0x7DC", "0x7DD", "0x7DE", "0x7DF", "0x7E0", "0x7E1", "0x7E2", "0x7E3", "0x7E4", "0x7E5", "0x7E6", "0x7E7", "0x7E8", "0x7E9", "0x7EA", "0x7EB", "0x7EC", "0x7ED", "0x7EE", "0x7EF" ,"0x7F0", "0x7F1", "0x7F2", "0x7F3", "0x7F4", "0x7F5", "0x7F6", "0x7F7", "0x7F8", "0x7F9", "0x7FA", "0x7FB", "0x7FC", "0x7FD", "0x7FE", "0x7FF" |
| 197 | 198 | #define CAN_ADDRESS_HEX = $CAN_ADDRESS_HEX_01XX, $CAN_ADDRESS_HEX_02XX, $CAN_ADDRESS_HEX_03XX, $CAN_ADDRESS_HEX_04XX, $CAN_ADDRESS_HEX_05XX, $CAN_ADDRESS_HEX_06XX, $CAN_ADDRESS_HEX_07XX, $CAN_ADDRESS_HEX_inv255 |
| 198 | 199 | |
| 199 | -;Page 1 is the fuel map and axis bins only | |
| 200 | -page = 1 | |
| 201 | - ; name = bits, type, offset, bits | |
| 202 | - ; name = array, type, offset, shape, units, scale, translate, lo, hi, digits | |
| 203 | - ; name = scalar, type, offset, units, scale, translate, lo, hi, digits | |
| 204 | - veTable = array, U08, 0, [16x16],"%", 1.0, 0.0, 0.0, 255.0, 0 | |
| 205 | - rpmBins = array, U08, 256, [ 16], "RPM", 100.0, 0.0, 100.0, 25500.0, 0 | |
| 206 | - fuelLoadBins = array, U08, 272, [ 16], { bitStringValue(algorithmUnits , algorithm) }, 2.0, 0.0, 0.0, {fuelLoadMax}, 0 | |
| 207 | - ;fuelLoadBins = array, U08, 272, [ 16], { bitStringValue(algorithmUnits , algorithm) }, 2.0, 0.0, 0.0, { arrayValue(rpmBins , algorithm) }, 0 | |
| 208 | 200 | |
| 209 | 201 | |
| 210 | - | |
| 211 | 202 | ;-------------------------------------------------- |
| 212 | -;Start Page 2 | |
| 213 | -;Page 2 is all general settings (Previously part of page 1) | |
| 203 | +;Start Page 1 | |
| 204 | +;Page 1 is all general settings. Note that some of these (algorithm and ignAlgorithm) MUST come before their use in the bitStringValue() calls in the fuel and ignition tables | |
| 214 | 205 | ;-------------------------------------------------- |
| 215 | -page = 2 | |
| 206 | +page = 1 | |
| 216 | 207 | unused2-1 = scalar, S08, 0, "kPa", 1.0, 0.0, -127, 127, 0 |
| 217 | 208 | unused2-2 = scalar, U08, 1, "kPa", 1.0, 0.0, 0.0, 255, 0 |
| 218 | 209 | asePct = scalar, U08, 2, "%", 1.0, 0.0, 0.0, 95.0, 0 |
| @@ -304,9 +295,22 @@ | ||
| 304 | 295 | baroMax = scalar, U16, 65, "kpa", 1.0, 0.0, 0.0, 25500, 0 |
| 305 | 296 | EMAPMin = scalar, S08, 67, "kpa", 1.0, 0.0, -100, 127.0, 0 |
| 306 | 297 | EMAPMax = scalar, U16, 68, "kpa", 1.0, 0.0, 0.0, 25500, 0 |
| 307 | - unused2-67 = array, U08, 70, [57], "%", 1.0, 0.0, 0.0, 255, 0 | |
| 308 | 298 | |
| 299 | + fanWhenOff = bits, U08, 70, [0:0], "No", "Yes" | |
| 300 | + unused_fan_bits = bits, U08, 70,[1:7] | |
| 309 | 301 | |
| 302 | + unused2-67 = array, U08, 71, [56], "%", 1.0, 0.0, 0.0, 255, 0 | |
| 303 | + | |
| 304 | +;Page 2 is the fuel map and axis bins only | |
| 305 | +page = 2 | |
| 306 | + ; name = bits, type, offset, bits | |
| 307 | + ; name = array, type, offset, shape, units, scale, translate, lo, hi, digits | |
| 308 | + ; name = scalar, type, offset, units, scale, translate, lo, hi, digits | |
| 309 | + veTable = array, U08, 0, [16x16],"%", 1.0, 0.0, 0.0, 255.0, 0 | |
| 310 | + rpmBins = array, U08, 256, [ 16], "RPM", 100.0, 0.0, 100.0, 25500.0, 0 | |
| 311 | + fuelLoadBins = array, U08, 272, [ 16], { bitStringValue(algorithmUnits , algorithm) }, 2.0, 0.0, 0.0, {fuelLoadMax}, 0 | |
| 312 | + ;fuelLoadBins = array, U08, 272, [ 16], { bitStringValue(algorithmUnits , algorithm) }, 2.0, 0.0, 0.0, { arrayValue(rpmBins , algorithm) }, 0 | |
| 313 | + | |
| 310 | 314 | ;-------------------------------------------------- |
| 311 | 315 | ;Start Ignition table (Page 3) |
| 312 | 316 | ;-------------------------------------------------- |
| @@ -313,7 +317,6 @@ | ||
| 313 | 317 | page = 3 |
| 314 | 318 | advTable1 = array, U08, 0,[16x16], "deg", 1.0, -40, -40, 215.0, 0 |
| 315 | 319 | rpmBins2 = array, U08, 256,[ 16], "RPM", 100.0, 0.0, 100, 25500, 0 |
| 316 | - ;ignLoadBins= array, U08, 272, [ 16], { bitStringValue(algorithmUnits , ignAlgorithm) }, 2.0, 0.0, 0.0, {ignLoadMax}, 0 | |
| 317 | 320 | mapBins1= array, U08, 272, [ 16], { bitStringValue(algorithmUnits , ignAlgorithm) }, 2.0, 0.0, 0.0, {ignLoadMax}, 0 ; This name has to be used in order for the table to show up in MLVs table. I can't find the regexs that make this work :( |
| 318 | 321 | |
| 319 | 322 | ;-------------------------------------------------- |
| @@ -532,7 +535,7 @@ | ||
| 532 | 535 | ; Begin fan control vairables |
| 533 | 536 | fanInv = bits, U08, 120, [0:0], "No", "Yes" |
| 534 | 537 | fanEnable = bits, U08, 120, [1:1], "Off", "On/Off" |
| 535 | - fanPin = bits , U08, 120, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID" | |
| 538 | + fanPin = bits, U08, 120, [2:7], "Board Default", "INVALID", "INVALID", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25", "26", "27", "28", "29", "30", "31", "32", "33", "34", "35", "36", "37", "38", "39", "40", "41", "42", "43", "44", "45", "46", "47", "48", "49", "50", "51", "52", "53", "54", "A8", "A9", "A10", "A11", "A12", "A13", "A14", "A15", "INVALID" | |
| 536 | 539 | #if CELSIUS |
| 537 | 540 | fanSP = scalar, U08, 121, "C", 1.0, -40, -40, 215.0, 0 |
| 538 | 541 | fanHyster = scalar, U08, 122, "C", 1.0, 0.0, 0.0, 40, 0 |
| @@ -852,7 +855,9 @@ | ||
| 852 | 855 | ;unused10_150 = scalar, U08, 150, "", 1, 0, 0, 255, 0 |
| 853 | 856 | ;unused10_151 = scalar, U08, 151, "", 1, 0, 0, 255, 0 |
| 854 | 857 | ;unused10_152 = scalar, U08, 152, "", 1, 0, 0, 255, 0 |
| 855 | - unused10_153 = scalar, U08, 153, "", 1, 0, 0, 255, 0 | |
| 858 | + ;unused10_153 = scalar, U08, 153, "", 1, 0, 0, 255, 0 | |
| 859 | + iacStepperInv = bits, U08, 153, [0:0], "No", "Yes" | |
| 860 | + | |
| 856 | 861 | unused10_154 = scalar, U08, 154, "", 1, 0, 0, 255, 0 |
| 857 | 862 | unused10_155 = scalar, U08, 155, "", 1, 0, 0, 255, 0 |
| 858 | 863 | unused10_156 = scalar, U08, 156, "", 1, 0, 0, 255, 0 |
| @@ -1351,6 +1356,7 @@ | ||
| 1351 | 1356 | iacCLmaxDuty= "When using closed loop idle control, this is the maximum duty cycle that the PID loop will allow. Combined with the minimum value, this specifies the working range of your idle valve" |
| 1352 | 1357 | iacFastTemp = "Below this temperature, the idle output will be high (On). Above this temperature, it will turn off." |
| 1353 | 1358 | idleUpPolarity = "Normal polarity is a ground switch where an earthed signal activates the Idle Up. The internal pullup will be enabled with Normal polarity. \n Inverted may be used if a 5v signal is used to enable the Idle Up." |
| 1359 | + idleUpAdder = "The amount (In either Duty Cycle % or Steps (Depending on the idle control method in use), that the idle control will increase by when Idle Up is active" | |
| 1354 | 1360 | |
| 1355 | 1361 | oddfire2 = "The ATDC angle of channel 2 for oddfire engines. This is relative to the TDC angle of channel 1" |
| 1356 | 1362 | oddfire3 = "The ATDC angle of channel 3 for oddfire engines. This is relative to the TDC angle of channel 1 (NOT channel 2)" |
| @@ -1705,6 +1711,7 @@ | ||
| 1705 | 1711 | |
| 1706 | 1712 | dialog = fanSettings,"Fan Settings",7 |
| 1707 | 1713 | field = "Fan Mode", fanEnable |
| 1714 | + field = "Fan when off", fanWhenOff, { fanEnable } | |
| 1708 | 1715 | field = "Fan output pin", fanPin, { fanEnable } |
| 1709 | 1716 | field = "Fan Output Inverted", fanInv , { fanEnable } |
| 1710 | 1717 | field = "Fan temperature SP", fanSP, { fanEnable } |
| @@ -1714,6 +1721,7 @@ | ||
| 1714 | 1721 | field = "Step time (ms)", iacStepTime, { iacAlgorithm == 4 || iacAlgorithm == 5 } |
| 1715 | 1722 | field = "Home steps", iacStepHome, { iacAlgorithm == 4 || iacAlgorithm == 5 } |
| 1716 | 1723 | field = "Minimum Steps", iacStepHyster, { iacAlgorithm == 4 || iacAlgorithm == 5 } |
| 1724 | + field = "Stepper Inverted", iacStepperInv, { iacAlgorithm == 4 || iacAlgorithm == 5 } | |
| 1717 | 1725 | |
| 1718 | 1726 | dialog = pwm_idle, "PWM Idle" |
| 1719 | 1727 | field = "Number of outputs", iacChannels, { iacAlgorithm == 2 || iacAlgorithm == 3 } |
| @@ -1739,7 +1747,8 @@ | ||
| 1739 | 1747 | dialog = idleUpSettings, "Idle Up Settings" |
| 1740 | 1748 | field = "Idle Up Enabled", idleUpEnabled |
| 1741 | 1749 | field = "Idle Up Pin", idleUpPin, { idleUpEnabled } |
| 1742 | - field = "Idle Up Polarity", idleUpPolarity, { idleUpEnabled } | |
| 1750 | + field = "Idle Up Pin Polarity", idleUpPolarity, { idleUpEnabled } | |
| 1751 | + field = "Idle Up Amount", idleUpAdder, { idleUpEnabled } | |
| 1743 | 1752 | |
| 1744 | 1753 | dialog = fuelpump, "Fuel pump" |
| 1745 | 1754 | field = "Fuel pump pin", fuelPumpPin |
| @@ -1801,7 +1810,7 @@ | ||
| 1801 | 1810 | field = "Cranking advance Angle", CrankAng |
| 1802 | 1811 | field = "Spark Outputs triggers", IgInv |
| 1803 | 1812 | field = "" |
| 1804 | - field = "Enabled Fixed/Locked timing", fixAngEnable | |
| 1813 | + field = "Enabled Fixed/Locked timing", fixAngEnable | |
| 1805 | 1814 | field = "Fixed Angle", FixAng, { fixAngEnable } |
| 1806 | 1815 | field = "#Note: During cranking the fixed/locked timing angle is overriden by the Cranking advance angle value above" |
| 1807 | 1816 | field = "" |
| @@ -1895,8 +1904,8 @@ | ||
| 1895 | 1904 | field = "Nitrous is armed when pin is", n2o_pin_polarity,{ n2o_enable > 0 } |
| 1896 | 1905 | field = "Minimum CLT", n2o_minCLT, { n2o_enable > 0 } |
| 1897 | 1906 | field = "Minimum TPS", n2o_minTPS, { n2o_enable > 0 } |
| 1898 | - field = "Maximum MAP", n2o_maxMAP, { n2o_enable > 0 } | |
| 1899 | - field = "Leanest AFR", n2o_maxAFR, { n2o_enable > 0 } | |
| 1907 | + field = "Maximum MAP", n2o_maxMAP, { n2o_enable > 0 } | |
| 1908 | + field = "Leanest AFR", n2o_maxAFR, { n2o_enable > 0 } | |
| 1900 | 1909 | |
| 1901 | 1910 | dialog = NitrousControl, "Nitrous" |
| 1902 | 1911 | panel = NitrousMain, North |
| @@ -2482,7 +2491,7 @@ | ||
| 2482 | 2491 | displayOnlyField = "Off 1", blankfield, {},{(caninput_sel1a == 0 && (!enable_secondarySerial && (!enable_intcan || (enable_intcan && intcan_available == 0)))) || (caninput_sel1b == 0 && ((enable_secondarySerial && enable_intcan) || (enable_secondarySerial && !enable_intcan) || (!enable_secondarySerial && enable_intcan)))} |
| 2483 | 2492 | displayOnlyField = "External Source 1 Via Secondary Serial", blankfield, {},{(caninput_sel1b == 1 && enable_secondarySerial && ((enable_intcan && intcan_available == 0) || !enable_intcan)) || (caninput_sel1b == 1 && enable_secondarySerial && (enable_intcan && intcan_available) && caninput_sel1extsourceb == 0)} |
| 2484 | 2493 | displayOnlyField = "External Source 1 Via Internal CAN", blankfield, {},{(caninput_sel1b == 1 && enable_secondarySerial && (enable_intcan && intcan_available) && caninput_sel1extsourceb == 1) ||(caninput_sel1b == 1 && !enable_secondarySerial && (enable_intcan && intcan_available) && caninput_sel1extsourcec == 1)} |
| 2485 | - field = "Local Analog Source 1 Pin No:", Auxin1pina , {}, {(caninput_sel1a == 2 && (!enable_secondarySerial && (!enable_intcan || (enable_intcan && intcan_available == 0)) || (caninput_sel1b == 2 && (enable_secondarySerial || enable_intcan))} | |
| 2494 | + field = "Local Analog Source 1 Pin No:", Auxin1pina , {}, {(caninput_sel1a == 2 && (!enable_secondarySerial && (!enable_intcan || (enable_intcan && intcan_available == 0)))) || (caninput_sel1b == 2 && (enable_secondarySerial || (enable_intcan && intcan_available == 1 )))} | |
| 2486 | 2495 | field = "Local Digital Source 1 Pin No:", Auxin1pinb , {}, {(caninput_sel1a == 3 && (!enable_secondarySerial && (!enable_intcan || (enable_intcan && intcan_available == 0)))) || (caninput_sel1b == 3 && (enable_secondarySerial || (enable_intcan && intcan_available == 1 )))} |
| 2487 | 2496 | |
| 2488 | 2497 | displayOnlyField = "Off 2", blankfield, {},{(caninput_sel2a == 0 && (!enable_secondarySerial && !enable_intcan)) || (caninput_sel2b == 0 && (enable_secondarySerial && enable_intcan)) || (caninput_sel2b == 0 && (enable_secondarySerial && !enable_intcan)) || (caninput_sel2b == 0 && (!enable_secondarySerial && enable_intcan))} |
| @@ -3173,7 +3182,7 @@ | ||
| 3173 | 3182 | softlimitOn = bits, U08, 31, [3:3] |
| 3174 | 3183 | boostCutSpark = bits, U08, 31, [4:4] |
| 3175 | 3184 | error = bits, U08, 31, [5:5] |
| 3176 | - idle = bits, U08, 31, [6:6] | |
| 3185 | + idleControlOn = bits, U08, 31, [6:6] | |
| 3177 | 3186 | sync = bits, U08, 31, [7:7] |
| 3178 | 3187 | rpmDOT = scalar, S16, 32, "rpm/s", 1.000, 0.000 |
| 3179 | 3188 | flex = scalar, U08, 34, "%", 1.000, 0.000 |
| @@ -3345,16 +3354,16 @@ | ||
| 3345 | 3354 | startCommand = "H" |
| 3346 | 3355 | stopCommand = "h" |
| 3347 | 3356 | dataReadCommand = "T" ; Basic TS command format |
| 3348 | - dataReadTimeout = 15000 ; time in ms | |
| 3349 | - dataReadyCondition = { toothLog1Ready } | |
| 3357 | + dataReadTimeout = 5000 ; time in ms | |
| 3358 | + dataReadyCondition = { toothLog1Ready == 1 } | |
| 3350 | 3359 | ;dataLength = 256 ; in bytes, including headers, footers and data (not used) |
| 3351 | - dataLength = 128 ; in bytes, including headers, footers and data (not used) | |
| 3360 | + ;dataLength = 128 ; in bytes, including headers, footers and data (not used) | |
| 3352 | 3361 | |
| 3353 | 3362 | ;recordDef = headerLen. footerLen, recordLen |
| 3354 | - recordDef = 0, 0, 2; in bytes, the recordLen is for each record, currently limited to 4 bytes | |
| 3363 | + recordDef = 0, 0, 4; in bytes, the recordLen is for each record, currently limited to 4 bytes | |
| 3355 | 3364 | |
| 3356 | 3365 | ;recordField = Name, HeaderName, startBit, bitCount, scale, units, updateCondition |
| 3357 | - recordField = toothTime, "ToothTime", 0, 16, 1.0, "uS" | |
| 3366 | + recordField = toothTime, "ToothTime", 0, 32, 1.0, "uS" | |
| 3358 | 3367 | |
| 3359 | 3368 | loggerDef = compositeLogger, "Composite Logger", composite |
| 3360 | 3369 | startCommand = "J" |
| @@ -3361,7 +3370,7 @@ | ||
| 3361 | 3370 | stopCommand = "j" |
| 3362 | 3371 | dataReadCommand = "T" ; Basic TS command format. Note that this is shared with the composite logger. Firmware detects which log is currently running |
| 3363 | 3372 | dataReadTimeout = 5000 ; time in ms |
| 3364 | - dataReadyCondition = { toothLog1Ready } | |
| 3373 | + dataReadyCondition = { toothLog1Ready == 1 } | |
| 3365 | 3374 | ;dataLength = 256 ; in bytes, including headers, footers and data (not used) |
| 3366 | 3375 | ;dataLength = 320 ; in bytes, including headers, footers and data (not used) |
| 3367 | 3376 |
| @@ -3373,10 +3382,10 @@ | ||
| 3373 | 3382 | recordField = secLevel, "SecLevel", 1, 1, 1.0, "Flag" |
| 3374 | 3383 | recordField = trigger, "Trigger", 2, 1, 1.0, "Flag" |
| 3375 | 3384 | recordField = sync, "Sync", 3, 1, 1.0, "Flag" |
| 3376 | - recordField = refTime, "RefTime", 8, 32, 0.001, "ms", hidden | |
| 3385 | + recordField = refTime, "RefTime", 8, 32, 0.001, "ms" | |
| 3377 | 3386 | |
| 3378 | 3387 | ; hidden calcField serves as intermediate variable |
| 3379 | - calcField = maxTime, "MaxTime", "ms", { maxValue(refTime) }, hidden | |
| 3388 | + calcField = maxTime, "MaxTime", "ms", { maxValue(refTime) } | |
| 3380 | 3389 | |
| 3381 | 3390 | calcField = toothTime, "ToothTime", "ms", { refTime - pastValue(refTime, 1) } |
| 3382 | 3391 | ;recordField = time, "Time", 24, 16, 1.0, "ms" |
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | #ifndef AUX_H |
| 2 | 2 | #define AUX_H |
| 3 | 3 | |
| 4 | +#include BOARD_H //Note that this is not a real file, it is defined in globals.h. | |
| 5 | + | |
| 4 | 6 | void initialiseAuxPWM(); |
| 5 | 7 | void boostControl(); |
| 6 | 8 | void boostDisable(); |
| @@ -10,55 +12,6 @@ | ||
| 10 | 12 | void nitrousControl(); |
| 11 | 13 | void fanControl(); |
| 12 | 14 | |
| 13 | -#if defined(CORE_AVR) | |
| 14 | - #define ENABLE_BOOST_TIMER() TIMSK1 |= (1 << OCIE1A) | |
| 15 | - #define DISABLE_BOOST_TIMER() TIMSK1 &= ~(1 << OCIE1A) | |
| 16 | - #define ENABLE_VVT_TIMER() TIMSK1 |= (1 << OCIE1B) | |
| 17 | - #define DISABLE_VVT_TIMER() TIMSK1 &= ~(1 << OCIE1B) | |
| 18 | - | |
| 19 | - #define BOOST_TIMER_COMPARE OCR1A | |
| 20 | - #define BOOST_TIMER_COUNTER TCNT1 | |
| 21 | - #define VVT_TIMER_COMPARE OCR1B | |
| 22 | - #define VVT_TIMER_COUNTER TCNT1 | |
| 23 | - | |
| 24 | -#elif defined(CORE_TEENSY) | |
| 25 | - #define ENABLE_BOOST_TIMER() FTM1_C0SC |= FTM_CSC_CHIE | |
| 26 | - #define DISABLE_BOOST_TIMER() FTM1_C0SC &= ~FTM_CSC_CHIE | |
| 27 | - | |
| 28 | - #define ENABLE_VVT_TIMER() FTM1_C1SC |= FTM_CSC_CHIE | |
| 29 | - #define DISABLE_VVT_TIMER() FTM1_C1SC &= ~FTM_CSC_CHIE | |
| 30 | - | |
| 31 | - #define BOOST_TIMER_COMPARE FTM1_C0V | |
| 32 | - #define BOOST_TIMER_COUNTER FTM1_CNT | |
| 33 | - #define VVT_TIMER_COMPARE FTM1_C1V | |
| 34 | - #define VVT_TIMER_COUNTER FTM1_CNT | |
| 35 | - | |
| 36 | -#elif defined(CORE_STM32) | |
| 37 | - #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core | |
| 38 | - #define ENABLE_BOOST_TIMER() (TIM1)->CCER |= TIM_CCER_CC2E | |
| 39 | - #define DISABLE_BOOST_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC2E | |
| 40 | - | |
| 41 | - #define ENABLE_VVT_TIMER() (TIM1)->CCER |= TIM_CCER_CC3E | |
| 42 | - #define DISABLE_VVT_TIMER() (TIM1)->CCER &= ~TIM_CCER_CC3E | |
| 43 | - | |
| 44 | - #define BOOST_TIMER_COMPARE (TIM1)->CCR2 | |
| 45 | - #define BOOST_TIMER_COUNTER (TIM1)->CNT | |
| 46 | - #define VVT_TIMER_COMPARE (TIM1)->CCR3 | |
| 47 | - #define VVT_TIMER_COUNTER (TIM1)->CNT | |
| 48 | - #else //libmaple core aka STM32DUINO | |
| 49 | - #define ENABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC2E | |
| 50 | - #define DISABLE_BOOST_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC2E | |
| 51 | - | |
| 52 | - #define ENABLE_VVT_TIMER() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC3E | |
| 53 | - #define DISABLE_VVT_TIMER() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC3E | |
| 54 | - | |
| 55 | - #define BOOST_TIMER_COMPARE (TIMER1->regs).gen->CCR2 | |
| 56 | - #define BOOST_TIMER_COUNTER (TIMER1->regs).gen->CNT | |
| 57 | - #define VVT_TIMER_COMPARE (TIMER1->regs).gen->CCR3 | |
| 58 | - #define VVT_TIMER_COUNTER (TIMER1->regs).gen->CNT | |
| 59 | - #endif | |
| 60 | -#endif | |
| 61 | - | |
| 62 | 15 | #define BOOST_PIN_LOW() *boost_pin_port &= ~(boost_pin_mask) |
| 63 | 16 | #define BOOST_PIN_HIGH() *boost_pin_port |= (boost_pin_mask) |
| 64 | 17 | #define VVT_PIN_LOW() *vvt_pin_port &= ~(vvt_pin_mask) |
| @@ -71,17 +24,17 @@ | ||
| 71 | 24 | #define N2O_STAGE2_PIN_HIGH() *n2o_stage2_pin_port |= (n2o_stage2_pin_mask) |
| 72 | 25 | #define READ_N2O_ARM_PIN() ((*n2o_arming_pin_port & n2o_arming_pin_mask) ? true : false) |
| 73 | 26 | |
| 74 | -volatile byte *boost_pin_port; | |
| 27 | +volatile PORT_TYPE *boost_pin_port; | |
| 75 | 28 | volatile byte boost_pin_mask; |
| 76 | -volatile byte *vvt_pin_port; | |
| 29 | +volatile PORT_TYPE *vvt_pin_port; | |
| 77 | 30 | volatile byte vvt_pin_mask; |
| 78 | -volatile byte *fan_pin_port; | |
| 31 | +volatile PORT_TYPE *fan_pin_port; | |
| 79 | 32 | volatile byte fan_pin_mask; |
| 80 | -volatile byte *n2o_stage1_pin_port; | |
| 33 | +volatile PORT_TYPE *n2o_stage1_pin_port; | |
| 81 | 34 | volatile byte n2o_stage1_pin_mask; |
| 82 | -volatile byte *n2o_stage2_pin_port; | |
| 35 | +volatile PORT_TYPE *n2o_stage2_pin_port; | |
| 83 | 36 | volatile byte n2o_stage2_pin_mask; |
| 84 | -volatile byte *n2o_arming_pin_port; | |
| 37 | +volatile PORT_TYPE *n2o_arming_pin_port; | |
| 85 | 38 | volatile byte n2o_arming_pin_mask; |
| 86 | 39 | |
| 87 | 40 | volatile bool boost_pwm_state; |
| @@ -98,10 +51,8 @@ | ||
| 98 | 51 | unsigned int vvt_pwm_max_count; //Used for variable PWM frequency |
| 99 | 52 | volatile unsigned int vvt_pwm_cur_value; |
| 100 | 53 | long vvt_pwm_target_value; |
| 101 | -#if defined (CORE_TEENSY) || defined(CORE_STM32) | |
| 102 | - static inline void boostInterrupt(); | |
| 103 | - static inline void vvtInterrupt(); | |
| 104 | -#endif | |
| 54 | +static inline void boostInterrupt(); | |
| 55 | +static inline void vvtInterrupt(); | |
| 105 | 56 | |
| 106 | 57 | |
| 107 | 58 | #endif |
| @@ -1,7 +1,5 @@ | ||
| 1 | 1 | #ifndef CANCOMMS_H |
| 2 | 2 | #define CANCOMMS_H |
| 3 | -//These are the page numbers that the Tuner Studio serial protocol uses to transverse the different map and config pages. | |
| 4 | -#define veMapPage 1 | |
| 5 | 3 | |
| 6 | 4 | #define CAN_PACKET_SIZE 75 |
| 7 | 5 |
| @@ -30,4 +28,4 @@ | ||
| 30 | 28 | void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum); |
| 31 | 29 | void sendCancommand(uint8_t cmdtype , uint16_t canadddress, uint8_t candata1, uint8_t candata2, uint16_t sourcecanAddress); |
| 32 | 30 | |
| 33 | -#endif // CANCOMMS_H | |
| 31 | +#endif // CANCOMMS_H |
| @@ -1,8 +1,8 @@ | ||
| 1 | 1 | #ifndef COMMS_H |
| 2 | 2 | #define COMMS_H |
| 3 | 3 | //These are the page numbers that the Tuner Studio serial protocol uses to transverse the different map and config pages. |
| 4 | -#define veMapPage 1 | |
| 5 | -#define veSetPage 2//Config Page 1 | |
| 4 | +#define veMapPage 2 | |
| 5 | +#define veSetPage 1 //Note that this and the veMapPage were swapped in Feb 2019 as the 'algorithm' field must be declared in the ini before it's used in the fuel table | |
| 6 | 6 | #define ignMapPage 3 |
| 7 | 7 | #define ignSetPage 4//Config Page 2 |
| 8 | 8 | #define afrMapPage 5 |
| @@ -43,12 +43,12 @@ | ||
| 43 | 43 | }; |
| 44 | 44 | |
| 45 | 45 | void command();//This is the heart of the Command Line Interpeter. All that needed to be done was to make it human readable. |
| 46 | -void sendValues(uint16_t offset, uint16_t packetlength,byte cmd, byte portnum); | |
| 47 | -void receiveValue(int offset, byte newValue); | |
| 46 | +void sendValues(uint16_t, uint16_t,byte, byte); | |
| 47 | +void receiveValue(int, byte); | |
| 48 | 48 | void saveConfig(); |
| 49 | -void sendPage(bool useChar); | |
| 50 | -void receiveCalibration(byte tableID); | |
| 51 | -void sendToothLog(bool useChar); | |
| 49 | +void sendPage(bool); | |
| 50 | +void receiveCalibration(byte); | |
| 51 | +void sendToothLog(bool); | |
| 52 | 52 | void testComm(); |
| 53 | 53 | void commandButtons(); |
| 54 | 54 |
| @@ -3,7 +3,7 @@ | ||
| 3 | 3 | #include <Arduino.h> |
| 4 | 4 | #include "table.h" |
| 5 | 5 | |
| 6 | -//These are configuration options for changing around the outputs that are used | |
| 6 | +//These are configuration options for changing around the outputs that are used. THese are just the defaults and may be changed in the sections below based on the hardware in use. | |
| 7 | 7 | #define INJ_CHANNELS 4 |
| 8 | 8 | #define IGN_CHANNELS 5 |
| 9 | 9 |
| @@ -12,15 +12,16 @@ | ||
| 12 | 12 | #define BOARD_NR_GPIO_PINS 62 |
| 13 | 13 | #define LED_BUILTIN 13 |
| 14 | 14 | #define CORE_AVR |
| 15 | + #define BOARD_H "board_avr2560.h" | |
| 15 | 16 | |
| 16 | 17 | //#define TIMER5_MICROS |
| 17 | 18 | |
| 18 | 19 | #elif defined(CORE_TEENSY) |
| 19 | - #define BOARD_DIGITAL_GPIO_PINS 34 | |
| 20 | - #define BOARD_NR_GPIO_PINS 34 | |
| 20 | + #define BOARD_H "board_teensy35.h" | |
| 21 | 21 | |
| 22 | 22 | #elif defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(__STM32F1__) || defined(STM32F4) || defined(STM32) |
| 23 | 23 | #define CORE_STM32 |
| 24 | + #define BOARD_H "board_stm32.h" | |
| 24 | 25 | #ifndef word |
| 25 | 26 | #define word(h, l) ((h << 8) | l) //word() function not defined for this platform in the main library |
| 26 | 27 | #endif |
| @@ -34,10 +35,16 @@ | ||
| 34 | 35 | #define BOARD_DIGITAL_GPIO_PINS 80 |
| 35 | 36 | #define BOARD_NR_GPIO_PINS 80 |
| 36 | 37 | #define LED_BUILTIN PA7 |
| 38 | + | |
| 39 | + //These boards always make 8/8 channels available | |
| 40 | + #undef INJ_CHANNELS | |
| 41 | + #undef IGN_CHANNELS | |
| 42 | + #define INJ_CHANNELS 8 | |
| 43 | + #define IGN_CHANNELS 8 | |
| 37 | 44 | #endif |
| 38 | 45 | |
| 39 | 46 | //Specific mode for Bluepill due to its small flash size. This disables a number of strings from being compiled into the flash |
| 40 | - #if defined(MCU_STM32F103C8) | defined(MCU_STM32F103CB) | |
| 47 | + #if defined(MCU_STM32F103C8) || defined(MCU_STM32F103CB) | |
| 41 | 48 | #define SMALL_FLASH_MODE |
| 42 | 49 | #endif |
| 43 | 50 |
| @@ -51,10 +58,16 @@ | ||
| 51 | 58 | #define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) ) |
| 52 | 59 | #define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) ) |
| 53 | 60 | #endif |
| 61 | +#elif defined(__SAMD21G18A__) | |
| 62 | + #define BOARD_H "board_samd21.h" | |
| 63 | + #define CORE_SAMD21 | |
| 54 | 64 | #else |
| 55 | 65 | #error Incorrect board selected. Please select the correct board (Usually Mega 2560) and upload again |
| 56 | 66 | #endif |
| 57 | 67 | |
| 68 | +//This can only be included after the above section | |
| 69 | +#include BOARD_H //Note that this is not a real file, it is defined in globals.h. | |
| 70 | + | |
| 58 | 71 | //Handy bitsetting macros |
| 59 | 72 | #define BIT_SET(a,b) ((a) |= (1<<(b))) |
| 60 | 73 | #define BIT_CLEAR(a,b) ((a) &= ~(1<<(b))) |
| @@ -85,7 +98,7 @@ | ||
| 85 | 98 | #define BIT_STATUS1_INJ2 1 //inj2 |
| 86 | 99 | #define BIT_STATUS1_INJ3 2 //inj3 |
| 87 | 100 | #define BIT_STATUS1_INJ4 3 //inj4 |
| 88 | -#define BIT_STATUS1_DFCO 4 //Decelleration fuel cutoff | |
| 101 | +#define BIT_STATUS1_DFCO 4 //Decelleration fuel cutoff | |
| 89 | 102 | #define BIT_STATUS1_BOOSTCUT 5 //Fuel component of MAP based boost cut out |
| 90 | 103 | #define BIT_STATUS1_TOOTHLOG1READY 6 //Used to flag if tooth log 1 is ready |
| 91 | 104 | #define BIT_STATUS1_TOOTHLOG2READY 7 //Used to flag if tooth log 2 is ready (Log is not currently used) |
| @@ -100,8 +113,8 @@ | ||
| 100 | 113 | #define BIT_SPARK_IDLE 6 // idle on |
| 101 | 114 | #define BIT_SPARK_SYNC 7 // Whether engine has sync or not |
| 102 | 115 | |
| 103 | -#define BIT_SPARK2_FLATSH 0 //Flat shift hard cut | |
| 104 | -#define BIT_SPARK2_FLATSS 1 //Flat shift soft cut | |
| 116 | +#define BIT_SPARK2_FLATSH 0 //Flat shift hard cut | |
| 117 | +#define BIT_SPARK2_FLATSS 1 //Flat shift soft cut | |
| 105 | 118 | #define BIT_SPARK2_UNUSED3 2 |
| 106 | 119 | #define BIT_SPARK2_UNUSED4 3 |
| 107 | 120 | #define BIT_SPARK2_UNUSED5 4 |
| @@ -128,7 +141,7 @@ | ||
| 128 | 141 | #define VALID_MAP_MIN 2 //The smallest ADC value that is valid for the MAP sensor |
| 129 | 142 | |
| 130 | 143 | #define TOOTH_LOG_SIZE 64 |
| 131 | -#define TOOTH_LOG_BUFFER 256 | |
| 144 | +#define TOOTH_LOG_BUFFER 128 //256 | |
| 132 | 145 | |
| 133 | 146 | #define COMPOSITE_LOG_PRI 0 |
| 134 | 147 | #define COMPOSITE_LOG_SEC 1 |
| @@ -237,48 +250,48 @@ | ||
| 237 | 250 | struct table2D knockWindowDurationTable; |
| 238 | 251 | |
| 239 | 252 | //These are for the direct port manipulation of the injectors, coils and aux outputs |
| 240 | -volatile byte *inj1_pin_port; | |
| 253 | +volatile PORT_TYPE *inj1_pin_port; | |
| 241 | 254 | volatile byte inj1_pin_mask; |
| 242 | -volatile byte *inj2_pin_port; | |
| 255 | +volatile PORT_TYPE *inj2_pin_port; | |
| 243 | 256 | volatile byte inj2_pin_mask; |
| 244 | -volatile byte *inj3_pin_port; | |
| 257 | +volatile PORT_TYPE *inj3_pin_port; | |
| 245 | 258 | volatile byte inj3_pin_mask; |
| 246 | -volatile byte *inj4_pin_port; | |
| 259 | +volatile PORT_TYPE *inj4_pin_port; | |
| 247 | 260 | volatile byte inj4_pin_mask; |
| 248 | -volatile byte *inj5_pin_port; | |
| 261 | +volatile PORT_TYPE *inj5_pin_port; | |
| 249 | 262 | volatile byte inj5_pin_mask; |
| 250 | -volatile byte *inj6_pin_port; | |
| 263 | +volatile PORT_TYPE *inj6_pin_port; | |
| 251 | 264 | volatile byte inj6_pin_mask; |
| 252 | -volatile byte *inj7_pin_port; | |
| 265 | +volatile PORT_TYPE *inj7_pin_port; | |
| 253 | 266 | volatile byte inj7_pin_mask; |
| 254 | -volatile byte *inj8_pin_port; | |
| 267 | +volatile PORT_TYPE *inj8_pin_port; | |
| 255 | 268 | volatile byte inj8_pin_mask; |
| 256 | 269 | |
| 257 | -volatile byte *ign1_pin_port; | |
| 270 | +volatile PORT_TYPE *ign1_pin_port; | |
| 258 | 271 | volatile byte ign1_pin_mask; |
| 259 | -volatile byte *ign2_pin_port; | |
| 272 | +volatile PORT_TYPE *ign2_pin_port; | |
| 260 | 273 | volatile byte ign2_pin_mask; |
| 261 | -volatile byte *ign3_pin_port; | |
| 274 | +volatile PORT_TYPE *ign3_pin_port; | |
| 262 | 275 | volatile byte ign3_pin_mask; |
| 263 | -volatile byte *ign4_pin_port; | |
| 276 | +volatile PORT_TYPE *ign4_pin_port; | |
| 264 | 277 | volatile byte ign4_pin_mask; |
| 265 | -volatile byte *ign5_pin_port; | |
| 278 | +volatile PORT_TYPE *ign5_pin_port; | |
| 266 | 279 | volatile byte ign5_pin_mask; |
| 267 | -volatile byte *ign6_pin_port; | |
| 280 | +volatile PORT_TYPE *ign6_pin_port; | |
| 268 | 281 | volatile byte ign6_pin_mask; |
| 269 | -volatile byte *ign7_pin_port; | |
| 282 | +volatile PORT_TYPE *ign7_pin_port; | |
| 270 | 283 | volatile byte ign7_pin_mask; |
| 271 | -volatile byte *ign8_pin_port; | |
| 284 | +volatile PORT_TYPE *ign8_pin_port; | |
| 272 | 285 | volatile byte ign8_pin_mask; |
| 273 | 286 | |
| 274 | -volatile byte *tach_pin_port; | |
| 287 | +volatile PORT_TYPE *tach_pin_port; | |
| 275 | 288 | volatile byte tach_pin_mask; |
| 276 | -volatile byte *pump_pin_port; | |
| 289 | +volatile PORT_TYPE *pump_pin_port; | |
| 277 | 290 | volatile byte pump_pin_mask; |
| 278 | 291 | |
| 279 | -volatile byte *triggerPri_pin_port; | |
| 292 | +volatile PORT_TYPE *triggerPri_pin_port; | |
| 280 | 293 | volatile byte triggerPri_pin_mask; |
| 281 | -volatile byte *triggerSec_pin_port; | |
| 294 | +volatile PORT_TYPE *triggerSec_pin_port; | |
| 282 | 295 | volatile byte triggerSec_pin_mask; |
| 283 | 296 | |
| 284 | 297 | //These need to be here as they are used in both speeduino.ino and scheduler.ino |
| @@ -298,7 +311,7 @@ | ||
| 298 | 311 | int ignition5EndAngle = 0; |
| 299 | 312 | |
| 300 | 313 | //These are variables used across multiple files |
| 301 | -bool initialisationComplete = false; //Tracks whether the setup() functino has run completely | |
| 314 | +bool initialisationComplete = false; //Tracks whether the setup() function has run completely | |
| 302 | 315 | volatile uint16_t mainLoopCount; |
| 303 | 316 | unsigned long revolutionTime; //The time in uS that one revolution would take at current speed (The time tooth 1 was last seen, minus the time it was seen prior to that) |
| 304 | 317 | volatile unsigned long timer5_overflow_count = 0; //Increments every time counter 5 overflows. Used for the fast version of micros() |
| @@ -306,7 +319,7 @@ | ||
| 306 | 319 | uint16_t fixedCrankingOverride = 0; |
| 307 | 320 | bool clutchTrigger; |
| 308 | 321 | bool previousClutchTrigger; |
| 309 | -volatile uint16_t toothHistory[TOOTH_LOG_BUFFER]; | |
| 322 | +volatile uint32_t toothHistory[TOOTH_LOG_BUFFER]; | |
| 310 | 323 | volatile uint8_t compositeLogHistory[TOOTH_LOG_BUFFER]; |
| 311 | 324 | volatile bool fpPrimed = false; //Tracks whether or not the fuel pump priming has been completed yet |
| 312 | 325 | volatile unsigned int toothHistoryIndex = 0; |
| @@ -315,7 +328,7 @@ | ||
| 315 | 328 | byte secondaryTriggerEdge; |
| 316 | 329 | int CRANK_ANGLE_MAX = 720; |
| 317 | 330 | int CRANK_ANGLE_MAX_IGN = 360; |
| 318 | -int CRANK_ANGLE_MAX_INJ = 360; // The number of crank degrees that the system track over. 360 for wasted / timed batch and 720 for sequential | |
| 331 | +int CRANK_ANGLE_MAX_INJ = 360; //The number of crank degrees that the system track over. 360 for wasted / timed batch and 720 for sequential | |
| 319 | 332 | |
| 320 | 333 | |
| 321 | 334 | //This needs to be here because using the config page directly can prevent burning the setting |
| @@ -522,8 +535,12 @@ | ||
| 522 | 535 | |
| 523 | 536 | int8_t EMAPMin; //Must be signed |
| 524 | 537 | uint16_t EMAPMax; |
| 525 | - byte unused1_70[58]; | |
| 526 | 538 | |
| 539 | + byte fanWhenOff : 1; // Only run fan when engine is running | |
| 540 | + byte fanUnused : 7; | |
| 541 | + | |
| 542 | + byte unused1_70[57]; | |
| 543 | + | |
| 527 | 544 | #if defined(CORE_AVR) |
| 528 | 545 | }; |
| 529 | 546 | #else |
| @@ -628,7 +645,7 @@ | ||
| 628 | 645 | byte egoTPSMax; //TPS must be below this for closed loop to function |
| 629 | 646 | byte vvtPin : 6; |
| 630 | 647 | byte useExtBaro : 1; |
| 631 | - byte boostMode : 1; //Simple of full boost contrl | |
| 648 | + byte boostMode : 1; //Simple of full boost control | |
| 632 | 649 | byte boostPin : 6; |
| 633 | 650 | byte VVTasOnOff : 1; //Whether or not to use the VVT table as an on/off map |
| 634 | 651 | byte useEMAP : 1; |
| @@ -678,7 +695,7 @@ | ||
| 678 | 695 | byte iacAlgorithm : 3; //Valid values are: "None", "On/Off", "PWM", "PWM Closed Loop", "Stepper", "Stepper Closed Loop" |
| 679 | 696 | byte iacStepTime : 3; //How long to pulse the stepper for to ensure the step completes (ms) |
| 680 | 697 | byte iacChannels : 1; //How many outputs to use in PWM mode (0 = 1 channel, 1 = 2 channels) |
| 681 | - byte iacPWMdir : 1; //Directino of the PWM valve. 0 = Normal = Higher RPM with more duty. 1 = Reverse = Lower RPM with more duty | |
| 698 | + byte iacPWMdir : 1; //Direction of the PWM valve. 0 = Normal = Higher RPM with more duty. 1 = Reverse = Lower RPM with more duty | |
| 682 | 699 | |
| 683 | 700 | byte iacFastTemp; //Fast idle temp when using a simple on/off valve |
| 684 | 701 |
| @@ -692,6 +709,7 @@ | ||
| 692 | 709 | byte fanHyster; // Fan hysteresis |
| 693 | 710 | byte fanFreq; // Fan PWM frequency |
| 694 | 711 | byte fanPWMBins[4]; //Temperature Bins for the PWM fan control |
| 712 | + | |
| 695 | 713 | #if defined(CORE_AVR) |
| 696 | 714 | }; |
| 697 | 715 | #else |
| @@ -726,8 +744,9 @@ | ||
| 726 | 744 | uint16_t obd_address; //speeduino OBD diagnostic address |
| 727 | 745 | uint8_t Auxinpina[16]; //analog pin number when internal aux in use |
| 728 | 746 | uint8_t Auxinpinb[16]; // digital pin number when internal aux in use |
| 729 | - | |
| 730 | - byte unused10_152; | |
| 747 | + | |
| 748 | + byte iacStepperInv : 1; //stepper direction of travel to allow reversing. 0=normal, 1=inverted. | |
| 749 | + | |
| 731 | 750 | byte unused10_153; |
| 732 | 751 | byte unused10_154; |
| 733 | 752 | byte unused10_155; |
| @@ -3,6 +3,7 @@ | ||
| 3 | 3 | |
| 4 | 4 | #include "globals.h" |
| 5 | 5 | #include "table.h" |
| 6 | +#include BOARD_H //Note that this is not a real file, it is defined in globals.h. | |
| 6 | 7 | |
| 7 | 8 | #define IAC_ALGORITHM_NONE 0 |
| 8 | 9 | #define IAC_ALGORITHM_ONOFF 1 |
| @@ -23,38 +24,10 @@ | ||
| 23 | 24 | int targetIdleStep; //What the targetted step is |
| 24 | 25 | volatile StepperStatus stepperStatus; |
| 25 | 26 | volatile unsigned long stepStartTime; //The time the curren |
| 27 | + byte lessAirDirection; | |
| 28 | + byte moreAirDirection; | |
| 26 | 29 | }; |
| 27 | 30 | |
| 28 | -#if defined(CORE_AVR) | |
| 29 | - #define IDLE_COUNTER TCNT4 | |
| 30 | - #define IDLE_COMPARE OCR4C | |
| 31 | - | |
| 32 | - #define IDLE_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4C) | |
| 33 | - #define IDLE_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4C) | |
| 34 | - | |
| 35 | -#elif defined(CORE_TEENSY) | |
| 36 | - #define IDLE_COUNTER FTM2_CNT | |
| 37 | - #define IDLE_COMPARE FTM2_C0V | |
| 38 | - | |
| 39 | - #define IDLE_TIMER_ENABLE() FTM2_C0SC |= FTM_CSC_CHIE | |
| 40 | - #define IDLE_TIMER_DISABLE() FTM2_C0SC &= ~FTM_CSC_CHIE | |
| 41 | - | |
| 42 | -#elif defined(CORE_STM32) | |
| 43 | - #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core | |
| 44 | - #define IDLE_COUNTER (TIM1)->CNT | |
| 45 | - #define IDLE_COMPARE (TIM1)->CCR4 | |
| 46 | - | |
| 47 | - #define IDLE_TIMER_ENABLE() (TIM1)->CCER |= TIM_CCER_CC4E | |
| 48 | - #define IDLE_TIMER_DISABLE() (TIM1)->CCER &= ~TIM_CCER_CC4E | |
| 49 | - #else //libmaple core aka STM32DUINO | |
| 50 | - #define IDLE_COUNTER (TIMER1->regs).gen->CNT | |
| 51 | - #define IDLE_COMPARE (TIMER1->regs).gen->CCR4 | |
| 52 | - | |
| 53 | - #define IDLE_TIMER_ENABLE() (TIMER1->regs).gen->CCER |= TIMER_CCER_CC4E | |
| 54 | - #define IDLE_TIMER_DISABLE() (TIMER1->regs).gen->CCER &= ~TIMER_CCER_CC4E | |
| 55 | - #endif | |
| 56 | -#endif | |
| 57 | - | |
| 58 | 31 | struct table2D iacClosedLoopTable; |
| 59 | 32 | struct table2D iacPWMTable; |
| 60 | 33 | struct table2D iacStepTable; |
| @@ -68,10 +41,11 @@ | ||
| 68 | 41 | unsigned int iacStepTime; |
| 69 | 42 | unsigned int completedHomeSteps; |
| 70 | 43 | |
| 71 | -volatile byte *idle_pin_port; | |
| 44 | +volatile PORT_TYPE *idle_pin_port; | |
| 72 | 45 | volatile byte idle_pin_mask; |
| 73 | -volatile byte *idle2_pin_port; | |
| 46 | +volatile PORT_TYPE *idle2_pin_port; | |
| 74 | 47 | volatile byte idle2_pin_mask; |
| 48 | + | |
| 75 | 49 | volatile bool idle_pwm_state; |
| 76 | 50 | unsigned int idle_pwm_max_count; //Used for variable PWM frequency |
| 77 | 51 | volatile unsigned int idle_pwm_cur_value; |
| @@ -86,8 +60,6 @@ | ||
| 86 | 60 | static inline byte isStepperHomed(); |
| 87 | 61 | static inline byte checkForStepping(); |
| 88 | 62 | static inline void doStep(); |
| 89 | -#if defined (CORE_TEENSY) || defined(CORE_STM32) | |
| 90 | - static inline void idleInterrupt(); | |
| 91 | -#endif | |
| 63 | +static inline void idleInterrupt(); | |
| 92 | 64 | |
| 93 | 65 | #endif |
| @@ -27,346 +27,7 @@ | ||
| 27 | 27 | |
| 28 | 28 | #define USE_IGN_REFRESH |
| 29 | 29 | #define IGNITION_REFRESH_THRESHOLD 30 //Time in uS that the refresh functions will check to ensure there is enough time before changing the end compare |
| 30 | -#if defined(CORE_AVR) | |
| 31 | - #include <avr/interrupt.h> | |
| 32 | - #include <avr/io.h> | |
| 33 | 30 | |
| 34 | - //Refer to http://svn.savannah.nongnu.org/viewvc/trunk/avr-libc/include/avr/iomxx0_1.h?root=avr-libc&view=markup | |
| 35 | - #define FUEL1_COUNTER TCNT3 | |
| 36 | - #define FUEL2_COUNTER TCNT3 | |
| 37 | - #define FUEL3_COUNTER TCNT3 | |
| 38 | - #define FUEL4_COUNTER TCNT4 | |
| 39 | - #define FUEL5_COUNTER TCNT1 | |
| 40 | - #define FUEL6_COUNTER TCNT4 //Replaces ignition 4 | |
| 41 | - #define FUEL7_COUNTER TCNT5 //Replaces ignition 3 | |
| 42 | - #define FUEL8_COUNTER TCNT5 //Replaces ignition 2 | |
| 43 | - | |
| 44 | - #define IGN1_COUNTER TCNT5 | |
| 45 | - #define IGN2_COUNTER TCNT5 | |
| 46 | - #define IGN3_COUNTER TCNT5 | |
| 47 | - #define IGN4_COUNTER TCNT4 | |
| 48 | - #define IGN5_COUNTER TCNT1 | |
| 49 | - #define IGN6_COUNTER TCNT4 //Replaces injector 4 | |
| 50 | - #define IGN7_COUNTER TCNT3 //Replaces injector 3 | |
| 51 | - #define IGN8_COUNTER TCNT3 //Replaces injector 2 | |
| 52 | - | |
| 53 | - #define FUEL1_COMPARE OCR3A | |
| 54 | - #define FUEL2_COMPARE OCR3B | |
| 55 | - #define FUEL3_COMPARE OCR3C | |
| 56 | - #define FUEL4_COMPARE OCR4B | |
| 57 | - #define FUEL5_COMPARE OCR1C //Shared with FUEL1 | |
| 58 | - #define FUEL6_COMPARE OCR4A //Replaces ignition4 | |
| 59 | - #define FUEL7_COMPARE OCR5C //Replaces ignition3 | |
| 60 | - #define FUEL8_COMPARE OCR5B //Replaces ignition2 | |
| 61 | - | |
| 62 | - #define IGN1_COMPARE OCR5A | |
| 63 | - #define IGN2_COMPARE OCR5B | |
| 64 | - #define IGN3_COMPARE OCR5C | |
| 65 | - #define IGN4_COMPARE OCR4A | |
| 66 | - #define IGN5_COMPARE OCR1C | |
| 67 | - #define IGN6_COMPARE OCR4B //Replaces injector 4 | |
| 68 | - #define IGN7_COMPARE OCR3C //Replaces injector 3 | |
| 69 | - #define IGN8_COMPARE OCR3B //Replaces injector 2 | |
| 70 | - | |
| 71 | - #define FUEL1_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3A) //Turn on the A compare unit (ie turn on the interrupt) | |
| 72 | - #define FUEL2_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3B) //Turn on the B compare unit (ie turn on the interrupt) | |
| 73 | - #define FUEL3_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3C) //Turn on the C compare unit (ie turn on the interrupt) | |
| 74 | - #define FUEL4_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4B) //Turn on the B compare unit (ie turn on the interrupt) | |
| 75 | - #define FUEL5_TIMER_ENABLE() TIMSK1 |= (1 << OCIE1C) // | |
| 76 | - #define FUEL6_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4A) // | |
| 77 | - #define FUEL7_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5C) // | |
| 78 | - #define FUEL8_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5B) // | |
| 79 | - | |
| 80 | - #define FUEL1_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3A); //Turn off this output compare unit | |
| 81 | - #define FUEL2_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3B); //Turn off this output compare unit | |
| 82 | - #define FUEL3_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3C); //Turn off this output compare unit | |
| 83 | - #define FUEL4_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4B); //Turn off this output compare unit | |
| 84 | - #define FUEL5_TIMER_DISABLE() TIMSK1 &= ~(1 << OCIE1C); // | |
| 85 | - #define FUEL6_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4A); // | |
| 86 | - #define FUEL7_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5C); // | |
| 87 | - #define FUEL8_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5B); // | |
| 88 | - | |
| 89 | - #define IGN1_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5A) //Turn on the A compare unit (ie turn on the interrupt) | |
| 90 | - #define IGN2_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5B) //Turn on the B compare unit (ie turn on the interrupt) | |
| 91 | - #define IGN3_TIMER_ENABLE() TIMSK5 |= (1 << OCIE5C) //Turn on the C compare unit (ie turn on the interrupt) | |
| 92 | - #define IGN4_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4A) //Turn on the A compare unit (ie turn on the interrupt) | |
| 93 | - #define IGN5_TIMER_ENABLE() TIMSK1 |= (1 << OCIE1C) //Turn on the A compare unit (ie turn on the interrupt) | |
| 94 | - #define IGN6_TIMER_ENABLE() TIMSK4 |= (1 << OCIE4B) //Replaces injector 4 | |
| 95 | - #define IGN7_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3C) //Replaces injector 3 | |
| 96 | - #define IGN8_TIMER_ENABLE() TIMSK3 |= (1 << OCIE3B) //Replaces injector 2 | |
| 97 | - | |
| 98 | - #define IGN1_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5A) //Turn off this output compare unit | |
| 99 | - #define IGN2_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5B) //Turn off this output compare unit | |
| 100 | - #define IGN3_TIMER_DISABLE() TIMSK5 &= ~(1 << OCIE5C) //Turn off this output compare unit | |
| 101 | - #define IGN4_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4A) //Turn off this output compare unit | |
| 102 | - #define IGN5_TIMER_DISABLE() TIMSK1 &= ~(1 << OCIE1C) //Turn off this output compare unit | |
| 103 | - #define IGN6_TIMER_DISABLE() TIMSK4 &= ~(1 << OCIE4B) //Replaces injector 4 | |
| 104 | - #define IGN7_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3C) //Replaces injector 3 | |
| 105 | - #define IGN8_TIMER_DISABLE() TIMSK3 &= ~(1 << OCIE3B) //Replaces injector 2 | |
| 106 | - | |
| 107 | - #define MAX_TIMER_PERIOD 262140UL //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 4, as each timer tick is 4uS) | |
| 108 | - #define MAX_TIMER_PERIOD_SLOW 1048560UL //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 16, as each timer tick is 16uS) | |
| 109 | - #define uS_TO_TIMER_COMPARE(uS1) (uS1 >> 2) //Converts a given number of uS into the required number of timer ticks until that time has passed | |
| 110 | - //This is a hack until I make all the AVR timers run at the same speed | |
| 111 | - #define uS_TO_TIMER_COMPARE_SLOW(uS1) (uS1 >> 4) | |
| 112 | - | |
| 113 | -#elif defined(CORE_TEENSY) | |
| 114 | - //http://shawnhymel.com/661/learning-the-teensy-lc-interrupt-service-routines/ | |
| 115 | - #define FUEL1_COUNTER FTM0_CNT | |
| 116 | - #define FUEL2_COUNTER FTM0_CNT | |
| 117 | - #define FUEL3_COUNTER FTM0_CNT | |
| 118 | - #define FUEL4_COUNTER FTM0_CNT | |
| 119 | - #define FUEL5_COUNTER FTM3_CNT | |
| 120 | - #define FUEL6_COUNTER FTM3_CNT | |
| 121 | - #define FUEL7_COUNTER FTM3_CNT | |
| 122 | - #define FUEL8_COUNTER FTM3_CNT | |
| 123 | - | |
| 124 | - #define IGN1_COUNTER FTM0_CNT | |
| 125 | - #define IGN2_COUNTER FTM0_CNT | |
| 126 | - #define IGN3_COUNTER FTM0_CNT | |
| 127 | - #define IGN4_COUNTER FTM0_CNT | |
| 128 | - #define IGN5_COUNTER FTM3_CNT | |
| 129 | - #define IGN6_COUNTER FTM3_CNT | |
| 130 | - #define IGN7_COUNTER FTM3_CNT | |
| 131 | - #define IGN8_COUNTER FTM3_CNT | |
| 132 | - | |
| 133 | - #define FUEL1_COMPARE FTM0_C0V | |
| 134 | - #define FUEL2_COMPARE FTM0_C1V | |
| 135 | - #define FUEL3_COMPARE FTM0_C2V | |
| 136 | - #define FUEL4_COMPARE FTM0_C3V | |
| 137 | - #define FUEL5_COMPARE FTM3_C0V | |
| 138 | - #define FUEL6_COMPARE FTM3_C1V | |
| 139 | - #define FUEL7_COMPARE FTM3_C2V | |
| 140 | - #define FUEL8_COMPARE FTM3_C3V | |
| 141 | - | |
| 142 | - #define IGN1_COMPARE FTM0_C4V | |
| 143 | - #define IGN2_COMPARE FTM0_C5V | |
| 144 | - #define IGN3_COMPARE FTM0_C6V | |
| 145 | - #define IGN4_COMPARE FTM0_C7V | |
| 146 | - #define IGN5_COMPARE FTM3_C4V | |
| 147 | - #define IGN6_COMPARE FTM3_C5V | |
| 148 | - #define IGN7_COMPARE FTM3_C6V | |
| 149 | - #define IGN8_COMPARE FTM3_C7V | |
| 150 | - | |
| 151 | - #define FUEL1_TIMER_ENABLE() FTM0_C0SC |= FTM_CSC_CHIE //Write 1 to the CHIE (Channel Interrupt Enable) bit of channel 0 Status/Control | |
| 152 | - #define FUEL2_TIMER_ENABLE() FTM0_C1SC |= FTM_CSC_CHIE | |
| 153 | - #define FUEL3_TIMER_ENABLE() FTM0_C2SC |= FTM_CSC_CHIE | |
| 154 | - #define FUEL4_TIMER_ENABLE() FTM0_C3SC |= FTM_CSC_CHIE | |
| 155 | - #define FUEL5_TIMER_ENABLE() FTM3_C0SC |= FTM_CSC_CHIE | |
| 156 | - #define FUEL6_TIMER_ENABLE() FTM3_C1SC |= FTM_CSC_CHIE | |
| 157 | - #define FUEL7_TIMER_ENABLE() FTM3_C2SC |= FTM_CSC_CHIE | |
| 158 | - #define FUEL8_TIMER_ENABLE() FTM3_C3SC |= FTM_CSC_CHIE | |
| 159 | - | |
| 160 | - #define FUEL1_TIMER_DISABLE() FTM0_C0SC &= ~FTM_CSC_CHIE //Write 0 to the CHIE (Channel Interrupt Enable) bit of channel 0 Status/Control | |
| 161 | - #define FUEL2_TIMER_DISABLE() FTM0_C1SC &= ~FTM_CSC_CHIE | |
| 162 | - #define FUEL3_TIMER_DISABLE() FTM0_C2SC &= ~FTM_CSC_CHIE | |
| 163 | - #define FUEL4_TIMER_DISABLE() FTM0_C3SC &= ~FTM_CSC_CHIE | |
| 164 | - #define FUEL5_TIMER_DISABLE() FTM3_C0SC &= ~FTM_CSC_CHIE //Write 0 to the CHIE (Channel Interrupt Enable) bit of channel 0 Status/Control | |
| 165 | - #define FUEL6_TIMER_DISABLE() FTM3_C1SC &= ~FTM_CSC_CHIE | |
| 166 | - #define FUEL7_TIMER_DISABLE() FTM3_C2SC &= ~FTM_CSC_CHIE | |
| 167 | - #define FUEL8_TIMER_DISABLE() FTM3_C3SC &= ~FTM_CSC_CHIE | |
| 168 | - | |
| 169 | - #define IGN1_TIMER_ENABLE() FTM0_C4SC |= FTM_CSC_CHIE | |
| 170 | - #define IGN2_TIMER_ENABLE() FTM0_C5SC |= FTM_CSC_CHIE | |
| 171 | - #define IGN3_TIMER_ENABLE() FTM0_C6SC |= FTM_CSC_CHIE | |
| 172 | - #define IGN4_TIMER_ENABLE() FTM0_C7SC |= FTM_CSC_CHIE | |
| 173 | - #define IGN5_TIMER_ENABLE() FTM3_C4SC |= FTM_CSC_CHIE | |
| 174 | - #define IGN6_TIMER_ENABLE() FTM3_C5SC |= FTM_CSC_CHIE | |
| 175 | - #define IGN7_TIMER_ENABLE() FTM3_C6SC |= FTM_CSC_CHIE | |
| 176 | - #define IGN8_TIMER_ENABLE() FTM3_C7SC |= FTM_CSC_CHIE | |
| 177 | - | |
| 178 | - #define IGN1_TIMER_DISABLE() FTM0_C4SC &= ~FTM_CSC_CHIE | |
| 179 | - #define IGN2_TIMER_DISABLE() FTM0_C5SC &= ~FTM_CSC_CHIE | |
| 180 | - #define IGN3_TIMER_DISABLE() FTM0_C6SC &= ~FTM_CSC_CHIE | |
| 181 | - #define IGN4_TIMER_DISABLE() FTM0_C7SC &= ~FTM_CSC_CHIE | |
| 182 | - #define IGN5_TIMER_DISABLE() FTM3_C4SC &= ~FTM_CSC_CHIE | |
| 183 | - #define IGN6_TIMER_DISABLE() FTM3_C5SC &= ~FTM_CSC_CHIE | |
| 184 | - #define IGN7_TIMER_DISABLE() FTM3_C6SC &= ~FTM_CSC_CHIE | |
| 185 | - #define IGN8_TIMER_DISABLE() FTM3_C7SC &= ~FTM_CSC_CHIE | |
| 186 | - | |
| 187 | - #define MAX_TIMER_PERIOD 139808 // 2.13333333uS * 65535 | |
| 188 | - #define MAX_TIMER_PERIOD_SLOW 139808 | |
| 189 | - #define uS_TO_TIMER_COMPARE(uS) ((uS * 15) >> 5) //Converts a given number of uS into the required number of timer ticks until that time has passed. | |
| 190 | - //Hack compatibility with AVR timers that run at different speeds | |
| 191 | - #define uS_TO_TIMER_COMPARE_SLOW(uS) ((uS * 15) >> 5) | |
| 192 | - | |
| 193 | -#elif defined(CORE_STM32) | |
| 194 | - #define MAX_TIMER_PERIOD 131070 //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 2, as each timer tick is 2uS) | |
| 195 | - #define MAX_TIMER_PERIOD_SLOW 131070 //The longest period of time (in uS) that the timer can permit (IN this case it is 65535 * 2, as each timer tick is 2uS) | |
| 196 | - #define uS_TO_TIMER_COMPARE(uS) (uS >> 1) //Converts a given number of uS into the required number of timer ticks until that time has passed. | |
| 197 | - #define uS_TO_TIMER_COMPARE_SLOW(uS) (uS >> 1) //Converts a given number of uS into the required number of timer ticks until that time has passed. | |
| 198 | - #if defined(ARDUINO_ARCH_STM32) // STM32GENERIC core | |
| 199 | - #include "HardwareTimer.h" | |
| 200 | - #define FUEL1_COUNTER (TIM2)->CNT | |
| 201 | - #define FUEL2_COUNTER (TIM2)->CNT | |
| 202 | - #define FUEL3_COUNTER (TIM2)->CNT | |
| 203 | - #define FUEL4_COUNTER (TIM2)->CNT | |
| 204 | - | |
| 205 | - #define FUEL1_COMPARE (TIM2)->CCR1 | |
| 206 | - #define FUEL2_COMPARE (TIM2)->CCR2 | |
| 207 | - #define FUEL3_COMPARE (TIM2)->CCR3 | |
| 208 | - #define FUEL4_COMPARE (TIM2)->CCR4 | |
| 209 | - | |
| 210 | - #define IGN1_COUNTER (TIM3)->CNT | |
| 211 | - #define IGN2_COUNTER (TIM3)->CNT | |
| 212 | - #define IGN3_COUNTER (TIM3)->CNT | |
| 213 | - #define IGN4_COUNTER (TIM3)->CNT | |
| 214 | - | |
| 215 | - #define IGN1_COMPARE (TIM3)->CCR1 | |
| 216 | - #define IGN2_COMPARE (TIM3)->CCR2 | |
| 217 | - #define IGN3_COMPARE (TIM3)->CCR3 | |
| 218 | - #define IGN4_COMPARE (TIM3)->CCR4 | |
| 219 | - | |
| 220 | -#ifndef SMALL_FLASH_MODE | |
| 221 | - #define FUEL5_COUNTER (TIM5)->CNT | |
| 222 | - #define FUEL6_COUNTER (TIM5)->CNT | |
| 223 | - #define FUEL7_COUNTER (TIM5)->CNT | |
| 224 | - #define FUEL8_COUNTER (TIM5)->CNT | |
| 225 | - | |
| 226 | - #define FUEL5_COMPARE (TIM5)->CCR1 | |
| 227 | - #define FUEL6_COMPARE (TIM5)->CCR2 | |
| 228 | - #define FUEL7_COMPARE (TIM5)->CCR3 | |
| 229 | - #define FUEL8_COMPARE (TIM5)->CCR4 | |
| 230 | - | |
| 231 | - #define IGN5_COUNTER (TIM4)->CNT | |
| 232 | - #define IGN6_COUNTER (TIM4)->CNT | |
| 233 | - #define IGN7_COUNTER (TIM4)->CNT | |
| 234 | - #define IGN8_COUNTER (TIM4)->CNT | |
| 235 | - | |
| 236 | - #define IGN5_COMPARE (TIM4)->CCR1 | |
| 237 | - #define IGN6_COMPARE (TIM4)->CCR2 | |
| 238 | - #define IGN7_COMPARE (TIM4)->CCR3 | |
| 239 | - #define IGN8_COMPARE (TIM4)->CCR4 | |
| 240 | -#endif | |
| 241 | - //https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/754bc2969921f1ef262bd69e7faca80b19db7524/STM32F1/system/libmaple/include/libmaple/timer.h#L444 | |
| 242 | - #define FUEL1_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC1E | |
| 243 | - #define FUEL2_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC2E | |
| 244 | - #define FUEL3_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC3E | |
| 245 | - #define FUEL4_TIMER_ENABLE() (TIM2)->CCER |= TIM_CCER_CC4E | |
| 246 | - | |
| 247 | - #define FUEL1_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC1E | |
| 248 | - #define FUEL2_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC2E | |
| 249 | - #define FUEL3_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC3E | |
| 250 | - #define FUEL4_TIMER_DISABLE() (TIM2)->CCER &= ~TIM_CCER_CC4E | |
| 251 | - | |
| 252 | - #define IGN1_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC1E | |
| 253 | - #define IGN2_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC2E | |
| 254 | - #define IGN3_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC3E | |
| 255 | - #define IGN4_TIMER_ENABLE() (TIM3)->CCER |= TIM_CCER_CC4E | |
| 256 | - | |
| 257 | - #define IGN1_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC1E | |
| 258 | - #define IGN2_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC2E | |
| 259 | - #define IGN3_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC3E | |
| 260 | - #define IGN4_TIMER_DISABLE() (TIM3)->CCER &= ~TIM_CCER_CC4E | |
| 261 | - | |
| 262 | -#ifndef SMALL_FLASH_MODE | |
| 263 | - #define FUEL5_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC1E | |
| 264 | - #define FUEL6_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC2E | |
| 265 | - #define FUEL7_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC3E | |
| 266 | - #define FUEL8_TIMER_ENABLE() (TIM5)->CCER |= TIM_CCER_CC4E | |
| 267 | - | |
| 268 | - #define FUEL5_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC1E | |
| 269 | - #define FUEL6_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC2E | |
| 270 | - #define FUEL7_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC3E | |
| 271 | - #define FUEL8_TIMER_DISABLE() (TIM5)->CCER &= ~TIM_CCER_CC4E | |
| 272 | - | |
| 273 | - #define IGN5_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC1E | |
| 274 | - #define IGN6_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC2E | |
| 275 | - #define IGN7_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC3E | |
| 276 | - #define IGN8_TIMER_ENABLE() (TIM4)->CCER |= TIM_CCER_CC4E | |
| 277 | - | |
| 278 | - #define IGN5_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC1E | |
| 279 | - #define IGN6_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC2E | |
| 280 | - #define IGN7_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC3E | |
| 281 | - #define IGN8_TIMER_DISABLE() (TIM4)->CCER &= ~TIM_CCER_CC4E | |
| 282 | -#endif | |
| 283 | - #else //libmaple core aka STM32DUINO | |
| 284 | - #define FUEL1_COUNTER (TIMER2->regs).gen->CNT | |
| 285 | - #define FUEL2_COUNTER (TIMER2->regs).gen->CNT | |
| 286 | - #define FUEL3_COUNTER (TIMER2->regs).gen->CNT | |
| 287 | - #define FUEL4_COUNTER (TIMER2->regs).gen->CNT | |
| 288 | - | |
| 289 | - #define FUEL1_COMPARE (TIMER2->regs).gen->CCR1 | |
| 290 | - #define FUEL2_COMPARE (TIMER2->regs).gen->CCR2 | |
| 291 | - #define FUEL3_COMPARE (TIMER2->regs).gen->CCR3 | |
| 292 | - #define FUEL4_COMPARE (TIMER2->regs).gen->CCR4 | |
| 293 | - | |
| 294 | - #define IGN1_COUNTER (TIMER3->regs).gen->CNT | |
| 295 | - #define IGN2_COUNTER (TIMER3->regs).gen->CNT | |
| 296 | - #define IGN3_COUNTER (TIMER3->regs).gen->CNT | |
| 297 | - #define IGN4_COUNTER (TIMER3->regs).gen->CNT | |
| 298 | - | |
| 299 | - #define IGN1_COMPARE (TIMER3->regs).gen->CCR1 | |
| 300 | - #define IGN2_COMPARE (TIMER3->regs).gen->CCR2 | |
| 301 | - #define IGN3_COMPARE (TIMER3->regs).gen->CCR3 | |
| 302 | - #define IGN4_COMPARE (TIMER3->regs).gen->CCR4 | |
| 303 | - | |
| 304 | -#ifndef SMALL_FLASH_MODE | |
| 305 | - #define FUEL5_COUNTER (TIMER5->regs).gen->CNT | |
| 306 | - #define FUEL6_COUNTER (TIMER5->regs).gen->CNT | |
| 307 | - #define FUEL7_COUNTER (TIMER5->regs).gen->CNT | |
| 308 | - #define FUEL8_COUNTER (TIMER5->regs).gen->CNT | |
| 309 | - | |
| 310 | - #define FUEL5_COMPARE (TIMER5->regs).gen->CCR1 | |
| 311 | - #define FUEL6_COMPARE (TIMER5->regs).gen->CCR2 | |
| 312 | - #define FUEL7_COMPARE (TIMER5->regs).gen->CCR3 | |
| 313 | - #define FUEL8_COMPARE (TIMER5->regs).gen->CCR4 | |
| 314 | - | |
| 315 | - #define IGN5_COUNTER (TIMER4->regs).gen->CNT | |
| 316 | - #define IGN6_COUNTER (TIMER4->regs).gen->CNT | |
| 317 | - #define IGN7_COUNTER (TIMER4->regs).gen->CNT | |
| 318 | - #define IGN8_COUNTER (TIMER4->regs).gen->CNT | |
| 319 | - | |
| 320 | - #define IGN5_COMPARE (TIMER4->regs).gen->CCR1 | |
| 321 | - #define IGN6_COMPARE (TIMER4->regs).gen->CCR2 | |
| 322 | - #define IGN7_COMPARE (TIMER4->regs).gen->CCR3 | |
| 323 | - #define IGN8_COMPARE (TIMER4->regs).gen->CCR4 | |
| 324 | -#endif | |
| 325 | - //https://github.com/rogerclarkmelbourne/Arduino_STM32/blob/754bc2969921f1ef262bd69e7faca80b19db7524/STM32F1/system/libmaple/include/libmaple/timer.h#L444 | |
| 326 | - #define FUEL1_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC1E | |
| 327 | - #define FUEL2_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC2E | |
| 328 | - #define FUEL3_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC3E | |
| 329 | - #define FUEL4_TIMER_ENABLE() (TIMER2->regs).gen->CCER |= TIMER_CCER_CC4E | |
| 330 | - | |
| 331 | - #define FUEL1_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC1E | |
| 332 | - #define FUEL2_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC2E | |
| 333 | - #define FUEL3_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC3E | |
| 334 | - #define FUEL4_TIMER_DISABLE() (TIMER2->regs).gen->CCER &= ~TIMER_CCER_CC4E | |
| 335 | - | |
| 336 | - #define IGN1_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC1E | |
| 337 | - #define IGN2_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC2E | |
| 338 | - #define IGN3_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC3E | |
| 339 | - #define IGN4_TIMER_DISABLE() (TIMER3->regs).gen->CCER &= ~TIMER_CCER_CC4E | |
| 340 | - | |
| 341 | - #define IGN1_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC1E | |
| 342 | - #define IGN2_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC2E | |
| 343 | - #define IGN3_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC3E | |
| 344 | - #define IGN4_TIMER_ENABLE() (TIMER3->regs).gen->CCER |= TIMER_CCER_CC4E | |
| 345 | - | |
| 346 | -#ifndef SMALL_FLASH_MODE | |
| 347 | - #define FUEL5_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC1E | |
| 348 | - #define FUEL6_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC2E | |
| 349 | - #define FUEL7_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC3E | |
| 350 | - #define FUEL8_TIMER_ENABLE() (TIMER5->regs).gen->CCER |= TIMER_CCER_CC4E | |
| 351 | - | |
| 352 | - #define IGN5_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC1E | |
| 353 | - #define IGN6_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC2E | |
| 354 | - #define IGN7_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC3E | |
| 355 | - #define IGN8_TIMER_ENABLE() (TIMER4->regs).gen->CCER |= TIMER_CCER_CC4E | |
| 356 | - | |
| 357 | - #define FUEL5_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC1E | |
| 358 | - #define FUEL6_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC2E | |
| 359 | - #define FUEL7_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC3E | |
| 360 | - #define FUEL8_TIMER_DISABLE() (TIMER5->regs).gen->CCER &= ~TIMER_CCER_CC4E | |
| 361 | - | |
| 362 | - #define IGN5_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC1E | |
| 363 | - #define IGN6_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC2E | |
| 364 | - #define IGN7_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC3E | |
| 365 | - #define IGN8_TIMER_DISABLE() (TIMER4->regs).gen->CCER &= ~TIMER_CCER_CC4E | |
| 366 | -#endif | |
| 367 | - #endif | |
| 368 | -#endif | |
| 369 | - | |
| 370 | 31 | void initialiseSchedulers(); |
| 371 | 32 | void setFuelSchedule1(unsigned long timeout, unsigned long duration); |
| 372 | 33 | void setFuelSchedule2(unsigned long timeout, unsigned long duration); |
| @@ -10,4 +10,67 @@ | ||
| 10 | 10 | uint16_t calculateInjector4StartAngle(unsigned int); |
| 11 | 11 | uint16_t calculateInjector4StartAngle(unsigned int); |
| 12 | 12 | |
| 13 | +struct config2 configPage2; | |
| 14 | +struct config4 configPage4; //Done | |
| 15 | +struct config6 configPage6; | |
| 16 | +struct config9 configPage9; | |
| 17 | +struct config10 configPage10; | |
| 18 | + | |
| 19 | +uint16_t req_fuel_uS, inj_opentime_uS; | |
| 20 | +uint16_t staged_req_fuel_mult_pri; | |
| 21 | +uint16_t staged_req_fuel_mult_sec; | |
| 22 | + | |
| 23 | +bool ignitionOn = false; //The current state of the ignition system | |
| 24 | +bool fuelOn = false; //The current state of the ignition system | |
| 25 | + | |
| 26 | +byte cltCalibrationTable[CALIBRATION_TABLE_SIZE]; | |
| 27 | +byte iatCalibrationTable[CALIBRATION_TABLE_SIZE]; | |
| 28 | +byte o2CalibrationTable[CALIBRATION_TABLE_SIZE]; | |
| 29 | + | |
| 30 | +unsigned long counter; | |
| 31 | +unsigned long currentLoopTime; //The time the current loop started (uS) | |
| 32 | +unsigned long previousLoopTime; //The time the previous loop started (uS) | |
| 33 | + | |
| 34 | +byte maxIgnOutputs = 1; //Used for rolling rev limiter | |
| 35 | +byte curRollingCut = 0; //Rolling rev limiter, current ignition channel being cut | |
| 36 | +byte rollingCutCounter = 0; //how many times (revolutions) the ignition has been cut in a row | |
| 37 | +uint32_t rollingCutLastRev = 0; //Tracks whether we're on the same or a different rev for the rolling cut | |
| 38 | + | |
| 39 | + | |
| 40 | +unsigned long secCounter; //The next time to incremen 'runSecs' counter. | |
| 41 | +int channel1IgnDegrees; //The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones) | |
| 42 | +int channel2IgnDegrees; //The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC | |
| 43 | +int channel3IgnDegrees; //The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC | |
| 44 | +int channel4IgnDegrees; //The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC | |
| 45 | +int channel5IgnDegrees; //The number of crank degrees until cylinder 5 is at TDC | |
| 46 | +int channel6IgnDegrees; //The number of crank degrees until cylinder 6 is at TDC | |
| 47 | +int channel7IgnDegrees; //The number of crank degrees until cylinder 7 is at TDC | |
| 48 | +int channel8IgnDegrees; //The number of crank degrees until cylinder 8 is at TDC | |
| 49 | +int channel1InjDegrees; //The number of crank degrees until cylinder 1 is at TDC (This is obviously 0 for virtually ALL engines, but there's some weird ones) | |
| 50 | +int channel2InjDegrees; //The number of crank degrees until cylinder 2 (and 5/6/7/8) is at TDC | |
| 51 | +int channel3InjDegrees; //The number of crank degrees until cylinder 3 (and 5/6/7/8) is at TDC | |
| 52 | +int channel4InjDegrees; //The number of crank degrees until cylinder 4 (and 5/6/7/8) is at TDC | |
| 53 | +int channel5InjDegrees; //The number of crank degrees until cylinder 5 is at TDC | |
| 54 | +int channel6InjDegrees; //The number of crank degrees until cylinder 6 is at TDC | |
| 55 | +int channel7InjDegrees; //The number of crank degrees until cylinder 7 is at TDC | |
| 56 | +int channel8InjDegrees; //The number of crank degrees until cylinder 8 is at TDC | |
| 57 | + | |
| 58 | +//These are the functions the get called to begin and end the ignition coil charging. They are required for the various spark output modes | |
| 59 | +void (*ign1StartFunction)(); | |
| 60 | +void (*ign1EndFunction)(); | |
| 61 | +void (*ign2StartFunction)(); | |
| 62 | +void (*ign2EndFunction)(); | |
| 63 | +void (*ign3StartFunction)(); | |
| 64 | +void (*ign3EndFunction)(); | |
| 65 | +void (*ign4StartFunction)(); | |
| 66 | +void (*ign4EndFunction)(); | |
| 67 | +void (*ign5StartFunction)(); | |
| 68 | +void (*ign5EndFunction)(); | |
| 69 | +void (*ign6StartFunction)(); | |
| 70 | +void (*ign6EndFunction)(); | |
| 71 | +void (*ign7StartFunction)(); | |
| 72 | +void (*ign7EndFunction)(); | |
| 73 | +void (*ign8StartFunction)(); | |
| 74 | +void (*ign8EndFunction)(); | |
| 75 | + | |
| 13 | 76 | #endif |
| @@ -31,7 +31,7 @@ | ||
| 31 | 31 | #define FastCRC_tables |
| 32 | 32 | #include "inttypes.h" |
| 33 | 33 | |
| 34 | -#if defined(__AVR__) || defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(_VARIANT_ARDUINO_STM32_) | |
| 34 | +#if defined(__AVR__) || defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(_VARIANT_ARDUINO_STM32_) || defined(__SAMD21G18A__) | |
| 35 | 35 | #include <avr/pgmspace.h> |
| 36 | 36 | #else |
| 37 | 37 | #include <pgmspace.h> |
| @@ -1,6 +1,8 @@ | ||
| 1 | 1 | #ifndef STORAGE_H |
| 2 | 2 | #define STORAGE_H |
| 3 | 3 | |
| 4 | +#include "globals.h" | |
| 5 | + | |
| 4 | 6 | void writeAllConfig(); |
| 5 | 7 | void writeConfig(byte); |
| 6 | 8 | void loadConfig(); |
| @@ -7,6 +9,13 @@ | ||
| 7 | 9 | void loadCalibration(); |
| 8 | 10 | void writeCalibration(); |
| 9 | 11 | |
| 12 | +//These are utility functions that prevent other files from having to use EEPROM.h directly | |
| 13 | +byte readLastBaro(); | |
| 14 | +void storeLastBaro(byte); | |
| 15 | +void storeCalibrationValue(byte, byte); | |
| 16 | +byte readEEPROMVersion(); | |
| 17 | +void storeEEPROMVersion(byte); | |
| 18 | + | |
| 10 | 19 | #if defined(CORE_STM32) || defined(CORE_TEENSY) |
| 11 | 20 | #define EEPROM_MAX_WRITE_BLOCK 64 //The maximum number of write operations that will be performed in one go. If we try to write to the EEPROM too fast (Each write takes ~3ms) then the rest of the system can hang) |
| 12 | 21 | #else |
| @@ -31,7 +31,8 @@ | ||
| 31 | 31 | byte cacheTime; //TRacks when the last cache value was set so it can expire after x seconds. A timeout is required to pickup when a tuning value is changed, otherwise the old cached value will continue to be returned as the X value isn't changing. |
| 32 | 32 | }; |
| 33 | 33 | |
| 34 | -void table2D_setSize(struct table2D targetTable, byte newSize); | |
| 34 | +//void table2D_setSize(struct table2D targetTable, byte newSize); | |
| 35 | +void table2D_setSize(struct table2D, byte); | |
| 35 | 36 | |
| 36 | 37 | struct table3D { |
| 37 | 38 |
| @@ -49,7 +50,8 @@ | ||
| 49 | 50 | byte lastYMax, lastYMin; |
| 50 | 51 | }; |
| 51 | 52 | |
| 52 | -void table3D_setSize(struct table3D *targetTable, byte newSize); | |
| 53 | +//void table3D_setSize(struct table3D *targetTable, byte); | |
| 54 | +void table3D_setSize(struct table3D *targetTable, byte); | |
| 53 | 55 | |
| 54 | 56 | /* |
| 55 | 57 | 3D Tables have an origin (0,0) in the top left hand corner. Vertical axis is expressed first. |
| @@ -29,14 +29,6 @@ | ||
| 29 | 29 | volatile uint16_t lastRPM_100ms; //Need to record this for rpmDOT calculation |
| 30 | 30 | volatile uint16_t last250msLoopCount = 1000; //Set to effectively random number on startup. Just need this to be different to what mainLoopCount equals initially (Probably 0) |
| 31 | 31 | |
| 32 | -#if defined(TIMER5_MICROS) | |
| 33 | - //#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 | |
| 34 | - #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. | |
| 35 | - static inline unsigned long micros_safe(); //A version of micros() that is interrupt safe | |
| 36 | -#else | |
| 37 | - #define micros_safe() micros() //If the timer5 method is not used, the micros_safe() macro is simply an alias for the normal micros() | |
| 38 | -#endif | |
| 39 | - | |
| 40 | 32 | #if defined (CORE_TEENSY) |
| 41 | 33 | IntervalTimer lowResTimer; |
| 42 | 34 | void oneMSInterval(); |
| @@ -6,49 +6,8 @@ | ||
| 6 | 6 | |
| 7 | 7 | #include <Arduino.h> |
| 8 | 8 | |
| 9 | -uint16_t freeRam (); | |
| 10 | -void setPinMapping(byte boardID); | |
| 11 | -void initialiseTriggers(); | |
| 9 | +void setResetControlPinState(); | |
| 10 | +byte pinTranslate(byte); | |
| 12 | 11 | |
| 13 | -//This is dumb, but it'll do for now to get things compiling | |
| 14 | -#if defined(CORE_STM32) | |
| 15 | - //STM32F1/variants/.../board.cpp | |
| 16 | - #if defined (STM32F4) | |
| 17 | - #define A0 PA0 | |
| 18 | - #define A1 PA1 | |
| 19 | - #define A2 PA2 | |
| 20 | - #define A3 PA3 | |
| 21 | - #define A4 PA4 | |
| 22 | - #define A5 PA5 | |
| 23 | - #define A6 PA6 | |
| 24 | - #define A7 PA7 | |
| 25 | - #define A8 PB0 | |
| 26 | - #define A9 PB1 | |
| 27 | - #define A10 PC0 | |
| 28 | - #define A11 PC1 | |
| 29 | - #define A12 PC2 | |
| 30 | - #define A13 PC3 | |
| 31 | - #define A14 PC4 | |
| 32 | - #define A15 PC5 | |
| 33 | - #else | |
| 34 | - #define A0 PB0 | |
| 35 | - #define A1 PA7 | |
| 36 | - #define A2 PA6 | |
| 37 | - #define A3 PA5 | |
| 38 | - #define A4 PA4 | |
| 39 | - #define A5 PA3 | |
| 40 | - #define A6 PA2 | |
| 41 | - #define A7 PA1 | |
| 42 | - #define A8 PA0 | |
| 43 | - //STM32F1 have only 9 12bit adc | |
| 44 | - #define A9 PB0 | |
| 45 | - #define A10 PA7 | |
| 46 | - #define A11 PA6 | |
| 47 | - #define A12 PA5 | |
| 48 | - #define A13 PA4 | |
| 49 | - #define A14 PA3 | |
| 50 | - #define A15 PA2 | |
| 51 | - #endif | |
| 52 | -#endif | |
| 53 | 12 | |
| 54 | 13 | #endif // UTILS_H |