jakobjung10 opened a new pull request, #21419:
URL: https://github.com/apache/nuttx/pull/21419
## Summary
The shared M0 ADC driver (`stm32_adc_m0_v1.c`, already used by C0, G0, L0
and U0) could not be used on the STM32F0:
* `arch/arm/stm32: Allow the M0 ADC driver on STM32F0` removes the `#error
Not tested` that stopped every F0 build with `CONFIG_STM32_ADC1`.
* `arch/arm/stm32: Define DMACHAN_SETTING() without CSELR`:
`stm32_dma_v1_7ch.h` defines `DMACHAN_SETTING()` only with `DMA_HAVE_CSELR`,
which is set only for the L0. On the F0, every `DMACHAN_*` definition therefore
expanded to a call of an undeclared function, and `#define ADC1_DMA_CHAN
DMACHAN_ADC1_1` failed with "initializer element is not constant". Without
CSELR, `stm32_dmachannel()` takes its argument as the channel index, so
`DMACHAN_SETTING()` now yields the channel.
## Impact
STM32F0 only. Boards can now enable ADC1, with or without DMA. No in-tree F0
configuration enables the ADC, so existing builds are unchanged. No
documentation change.
## Testing
Host: Windows 10, building in an Ubuntu 24.04 container with
arm-none-eabi-gcc 13.2.1, on nuttx 6569424c and nuttx-apps 09a59b9.
Hardware: an STM32F072VB board with an `nsh` configuration plus ADC1, DMA,
`STM32_ADC_MAX_SAMPLES=7` and `examples/adc` (group size 7, software trigger).
It samples seven regular channels: IN1, IN2, IN4, IN6, IN8, IN9 and IN14.
* With `ADC1_DMA_CHAN` set to `DMACHAN_ADC1_1`, the first commit alone fails
to build; with both commits it builds, and `adc` reads all seven channels in
order.
* A variable voltage on IN14 reads over the full range, 0 to 4095. This
check was done before rebasing onto 6569424c.
* All six `boards/arm/stm32f0` configurations build before and after this
PR, with the same warnings and the same `savedefconfig` output.
* `tools/checkpatch.sh` passes on both commits.
<details>
<summary>Build with the first commit only</summary>
stm32_dma_v1_7ch.h:327:35: warning: implicit declaration of function
'DMACHAN_SETTING'; did you mean 'DMACHAN_AES_IN_1'?
[-Wimplicit-function-declaration]
327 | # define DMACHAN_ADC1_1
DMACHAN_SETTING(STM32_DMA1_CHAN1, 0)
stm32_dma_v1_7ch.h:327:35: error: initializer element is not constant
</details>
<details>
<summary>adc with both commits</summary>
nsh> adc -n 2
adc_main: g_adcstate.count: 2
adc_main: Hardware initialized. Opening the ADC device: /dev/adc0
Sample:
1: channel: 1 value: 1893
2: channel: 2 value: 1604
3: channel: 4 value: 1956
4: channel: 6 value: 1980
5: channel: 8 value: 2854
6: channel: 9 value: 2521
7: channel: 14 value: 33
Sample:
1: channel: 1 value: 1921
2: channel: 2 value: 1966
3: channel: 4 value: 1996
4: channel: 6 value: 2124
5: channel: 8 value: 2454
6: channel: 9 value: 2321
7: channel: 14 value: 33
</details>
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]