Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/stm32/periph_adc: fixes and improvements for L4 support #19571

Merged

Conversation

gschorcht
Copy link
Contributor

Contribution description

This PR provides the following fixes and improvements for the periph_adc implementation for STM32L4.

  • Support STM32L496AG added.
  • Instead of defining the number of ADC devices for each MCU model, the number of ADC devices is determined from ADCx definitions in CMSIS header.
  • MCU specific register/value defines are valid for all L4 MCUs, model based conditional compilation is removed.
  • The ADC clock disable function is fixed using a counter. The counter is incremented in prep and decremented in done. The ADC clock is disabled if the counter becomes 0.
  • For boards that have not connected the V_REF+ pin to an external reference voltage, the VREFBUF peripheral can be used as V_REF+ (if supported) by setting VREFBUF_ENABLE=1.
  • The ASCR register is available and has to be set for all STM32L471xx, STM32L475xx, STM32L476xx, STM32L485xx and STM32L486xx MCUs. Instead of using the CPU model for conditional compilation, the CPU line is used to support all MCU of that lines.
  • Setting of SQR1 is fixed. Setting the SQR1 did only work before because the ADC_SRQ_L is set to 0 for a sequence length of 1.
  • Setting the ADC_CCR_CKMODE did only work for the reset state. It is now cleared before it is set. Instead of using the ADC_CCR_CKMODE_x bits to set the mode, the mode defines are used.
  • Support for V_REFINT as ADC channel added.

Testing procedure

Issues/PRs references

Instead of defining the number of ADC devices for each MCU model, the number of ADC devices is determined from ADCx definitions in CMSIS header.
The ADC clock disable is fixed using a counter. The counter is incremented in `prep` and decremented in `done`. The ADC clock is disabled if the counter becomes 0.
For boards that have not connected the V_REF+ pin to an external reference voltage, the VREFBUF peripheral can be used as V_REF+ if supported by setting `VREFBUF_ENABLE=1`.
The ASCR register is available and has to be set for all STM32L471xx, STM32L475xx, STM32L476xx, STM32L485xx and STM32L486xx MCUs. Instead of using the CPU model for conditional compilation, the CPU line is used to support all MCU of that lines.
The setting of SQR1 is fixed. Setting the SQR1 did only work before because the ADC_SRQ_L is set to 0 for a sequence length of 1.
@github-actions github-actions bot added Area: cpu Area: CPU/MCU ports Platform: ARM Platform: This PR/issue effects ARM-based platforms labels May 10, 2023
@gschorcht gschorcht added Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Type: new feature The issue requests / The PR implemements a new feature for RIOT Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation and removed Type: enhancement The issue suggests enhanceable parts / The PR enhances parts of the codebase / documentation labels May 10, 2023
@riot-ci
Copy link

riot-ci commented May 10, 2023

Murdock results

✔️ PASSED

caa50a5 cpu/stm32/periph_adc: support V_REFINT as ADC channel on L4

Success Failures Total Runtime
6931 0 6931 08m:50s

Artifacts

@benpicco
Copy link
Contributor

bors merge

bors bot added a commit that referenced this pull request May 15, 2023
18056: pkg/cmsis: use unique package for CMSIS headers, DSP and NN modules r=benpicco a=aabadie



19571: cpu/stm32/periph_adc: fixes and improvements for L4 support r=benpicco a=gschorcht

### Contribution description

This PR provides the following fixes and improvements for the `periph_adc` implementation for STM32L4.
- Support STM32L496AG added.
- Instead of defining the number of ADC devices for each MCU model, the number of ADC devices is determined from ADCx definitions in CMSIS header.
- MCU specific register/value defines are valid for all L4 MCUs, model based conditional compilation is removed.
- The ADC clock disable function is fixed using a counter. The counter is incremented in `prep` and decremented in `done`. The ADC clock is disabled if the counter becomes 0.
- For boards that have not connected the V_REF+ pin to an external reference voltage, the VREFBUF peripheral can be used as V_REF+ (if supported) by setting `VREFBUF_ENABLE=1`.
- The ASCR register is available and has to be set for all STM32L471xx, STM32L475xx, STM32L476xx, STM32L485xx and STM32L486xx MCUs. Instead of using the CPU model for conditional compilation, the CPU line is used to support all MCU of that lines.
- Setting of SQR1 is fixed. Setting the SQR1 did only work before because the `ADC_SRQ_L` is set to 0 for a sequence length of 1.
- Setting the `ADC_CCR_CKMODE` did only work for the reset state. It is now cleared before it is set. Instead of using the `ADC_CCR_CKMODE_x` bits to set the mode, the mode defines are used.
 - Support for V_REFINT as ADC channel added.

### Testing procedure



19589: gnrc/gnrc_netif_hdr_print: printout timestamp if enabled r=benpicco a=chudov



Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: chudov <chudov@gmail.com>
@bors
Copy link
Contributor

bors bot commented May 15, 2023

Build failed (retrying...):

Setting the `ADC_CCR_CKMODE` did only work for the reset state. It is now cleared before it is set. Instead of using the `ADC_CCR_CKMODE_x` bits to set the mode, the mode defines are used.
@gschorcht gschorcht force-pushed the cpu/stm32/periph/adc_l4_fixes_improvements branch from 8fee2a3 to caa50a5 Compare May 15, 2023 12:25
@bors
Copy link
Contributor

bors bot commented May 15, 2023

Canceled.

@gschorcht
Copy link
Contributor Author

Small typo 😎 Fixed.

@gschorcht
Copy link
Contributor Author

gschorcht commented May 15, 2023

I squashed the small fix directly

adc_l4.c:153:21: error: 'ADC_CCR_CKMODE_HCLK_22' undeclared (first use in this function); did you mean 'ADC_CCR_CKMODE_HCLK_2'?
  153 |         ADC->CCR |= ADC_CCR_CKMODE_HCLK_22 << ADC_CCR_CKMODE_Pos;
      |                     ^~~~~~~~~~~~~~~~~~~~~~
      |                     ADC_CCR_CKMODE_HCLK_2```

@benpicco
Copy link
Contributor

bors merge

@bors
Copy link
Contributor

bors bot commented May 15, 2023

Build succeeded!

The publicly hosted instance of bors-ng is deprecated and will go away soon.

If you want to self-host your own instance, instructions are here.
For more help, visit the forum.

If you want to switch to GitHub's built-in merge queue, visit their help page.

@bors bors bot merged commit 2b97b76 into RIOT-OS:master May 15, 2023
@gschorcht
Copy link
Contributor Author

Thanks

@gschorcht gschorcht deleted the cpu/stm32/periph/adc_l4_fixes_improvements branch May 22, 2023 14:58
bors bot added a commit that referenced this pull request May 24, 2023
18005: pkg/semtech-loramac: model in Kconfig r=aabadie a=aabadie



19576: boards: add stm32l496g-disco support r=aabadie a=gschorcht

### Contribution description

The PR adds the board definition for the STM2L496G-DISO board.

It is the same board that is also shipped with the P-L496G-CELL02 LTE pack for which we already have the board definition `p-l496g-cell02`. However, `stm32l496g-disco` provides a complete configuration of the board and supports the following features in addition to `p-l496g-cell02`:
```
> FEATURES_PROVIDED += periph_adc
> FEATURES_PROVIDED += periph_dac
> FEATURES_PROVIDED += periph_dma
> FEATURES_PROVIDED += periph_pwm
> FEATURES_PROVIDED += periph_uart_hw_fc
> FEATURES_PROVIDED += arduino
```
In the long term, `p-l496g-cell02` is to be based on the new full `stm32l496g-disco` board definition.

The CPT and the LCD display are not yet supported since they are connected to/controlled by the MFX (a STM32L152-based sub-system) and the FMC peripheral.

### Testing procedure

All basic tests should work with the new board definition. The following tests were executed and did succeed:

- [x] `tests/periph/adc`
- [x] `tests/periph/dac`
- [x] `tests/periph/i2c` for `I2C_DEV(0)`, `I2C_DEV(1)` is not exposed and not tested
- [x] `tests/periph/pwm`
- [x] `tests/periph/spi` for `SPI_DEV(0)`, `SPI_DEV(1) connection not soldered and not tested
- [x] `tests/periph/timer` for `TIMER_DEV(0)` and `TIMER_DEV(1)`
- [x] `tests/periph/uart` for `UART_DEV(0)`, `UART_DEV(1)` and `UART_DEV(2)`
- [x] `tests/usbus_cdc_ecm` together with `stdio_cdc_acm`

