<commit_before>/*
 * Copyright (C) 2019 <NAME> <<EMAIL>>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 */

/**
 * @ingroup     tests
 * @{
 *
 * @file
 * @brief       Peripheral timer test application
 *
 * @author      <NAME> <<EMAIL>>
 *
 * @}
 */

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

#include "board.h"
#include "thread.h"
#include "thread_flags.h"

#include "periph/timer.h"

#ifndef TEST_TIMER_DEV
# include "xtimer.h"
# define TEST_TIMER_DEV      XTIMER_DEV
# define TEST_TIMER_FREQ     XTIMER_HZ
# define TEST_TIMER_WIDTH    XTIMER_WIDTH
#else
# ifndef TEST_TIMER_FREQ
#  define TEST_TIMER_FREQ     (1000000LU)
# endif
#endif

#ifndef TEST_MAX_DIFF
#define TEST_MAX_DIFF   (1000LU)
#endif

#if TEST_TIMER_WIDTH == 32
# define TEST_TIMER_MAX      (0xFFFFFFFFLU)
#else
# define TEST_TIMER_MAX      ((1UL << TEST_TIMER_WIDTH) - 1)
#endif

static void cb(void *arg, int chan)
{
    (void)chan;
    thread_flags_set(arg, 1);
}

int main(void)
{
    puts("\nTest for peripheral TIMER short timer_set()\n");

    printf("This test tries timer_set() with decreasing intervals down to 0.\n"
           "You should see lines like 'interval <n> ok', followed by a success"
           " message.\n"
           "On failure, this test prints an error message.\n\n");

    printf("testing periph_timer %u, freq %lu\n", TEST_TIMER_DEV, TEST_TIMER_FREQ);<commit_msg>tests/periph_timer_short_relative_set: Don't include xtimer.h<commit_after>/*
 * Copyright (C) 2019 <NAME> <<EMAIL>>
 *
 * This file is subject to the terms and conditions of the GNU Lesser
 * General Public License v2.1. See the file LICENSE in the top level
 * directory for more details.
 */

/**
 * @ingroup     tests
 * @{
 *
 * @file
 * @brief       Peripheral timer test application
 *
 * @author      <NAME> <<EMAIL>>
 *
 * @}
 */

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

#include "board.h"
#include "macros/units.h"
#include "thread.h"
#include "thread_flags.h"

#include "periph/timer.h"

/* recreate logic to obtain valid XTIMER_DEV used in xtimer.h, but don't include
 * xtimer.h, as this leads to issues on some boards when the xtimer module is
 * not used */
#ifndef XTIMER_DEV
# define XTIMER_DEV         TIMER_DEV(0)
#endif
#ifndef XTIMER_HZ
# define XTIMER_HZ          MHZ(1)
#endif
#ifndef XTIMER_WIDTH
# if(TIMER_0_MAX_VALUE) == 0xfffffful
#  define XTIMER_WIDTH      (24)
# elif (TIMER_0_MAX_VALUE) == 0xffff
#  define XTIMER_WIDTH      (16)
# else
#  define XTIMER_WIDTH      (32)
# endif
#endif /* !defined(XTIMER_WIDTH) */

#ifndef TEST_TIMER_FREQ
# define TEST_TIMER_DEV     XTIMER_DEV
# define TEST_TIMER_FREQ    XTIMER_HZ
# define TEST_TIMER_WIDTH   XTIMER_WIDTH
#endif

#ifndef TEST_MAX_DIFF
#define TEST_MAX_DIFF   (1000LU)
#endif

#if TEST_TIMER_WIDTH == 32
# define TEST_TIMER_MAX      (0xFFFFFFFFLU)
#else
# define TEST_TIMER_MAX      ((1UL << TEST_TIMER_WIDTH) - 1)
#endif

static void cb(void *arg, int chan)
{
    (void)chan;
    thread_flags_set(arg, 1);
}

int main(void)
{
    puts("\nTest for peripheral TIMER short timer_set()\n");

    printf("This test tries timer_set() with decreasing intervals down to 0.\n"
           "You should see lines like 'interval <n> ok', followed by a success"
           " message.\n"
           "On failure, this test prints an error message.\n\n");

    printf("testing periph_timer %u, freq %lu\n", TEST_TIMER_DEV, TEST_TIMER_FREQ);
{'fraction_non_alphanumeric': 0.11481900452488687, 'fraction_numerical': 0.01498868778280543, 'mean_word_length': 3.482889733840304, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 2, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4254487', 'n_tokens_mistral': 1330, 'n_tokens_neox': 1265, 'n_words': 365}