From b9cb75fedf899229df5b2a35ecc4d5b45a4916f0 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 3 Mar 2021 17:05:35 +0100 Subject: [PATCH] drivers/periph/rtt: add periph_rtt_set_counter feature Some periph_rtt implementations do not provide `rtt_set_counter()`. This adds `periph_rtt_set_counter` as feature to allow testing for its availability. The feature is provided at CPU level if periph_rtt is provided by the board for all CPUs implementing `rtt_set_counter()`. --- cpu/atmega_common/Makefile.features | 1 + cpu/cc2538/Makefile.features | 1 + cpu/efm32/Makefile.features | 1 + cpu/esp32/Makefile.features | 1 + cpu/esp8266/Makefile.features | 1 + cpu/fe310/Makefile.features | 1 + cpu/kinetis/Makefile.features | 1 + cpu/nrf5x_common/Makefile.features | 1 + cpu/sam0_common/Makefile.features | 1 + cpu/stm32/Makefile.features | 1 + drivers/include/periph/rtt.h | 4 +++- 11 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cpu/atmega_common/Makefile.features b/cpu/atmega_common/Makefile.features index a2d93c21ae..a90abb1aa5 100644 --- a/cpu/atmega_common/Makefile.features +++ b/cpu/atmega_common/Makefile.features @@ -8,6 +8,7 @@ FEATURES_PROVIDED += periph_cpuid FEATURES_PROVIDED += periph_eeprom FEATURES_PROVIDED += periph_gpio periph_gpio_irq FEATURES_PROVIDED += periph_pm +FEATURES_PROVIDED += periph_rtt_set_counter FEATURES_PROVIDED += periph_timer_periodic FEATURES_PROVIDED += periph_wdt FEATURES_PROVIDED += puf_sram diff --git a/cpu/cc2538/Makefile.features b/cpu/cc2538/Makefile.features index 1fca8a7ced..cafaf3ec9a 100644 --- a/cpu/cc2538/Makefile.features +++ b/cpu/cc2538/Makefile.features @@ -6,6 +6,7 @@ FEATURES_PROVIDED += periph_flashpage FEATURES_PROVIDED += periph_flashpage_pagewise FEATURES_PROVIDED += periph_gpio periph_gpio_irq FEATURES_PROVIDED += periph_hwrng +FEATURES_PROVIDED += periph_rtt_set_counter FEATURES_PROVIDED += periph_uart_modecfg FEATURES_PROVIDED += periph_uart_nonblocking FEATURES_PROVIDED += periph_wdt diff --git a/cpu/efm32/Makefile.features b/cpu/efm32/Makefile.features index 8f369cefec..2f6363f8f9 100644 --- a/cpu/efm32/Makefile.features +++ b/cpu/efm32/Makefile.features @@ -13,6 +13,7 @@ FEATURES_PROVIDED += periph_cpuid FEATURES_PROVIDED += periph_flashpage FEATURES_PROVIDED += periph_flashpage_pagewise FEATURES_PROVIDED += periph_gpio periph_gpio_irq +FEATURES_PROVIDED += periph_rtt_set_counter FEATURES_PROVIDED += periph_wdt FEATURES_CONFLICT += periph_rtc:periph_rtt diff --git a/cpu/esp32/Makefile.features b/cpu/esp32/Makefile.features index 455772f86f..699f7b2126 100644 --- a/cpu/esp32/Makefile.features +++ b/cpu/esp32/Makefile.features @@ -9,3 +9,4 @@ FEATURES_PROVIDED += esp_wifi_enterprise FEATURES_PROVIDED += periph_adc_ctrl FEATURES_PROVIDED += periph_rtc FEATURES_PROVIDED += periph_rtt +FEATURES_PROVIDED += periph_rtt_set_counter diff --git a/cpu/esp8266/Makefile.features b/cpu/esp8266/Makefile.features index 899fbfa891..a927f8502e 100644 --- a/cpu/esp8266/Makefile.features +++ b/cpu/esp8266/Makefile.features @@ -7,3 +7,4 @@ include $(RIOTCPU)/esp_common/Makefile.features FEATURES_PROVIDED += arch_esp8266 FEATURES_PROVIDED += periph_rtt FEATURES_PROVIDED += periph_rtc +FEATURES_PROVIDED += periph_rtt_set_counter diff --git a/cpu/fe310/Makefile.features b/cpu/fe310/Makefile.features index b4998dd7b5..0d8c7eca27 100644 --- a/cpu/fe310/Makefile.features +++ b/cpu/fe310/Makefile.features @@ -1,6 +1,7 @@ FEATURES_PROVIDED += periph_cpuid FEATURES_PROVIDED += periph_gpio periph_gpio_irq FEATURES_PROVIDED += periph_pm +FEATURES_PROVIDED += periph_rtt_set_counter FEATURES_PROVIDED += periph_wdt include $(RIOTCPU)/riscv_common/Makefile.features diff --git a/cpu/kinetis/Makefile.features b/cpu/kinetis/Makefile.features index 33484b682f..853bb78bb5 100644 --- a/cpu/kinetis/Makefile.features +++ b/cpu/kinetis/Makefile.features @@ -14,6 +14,7 @@ endif FEATURES_PROVIDED += periph_gpio FEATURES_PROVIDED += periph_gpio_irq +FEATURES_PROVIDED += periph_rtt_set_counter # Parse parameters from CPU_MODEL using the kinetis-info.mk script in the same # directory as this Makefile. diff --git a/cpu/nrf5x_common/Makefile.features b/cpu/nrf5x_common/Makefile.features index 30f8cf3aa7..270dfbc80a 100644 --- a/cpu/nrf5x_common/Makefile.features +++ b/cpu/nrf5x_common/Makefile.features @@ -4,6 +4,7 @@ FEATURES_PROVIDED += periph_flashpage FEATURES_PROVIDED += periph_flashpage_pagewise FEATURES_PROVIDED += periph_gpio periph_gpio_irq FEATURES_PROVIDED += periph_hwrng +FEATURES_PROVIDED += periph_rtt_set_counter FEATURES_PROVIDED += periph_temperature FEATURES_PROVIDED += periph_timer_periodic FEATURES_PROVIDED += periph_uart_modecfg diff --git a/cpu/sam0_common/Makefile.features b/cpu/sam0_common/Makefile.features index 02dd8d1258..51d75bdd26 100644 --- a/cpu/sam0_common/Makefile.features +++ b/cpu/sam0_common/Makefile.features @@ -12,6 +12,7 @@ FEATURES_PROVIDED += periph_flashpage_pagewise FEATURES_PROVIDED += periph_flashpage_rwee FEATURES_PROVIDED += periph_gpio periph_gpio_irq FEATURES_PROVIDED += periph_i2c_reconfigure +FEATURES_PROVIDED += periph_rtt_set_counter FEATURES_PROVIDED += periph_spi_reconfigure FEATURES_PROVIDED += periph_timer_periodic # implements timer_set_periodic() FEATURES_PROVIDED += periph_uart_modecfg diff --git a/cpu/stm32/Makefile.features b/cpu/stm32/Makefile.features index b294249711..ac635c9b11 100644 --- a/cpu/stm32/Makefile.features +++ b/cpu/stm32/Makefile.features @@ -28,6 +28,7 @@ endif ifeq (f1,$(CPU_FAM)) FEATURES_CONFLICT += periph_rtc:periph_rtt FEATURES_CONFLICT_MSG += "On the STM32F1, the RTC and RTT map to the same hardware peripheral." + FEATURES_PROVIDED += periph_rtt_set_counter endif # Not all F4 and L0 parts implement a RNG. diff --git a/drivers/include/periph/rtt.h b/drivers/include/periph/rtt.h index 6d0cab57a9..59a0a3dfe8 100644 --- a/drivers/include/periph/rtt.h +++ b/drivers/include/periph/rtt.h @@ -191,9 +191,11 @@ void rtt_clear_overflow_cb(void); uint32_t rtt_get_counter(void); /** - * @brief Set the RTT counter to a specified value. + * @brief Set the RTT counter to a specified value. * * @param[in] counter The value to set the RTT to. + * + * @note This function is only provided when the feature `periph_rtt_set_counter` is provided */ void rtt_set_counter(uint32_t counter);