### Issues/PRs references

~Depends on PR #19571~
~Depends on PR #19572~
~Depends on PR #19573~

19650: drivers/nrf24l01p: model in kconfig r=aabadie a=aabadie



19660: cpu/rpx0xx: Fix kconfig model r=aabadie a=MrKevinWeiss



### Contribution description

Broken master due to incorrect model of the periph_pio in kconfig.

### Testing procedure

Green murdock (now that the board is added to the list)

### Issues/PRs references

Look at the master CI...

Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
bors bot added a commit that referenced this pull request May 24, 2023
19576: boards: add stm32l496g-disco support r=aabadie a=gschorcht

### Contribution description

The PR adds the board definition for the STM2L496G-DISO board.

It is the same board that is also shipped with the P-L496G-CELL02 LTE pack for which we already have the board definition `p-l496g-cell02`. However, `stm32l496g-disco` provides a complete configuration of the board and supports the following features in addition to `p-l496g-cell02`:
```
> FEATURES_PROVIDED += periph_adc
> FEATURES_PROVIDED += periph_dac
> FEATURES_PROVIDED += periph_dma
> FEATURES_PROVIDED += periph_pwm
> FEATURES_PROVIDED += periph_uart_hw_fc
> FEATURES_PROVIDED += arduino
```
In the long term, `p-l496g-cell02` is to be based on the new full `stm32l496g-disco` board definition.

The CPT and the LCD display are not yet supported since they are connected to/controlled by the MFX (a STM32L152-based sub-system) and the FMC peripheral.

### Testing procedure

All basic tests should work with the new board definition. The following tests were executed and did succeed:

- [x] `tests/periph/adc`
- [x] `tests/periph/dac`
- [x] `tests/periph/i2c` for `I2C_DEV(0)`, `I2C_DEV(1)` is not exposed and not tested
- [x] `tests/periph/pwm`
- [x] `tests/periph/spi` for `SPI_DEV(0)`, `SPI_DEV(1) connection not soldered and not tested
- [x] `tests/periph/timer` for `TIMER_DEV(0)` and `TIMER_DEV(1)`
- [x] `tests/periph/uart` for `UART_DEV(0)`, `UART_DEV(1)` and `UART_DEV(2)`
- [x] `tests/usbus_cdc_ecm` together with `stdio_cdc_acm`

### Issues/PRs references

~Depends on PR #19571~
~Depends on PR #19572~
~Depends on PR #19573~

19650: drivers/nrf24l01p: model in kconfig r=aabadie a=aabadie



19660: cpu/rpx0xx: Fix kconfig model r=aabadie a=MrKevinWeiss



### Contribution description

Broken master due to incorrect model of the periph_pio in kconfig.

### Testing procedure

Green murdock (now that the board is added to the list)

### Issues/PRs references

Look at the master CI...

Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
Co-authored-by: Alexandre Abadie <alexandre.abadie@inria.fr>
Co-authored-by: MrKevinWeiss <weiss.kevin604@gmail.com>
bors bot added a commit that referenced this pull request May 24, 2023
19576: boards: add stm32l496g-disco support r=aabadie a=gschorcht

### Contribution description

The PR adds the board definition for the STM2L496G-DISO board.

It is the same board that is also shipped with the P-L496G-CELL02 LTE pack for which we already have the board definition `p-l496g-cell02`. However, `stm32l496g-disco` provides a complete configuration of the board and supports the following features in addition to `p-l496g-cell02`:
```
> FEATURES_PROVIDED += periph_adc
> FEATURES_PROVIDED += periph_dac
> FEATURES_PROVIDED += periph_dma
> FEATURES_PROVIDED += periph_pwm
> FEATURES_PROVIDED += periph_uart_hw_fc
> FEATURES_PROVIDED += arduino
```
In the long term, `p-l496g-cell02` is to be based on the new full `stm32l496g-disco` board definition.

The CPT and the LCD display are not yet supported since they are connected to/controlled by the MFX (a STM32L152-based sub-system) and the FMC peripheral.

### Testing procedure

All basic tests should work with the new board definition. The following tests were executed and did succeed:

- [x] `tests/periph/adc`
- [x] `tests/periph/dac`
- [x] `tests/periph/i2c` for `I2C_DEV(0)`, `I2C_DEV(1)` is not exposed and not tested
- [x] `tests/periph/pwm`
- [x] `tests/periph/spi` for `SPI_DEV(0)`, `SPI_DEV(1) connection not soldered and not tested
- [x] `tests/periph/timer` for `TIMER_DEV(0)` and `TIMER_DEV(1)`
- [x] `tests/periph/uart` for `UART_DEV(0)`, `UART_DEV(1)` and `UART_DEV(2)`
- [x] `tests/usbus_cdc_ecm` together with `stdio_cdc_acm`

