From e6154a04a185209da1b61f279d90fc61cc3a2564 Mon Sep 17 00:00:00 2001 From: Marian Buschsieweke Date: Wed, 6 Dec 2023 20:35:19 +0100 Subject: [PATCH] cpu/msp430: aid optimizer Declare functions retrieving the clock domains frequency as pure so that common subexpressions can be eliminated more easily. --- cpu/msp430/clock.c | 5 +++-- cpu/msp430/include/periph_cpu_common.h | 4 ++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/cpu/msp430/clock.c b/cpu/msp430/clock.c index eb27cd01ee..e9d7f55070 100644 --- a/cpu/msp430/clock.c +++ b/cpu/msp430/clock.c @@ -348,7 +348,8 @@ void default_clock_init(void) __attribute__((weak, alias("default_clock_init"))) void clock_init(void); -uint32_t msp430_submain_clock_freq(void) { +uint32_t PURE msp430_submain_clock_freq(void) +{ uint16_t shift = (clock_params.submain_clock_divier >> 1) & 0x3; switch (clock_params.submain_clock_source) { case SUBMAIN_CLOCK_SOURCE_LFXT1CLK: @@ -365,7 +366,7 @@ uint32_t msp430_submain_clock_freq(void) { } } -uint32_t msp430_auxiliary_clock_freq(void) +uint32_t PURE msp430_auxiliary_clock_freq(void) { uint16_t shift = (clock_params.auxiliary_clock_divier >> 4) & 0x3; return clock_params.lfxt1_frequency >> shift; diff --git a/cpu/msp430/include/periph_cpu_common.h b/cpu/msp430/include/periph_cpu_common.h index a904e6e949..8034e0d79d 100644 --- a/cpu/msp430/include/periph_cpu_common.h +++ b/cpu/msp430/include/periph_cpu_common.h @@ -358,14 +358,14 @@ void clock_init(void); * * @note This is only useful when implementing MSP430 peripheral drivers */ -uint32_t msp430_submain_clock_freq(void); +uint32_t PURE msp430_submain_clock_freq(void); /** * @brief Get the configured auxiliary clock frequency * * @note This is only useful when implementing MSP430 peripheral drivers */ -uint32_t msp430_auxiliary_clock_freq(void); +uint32_t PURE msp430_auxiliary_clock_freq(void); #ifdef __cplusplus }