• R/O
  • SSH
  • HTTPS

Commit

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

PJSC(Pump Jet Solenoid Controller)はArduinoを使用したバイク用燃料噴射コントローラです。このプロジェクトは、オープンソースECUプロジェクト『Speeduino』をベースにしています。


Commit MetaInfo

Revision31 (tree)
Time2019-02-16 20:02:50
Authormaharu

Log Message

Speeduino Feb.2019 version.

Change Summary

Incremental Difference

--- branches/Speeduino/README.md (revision 30)
+++ branches/Speeduino/README.md (revision 31)
@@ -1,8 +1,8 @@
11
22 | | |
33 | --- | --- |
4-| **Dev Status** | ![Mostly stable](https://img.shields.io/badge/Status-Mostly--Stable-orange.svg) |
5-| **Latest Release** | [![GitHub release](https://img.shields.io/github/release/noisymime/speeduino.svg)](https://github.com/noisymime/speeduino/releases/tag/201808) |
4+| **Dev Status** | ![Stable](https://img.shields.io/badge/Status-Stable-green.svg) |
5+| **Latest Release** | [![GitHub release](https://img.shields.io/github/release/noisymime/speeduino.svg)](https://github.com/noisymime/speeduino/releases/tag/201810) |
66 | **MISRA Status** | [![MISRA](https://img.shields.io/travis/noisymime/speeduino.svg)](https://travis-ci.org/noisymime/speeduino/) |
77 | **Feature Bounties** | [![Bountysource](https://img.shields.io/bountysource/team/speeduino/activity.svg)](https://www.bountysource.com/teams/speeduino)
88
@@ -18,7 +18,7 @@
1818
1919 Q: Arduino ECU,pffft, heard THAT before. Does this one actually work?
2020
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.
2222
2323 ========================================================================
2424
@@ -30,7 +30,7 @@
3030
3131 Q: Target platform?
3232
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.
3434
3535 ========================================================================
3636
--- branches/Speeduino/platformio.ini (revision 30)
+++ branches/Speeduino/platformio.ini (revision 31)
@@ -30,7 +30,7 @@
3030 ;lib_deps = EEPROM
3131
3232 [env:genericSTM32F103RB]
33-platform = ststm32
33+platform = ststm32@~4.5.0
3434 framework = arduino
3535 ; framework-arduinoststm32
3636 board = genericSTM32F103RB
@@ -37,6 +37,24 @@
3737 lib_deps = EEPROM
3838 build_flags = -fpermissive -std=gnu++11
3939
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+
4058 [env:bluepill_f103c8]
4159 platform = ststm32
4260 framework = arduino
@@ -44,8 +62,18 @@
4462 board = bluepill_f103c8
4563 lib_deps = EEPROM
4664 ;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
4866
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+
4977 ;Support for the stm32f407 doesn't look ready in platformio yet
5078 ;[env:genericSTM32F407VE]
5179 ;platform = https://github.com/maichaell/platform-ststm32
--- branches/Speeduino/reference/hardware/VR Conditioner/BOM/Bom-pcbng.csv (revision 30)
+++ branches/Speeduino/reference/hardware/VR Conditioner/BOM/Bom-pcbng.csv (revision 31)
@@ -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
1515 C1,CC0805ZRY5V9BB104
\ No newline at end of file
--- branches/Speeduino/reference/hardware/VR Conditioner/BOM/Bom-seeedstudio-v3.csv (revision 30)
+++ branches/Speeduino/reference/hardware/VR Conditioner/BOM/Bom-seeedstudio-v3.csv (revision 31)
@@ -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
88 C1,CC0805ZRY5V9BB104,1
\ No newline at end of file
--- branches/Speeduino/reference/hardware/VR Conditioner/BOM/Bom-seeedstudio.csv (revision 30)
+++ branches/Speeduino/reference/hardware/VR Conditioner/BOM/Bom-seeedstudio.csv (revision 31)
@@ -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
88 C1,CC0805ZRY5V9BB104,1
\ No newline at end of file
--- branches/Speeduino/reference/speeduino.ini (revision 30)
+++ branches/Speeduino/reference/speeduino.ini (revision 31)
@@ -6,7 +6,7 @@
66 MTversion = 2.25
77
88 queryCommand = "Q"
9- signature = "speeduino 201810"
9+ signature = "speeduino 201902"
1010 versionInfo = "S" ;This info is what is displayed to user
1111
1212 [TunerStudio]
@@ -151,7 +151,8 @@
151151
152152 endianness = little
153153 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
155156
156157 ;burnCommand = "B"
157158 ;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 @@
181182 #define PIN_OUT16inv = "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
182183 #define PIN_16inv = "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID", "INVALID"
183184
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
185186 #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"
186187 #define ANALOG_DIG_PIN_LIST = $DIGITAL_PIN, $ANALOG_PIN
187188 #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 @@
196197 #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"
197198 #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
198199
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
208200
209201
210-
211202 ;--------------------------------------------------
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
214205 ;--------------------------------------------------
215-page = 2
206+page = 1
216207 unused2-1 = scalar, S08, 0, "kPa", 1.0, 0.0, -127, 127, 0
217208 unused2-2 = scalar, U08, 1, "kPa", 1.0, 0.0, 0.0, 255, 0
218209 asePct = scalar, U08, 2, "%", 1.0, 0.0, 0.0, 95.0, 0
@@ -304,9 +295,22 @@
304295 baroMax = scalar, U16, 65, "kpa", 1.0, 0.0, 0.0, 25500, 0
305296 EMAPMin = scalar, S08, 67, "kpa", 1.0, 0.0, -100, 127.0, 0
306297 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
308298
299+ fanWhenOff = bits, U08, 70, [0:0], "No", "Yes"
300+ unused_fan_bits = bits, U08, 70,[1:7]
309301
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+
310314 ;--------------------------------------------------
311315 ;Start Ignition table (Page 3)
312316 ;--------------------------------------------------
@@ -313,7 +317,6 @@
313317 page = 3
314318 advTable1 = array, U08, 0,[16x16], "deg", 1.0, -40, -40, 215.0, 0
315319 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
317320 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 :(
318321
319322 ;--------------------------------------------------
@@ -532,7 +535,7 @@
532535 ; Begin fan control vairables
533536 fanInv = bits, U08, 120, [0:0], "No", "Yes"
534537 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"
536539 #if CELSIUS
537540 fanSP = scalar, U08, 121, "C", 1.0, -40, -40, 215.0, 0
538541 fanHyster = scalar, U08, 122, "C", 1.0, 0.0, 0.0, 40, 0
@@ -852,7 +855,9 @@
852855 ;unused10_150 = scalar, U08, 150, "", 1, 0, 0, 255, 0
853856 ;unused10_151 = scalar, U08, 151, "", 1, 0, 0, 255, 0
854857 ;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+
856861 unused10_154 = scalar, U08, 154, "", 1, 0, 0, 255, 0
857862 unused10_155 = scalar, U08, 155, "", 1, 0, 0, 255, 0
858863 unused10_156 = scalar, U08, 156, "", 1, 0, 0, 255, 0
@@ -1351,6 +1356,7 @@
13511356 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"
13521357 iacFastTemp = "Below this temperature, the idle output will be high (On). Above this temperature, it will turn off."
13531358 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"
13541360
13551361 oddfire2 = "The ATDC angle of channel 2 for oddfire engines. This is relative to the TDC angle of channel 1"
13561362 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 @@
17051711
17061712 dialog = fanSettings,"Fan Settings",7
17071713 field = "Fan Mode", fanEnable
1714+ field = "Fan when off", fanWhenOff, { fanEnable }
17081715 field = "Fan output pin", fanPin, { fanEnable }
17091716 field = "Fan Output Inverted", fanInv , { fanEnable }
17101717 field = "Fan temperature SP", fanSP, { fanEnable }
@@ -1714,6 +1721,7 @@
17141721 field = "Step time (ms)", iacStepTime, { iacAlgorithm == 4 || iacAlgorithm == 5 }
17151722 field = "Home steps", iacStepHome, { iacAlgorithm == 4 || iacAlgorithm == 5 }
17161723 field = "Minimum Steps", iacStepHyster, { iacAlgorithm == 4 || iacAlgorithm == 5 }
1724+ field = "Stepper Inverted", iacStepperInv, { iacAlgorithm == 4 || iacAlgorithm == 5 }
17171725
17181726 dialog = pwm_idle, "PWM Idle"
17191727 field = "Number of outputs", iacChannels, { iacAlgorithm == 2 || iacAlgorithm == 3 }
@@ -1739,7 +1747,8 @@
17391747 dialog = idleUpSettings, "Idle Up Settings"
17401748 field = "Idle Up Enabled", idleUpEnabled
17411749 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 }
17431752
17441753 dialog = fuelpump, "Fuel pump"
17451754 field = "Fuel pump pin", fuelPumpPin
@@ -1801,7 +1810,7 @@
18011810 field = "Cranking advance Angle", CrankAng
18021811 field = "Spark Outputs triggers", IgInv
18031812 field = ""
1804- field = "Enabled Fixed/Locked timing", fixAngEnable
1813+ field = "Enabled Fixed/Locked timing", fixAngEnable
18051814 field = "Fixed Angle", FixAng, { fixAngEnable }
18061815 field = "#Note: During cranking the fixed/locked timing angle is overriden by the Cranking advance angle value above"
18071816 field = ""
@@ -1895,8 +1904,8 @@
18951904 field = "Nitrous is armed when pin is", n2o_pin_polarity,{ n2o_enable > 0 }
18961905 field = "Minimum CLT", n2o_minCLT, { n2o_enable > 0 }
18971906 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 }
19001909
19011910 dialog = NitrousControl, "Nitrous"
19021911 panel = NitrousMain, North
@@ -2482,7 +2491,7 @@
24822491 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)))}
24832492 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)}
24842493 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 )))}
24862495 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 )))}
24872496
24882497 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 @@
31733182 softlimitOn = bits, U08, 31, [3:3]
31743183 boostCutSpark = bits, U08, 31, [4:4]
31753184 error = bits, U08, 31, [5:5]
3176- idle = bits, U08, 31, [6:6]
3185+ idleControlOn = bits, U08, 31, [6:6]
31773186 sync = bits, U08, 31, [7:7]
31783187 rpmDOT = scalar, S16, 32, "rpm/s", 1.000, 0.000
31793188 flex = scalar, U08, 34, "%", 1.000, 0.000
@@ -3345,16 +3354,16 @@
33453354 startCommand = "H"
33463355 stopCommand = "h"
33473356 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 }
33503359 ;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)
33523361
33533362 ;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
33553364
33563365 ;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"
33583367
33593368 loggerDef = compositeLogger, "Composite Logger", composite
33603369 startCommand = "J"
@@ -3361,7 +3370,7 @@
33613370 stopCommand = "j"
33623371 dataReadCommand = "T" ; Basic TS command format. Note that this is shared with the composite logger. Firmware detects which log is currently running
33633372 dataReadTimeout = 5000 ; time in ms
3364- dataReadyCondition = { toothLog1Ready }
3373+ dataReadyCondition = { toothLog1Ready == 1 }
33653374 ;dataLength = 256 ; in bytes, including headers, footers and data (not used)
33663375 ;dataLength = 320 ; in bytes, including headers, footers and data (not used)
33673376
@@ -3373,10 +3382,10 @@
33733382 recordField = secLevel, "SecLevel", 1, 1, 1.0, "Flag"
33743383 recordField = trigger, "Trigger", 2, 1, 1.0, "Flag"
33753384 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"
33773386
33783387 ; hidden calcField serves as intermediate variable
3379- calcField = maxTime, "MaxTime", "ms", { maxValue(refTime) }, hidden
3388+ calcField = maxTime, "MaxTime", "ms", { maxValue(refTime) }
33803389
33813390 calcField = toothTime, "ToothTime", "ms", { refTime - pastValue(refTime, 1) }
33823391 ;recordField = time, "Time", 24, 16, 1.0, "ms"
--- branches/Speeduino/speeduino/auxiliaries.h (revision 30)
+++ branches/Speeduino/speeduino/auxiliaries.h (revision 31)
@@ -1,6 +1,8 @@
11 #ifndef AUX_H
22 #define AUX_H
33
4+#include BOARD_H //Note that this is not a real file, it is defined in globals.h.
5+
46 void initialiseAuxPWM();
57 void boostControl();
68 void boostDisable();
@@ -10,55 +12,6 @@
1012 void nitrousControl();
1113 void fanControl();
1214
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-
6215 #define BOOST_PIN_LOW() *boost_pin_port &= ~(boost_pin_mask)
6316 #define BOOST_PIN_HIGH() *boost_pin_port |= (boost_pin_mask)
6417 #define VVT_PIN_LOW() *vvt_pin_port &= ~(vvt_pin_mask)
@@ -71,17 +24,17 @@
7124 #define N2O_STAGE2_PIN_HIGH() *n2o_stage2_pin_port |= (n2o_stage2_pin_mask)
7225 #define READ_N2O_ARM_PIN() ((*n2o_arming_pin_port & n2o_arming_pin_mask) ? true : false)
7326
74-volatile byte *boost_pin_port;
27+volatile PORT_TYPE *boost_pin_port;
7528 volatile byte boost_pin_mask;
76-volatile byte *vvt_pin_port;
29+volatile PORT_TYPE *vvt_pin_port;
7730 volatile byte vvt_pin_mask;
78-volatile byte *fan_pin_port;
31+volatile PORT_TYPE *fan_pin_port;
7932 volatile byte fan_pin_mask;
80-volatile byte *n2o_stage1_pin_port;
33+volatile PORT_TYPE *n2o_stage1_pin_port;
8134 volatile byte n2o_stage1_pin_mask;
82-volatile byte *n2o_stage2_pin_port;
35+volatile PORT_TYPE *n2o_stage2_pin_port;
8336 volatile byte n2o_stage2_pin_mask;
84-volatile byte *n2o_arming_pin_port;
37+volatile PORT_TYPE *n2o_arming_pin_port;
8538 volatile byte n2o_arming_pin_mask;
8639
8740 volatile bool boost_pwm_state;
@@ -98,10 +51,8 @@
9851 unsigned int vvt_pwm_max_count; //Used for variable PWM frequency
9952 volatile unsigned int vvt_pwm_cur_value;
10053 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();
10556
10657
10758 #endif
--- branches/Speeduino/speeduino/cancomms.h (revision 30)
+++ branches/Speeduino/speeduino/cancomms.h (revision 31)
@@ -1,7 +1,5 @@
11 #ifndef CANCOMMS_H
22 #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
53
64 #define CAN_PACKET_SIZE 75
75
@@ -30,4 +28,4 @@
3028 void sendcanValues(uint16_t offset, uint16_t packetLength, byte cmd, byte portNum);
3129 void sendCancommand(uint8_t cmdtype , uint16_t canadddress, uint8_t candata1, uint8_t candata2, uint16_t sourcecanAddress);
3230
33-#endif // CANCOMMS_H
31+#endif // CANCOMMS_H
--- branches/Speeduino/speeduino/comms.h (revision 30)
+++ branches/Speeduino/speeduino/comms.h (revision 31)
@@ -1,8 +1,8 @@
11 #ifndef COMMS_H
22 #define COMMS_H
33 //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
66 #define ignMapPage 3
77 #define ignSetPage 4//Config Page 2
88 #define afrMapPage 5
@@ -43,12 +43,12 @@
4343 };
4444
4545 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);
4848 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);
5252 void testComm();
5353 void commandButtons();
5454
--- branches/Speeduino/speeduino/globals.h (revision 30)
+++ branches/Speeduino/speeduino/globals.h (revision 31)
@@ -3,7 +3,7 @@
33 #include <Arduino.h>
44 #include "table.h"
55
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.
77 #define INJ_CHANNELS 4
88 #define IGN_CHANNELS 5
99
@@ -12,15 +12,16 @@
1212 #define BOARD_NR_GPIO_PINS 62
1313 #define LED_BUILTIN 13
1414 #define CORE_AVR
15+ #define BOARD_H "board_avr2560.h"
1516
1617 //#define TIMER5_MICROS
1718
1819 #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"
2121
2222 #elif defined(STM32_MCU_SERIES) || defined(ARDUINO_ARCH_STM32) || defined(__STM32F1__) || defined(STM32F4) || defined(STM32)
2323 #define CORE_STM32
24+ #define BOARD_H "board_stm32.h"
2425 #ifndef word
2526 #define word(h, l) ((h << 8) | l) //word() function not defined for this platform in the main library
2627 #endif
@@ -34,10 +35,16 @@
3435 #define BOARD_DIGITAL_GPIO_PINS 80
3536 #define BOARD_NR_GPIO_PINS 80
3637 #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
3744 #endif
3845
3946 //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)
4148 #define SMALL_FLASH_MODE
4249 #endif
4350
@@ -51,10 +58,16 @@
5158 #define portOutputRegister(port) (volatile byte *)( &(port->regs->ODR) )
5259 #define portInputRegister(port) (volatile byte *)( &(port->regs->IDR) )
5360 #endif
61+#elif defined(__SAMD21G18A__)
62+ #define BOARD_H "board_samd21.h"
63+ #define CORE_SAMD21
5464 #else
5565 #error Incorrect board selected. Please select the correct board (Usually Mega 2560) and upload again
5666 #endif
5767
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+
5871 //Handy bitsetting macros
5972 #define BIT_SET(a,b) ((a) |= (1<<(b)))
6073 #define BIT_CLEAR(a,b) ((a) &= ~(1<<(b)))
@@ -85,7 +98,7 @@
8598 #define BIT_STATUS1_INJ2 1 //inj2
8699 #define BIT_STATUS1_INJ3 2 //inj3
87100 #define BIT_STATUS1_INJ4 3 //inj4
88-#define BIT_STATUS1_DFCO 4 //Decelleration fuel cutoff
101+#define BIT_STATUS1_DFCO 4 //Decelleration fuel cutoff
89102 #define BIT_STATUS1_BOOSTCUT 5 //Fuel component of MAP based boost cut out
90103 #define BIT_STATUS1_TOOTHLOG1READY 6 //Used to flag if tooth log 1 is ready
91104 #define BIT_STATUS1_TOOTHLOG2READY 7 //Used to flag if tooth log 2 is ready (Log is not currently used)
@@ -100,8 +113,8 @@
100113 #define BIT_SPARK_IDLE 6 // idle on
101114 #define BIT_SPARK_SYNC 7 // Whether engine has sync or not
102115
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
105118 #define BIT_SPARK2_UNUSED3 2
106119 #define BIT_SPARK2_UNUSED4 3
107120 #define BIT_SPARK2_UNUSED5 4
@@ -128,7 +141,7 @@
128141 #define VALID_MAP_MIN 2 //The smallest ADC value that is valid for the MAP sensor
129142
130143 #define TOOTH_LOG_SIZE 64
131-#define TOOTH_LOG_BUFFER 256
144+#define TOOTH_LOG_BUFFER 128 //256
132145
133146 #define COMPOSITE_LOG_PRI 0
134147 #define COMPOSITE_LOG_SEC 1
@@ -237,48 +250,48 @@
237250 struct table2D knockWindowDurationTable;
238251
239252 //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;
241254 volatile byte inj1_pin_mask;
242-volatile byte *inj2_pin_port;
255+volatile PORT_TYPE *inj2_pin_port;
243256 volatile byte inj2_pin_mask;
244-volatile byte *inj3_pin_port;
257+volatile PORT_TYPE *inj3_pin_port;
245258 volatile byte inj3_pin_mask;
246-volatile byte *inj4_pin_port;
259+volatile PORT_TYPE *inj4_pin_port;
247260 volatile byte inj4_pin_mask;
248-volatile byte *inj5_pin_port;
261+volatile PORT_TYPE *inj5_pin_port;
249262 volatile byte inj5_pin_mask;
250-volatile byte *inj6_pin_port;
263+volatile PORT_TYPE *inj6_pin_port;
251264 volatile byte inj6_pin_mask;
252-volatile byte *inj7_pin_port;
265+volatile PORT_TYPE *inj7_pin_port;
253266 volatile byte inj7_pin_mask;
254-volatile byte *inj8_pin_port;
267+volatile PORT_TYPE *inj8_pin_port;
255268 volatile byte inj8_pin_mask;
256269
257-volatile byte *ign1_pin_port;
270+volatile PORT_TYPE *ign1_pin_port;
258271 volatile byte ign1_pin_mask;
259-volatile byte *ign2_pin_port;
272+volatile PORT_TYPE *ign2_pin_port;
260273 volatile byte ign2_pin_mask;
261-volatile byte *ign3_pin_port;
274+volatile PORT_TYPE *ign3_pin_port;
262275 volatile byte ign3_pin_mask;
263-volatile byte *ign4_pin_port;
276+volatile PORT_TYPE *ign4_pin_port;
264277 volatile byte ign4_pin_mask;
265-volatile byte *ign5_pin_port;
278+volatile PORT_TYPE *ign5_pin_port;
266279 volatile byte ign5_pin_mask;
267-volatile byte *ign6_pin_port;
280+volatile PORT_TYPE *ign6_pin_port;
268281 volatile byte ign6_pin_mask;
269-volatile byte *ign7_pin_port;
282+volatile PORT_TYPE *ign7_pin_port;
270283 volatile byte ign7_pin_mask;
271-volatile byte *ign8_pin_port;
284+volatile PORT_TYPE *ign8_pin_port;
272285 volatile byte ign8_pin_mask;
273286
274-volatile byte *tach_pin_port;
287+volatile PORT_TYPE *tach_pin_port;
275288 volatile byte tach_pin_mask;
276-volatile byte *pump_pin_port;
289+volatile PORT_TYPE *pump_pin_port;
277290 volatile byte pump_pin_mask;
278291
279-volatile byte *triggerPri_pin_port;
292+volatile PORT_TYPE *triggerPri_pin_port;
280293 volatile byte triggerPri_pin_mask;
281-volatile byte *triggerSec_pin_port;
294+volatile PORT_TYPE *triggerSec_pin_port;
282295 volatile byte triggerSec_pin_mask;
283296
284297 //These need to be here as they are used in both speeduino.ino and scheduler.ino
@@ -298,7 +311,7 @@
298311 int ignition5EndAngle = 0;
299312
300313 //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
302315 volatile uint16_t mainLoopCount;
303316 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)
304317 volatile unsigned long timer5_overflow_count = 0; //Increments every time counter 5 overflows. Used for the fast version of micros()
@@ -306,7 +319,7 @@
306319 uint16_t fixedCrankingOverride = 0;
307320 bool clutchTrigger;
308321 bool previousClutchTrigger;
309-volatile uint16_t toothHistory[TOOTH_LOG_BUFFER];
322+volatile uint32_t toothHistory[TOOTH_LOG_BUFFER];
310323 volatile uint8_t compositeLogHistory[TOOTH_LOG_BUFFER];
311324 volatile bool fpPrimed = false; //Tracks whether or not the fuel pump priming has been completed yet
312325 volatile unsigned int toothHistoryIndex = 0;
@@ -315,7 +328,7 @@
315328 byte secondaryTriggerEdge;
316329 int CRANK_ANGLE_MAX = 720;
317330 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
319332
320333
321334 //This needs to be here because using the config page directly can prevent burning the setting
@@ -522,8 +535,12 @@
522535
523536 int8_t EMAPMin; //Must be signed
524537 uint16_t EMAPMax;
525- byte unused1_70[58];
526538
539+ byte fanWhenOff : 1; // Only run fan when engine is running
540+ byte fanUnused : 7;
541+
542+ byte unused1_70[57];
543+
527544 #if defined(CORE_AVR)
528545 };
529546 #else
@@ -628,7 +645,7 @@
628645 byte egoTPSMax; //TPS must be below this for closed loop to function
629646 byte vvtPin : 6;
630647 byte useExtBaro : 1;
631- byte boostMode : 1; //Simple of full boost contrl
648+ byte boostMode : 1; //Simple of full boost control
632649 byte boostPin : 6;
633650 byte VVTasOnOff : 1; //Whether or not to use the VVT table as an on/off map
634651 byte useEMAP : 1;
@@ -678,7 +695,7 @@
678695 byte iacAlgorithm : 3; //Valid values are: "None", "On/Off", "PWM", "PWM Closed Loop", "Stepper", "Stepper Closed Loop"
679696 byte iacStepTime : 3; //How long to pulse the stepper for to ensure the step completes (ms)
680697 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
682699
683700 byte iacFastTemp; //Fast idle temp when using a simple on/off valve
684701
@@ -692,6 +709,7 @@
692709 byte fanHyster; // Fan hysteresis
693710 byte fanFreq; // Fan PWM frequency
694711 byte fanPWMBins[4]; //Temperature Bins for the PWM fan control
712+
695713 #if defined(CORE_AVR)
696714 };
697715 #else
@@ -726,8 +744,9 @@
726744 uint16_t obd_address; //speeduino OBD diagnostic address
727745 uint8_t Auxinpina[16]; //analog pin number when internal aux in use
728746 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+
731750 byte unused10_153;
732751 byte unused10_154;
733752 byte unused10_155;
--- branches/Speeduino/speeduino/idle.h (revision 30)
+++ branches/Speeduino/speeduino/idle.h (revision 31)
@@ -3,6 +3,7 @@
33
44 #include "globals.h"
55 #include "table.h"
6+#include BOARD_H //Note that this is not a real file, it is defined in globals.h.
67
78 #define IAC_ALGORITHM_NONE 0
89 #define IAC_ALGORITHM_ONOFF 1
@@ -23,38 +24,10 @@
2324 int targetIdleStep; //What the targetted step is
2425 volatile StepperStatus stepperStatus;
2526 volatile unsigned long stepStartTime; //The time the curren
27+ byte lessAirDirection;
28+ byte moreAirDirection;
2629 };
2730
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-
5831 struct table2D iacClosedLoopTable;
5932 struct table2D iacPWMTable;
6033 struct table2D iacStepTable;
@@ -68,10 +41,11 @@
6841 unsigned int iacStepTime;
6942 unsigned int completedHomeSteps;
7043
71-volatile byte *idle_pin_port;
44+volatile PORT_TYPE *idle_pin_port;
7245 volatile byte idle_pin_mask;
73-volatile byte *idle2_pin_port;
46+volatile PORT_TYPE *idle2_pin_port;
7447 volatile byte idle2_pin_mask;
48+
7549 volatile bool idle_pwm_state;
7650 unsigned int idle_pwm_max_count; //Used for variable PWM frequency
7751 volatile unsigned int idle_pwm_cur_value;
@@ -86,8 +60,6 @@
8660 static inline byte isStepperHomed();
8761 static inline byte checkForStepping();
8862 static inline void doStep();
89-#if defined (CORE_TEENSY) || defined(CORE_STM32)
90- static inline void idleInterrupt();
91-#endif
63+static inline void idleInterrupt();
9264
9365 #endif
--- branches/Speeduino/speeduino/scheduler.h (revision 30)
+++ branches/Speeduino/speeduino/scheduler.h (revision 31)
@@ -27,346 +27,7 @@
2727
2828 #define USE_IGN_REFRESH
2929 #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>
3330
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-
37031 void initialiseSchedulers();
37132 void setFuelSchedule1(unsigned long timeout, unsigned long duration);
37233 void setFuelSchedule2(unsigned long timeout, unsigned long duration);
--- branches/Speeduino/speeduino/speeduino.h (revision 30)
+++ branches/Speeduino/speeduino/speeduino.h (revision 31)
@@ -10,4 +10,67 @@
1010 uint16_t calculateInjector4StartAngle(unsigned int);
1111 uint16_t calculateInjector4StartAngle(unsigned int);
1212
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+
1376 #endif
--- branches/Speeduino/speeduino/src/FastCRC/FastCRC_tables.h (revision 30)
+++ branches/Speeduino/speeduino/src/FastCRC/FastCRC_tables.h (revision 31)
@@ -31,7 +31,7 @@
3131 #define FastCRC_tables
3232 #include "inttypes.h"
3333
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__)
3535 #include <avr/pgmspace.h>
3636 #else
3737 #include <pgmspace.h>
--- branches/Speeduino/speeduino/storage.h (revision 30)
+++ branches/Speeduino/speeduino/storage.h (revision 31)
@@ -1,6 +1,8 @@
11 #ifndef STORAGE_H
22 #define STORAGE_H
33
4+#include "globals.h"
5+
46 void writeAllConfig();
57 void writeConfig(byte);
68 void loadConfig();
@@ -7,6 +9,13 @@
79 void loadCalibration();
810 void writeCalibration();
911
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+
1019 #if defined(CORE_STM32) || defined(CORE_TEENSY)
1120 #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)
1221 #else
--- branches/Speeduino/speeduino/table.h (revision 30)
+++ branches/Speeduino/speeduino/table.h (revision 31)
@@ -31,7 +31,8 @@
3131 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.
3232 };
3333
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);
3536
3637 struct table3D {
3738
@@ -49,7 +50,8 @@
4950 byte lastYMax, lastYMin;
5051 };
5152
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);
5355
5456 /*
5557 3D Tables have an origin (0,0) in the top left hand corner. Vertical axis is expressed first.
--- branches/Speeduino/speeduino/timers.h (revision 30)
+++ branches/Speeduino/speeduino/timers.h (revision 31)
@@ -29,14 +29,6 @@
2929 volatile uint16_t lastRPM_100ms; //Need to record this for rpmDOT calculation
3030 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)
3131
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-
4032 #if defined (CORE_TEENSY)
4133 IntervalTimer lowResTimer;
4234 void oneMSInterval();
--- branches/Speeduino/speeduino/utils.h (revision 30)
+++ branches/Speeduino/speeduino/utils.h (revision 31)
@@ -6,49 +6,8 @@
66
77 #include <Arduino.h>
88
9-uint16_t freeRam ();
10-void setPinMapping(byte boardID);
11-void initialiseTriggers();
9+void setResetControlPinState();
10+byte pinTranslate(byte);
1211
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
5312
5413 #endif // UTILS_H