### Issues/PRs references

~Depends on PR #19571~
~Depends on PR #19572~
~Depends on PR #19573~

Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
bors bot added a commit that referenced this pull request May 27, 2023
19576: boards: add stm32l496g-disco support r=aabadie a=gschorcht

### Contribution description

The PR adds the board definition for the STM2L496G-DISO board.

It is the same board that is also shipped with the P-L496G-CELL02 LTE pack for which we already have the board definition `p-l496g-cell02`. However, `stm32l496g-disco` provides a complete configuration of the board and supports the following features in addition to `p-l496g-cell02`:
```
> FEATURES_PROVIDED += periph_adc
> FEATURES_PROVIDED += periph_dac
> FEATURES_PROVIDED += periph_dma
> FEATURES_PROVIDED += periph_pwm
> FEATURES_PROVIDED += periph_uart_hw_fc
> FEATURES_PROVIDED += arduino
```
In the long term, `p-l496g-cell02` is to be based on the new full `stm32l496g-disco` board definition.

The CPT and the LCD display are not yet supported since they are connected to/controlled by the MFX (a STM32L152-based sub-system) and the FMC peripheral.

### Testing procedure

All basic tests should work with the new board definition. The following tests were executed and did succeed:

- [x] `tests/periph/adc`
- [x] `tests/periph/dac`
- [x] `tests/periph/i2c` for `I2C_DEV(0)`, `I2C_DEV(1)` is not exposed and not tested
- [x] `tests/periph/pwm`
- [x] `tests/periph/spi` for `SPI_DEV(0)`, `SPI_DEV(1) connection not soldered and not tested
- [x] `tests/periph/timer` for `TIMER_DEV(0)` and `TIMER_DEV(1)`
- [x] `tests/periph/uart` for `UART_DEV(0)`, `UART_DEV(1)` and `UART_DEV(2)`
- [x] `tests/usbus_cdc_ecm` together with `stdio_cdc_acm`

### Issues/PRs references

~Depends on PR #19571~
~Depends on PR #19572~
~Depends on PR #19573~

Co-authored-by: Gunar Schorcht <gunar@schorcht.net>
@benpicco benpicco added this to the Release 2023.07 milestone Aug 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: cpu Area: CPU/MCU ports CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Platform: ARM Platform: This PR/issue effects ARM-based platforms Type: bug The issue reports a bug / The PR fixes a bug (including spelling errors) Type: cleanup The issue proposes a clean-up / The PR cleans-up parts of the codebase / documentation Type: new feature The issue requests / The PR implemements a new feature for RIOT
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants