Skip to content

Commit

Permalink
tests/periph_timer: Use XTIMER_HZ over manual list
Browse files Browse the repository at this point in the history
  • Loading branch information
maribu committed Aug 20, 2020
1 parent 10c6bcc commit 9575ffd
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 42 deletions.
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 := \
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
17 changes: 13 additions & 4 deletions tests/periph_timer/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <stdint.h>
#include <stdlib.h>

#include "macros/units.h"
#include "periph/timer.h"

/**
Expand All @@ -35,10 +36,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)
#endif

#ifndef TIMER_SPEED
#define TIMER_SPEED XTIMER_HZ
#endif

static int fired;
static uint32_t sw_count;
static uint32_t timeouts[MAX_CHANNELS];
static unsigned args[MAX_CHANNELS];

static void cb(void *arg, int chan)
{
Expand Down

0 comments on commit 9575ffd

Please sign in to comment.