Commit Graph

33 Commits

Author SHA1 Message Date
tx_haggis 0f13753ed3
Performance: optimized 32-bit shifts (#1187)
* Add optimized 32-bit shifting

* Tooth based time to angle coversion is only used by a few decoders.
So move the functions into decoders.cpp

* Better separation of deocders and crank maths.

* Apply optimised shifts

* Doxygen
2024-05-30 14:12:14 +10:00
tx_haggis 170c3a8a31
Fix compile failure (PR->master branch mismatch issue) (#1200) 2024-03-22 22:48:01 +11:00
tx_haggis e08d5dab25
test_math: make unit tests pass on Teensy (#1137)
Required converting dwell, actualDwell, dwellCrank & dwellRun to unsigned.
2024-03-21 11:45:10 +11:00
Daniel Tobias 3a712baf23
Comment typos correction (#1189)
* basic spelling fixes

* basic spelling fixes, external libs
2024-03-21 11:37:45 +11:00
Josh Stewart 288b98d31c Make percentage() safe for 32-bit values. Fixes pwLimit overflow regression 2024-01-16 16:22:56 +11:00
tx_haggis 9bbd16c81b
Performance: optimize division (#1082)
* Add udiv_32_16

* Apply udiv_32_16() where possible

* Convert udiv_32_16 to assembler
It's worth 20 loop/s

* Remove unused functions

* Remove degreesPeruSx2048 - unused

* Remove angleToTime - replace with direct calls
1. Drop angleToTime()
It's slow, only partially implemented and adds zero value
(and has MISRA violations)
2. Consistent function naming
3. Doxygen

* triggerPri_Nissan360 shouldn't set timePerDegree.
It will be overwritten every loop by doCrankSpeedCalcs()

* Use angleToTimeMicroSecPerDegree() instead of timePerDegree
No loss in performance
Increased injection open/close time accuracy (so unit test values must change)
Can remove timePerDegree global.

* Hide (encapsulate) crank math globals.

* Base all angle to time conversions on decoder computed variables.
This is within 2us of the revolution based method
and is much faster - which is essentially zero percent change.

* Performance: move calculation of degreesPeruSx32768
into decoders.
Remove doCrankSpeedCalcs() - it's doing nothing
at the moment.

* Apply libdivide to triggerSetEndTeeth functions.
Since triggerToothAngle is set once at initialization
time, we can generate the libdivide struct
once and reuse it many times.

* Remove lastToothCalcAdvance - unused

* Replace 16-bit division with shift

* Replace 32-bit divison with 16-bit division

* Avoid 32-bit division; use div100()

* inline percentage()

* Optimize div100()

* MISRA fixes

* Replace magic numbers with #defs

* Replace libdivide structs with inline constants
No perf or memory changes

* Use fixed types for PWM max count variables

* Accurate rounded integer division
* Formalise rounding behavior (DIV_ROUND_CORRECT)
* Apply DIV_ROUND_CORRECT to DIV_ROUND_CLOSEST(),
UDIV_ROUND_CLOSEST(), div100(), div360(),
percentage() & halfPercentage()
* Add, fix & improve unit tests

* Add udiv_32_16_closest()

* Perf: Limit percentage calculations to 16-bits

* MISRA fixes

* Add compare_executiontime() to encapsulate common perf testing code

* Signed to unsigned division

* Convert ignitionLimits() to an inline function.
Slight speed up, probably due to removing
multiple evaluations of macro arguments.

* Split unit tests up.

* udiv_32_16 - check for valid parameters
2023-11-06 09:10:08 +11:00
Josh Stewart fc536d15f0 Rename all ino files to cpp (Excluding speeduino.ino).
Confirmed this compiles OK in Arduino IDE 2.x
Frees up 8 bytes of RAM
2023-10-06 18:10:20 +11:00
Josh Stewart 9c3e993b53 Initial commit of new rolling rev limiter 2023-06-09 16:10:43 +10:00
Josh Stewart 2fc29ceef5 MISRA cleanup rule: misra-c2012-8.2 2022-11-06 09:43:29 +11:00
tx_haggis b8278e7ecb
Include CPP files in MISRA script (#925)
* Push libdivide #def into build flags

* Allow build without USE_LIBDIVIDE

* Rename libdivide folder before & after scan

It's the only way to really exclude it
2022-09-15 12:16:14 +10:00
Josh Stewart 16403b41bc Allow for float values in SD log where supported with FPU 2022-08-10 12:12:42 +10:00
tx_haggis 70bf16e16b
libdivide structs can be const - saves a few bytes (#886) 2022-07-27 13:51:45 +10:00
tx_haggis fc9967e31d
Performance: optimize fuel trim PW calcs (#756)
* Consistent set of div100 functions

* Add typedef for trimTable3d

* Performance: use div100() function
when applying fuel trim corrections

* Silly ARM compiler!

* Unit test fixes

* Fix tests: expected & actual parameters were swapped

* div100(): add 8-bit overloads for completeness

* Fix unit tests
1. Force call to correct div100() overload
2. Use appropriately typed assertion

* Restore use of USE_LIBDIVIDE preprocessor symbol

* Add div360() - encapsulate libdivide use

* Fix copy/paste issue.
2022-02-18 14:55:43 +11:00
DeionSi 6be6cd7795
libdivide for angletotime (#791) 2022-02-14 10:24:34 +11:00
Josh Stewart b74355535c Allow up to 32-bit values for signed div 100 and unsigned div 10 2022-01-05 13:14:17 +11:00
Josh Stewart 105534efb8 Add option to use libdivide in maths.h functions 2021-12-09 10:50:17 +11:00
Josh Stewart e187285e63 Small fixes for broken builds from the last few PRs 2021-04-22 10:58:50 +10:00
Josh Stewart 0e8cb0bb9e Change stm32 boards to use 10-bit ADC and match other boards 2020-08-10 08:54:36 +10:00
Bruno Bousquet f1521b65d8 Fix MISRA violations (#268)
* improve misra checking

* fix 1600 misra violations

* fix mistyped pointer

* misra script was not filtering duplicates
2019-10-22 11:49:07 +10:00
hoogendijkta 93b8d5cc8a New pins assigned to BLACK_STM32F407VE. 2019-02-20 22:46:10 +01:00
hoogendijkta 7863cc1eef Working analog read of TPS/MAP/CLT 2019-02-20 17:21:16 +01:00
Josh Stewart ce0e399201 More warnings cleanup 2018-07-19 23:26:31 +10:00
Josh Stewart 9e2d649f61 Begin some work on warnings cleanup 2018-07-19 17:35:35 +10:00
Josh Stewart 5ce2d61186 Stub versions of new crank maths files to allow compiling 2018-06-30 09:21:13 +10:00
Vitor Moreno B. Sales 2c10a969dd
Merge pull request #12 from noisymime/master
December merge
2017-12-13 15:25:10 -02:00
Josh Stewart 35fa068575 Staged injection (Table and automatic modes) 2017-12-07 13:46:04 +11:00
VitorBoss 31d134c05d Merge branch 'master' of git://github.com/noisymime/speeduino 2017-12-06 16:13:58 -02:00
Josh Stewart 0de3a231c9 Minor cleanups before release 2017-11-07 22:05:23 +11:00
VitorBoss 8af08a7209 Included 12bit math for STM
Boost/VVT pins dont change if 0%
Change visual led clock to 4Hz
Change analog resolution to 10bits on STM32GENERIC core
2017-09-02 13:26:41 -03:00
Josh Stewart b71c59947e Cleanup #defines in maths.x 2017-08-21 11:51:05 +10:00
Josh Stewart afa83cfdd7 Experimental new low res mode (Testing only) 2017-08-17 13:51:12 +10:00
Josh Stewart 4f42c289b2 MISRA compliant maths.ino 2017-06-19 22:02:40 +10:00
Josh Stewart c555bbc060 Move to PlatformIO for project layout 2017-02-06 20:56:46 +11:00