Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
On stm32, when injected adc is used, the adc samples are saved in specific register.
The implementations for F1/F4/G4/L4 use an interrupt to save injected adc values in an array.
The way simplefoc works now, this is not required as those values are accessible anytime from the registers.
I introduced a SIMPLEFOC_STM32_ADC_INTERRUPT build flag.
By default, it will remove any code related to the adc interrupt.
When SIMPLEFOC_STM32_ADC_INTERRUPT is declared, code will work as before.
The reason why I kept this code as optional is that someone my want to use this interrupt for different reasons (e.g. running loopfoc, triggering an output for the scope).
I could test this on stm32f1 only, here are the results:
Without interrupt
RAM: [= ] 8.9% (used 4376 bytes from 49152 bytes)
Flash: [=== ] 26.7% (used 69916 bytes from 262144 bytes)
loopfoc = 270us
With interrupt
RAM: [= ] 9.0% (used 4428 bytes from 49152 bytes)
Flash: [=== ] 26.8% (used 70284 bytes from 262144 bytes)
loopfoc = 290us
It is slightly reducing the code size and reducing loopfoc duration as this interrupt was stopping the loopfoc execution several times unnecessarily.
Because of the priority of this interrupt, it might also delay the hall sensor interrupt.
Additionally this PR has the adc calibration for G4/L4 ( this was already merged for F1 and G431-ESC1).