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

boards/nucleo-l432k: provide three periph_timer instances #19677

Merged
merged 3 commits into from
May 30, 2023

Conversation

maribu
Copy link
Member

@maribu maribu commented May 30, 2023

Contribution description

  • cpu/stm32/periph_timer: Generalize to also work with timers that do not have 4 channels
  • boards/common/stm32: Add timer config for three timers based on TIM2, TIM15, and TIM16 (the three general-purpose timers of the STM32L4)
  • boards/nucleo-l432kc: Make use of the new timer config

Testing procedure

make BOARD=nucleo-l432kc -C tests/periph/timer flash test

[...]
READY
s
START
main(): This is RIOT! (Version: 2023.07-devel-510-ge690e-stm32_cfg_timer_tim2_tim15_tim16)

Test for peripheral TIMERs

Available timers: 3

Testing TIMER_0:
TIMER_0: initialization successful
TIMER_0: stopped
TIMER_0: set channel 0 to 5000
TIMER_0: set channel 1 to 10000
TIMER_0: set channel 2 to 15000
TIMER_0: set channel 3 to 20000
TIMER_0: starting
TIMER_0: channel 0 fired at SW count    24996 - init:    24996
TIMER_0: channel 1 fired at SW count    49983 - diff:    24987
TIMER_0: channel 2 fired at SW count    74972 - diff:    24989
TIMER_0: channel 3 fired at SW count    99961 - diff:    24989

Testing TIMER_1:
TIMER_1: initialization successful
TIMER_1: stopped
TIMER_1: set channel 0 to 5000
TIMER_1: set channel 1 to 10000
TIMER_1: starting
TIMER_1: channel 0 fired at SW count    24996 - init:    24996
TIMER_1: channel 1 fired at SW count    49984 - diff:    24988

Testing TIMER_2:
TIMER_2: initialization successful
TIMER_2: stopped
TIMER_2: set channel 0 to 5000
TIMER_2: starting
TIMER_2: channel 0 fired at SW count    24996 - init:    24996

TEST SUCCEEDED

make: Leaving directory '/home/maribu/Repos/software/RIOT/stm32_cfg_timer_tim2_tim15_tim16/tests/periph/timer'

Issues/PRs references

None

The assumption that all STM32 timers have exactly four channels no
longer holds. E.g. the STM32L4 has the following general purpose timers:

- TIM2: 32 bit, 4 channels
- TIM15: 16 bit, 2 channels
- TIM16: 16 bit, 1 channel

Hence, a new field is added to the timer configuration to also contain
the number of timer channels. Due to alignment the `struct` previously
was padded by 16 bit, so adding another 8 bit field doesn't increase
its size.

For backward compatibility, a value of `0` is considered as alias for
`TIMER_CHANNEL_NUMOF` (or 4), so that the number of timer channels
only needs to be set when the timer is different from the typical 4
channel timer. This helps backward compatibility.
This adds the three general purpose timers on STM32L4 boards in a
central place so that STM32L4 boards can just include it.

Some other families may also have TIM15 and TIM16 and could use this,
but likely some generalization is needed to use this for other
families as well. This can be added later on.
@maribu maribu added Type: new feature The issue requests / The PR implemements a new feature for RIOT CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports labels May 30, 2023
@github-actions github-actions bot added the Platform: ARM Platform: This PR/issue effects ARM-based platforms label May 30, 2023
@riot-ci
Copy link

riot-ci commented May 30, 2023

Murdock results

✔️ PASSED

0051d41 boards/nucleo-l432kc: provide three periph_timer instances

Success Failures Total Runtime
6933 0 6933 17m:37s

Artifacts

Copy link
Contributor

@aabadie aabadie left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK

bors merge

bors bot added a commit that referenced this pull request May 30, 2023
19677: boards/nucleo-l432k: provide three periph_timer instances r=aabadie a=maribu

### Contribution description

- `cpu/stm32/periph_timer`: Generalize to also work with timers that do not have 4 channels
- `boards/common/stm32`: Add timer config for three timers based on TIM2, TIM15, and TIM16 (the three general-purpose timers of the STM32L4)
- `boards/nucleo-l432kc`: Make use of the new timer config


Co-authored-by: Marian Buschsieweke <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 30, 2023

Build failed:

