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/periph_timer: fix timer_query_freqs() [backport 2024.04] #20580

Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions cpu/msp430/periph/timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@
TIMER_ISR_NUMOF
};

static_assert((TXID_DIV_MAX << TXID_DIV_Pos) == TXID_DIV_Msk, "TXID_DIV_MAX or TXID_DIV_Pos is incorrect.");

Check warning on line 52 in cpu/msp430/periph/timer.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

Check warning on line 52 in cpu/msp430/periph/timer.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters
static_assert(TIMER_ISR_NUMOF == TIMER_NUMOF,
"For each provided timer a corresponding IRQ number needs to be provided by the board.");

Check warning on line 54 in cpu/msp430/periph/timer.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

Check warning on line 54 in cpu/msp430/periph/timer.c

View workflow job for this annotation

GitHub Actions / static-tests

line is longer than 100 characters

static uint32_t abs_diff(uint32_t a, uint32_t b)
{
Expand Down Expand Up @@ -188,6 +188,10 @@
assume((clock_source == TIMER_CLOCK_SOURCE_AUXILIARY_CLOCK) ||
(clock_source == TIMER_CLOCK_SOURCE_SUBMAIN_CLOCK));

if (index > TXID_DIV_MAX) {
return 0;
}

uint32_t clock_freq;
switch (clock_source) {
default:
Expand Down
2 changes: 2 additions & 0 deletions tests/periph/timer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,8 @@ static void print_supported_frequencies(tim_t dev)
" %u: %" PRIu32 "\n",
(unsigned)(end - 1), timer_query_freqs(dev, end - 1));
}

expect(timer_query_freqs(dev, end) == 0);
}

int main(void)
Expand Down
Loading