Loading...
Searching...
No Matches
qdec.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2017 Gilles DOFFE <gdoffe@gmail.com>
3 *
4 * This file is subject to the terms and conditions of the GNU Lesser
5 * General Public License v2.1. See the file LICENSE in the top level
6 * directory for more details.
7 */
8
77#ifndef PERIPH_QDEC_H
78#define PERIPH_QDEC_H
79
80#include <stdint.h>
81#include <limits.h>
82
83#include "periph_cpu.h"
84#include "periph_conf.h"
85
86#ifdef __cplusplus
87extern "C" {
88#endif
89
93#ifndef QDEC_DEV
94#define QDEC_DEV(x) (x)
95#endif
96
100#ifndef QDEC_UNDEF
101#define QDEC_UNDEF (UINT_FAST8_MAX)
102#endif
103
107#ifndef HAVE_QDEC_T
108typedef uint_fast8_t qdec_t;
109#endif
110
114#ifndef HAVE_QDEC_MODE_T
115typedef enum {
116 QDEC_X1, /* X1 mode */
117 QDEC_X2, /* X2 mode */
118 QDEC_X4, /* X4 mode */
120#endif
121
127typedef void (*qdec_cb_t)(void *arg);
128
132#ifndef HAVE_TIMER_ISR_CTX_T
133typedef struct {
135 void *arg;
137#endif
138
160int32_t qdec_init(qdec_t dev, qdec_mode_t mode, qdec_cb_t cb, void *arg);
161
169int32_t qdec_read(qdec_t dev);
170
179
188
196void qdec_stop(qdec_t qdec);
197
198#ifdef __cplusplus
199}
200#endif
201
202#endif /* PERIPH_QDEC_H */
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:115
uint_fast8_t qdec_t
Default QDEC type definition.
Definition qdec.h:108
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:127
Default interrupt context entry holding callback and argument.
Definition qdec.h:133
qdec_cb_t cb
callback executed from qdec interrupt
Definition qdec.h:134
void * arg
optional argument given to that callback
Definition qdec.h:135