Commit Graph

78 Commits

Author SHA1 Message Date
tx_haggis 5ac589752b
Provide hook for developer local PIO configuration (#1212) 2024-05-10 08:04:13 +10:00
Pasi Kemppainen 8cb4e382e4
Fix STM32duino RTC library version to 1.2.0 (#1076) 2023-12-11 13:31:39 +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
Vitor Moreno B. Sales f133b0f613
Moved STM32 definitions from globals to board file (#1117)
* Moved STM32 definitions from globals to board file

Moved definitions from globals.h

Removed old STM32 generic library as this is very old and unused for almost 5 years.

* Remove old stm32_generic build environment from platformio.ini

---------

Co-authored-by: Josh Stewart <josh@noisymime.org>
2023-10-11 12:24:46 +11:00
Josh Stewart 4cf7141b0b Add environment builds for mega2560 6/3 and 8/1 channel configurations. Add these builds to unit tests 2023-10-11 08:21:47 +11:00
tx_haggis b03db96ad7
Save 600+ bytes RAM (step 4 of 9) - deduplicate scheduler ISR functions (#1063) 2023-10-07 08:25:26 +11:00
Pasi Kemppainen 3857cc4514
Change serial buffer size to 128 (#1014) 2023-05-18 17:37:10 +10:00
tx_haggis d1399a0f33
Enable Teensy 3.5 unit testing (#1038)
* Add missing forward declarations
Found while compiling teensy35 unit tests

* Unit test should not rely on EEPROM

* Fix bad lib_dep
Teensy35 #includes FlexCAN_4 headers

* Fix circular include
logger.h needs FPU_MAX_SIZE which is defined
in globals.h. Globals.h includes logger.h!

* Ambguity in integer typedefs
2023-04-26 15:54:15 +10: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 5fafa94056 Fix unit test value 2022-06-01 17:06:44 +10:00
Josh Stewart ec2fcd906f Add more unit tests for TAE 2022-05-25 15:28:11 +10:00
Josh Stewart 3bd945f546 Add unit test for basic TAE 2022-05-25 11:02:55 +10:00
tx_haggis c9213a5555
Fix native unit test (#763)
* Fix native unit test

* Include native unit test in CI build
2022-02-14 11:04:11 +11:00
Pasi Kemppainen fb0a52bf6f
SD-Card logging for STM32 [EXPERIMENTAL] (#782)
* First test

* Update comments.
2022-02-05 09:15:58 +11:00
tx_haggis be0f2c69c7
Add table2d tests (#748)
* Improve native debug experience

* Add unit tests for table2d
2021-12-23 15:07:38 +11:00
Pasi Kemppainen 34116ad223
New CAN-bus library for STM32 (#725)
* Use new CAN-library

* Fix CAN3 pin number

* Fix building on other platforms
2021-12-23 13:46:13 +11:00
tx_haggis 9ad500189b
Performance: 15%+ loop/sec speedup by optimising 3d table bilinear interpolation (#735)
* Bi-linear interpolation - round towards nearest integer

Add the equivalent of 0.5 to the final calculation pre-rounding.
This will have the effect of rounding to the nearest integer, rather
than truncating. I.e. rounding down

* Unit tests: isolate table tests and check interpolation x/y bins

* Unit tests: add native table3d tests

* Unit tests: derive min/max from axis test values

* Unit tests: more detailed messages

* Unit tests: fix rounding & unit tests

* Performance

* Performance: use uint16_t instead of unsigned long
for the fixed point math: we only need the fractional
part. I.e. 1.16 not 16.16

* Use narrowest possible type

* Optimise bin position logic for performance

* Only promote to uint32_t when really required.

* Simplify bin checks - no zero width bins

* Save memory: use a single byte for the last bin caches

* Performance: increment pointers instead of
repeatedly dereferncing array by index.

* Comments

* Incorrect array underrun logic

* Rename type, comments

* Fix unit tests
2021-12-09 20:40:31 +11:00
tx_haggis 6344fdc76f
Use -fshort-enums instead of packing individual enums (#692) 2021-10-23 09:04:31 +11:00
Wilmar den Ouden 0024c66b89
chore(stm32): set the RTC lib the PlatformIO lib package (#661)
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2021-09-18 09:10:29 +10:00
Josh Stewart d8f7f8d21d Force Teensy platform to the latest 1.54 2021-07-22 11:57:33 +10:00
Wilmar den Ouden 7c8513e477
fix: install STM32RTC from Github (#590)
Signed-off-by: wilmardo <info@wilmardenouden.nl>
2021-06-08 08:47:45 +10:00
Vitor Moreno B. Sales dd3847bfd3
STM32 fixes and tweaks (#553)
* STM32 fixes and tweaks

Removed generic STM32F103 options from PlatformIO
Added optional serial compilations on PlatforIO
Make sure all timers are stoped at boot
Small speed improve at SPIasEEPROM
Added timers usage table to board_stm32_official.h

* Added base board
2021-04-15 10:26:58 +10:00
Tjeerd 6179d4b5ae
Create better support for STM32F401 and STM32F411 blackpills (#548)
* Create support for STM32F401 and STM32F411 blackpills

* Small bug introduced now fixed.

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2021-03-23 08:33:03 +11:00
Josh Stewart f02d75bfbe Some initial work for same51 board support 2021-03-13 08:43:51 +11:00
Tjeerd 060ec77010
STM32F401 build fix (#537)
* Remove disable RTC from build, now STM32F401 builds no problem

* bug fix

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2021-02-24 10:15:52 +11:00
Vitor Moreno B. Sales 132cc6200d
Fix pin 54 selection (#511)
Fix pin 54 listing and renamed macros to better understanding

Co-authored-by: Josh Stewart <josh@noisymime.org>
2021-02-02 10:00:04 +11:00
Josh Stewart 1da8672bf7 RTC fixes for Teensy41 and mega2561 2021-01-23 14:19:45 +11:00
Josh Stewart ca6eef2b31 Initial layout work on RTC and SD 2021-01-22 16:16:30 +11:00
Josh Stewart 5aeb794c2a Add teensy36 build and master uploads for teensy36 and teensy41 2021-01-17 23:16:09 +11:00
Tjeerd 5c5ecbbcea
Fix building stm32 f401 (#489)
* fix building for STM32F401CC and general macro cleanup

* Now building for all generic STM32F4x7 boards in arduino IDE is ok.

* buildflag cleanup

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2020-12-08 00:43:01 +11:00
Josh Stewart e073834135 Cleanup some stm32 warnings 2020-12-02 13:21:00 +11:00
Tjeerd 8451aacf55
Add support for stm32F401internal flash as EEPROM emulation (#462)
* Add support STM32F401CC using internal flash as EEPROM

* update flash location of EEPROM

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2020-12-02 10:52:13 +11:00
Josh Stewart cfe9930416 Minor performance change in 2560 compile options 2020-09-18 10:50:23 +10:00
Tjeerd 6faab8e485
Update on eeprom emulation (#424)
* Fix building for FRAM with globals.h setting

On request of vitor boss. A lot has been changed around  to make the selection of EEPROM emulation  type from the globals.h (including FRAM selection)

* Add support for EEPROM emulation on internal flash of STM32F7

* Updates on SPI Flash EEPROM

* Fix building for BACKUPSRAM as EEPROM.

* Add put() and get() functions to the EEPROM emulation. This is needed for the latest terminstor and other calibrations routines

Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2020-08-10 08:58:00 +10:00
Tjeerd b9bab9cbfc
Changed platformio.ini to build with the newest visual studio code and PIO. (#418)
Co-authored-by: Tjeerd <tjeerdie@users.noreply.github.com>
2020-07-19 20:31:00 +10:00
Josh Stewart e17874553f Change the TEENSY40 config to be TEENSY41 2020-07-14 13:57:36 +10:00
Josh Stewart 904e1956f4 For Travis to do a platform update to try and resolve board not found error 2020-05-21 16:24:13 +10:00
Josh Stewart fc1663e5d3 Fix compiling for atmega2561 and add profile for it 2020-05-21 15:42:02 +10:00
Tjeerd 1530bb892e
EEPROM emulation on internal flash for STM32F407 (#372)
* Added new Flash EEPROM emulation

# Conflicts:
#	platformio.ini
#	speeduino/board_stm32_official.ino
#	speeduino/init.ino
#	speeduino/src/SPIAsEEPROM/SPIAsEEPROM.cpp
#	speeduino/src/SPIAsEEPROM/SPIAsEEPROM.h

* changes to storage to make SPI flash work again

* cleanup
2020-05-06 15:22:48 +10:00
Tjeerd fae9ab5a6b
Configurable CS pin flash chip (#345)
* fix building with spi flash as config storage

* Fixing build with spi flash as EEPROM. Changed some pin numbers to match the board i am designing and testing now.

* Now cs pin for spi eeprom is settable by flag in build enviroment.

* Correct overflow for 32bit timers

* fix pins PA0-PA5 on some f407 boards

* Enable access to SRAM Backup domain at boot

* Add missing callback functions

* Change timer resolutions. Corrects idle/aux timer frequencies

* 32 bit overflow only for STM32F4

* Update platformio.ini

debug tool added as default

* fix building with spi flash as config storage

* Fixing build with spi flash as EEPROM. Changed some pin numbers to match the board i am designing and testing now.

* Now cs pin for spi eeprom is settable by flag in build enviroment.

* Update platformio.ini

debug tool added as default

* Update cancomms.ino

Removed CAN build on black_F407VE for now. It needs fixing the build fails otherwise.

Co-authored-by: hoogendijkta <tjeerdie@users.noreply.github.com>
Co-authored-by: iLeeeZi <ilari.vehniainen@hotmail.fi>
2020-04-18 08:04:03 +10:00
Autohome2 1add450cf5
Branch 082019ma (#326)
* fix to serial0 and serial3 when offset is 0 uses wrong command

* fix to serial0 and serial3 when offset is 0 uses wrong command

* fix hex num

* add teensy canbus library
teensy can read and write functions enabled

* update to teensyduino 1.49

* part 1 prepare structure for obd can port works
rename old can_command() to secondarySerial_command() for secondary serial and create new can_command for real CAN instruction decode.
fix masking for teensy 3x and 4

* set mega as default build

Co-authored-by: Josh Stewart <josh@noisymime.org>
2020-02-28 10:18:37 +11:00
Josh Stewart b02b33d4bf Minor cleanup for compiling on Teensy with MC33810 2020-02-23 09:54:13 +11:00
Josh Stewart 11c3c97280 Change Bluepill to force 128k variant. See #311 2020-02-19 08:54:51 +11:00
Josh Stewart a93e78c3f3 Merge branch 'master' of https://github.com/noisymime/speeduino 2020-02-03 09:07:41 +11:00
Josh Stewart 2231a4a1ff Set stm32f407 build to use current PIO platform code 2020-02-03 09:06:14 +11:00
Bruno Bousquet 68f2288dd7
add schedule test (#312)
add temp test file to gitignore


improve schedule testing


add check for schedule delays and pending variants

move time sampling to callback methods

add comments and improve pending tests
2020-01-30 16:17:20 +11:00
Josh Stewart 76ef814847 Large cleanup of global varialbes in preparation for unit test framework 2020-01-24 11:31:39 +11:00
Josh Stewart 106b75509d Generic SPI as EEPROM changes. 2020-01-13 12:14:00 +10:00
Josh Stewart fbbeb8a7a1 Basework for new DB board 2019-12-15 09:55:46 +11:00
Josh Stewart 73f4058f6b Reenable LED indicator on the calibration routing 2019-10-15 16:56:41 +11:00