<commit_before>/*
 * Copyright (C) 2014-2015 Freie Universität Berlin
 *
 * 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.
 */

/**
 * @defgroup    drivers_periph_timer Timer
 * @ingroup     drivers_periph
 * @brief       Low-level timer peripheral driver
 *
 * # (Low-) Power Implications
 *
 * After calling timer_init(), the underlying hardware timer **should** be
 * powered on and running. When a timer is explicitly stopped by calling
 * timer_stop(), the timer **should** be stopped and powered down (e.g. by
 * peripheral clock gating). Once the timer is started again (by calling
 * timer_start()), it should transparently continue its previously configured
 * operation.
 *
 * While the timer is active, the implementation might need to block certain
 * power modes on specific CPU implementation.
 *
 * @{
 * @file
 * @brief       Low-level timer peripheral driver interface definitions
 *
 * @author      <NAME> <hauke.petersen@fu-berlin.de>
 */

#ifndef PERIPH_TIMER_H
#define PERIPH_TIMER_H

#include <limits.h>
#include <stdint.h>

#include "periph_cpu.h"
#include "periph_conf.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief   Default timer definition macro
 *
 * Overwrite this in your CPUs periph_cpu.h file if needed
 */
#ifndef TIMER_DEV
#define TIMER_DEV(x)        (x)
#endif

/**
 * @brief   Default value for timer not defined
 */
#ifndef TIMER_UNDEF
#define TIMER_UNDEF         (UINT_FAST8_MAX)
#endif

/**
 * @brief   Default timer type
 *
 * We chose the name of tim_t here to avoid naming clashes with other libraries
 * and vendor device header.
 */
#ifndef HAVE_TIMER_T
typedef uint_fast8_t tim_t;
#endif

/**
 * @brief   Reset the timer when the set() function is called
 *
 * When set, calling the timer_set_periodic() function resets the timer count value.
 */
#ifndef TIM_FLAG_RESET_ON_SET
#define TIM_FLAG_RESET_ON_SET   (0x01)
#endif

/**
 * @brief   Reset the timer on match
 *
 * When set, a match on this channel will reset the timer count value.
 * When set on multiple channels, only the channel with the lowest match value
 * will be reached.
 */
#ifndef TIM_FLAG_RESET_ON_MATCH
#define TIM_FLAG_RESET_ON_MATCH (0x02)
#endif

/**
 * @brief   Signature of event callback functions triggered from interrupts
 *
 * @param[in] arg       optional context for the callback
 * @param[in] channel   timer channel that triggered the interrupt
 */
typedef void (*timer_cb_t)(void *arg, int channel);

/**
 * @brief   Default interrupt context entry holding callback and argument
 */
#ifndef HAVE_TIMER_ISR_CTX_T
typedef struct {
    timer_cb_t cb;          /**< callback executed from timer interrupt */<commit_msg>drivers/periph/timer: add TIM_FLAG_SET_STOPPED flag<commit_after>/*
 * Copyright (C) 2014-2015 Freie Universität Berlin
 *
 * 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.
 */

/**
 * @defgroup    drivers_periph_timer Timer
 * @ingroup     drivers_periph
 * @brief       Low-level timer peripheral driver
 *
 * # (Low-) Power Implications
 *
 * After calling timer_init(), the underlying hardware timer **should** be
 * powered on and running. When a timer is explicitly stopped by calling
 * timer_stop(), the timer **should** be stopped and powered down (e.g. by
 * peripheral clock gating). Once the timer is started again (by calling
 * timer_start()), it should transparently continue its previously configured
 * operation.
 *
 * While the timer is active, the implementation might need to block certain
 * power modes on specific CPU implementation.
 *
 * @{
 * @file
 * @brief       Low-level timer peripheral driver interface definitions
 *
 * @author      <NAME> <<EMAIL>>
 */

#ifndef PERIPH_TIMER_H
#define PERIPH_TIMER_H

#include <limits.h>
#include <stdint.h>

#include "periph_cpu.h"
#include "periph_conf.h"

#ifdef __cplusplus
extern "C" {
#endif

/**
 * @brief   Default timer definition macro
 *
 * Overwrite this in your CPUs periph_cpu.h file if needed
 */
#ifndef TIMER_DEV
#define TIMER_DEV(x)        (x)
#endif

/**
 * @brief   Default value for timer not defined
 */
#ifndef TIMER_UNDEF
#define TIMER_UNDEF         (UINT_FAST8_MAX)
#endif

/**
 * @brief   Default timer type
 *
 * We chose the name of tim_t here to avoid naming clashes with other libraries
 * and vendor device header.
 */
#ifndef HAVE_TIMER_T
typedef uint_fast8_t tim_t;
#endif

/**
 * @brief   Reset the timer when the set() function is called
 *
 * When set, calling the timer_set_periodic() function resets the timer count value.
 */
#ifndef TIM_FLAG_RESET_ON_SET
#define TIM_FLAG_RESET_ON_SET   (0x01)
#endif

/**
 * @brief   Reset the timer on match
 *
 * When set, a match on this channel will reset the timer count value.
 * When set on multiple channels, only the channel with the lowest match value
 * will be reached.
 */
#ifndef TIM_FLAG_RESET_ON_MATCH
#define TIM_FLAG_RESET_ON_MATCH (0x02)
#endif

/**
 * @brief   Keep the timer stopped after setting alarm.
 *
 * When set, the timer will remained stopped after a timer_set_periodic() and
 * can be started manually with timer_start().
 */
#ifndef TIM_FLAG_SET_STOPPED
#define TIM_FLAG_SET_STOPPED    (0x04)
#endif

/**
 * @brief   Signature of event callback functions triggered from interrupts
 *
 * @param[in] arg       optional context for the callback
 * @param[in] channel   timer channel that triggered the interrupt
 */
typedef void (*timer_cb_t)(void *arg, int channel);

/**
 * @brief   Default interrupt context entry holding callback and argument
 */
#ifndef HAVE_TIMER_ISR_CTX_T
typedef struct {
    timer_cb_t cb;          /**< callback executed from timer interrupt */
{'fraction_non_alphanumeric': 0.08613013698630137, 'fraction_numerical': 0.006678082191780822, 'mean_word_length': 3.775960752248569, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 12, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 1, 'substrings_counts': 0, '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': '7223866', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1718, 'n_words': 686}