Skip to content

cpu/kinetis: use LPTMR as rtt backend #16546

Merged
kaspar030 merged 2 commits intoRIOT-OS:masterfrom
fjmolinas:pr_kinetis_lptmr_rtt
Jun 15, 2021
Merged

cpu/kinetis: use LPTMR as rtt backend #16546
kaspar030 merged 2 commits intoRIOT-OS:masterfrom
fjmolinas:pr_kinetis_lptmr_rtt

Conversation

@fjmolinas
Copy link
Copy Markdown
Contributor

@fjmolinas fjmolinas commented Jun 11, 2021

Contribution description

This pr makes rtc use the RTC peripheral and rtt use the RTT peripheral. This wants to remove the remaining od-ball that is kinetis, with this we can simply do:

ifneq (,$(filter ztimer_msec,$(USEMODULE))
  FEATURES_OPTIONAL += periph_rtt
  ifneq (,$(filter periph_rtt,$(FEATURES_USED)))
    USEMODULE += ztimer_periph_rtt
  endif
endif

ifneq (,$(filter stm32 nrf52 sam%,$(CPU)))
  RTT_FREQUENCY ?= RTT_MAX_FREQUENCY
  CFLAGS += -DRTT_FREQUENCY=$(RTT_FREQUENCY)
endif

And have rtt always pulled as the ztimer_msec backend if available.

Testing procedure

On all kinetis as possible run

  • tests/periph_rtt
2021-06-11 17:59:01,668 # main(): This is RIOT! (Version: 2021.07-devel-322-g92924-HEAD)
2021-06-11 17:59:01,668 # 
2021-06-11 17:59:01,671 # RIOT RTT low-level driver test
2021-06-11 17:59:01,673 # RTT configuration:
2021-06-11 17:59:01,675 # RTT_MAX_VALUE: 0x0000ffff
2021-06-11 17:59:01,677 # RTT_FREQUENCY: 1024
2021-06-11 17:59:01,677 # 
2021-06-11 17:59:01,680 # Testing the tick conversion
2021-06-11 17:59:01,683 # Trying to convert 1 to seconds and back
2021-06-11 17:59:01,687 # Trying to convert 256 to seconds and back
2021-06-11 17:59:01,691 # Trying to convert 65536 to seconds and back
2021-06-11 17:59:01,694 # Trying to convert 16777216 to seconds and back
2021-06-11 17:59:01,699 # Trying to convert 2147483648 to seconds and back
2021-06-11 17:59:01,700 # All ok
2021-06-11 17:59:01,700 # 
2021-06-11 17:59:01,702 # Initializing the RTT driver
2021-06-11 17:59:01,707 # This test will now display 'Hello' every 5 seconds
2021-06-11 17:59:01,707 # 
2021-06-11 17:59:01,708 # RTT now: 4
2021-06-11 17:59:01,711 # Setting initial alarm to now + 5 s (5124)
2021-06-11 17:59:01,714 # rtt_get_alarm() PASSED
2021-06-11 17:59:01,718 # Done setting up the RTT, wait for many Hellos
2021-06-11 17:59:06,708 # Hello
2021-06-11 17:59:11,708 # Hello
2021-06-11 17:59:16,708 # Hello
2021-06-11 17:59:21,709 # Hello
2021-06-11 17:59:26,709 # Hello
2021-06-11 17:59:31,709 # Hello
2021-06-11 17:59:36,709 # Hello
2021-06-11 17:59:41,708 # Hello
2021-06-11 17:59:46,709 # Hello
  • tests/periph_rtc
main(): This is RIOT! (Version: 2021.07-devel-323-g3aa10-pr_kinetis_lptmr_rtt)

RIOT RTC low-level driver test
This test will display 'Alarm!' every 2 seconds for 4 times
  Setting clock to   2020-02-28 23:59:57
Clock value is now   2020-02-28 23:59:57
  Setting alarm to   2020-02-28 23:59:59
   Alarm is set to   2020-02-28 23:59:59
  Alarm cleared at   2020-02-28 23:59:59
       No alarm at   2020-02-28 23:59:59
  Setting alarm to   2020-02-28 23:59:61

Alarm!
Alarm!
Alarm!
Alarm!

@fjmolinas fjmolinas added the CI: ready for build If set, CI server will compile all applications for all available boards for the labeled PR label Jun 11, 2021
@github-actions github-actions bot added Area: boards Area: Board ports Area: cpu Area: CPU/MCU ports Area: tests Area: tests and testing framework Platform: ARM Platform: This PR/issue effects ARM-based platforms labels Jun 11, 2021
@fjmolinas fjmolinas force-pushed the pr_kinetis_lptmr_rtt branch from 3aa10b7 to d9ee424 Compare June 15, 2021 06:29
@fjmolinas fjmolinas requested a review from cgundogan as a code owner June 15, 2021 06:29
@github-actions github-actions bot added the Area: Kconfig Area: Kconfig integration label Jun 15, 2021
@fjmolinas
Copy link
Copy Markdown
Contributor Author

pba-d-01-kw2x doesn't seem to have LPTMR so removed periph_rtt

@kaspar030 kaspar030 added Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines labels Jun 15, 2021
@kaspar030
Copy link
Copy Markdown
Contributor

LGTM, but I don't have a board to test.

@fjmolinas
Copy link
Copy Markdown
Contributor Author

Maybe @benpicco can test? I can provided test output for frdm-64f, frdm-kw41z, pba-d-01-kw2x

@benpicco
Copy link
Copy Markdown
Contributor

Looks good!

2021-06-15 10:36:05,811 # main(): This is RIOT! (Version: 2021.04-devel-766-gddbaa-HEAD)
2021-06-15 10:36:05,812 # 
2021-06-15 10:36:05,814 # RIOT RTT low-level driver test
2021-06-15 10:36:05,815 # RTT configuration:
2021-06-15 10:36:05,817 # RTT_MAX_VALUE: 0xffffffff
2021-06-15 10:36:05,819 # RTT_FREQUENCY: 1
2021-06-15 10:36:05,820 # 
2021-06-15 10:36:05,821 # Testing the tick conversion
2021-06-15 10:36:05,825 # Trying to convert 1 to seconds and back
2021-06-15 10:36:05,828 # Trying to convert 256 to seconds and back
2021-06-15 10:36:05,831 # Trying to convert 65536 to seconds and back
2021-06-15 10:36:05,836 # Trying to convert 16777216 to seconds and back
2021-06-15 10:36:05,839 # Trying to convert 2147483648 to seconds and back
2021-06-15 10:36:05,842 # All ok
2021-06-15 10:36:05,842 # 
2021-06-15 10:36:05,844 # Initializing the RTT driver
2021-06-15 10:36:05,847 # This test will now display 'Hello' every 5 seconds
2021-06-15 10:36:05,847 # 
2021-06-15 10:36:05,850 # RTT now: 0
2021-06-15 10:36:05,853 # Setting initial alarm to now + 5 s (5)
2021-06-15 10:36:05,857 # Done setting up the RTT, wait for many Hellos
2021-06-15 10:36:10,844 # Hello
2021-06-15 10:36:15,845 # Hello
2021-06-15 10:36:20,844 # Hello

@fjmolinas
Copy link
Copy Markdown
Contributor Author

  • frdm-kw64F
main(): This is RIOT! (Version: 2021.07-devel-323-gd9ee42-pr_kinetis_lptmr_rtt)

RIOT RTT low-level driver test
RTT configuration:
RTT_MAX_VALUE: 0x0000ffff
RTT_FREQUENCY: 1024

Testing the tick conversion
Trying to convert 1 to seconds and back
Trying to convert 256 to seconds and back
Trying to convert 65536 to seconds and back
Trying to convert 16777216 to seconds and back
Trying to convert 2147483648 to seconds and back
All ok

Initializing the RTT driver
This test will now display 'Hello' every 5 seconds

RTT now: 4
Setting initial alarm to now + 5 s (5124)
rtt_get_alarm() PASSED
Done setting up the RTT, wait for many Hellos
Hello
Hello
Hello
Hello
Hello
main(): This is RIOT! (Version: 2021.07-devel-323-gd9ee42-pr_kinetis_lptmr_rtt)

RIOT RTC low-level driver test
This test will display 'Alarm!' every 2 seconds for 4 times
  Setting clock to   2020-02-28 23:59:57
Clock value is now   2020-02-28 23:59:57
  Setting alarm to   2020-02-28 23:59:59
   Alarm is set to   2020-02-28 23:59:59
  Alarm cleared at   2020-02-28 23:59:59
       No alarm at   2020-02-28 23:59:59
  Setting alarm to   2020-02-28 23:59:61

Alarm!
Alarm!
Alarm!
Alarm!
  • pba-d01-kw2x
main(): This is RIOT! (Version: 2021.07-devel-323-gd9ee42-pr_kinetis_lptmr_rtt)

RIOT RTC low-level driver test
This test will display 'Alarm!' every 2 seconds for 4 times
  Setting clock to   2020-02-28 23:59:57
Clock value is now   2020-02-28 23:59:57
  Setting alarm to   2020-02-28 23:59:59
   Alarm is set to   2020-02-28 23:59:59
  Alarm cleared at   2020-02-28 23:59:59
       No alarm at   2020-02-28 23:59:59
  Setting alarm to   2020-02-28 23:59:61

Alarm!
Alarm!
Alarm!
Alarm!

@kaspar030
Copy link
Copy Markdown
Contributor

ACK.

@kaspar030 kaspar030 merged commit beb171d into RIOT-OS:master Jun 15, 2021
@fjmolinas fjmolinas deleted the pr_kinetis_lptmr_rtt branch June 15, 2021 09:24
@MrKevinWeiss MrKevinWeiss added Process: release backport Integration Process: The PR is a release backport of a change previously provided to master and removed Process: release backport Integration Process: The PR is a release backport of a change previously provided to master labels Jul 15, 2021
@MrKevinWeiss MrKevinWeiss added this to the Release 2021.07 milestone Jul 15, 2021
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 Area: Kconfig Area: Kconfig integration Area: tests Area: tests and testing framework 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 Reviewed: 1-fundamentals The fundamentals of the PR were reviewed according to the maintainer guidelines Reviewed: 2-code-design The code design of the PR was reviewed according to the maintainer guidelines Reviewed: 4-code-style The adherence to coding conventions by the PR were reviewed according to the maintainer guidelines Reviewed: 5-documentation The documentation details of the PR were reviewed according to the maintainer guidelines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants