Loading...
Searching...
No Matches
qdec.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2017 Gilles DOFFE <gdoffe@gmail.com>
3 * SPDX-License-Identifier: LGPL-2.1-only
4 */
5
6#pragma once
7
75
76#include <stdint.h>
77#include <limits.h>
78
79#include "periph_cpu.h"
80#include "periph_conf.h"
81
82#ifdef __cplusplus
83extern "C" {
84#endif
85
89#ifndef QDEC_DEV
90#define QDEC_DEV(x) (x)
91#endif
92
96#ifndef QDEC_UNDEF
97#define QDEC_UNDEF (UINT_FAST8_MAX)
98#endif
99
103#ifndef HAVE_QDEC_T
104typedef uint_fast8_t qdec_t;
105#endif
106
110#ifndef HAVE_QDEC_MODE_T
111typedef enum {
112 QDEC_X1, /* X1 mode */
113 QDEC_X2, /* X2 mode */
114 QDEC_X4, /* X4 mode */
116#endif
117
123typedef void (*qdec_cb_t)(void *arg);
124
128#ifndef HAVE_TIMER_ISR_CTX_T
129typedef struct {
131 void *arg;
133#endif
134
156int32_t qdec_init(qdec_t dev, qdec_mode_t mode, qdec_cb_t cb, void *arg);
157
165int32_t qdec_read(qdec_t dev);
166
175
184
192void qdec_stop(qdec_t qdec);
193
194#ifdef __cplusplus
195}
196#endif
197
int32_t qdec_init(qdec_t dev, qdec_mode_t mode, qdec_cb_t cb, void *arg)
Initialize a QDEC device.
int32_t qdec_read_and_reset(qdec_t dev)
Read the current value of the given qdec device and reset it.
qdec_mode_t
Default QDEC mode definition.
Definition qdec.h:111
uint_fast8_t qdec_t
Default QDEC type definition.
Definition qdec.h:104
int32_t qdec_read(qdec_t dev)
Read the current value of the given qdec device.
void qdec_stop(qdec_t qdec)
Stop the given qdec timer.
void qdec_start(qdec_t qdec)
Start the given qdec timer.
void(* qdec_cb_t)(void *arg)
Signature of event callback functions triggered from interrupts.
Definition qdec.h:123
Default interrupt context entry holding callback and argument.
Definition qdec.h:129
qdec_cb_t cb
callback executed from qdec interrupt
Definition qdec.h:130
void * arg
optional argument given to that callback
Definition qdec.h:131