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

tests/periph_timer: Cleanup #14808

Closed
wants to merge 2 commits into from
Closed
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
38 changes: 0 additions & 38 deletions tests/periph_timer/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,42 +2,4 @@ include ../Makefile.tests_common

FEATURES_REQUIRED = periph_timer

BOARDS_TIMER_25kHz := \
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this should have been 250kHz :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BTW this should have been 250kHz :)

Also noticed that and even opened a PR until I noticed that #14799 was removing it...

arduino-duemilanove \
arduino-leonardo \
arduino-mega2560 \
arduino-uno \
atmega256rfr2-xpro \
atmega328p \
waspmote-pro \
#

BOARDS_TIMER_32kHz := \
hifive1 \
hifive1b \
%-kw41z \
openlabs-kw41z-mini \
frdm-k64f \
frdm-k22f \
#

BOARDS_TIMER_CLOCK_CORECLOCK := \
cc2538dk \
openmote-b \
openmote-cc2538 \
remote-reva \
remote-revb \
#

ifneq (,$(filter $(BOARDS_TIMER_25kHz),$(BOARD)))
TIMER_SPEED ?= 250000
else ifneq (,$(filter $(BOARDS_TIMER_32kHz),$(BOARD)))
TIMER_SPEED ?= 32768
else ifneq (,$(filter $(BOARDS_TIMER_CLOCK_CORECLOCK),$(BOARD)))
TIMER_SPEED ?= CLOCK_CORECLOCK
endif

TIMER_SPEED ?= 1000000

CFLAGS += -DTIMER_SPEED=$(TIMER_SPEED)
include $(RIOTBASE)/Makefile.include
20 changes: 15 additions & 5 deletions tests/periph_timer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,10 @@

#include <stdio.h>
#include <stdint.h>
#include <stdatomic.h>
#include <stdlib.h>

#include "macros/units.h"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#include "macros/units.h"
#include "board.h"
#include "macros/units.h"

This fixes the failing test on usb-kw41z (and probably on other boards)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I'll fix tonight. (Feel free to (force) push instead, of you want.)

#include "periph/timer.h"

/**
Expand All @@ -35,10 +37,18 @@
#define CHAN_OFFSET (5000U) /* fire every 5ms */
#define COOKIE (100U) /* for checking if arg is passed */

static volatile int fired;
static volatile uint32_t sw_count;
static volatile uint32_t timeouts[MAX_CHANNELS];
static volatile unsigned args[MAX_CHANNELS];
#ifndef XTIMER_HZ
#define XTIMER_HZ MHZ(1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a minor style improvement.

Suggested change
#define XTIMER_HZ MHZ(1)
#define XTIMER_HZ MHZ(1)

I can try on usb-kw41z, remote, hifive1b.

#endif

#ifndef TIMER_SPEED
#define TIMER_SPEED XTIMER_HZ
#endif

static atomic_int fired;
static atomic_uint_least32_t sw_count;
static atomic_uint_least32_t timeouts[MAX_CHANNELS];
static atomic_uint args[MAX_CHANNELS];

static void cb(void *arg, int chan)
{
Expand Down Expand Up @@ -89,7 +99,7 @@ static int test_timer(unsigned num)
timer_start(TIMER_DEV(num));
/* wait for all channels to fire */
do {
++sw_count;
sw_count++;
} while (fired != set);
/* collect results */
for (int i = 0; i < fired; i++) {
Expand Down