Add support for interrupt driven Toggle Inputs
This commit is contained in:
parent
e23485273e
commit
99a9bf45e7
2 changed files with 38 additions and 18 deletions
|
@ -30,22 +30,28 @@
|
||||||
#ifndef GFX_USE_GINPUT
|
#ifndef GFX_USE_GINPUT
|
||||||
#define GFX_USE_GINPUT FALSE
|
#define GFX_USE_GINPUT FALSE
|
||||||
#endif
|
#endif
|
||||||
|
#ifndef GINPUT_NEED_TOGGLE
|
||||||
#if GFX_USE_GINPUT || defined(__DOXYGEN__)
|
#define GINPUT_NEED_TOGGLE FALSE
|
||||||
|
|
||||||
#if GINPUT_NEED_TOGGLE
|
|
||||||
// Describes how the toggle bits are obtained
|
|
||||||
typedef struct GToggleConfig_t {
|
|
||||||
void *id;
|
|
||||||
unsigned mask;
|
|
||||||
unsigned invert;
|
|
||||||
iomode_t mode;
|
|
||||||
} GToggleConfig;
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if (GFX_USE_GINPUT && GINPUT_NEED_TOGGLE) || defined(__DOXYGEN__)
|
||||||
|
|
||||||
|
// Describes how the toggle bits are obtained
|
||||||
|
typedef struct GToggleConfig_t {
|
||||||
|
void *id;
|
||||||
|
unsigned mask;
|
||||||
|
unsigned invert;
|
||||||
|
iomode_t mode;
|
||||||
|
} GToggleConfig;
|
||||||
|
|
||||||
// This must be included after the above type definition
|
// This must be included after the above type definition
|
||||||
#include "ginput.h"
|
#include "ginput.h"
|
||||||
|
|
||||||
|
// n - Millisecs between poll's
|
||||||
|
#ifndef GINPUT_TOGGLE_POLL_PERIOD
|
||||||
|
#define GINPUT_TOGGLE_POLL_PERIOD 200
|
||||||
|
#endif
|
||||||
|
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
/* External declarations. */
|
/* External declarations. */
|
||||||
/*===========================================================================*/
|
/*===========================================================================*/
|
||||||
|
@ -54,18 +60,26 @@
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if GINPUT_NEED_TOGGLE
|
|
||||||
extern const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES];
|
extern const GToggleConfig GInputToggleConfigTable[GINPUT_TOGGLE_CONFIG_ENTRIES];
|
||||||
|
|
||||||
void ginput_lld_toggle_init(const GToggleConfig *ptc);
|
void ginput_lld_toggle_init(const GToggleConfig *ptc);
|
||||||
unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc);
|
unsigned ginput_lld_toggle_getbits(const GToggleConfig *ptc);
|
||||||
#endif
|
|
||||||
|
/* This routine is provided to low level drivers to wakeup a value read from a thread context.
|
||||||
|
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
|
||||||
|
*/
|
||||||
|
void ginputToggleWakeup(void);
|
||||||
|
|
||||||
|
/* This routine is provided to low level drivers to wakeup a value read from an ISR
|
||||||
|
* Particularly useful if GINPUT_TOGGLE_POLL_PERIOD = TIME_INFINITE
|
||||||
|
*/
|
||||||
|
void ginputToggleWakeupI(void);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* GFX_USE_GINPUT */
|
#endif /* GFX_USE_GINPUT && GINPUT_NEED_TOGGLE */
|
||||||
|
|
||||||
#endif /* _LLD_GINPUT_TOGGLE_H */
|
#endif /* _LLD_GINPUT_TOGGLE_H */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
|
@ -34,10 +34,6 @@
|
||||||
|
|
||||||
#include "lld/ginput/toggle.h"
|
#include "lld/ginput/toggle.h"
|
||||||
|
|
||||||
#ifndef GINPUT_TOGGLE_POLL_PERIOD
|
|
||||||
#define GINPUT_TOGGLE_POLL_PERIOD 250
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define GINPUT_TOGGLE_ISON 0x01
|
#define GINPUT_TOGGLE_ISON 0x01
|
||||||
#define GINPUT_TOGGLE_INVERT 0x02
|
#define GINPUT_TOGGLE_INVERT 0x02
|
||||||
|
|
||||||
|
@ -157,5 +153,15 @@ bool_t ginputGetToggleStatus(uint16_t instance, GEventToggle *ptoggle) {
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */
|
||||||
|
void ginputToggleWakeup(void) {
|
||||||
|
gtimerJab(&ToggleTimer);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Wake up the mouse driver from an interrupt service routine (there may be new readings available) */
|
||||||
|
void ginputToggleWakeupI(void) {
|
||||||
|
gtimerJabI(&ToggleTimer);
|
||||||
|
}
|
||||||
|
|
||||||
#endif /* GINPUT_NEED_TOGGLE */
|
#endif /* GINPUT_NEED_TOGGLE */
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
Loading…
Add table
Reference in a new issue