@maribu
Copy link
Member Author

maribu commented May 30, 2023

bors merge

(failed due to CI glitch)

bors bot added a commit that referenced this pull request May 30, 2023
19677: boards/nucleo-l432k: provide three periph_timer instances r=maribu a=maribu

### Contribution description

- `cpu/stm32/periph_timer`: Generalize to also work with timers that do not have 4 channels
- `boards/common/stm32`: Add timer config for three timers based on TIM2, TIM15, and TIM16 (the three general-purpose timers of the STM32L4)
- `boards/nucleo-l432kc`: Make use of the new timer config


19681: sys/xtimer: improve documentation r=maribu a=maribu

### Contribution description

- Add a warning that xtimer is deprecated, so that new code hopefully starts using ztimer
- Add a hint that `ztimer_xtimer_compat` can be used even after `xtimer` is gone


Co-authored-by: Marian Buschsieweke <[email protected]>
@maribu
Copy link
Member Author

maribu commented May 30, 2023

bors cancel
bors merge

@bors
Copy link
Contributor

bors bot commented May 30, 2023

Canceled.

bors bot added a commit that referenced this pull request May 30, 2023
19677: boards/nucleo-l432k: provide three periph_timer instances r=maribu a=maribu

### Contribution description

- `cpu/stm32/periph_timer`: Generalize to also work with timers that do not have 4 channels
- `boards/common/stm32`: Add timer config for three timers based on TIM2, TIM15, and TIM16 (the three general-purpose timers of the STM32L4)
- `boards/nucleo-l432kc`: Make use of the new timer config


19678: gnrc_sixlowpan_iphc: fix NULL pointer dereference r=maribu a=miri64



19681: sys/xtimer: improve documentation r=maribu a=maribu

### Contribution description

- Add a warning that xtimer is deprecated, so that new code hopefully starts using ztimer
- Add a hint that `ztimer_xtimer_compat` can be used even after `xtimer` is gone


Co-authored-by: Marian Buschsieweke <[email protected]>
Co-authored-by: Martine Lenders <[email protected]>
@bors
Copy link
Contributor

bors bot commented May 30, 2023

Build failed (retrying...):

bors bot added a commit that referenced this pull request May 30, 2023
19677: boards/nucleo-l432k: provide three periph_timer instances r=maribu a=maribu

### Contribution description

- `cpu/stm32/periph_timer`: Generalize to also work with timers that do not have 4 channels
- `boards/common/stm32`: Add timer config for three timers based on TIM2, TIM15, and TIM16 (the three general-purpose timers of the STM32L4)
- `boards/nucleo-l432kc`: Make use of the new timer config


19683: cpu/sam0_eth: clean up init() r=dylad a=benpicco





Co-authored-by: Marian Buschsieweke <[email protected]>
Co-authored-by: Benjamin Valentin <[email protected]>
@maribu
Copy link
Member Author

maribu commented May 30, 2023

bors cancel
bors merge

@bors
Copy link
Contributor

bors bot commented May 30, 2023

Canceled.

bors bot added a commit that referenced this pull request May 30, 2023
19677: boards/nucleo-l432k: provide three periph_timer instances r=maribu a=maribu

### Contribution description

- `cpu/stm32/periph_timer`: Generalize to also work with timers that do not have 4 channels
- `boards/common/stm32`: Add timer config for three timers based on TIM2, TIM15, and TIM16 (the three general-purpose timers of the STM32L4)
- `boards/nucleo-l432kc`: Make use of the new timer config


19683: cpu/sam0_eth: clean up init() r=dylad a=benpicco





Co-authored-by: Marian Buschsieweke <[email protected]>
Co-authored-by: Benjamin Valentin <[email protected]>
@maribu
Copy link
Member Author

maribu commented May 30, 2023

C'mon...
bors cancel
bors merge

@bors
Copy link
Contributor

bors bot commented May 30, 2023

Canceled.

@bors
Copy link
Contributor

bors bot commented May 30, 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 f104267 into RIOT-OS:master May 30, 2023
@maribu maribu deleted the stm32_cfg_timer_tim2_tim15_tim16 branch May 31, 2023 04:26
@maribu
Copy link
Member Author

maribu commented May 31, 2023

Thx :)

@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: boards Area: Board ports 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: 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.

4 participants