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/msp430: improve periph_timer #20160

Merged
merged 4 commits into from
Dec 10, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
cpu/msp430: aid optimizer
Declare functions retrieving the clock domains frequency as pure so
that common subexpressions can be eliminated more easily.
  • Loading branch information
maribu committed Dec 10, 2023
commit e6154a04a185209da1b61f279d90fc61cc3a2564
5 changes: 3 additions & 2 deletions cpu/msp430/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions cpu/msp430/include/periph_cpu_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down