LibreSolar / charge-controller-firmware

Firmware for Libre Solar MPPT/PWM charge controllers
https://libre.solar/charge-controller-firmware/
Apache License 2.0
144 stars 71 forks source link

ADC-DMA for STM32G431 in the Zephyr framework #88

Closed azeemshatp closed 4 years ago

azeemshatp commented 4 years ago

What does this PR do? ADC-DMA support for STM32G431 and ADC2 support for MPPT_2420_HPX in the Zephyr framework.

What are the relevant tickets? NA

Where should the reviewer start? The file daq_zephyr.c

How should this be manually tested? ADC values must be updated automatically by the DMA interrupt routine.

Any background context you want to provide? To work with ADC2, stm32 adc driver macro in the file adc_stm32.c needs to be modified.

azeemshatp commented 4 years ago

Looks good to me.

What is the plan to actually use ADC2 in our firmware now? Are you going to submit a PR to Zephyr (cleanest solution, but takes longer) or will you copy the needed parts of the driver to our repository (don't know how much of the driver is needed or if we can just circumvent some parts of the official driver)?

I think it is better to copy the needed parts of the driver to our repository.

hogthrob commented 4 years ago

Hi, I suggest to go dual-mode: have a copy of the relevant files but in parallel submit changes to Zephyr guys for inclusion.

martinjaeger commented 4 years ago

Hi, I suggest to go dual-mode: have a copy of the relevant files but in parallel submit changes to Zephyr guys for inclusion.

Agree that makes sense. Just attended the Zephyr API meeting regarding my DAC PR and they were very helpful.

martinjaeger commented 4 years ago

If I build this in PlatformIO I get some Kconfig related warnings and the following error:

Error: Aborting due to non-whitelisted Kconfig warning 'warning: default on the choice symbol ADC_1
(defined at charge-controller/boards/arm/mppt_2420_hpx/Kconfig.board:10, drivers/adc/Kconfig:42,
drivers/adc/Kconfig.stm32:16) will have no effect, as defaults do not affect choice symbols'.

Did it compile without issues on your end, @azeemshatp ?

martinjaeger commented 4 years ago

These fixups are also still wrong (which was my fault). But would be good to correct that within this PR: https://github.com/LibreSolar/charge-controller-firmware/blob/14249492a351e06e642f15a480012ee782a3c687/boards/arm/mppt_2420_hpx/dts_fixup.h#L14

martinjaeger commented 4 years ago

Closing this PR. DMA support (first commit) was cherry-picked to master. Inclusion of ADC2 will be done in a dedicated PR.