qdec.h¶
Low-level QDEC peripheral driver interface definitions.
-
QDEC_DEV
( x)¶ Default QDEC access macro.
1
(x)
-
QDEC_UNDEF
¶ Default QDEC undefined value.
1
(UINT_MAX)
-
enum
qdec_mode_t
¶ - QDEC_X1
- QDEC_X2
- QDEC_X4
-
unsigned int
qdec_t
¶ Default QDEC type definition.
-
void(*
qdec_cb_t
()¶ Signature of event callback functions triggered from interrupts.
Parameters
arg: optional context for the callback
-
int32_t
qdec_init
(qdec.h::qdec_t
dev,qdec.h::qdec_mode_t
mode,qdec.h::qdec_cb_t
cb, void * arg)¶ Initialize a QDEC device.
The QDEC module is based on virtual QDEC devices. The QDEC devices can be configured to run in three modes :
- X1
- X2
- X4 See description above for more details about modes.
On QDEC counter overflow, an interrupt is triggered. The interruption calls the callback defined.
Parameters
dev: QDEC device to initialize mode: QDEC mode : X1, X2 or X4 cb: Callback on QDEC timer overflow arg: Callback arguments Return values
- error code on error
- 0 on success
-
int32_t
qdec_read
(qdec.h::qdec_t
dev)¶ Read the current value of the given qdec device.
Parameters
dev: the qdec to read the current value from Return values
- the qdecs current value
-
int32_t
qdec_read_and_reset
(qdec.h::qdec_t
dev)¶ Read the current value of the given qdec device and reset it.
Parameters
dev: the qdec to read the current value from Return values
- the qdecs current value
-
void
qdec_start
(qdec.h::qdec_t
qdec)¶ Start the given qdec timer.
This function is only needed if the qdec timer was stopped manually before.
Parameters
qdec: the qdec device to start
-
void
qdec_stop
(qdec.h::qdec_t
qdec)¶ Stop the given qdec timer.
This will effect all of the timer’s channels.
Parameters
qdec: the qdec device to stop
-
struct
qdec_isr_ctx_t
¶ Default interrupt context entry holding callback and argument.
-
qdec.h::qdec_cb_t
cb
¶ callback executed from qdec interrupt
-
void *
arg
¶ optional argument given to that callback
-