#include "controller.h"
#include "board.h"
#include "gpio.h"
#include "spi.h"
#include "qt60168.h"
#include "conf_qt60168.h"
#include "cycle_counter.h"
Macros | |
#define | CLEAR_PRESSED_STATE(x) controller_state &= ~STATE_##x##_PRESSED |
#define | CLEAR_RELEASED_STATE(x) controller_state &= ~STATE_##x##_RELEASED |
#define | SET_PRESSED_STATE(x) controller_state = (controller_state & ~STATE_##x##_RELEASED) | STATE_##x##_PRESSED |
#define | SET_RELEASED_STATE(x) controller_state = (controller_state & ~STATE_##x##_PRESSED) | STATE_##x##_RELEASED |
Enumerations | |
enum | { TOUCH_IDLE = 0, TOUCH_PRESS = 1, TOUCH_RELEASE = 2 } |
enum | { STATE_IDLE = 0x0000, STATE_BACK_PRESSED = 0x0001, STATE_FCT1_PRESSED = 0x0002, STATE_FCT2_PRESSED = 0x0004, STATE_FCT3_PRESSED = 0x0008, STATE_BACK_RELEASED = 0x0010, STATE_FCT1_RELEASED = 0x0020, STATE_FCT2_RELEASED = 0x0040, STATE_FCT3_RELEASED = 0x0080, STATE_WHEEL_LEFT = 0x0100, STATE_WHEEL_RIGHT = 0x0200, STATE_BACK_PRESSING = 0x0400, STATE_BACK_LONG_PRESS = 0x0800 } |
Functions | |
void | controller_init (int cpu_hz, int hsb_hz, int pba_hz, int pbb_hz) |
bool | controller_key_back (void) |
bool | controller_key_fct1 (void) |
bool | controller_key_fct1_pressed (void) |
bool | controller_key_fct2 (void) |
bool | controller_key_fct2_pressed (void) |
bool | controller_key_fct3 (void) |
bool | controller_key_fct3_pressed (void) |
bool | controller_key_pressed (void) |
bool | controller_key_released (void) |
bool | controller_key_reset (void) |
void | controller_reset (void) |
void | controller_task (void) |
bool | controller_wheel_left (int wheel_inc) |
bool | controller_wheel_pressed (void) |
bool | controller_wheel_right (int wheel_inc) |
static void | qt60168_resources_init (int cpu_hz) |
Initializes QT60168 resources: GPIO and SPI. More... | |
static void | set_wheel_left () |
static void | set_wheel_right () |
static void | update_controller_state (void) |
Variables | |
static int | controller_cpu_hz |
static enum { ... } | controller_state = STATE_IDLE |
static t_cpu_time | long_press_timer |
static enum { ... } | touch_states [QT60168_TOUCH_NUMBER_OF_SENSORS] |
static int | wheel_step_counter = 0 |
#define CLEAR_PRESSED_STATE | ( | x | ) | controller_state &= ~STATE_##x##_PRESSED |
#define CLEAR_RELEASED_STATE | ( | x | ) | controller_state &= ~STATE_##x##_RELEASED |
Referenced by controller_key_back(), controller_key_fct1(), controller_key_fct2(), and controller_key_fct3().
#define SET_PRESSED_STATE | ( | x | ) | controller_state = (controller_state & ~STATE_##x##_RELEASED) | STATE_##x##_PRESSED |
Referenced by update_controller_state().
#define SET_RELEASED_STATE | ( | x | ) | controller_state = (controller_state & ~STATE_##x##_PRESSED) | STATE_##x##_RELEASED |
Referenced by update_controller_state().
anonymous enum |
void controller_init | ( | int | cpu_hz, |
int | hsb_hz, | ||
int | pba_hz, | ||
int | pbb_hz | ||
) |
References controller_cpu_hz, cpu_hz, qt60168_init(), qt60168_resources_init(), QT60168_TOUCH_NUMBER_OF_SENSORS, TOUCH_IDLE, and touch_states.
Referenced by main().
bool controller_key_back | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_BACK_RELEASED.
Referenced by state_machine_task().
bool controller_key_fct1 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_FCT1_RELEASED.
Referenced by state_machine_task().
bool controller_key_fct1_pressed | ( | void | ) |
References controller_state, and STATE_FCT1_PRESSED.
bool controller_key_fct2 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_FCT2_RELEASED.
Referenced by state_machine_task().
bool controller_key_fct2_pressed | ( | void | ) |
References controller_state, and STATE_FCT2_PRESSED.
bool controller_key_fct3 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_FCT3_RELEASED.
Referenced by state_machine_task().
bool controller_key_fct3_pressed | ( | void | ) |
References controller_state, and STATE_FCT3_PRESSED.
Referenced by state_machine_task().
bool controller_key_pressed | ( | void | ) |
References controller_state, and STATE_IDLE.
bool controller_key_released | ( | void | ) |
References controller_state, STATE_BACK_RELEASED, STATE_FCT1_RELEASED, STATE_FCT2_RELEASED, and STATE_FCT3_RELEASED.
bool controller_key_reset | ( | void | ) |
References controller_state, and STATE_BACK_LONG_PRESS.
Referenced by state_machine_task().
void controller_reset | ( | void | ) |
References controller_state, STATE_IDLE, and wheel_step_counter.
Referenced by state_machine_filter(), state_machine_signal(), state_machine_source(), and state_machine_task().
void controller_task | ( | void | ) |
References qt60168_is_key_pressed(), QT60168_TOUCH_NUMBER_OF_SENSORS, TOUCH_IDLE, TOUCH_PRESS, TOUCH_RELEASE, touch_states, and update_controller_state().
Referenced by main().
bool controller_wheel_left | ( | int | wheel_inc | ) |
References controller_state, STATE_WHEEL_LEFT, and wheel_step_counter.
Referenced by state_machine_filter(), state_machine_idle(), state_machine_signal(), and state_machine_source().
bool controller_wheel_pressed | ( | void | ) |
References controller_state, STATE_WHEEL_LEFT, and STATE_WHEEL_RIGHT.
bool controller_wheel_right | ( | int | wheel_inc | ) |
References controller_state, STATE_WHEEL_RIGHT, and wheel_step_counter.
Referenced by state_machine_filter(), state_machine_idle(), state_machine_signal(), and state_machine_source().
|
static |
Initializes QT60168 resources: GPIO and SPI.
References gpio_enable_module(), QT60168_SPI, QT60168_SPI_BITS, QT60168_SPI_MASTER_SPEED, QT60168_SPI_MISO_FUNCTION, QT60168_SPI_MISO_PIN, QT60168_SPI_MOSI_FUNCTION, QT60168_SPI_MOSI_PIN, QT60168_SPI_NCPS, QT60168_SPI_NPCS0_FUNCTION, QT60168_SPI_NPCS0_PIN, QT60168_SPI_SCK_FUNCTION, QT60168_SPI_SCK_PIN, spi_options_t::reg, spi_enable(), spi_initMaster(), spi_selectionMode(), and spi_setupChipReg().
Referenced by controller_init().
|
inlinestatic |
References controller_state, STATE_WHEEL_LEFT, STATE_WHEEL_RIGHT, and wheel_step_counter.
Referenced by update_controller_state().
|
inlinestatic |
References controller_state, STATE_WHEEL_LEFT, STATE_WHEEL_RIGHT, and wheel_step_counter.
Referenced by update_controller_state().
|
static |
References controller_cpu_hz, CONTROLLER_LONG_PRESS_TIME_MS, controller_state, cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), QT60168_TOUCH_SENSOR_BUTTON_0, QT60168_TOUCH_SENSOR_BUTTON_1, QT60168_TOUCH_SENSOR_BUTTON_2, QT60168_TOUCH_SENSOR_BUTTON_3, QT60168_TOUCH_SENSOR_WHEEL_0, QT60168_TOUCH_SENSOR_WHEEL_1, QT60168_TOUCH_SENSOR_WHEEL_10, QT60168_TOUCH_SENSOR_WHEEL_11, QT60168_TOUCH_SENSOR_WHEEL_2, QT60168_TOUCH_SENSOR_WHEEL_3, QT60168_TOUCH_SENSOR_WHEEL_4, QT60168_TOUCH_SENSOR_WHEEL_5, QT60168_TOUCH_SENSOR_WHEEL_6, QT60168_TOUCH_SENSOR_WHEEL_7, QT60168_TOUCH_SENSOR_WHEEL_8, QT60168_TOUCH_SENSOR_WHEEL_9, SET_PRESSED_STATE, SET_RELEASED_STATE, set_wheel_left(), set_wheel_right(), STATE_BACK_LONG_PRESS, STATE_BACK_PRESSING, TOUCH_PRESS, TOUCH_RELEASE, and touch_states.
Referenced by controller_task().
|
static |
Referenced by controller_init(), and update_controller_state().
enum { ... } controller_state |
Referenced by controller_key_back(), controller_key_fct1(), controller_key_fct1_pressed(), controller_key_fct2(), controller_key_fct2_pressed(), controller_key_fct3(), controller_key_fct3_pressed(), controller_key_pressed(), controller_key_released(), controller_key_reset(), controller_reset(), controller_wheel_left(), controller_wheel_pressed(), controller_wheel_right(), set_wheel_left(), set_wheel_right(), and update_controller_state().
|
static |
enum { ... } touch_states[QT60168_TOUCH_NUMBER_OF_SENSORS] |
Referenced by controller_init(), controller_task(), and update_controller_state().
|
static |
Referenced by controller_reset(), controller_wheel_left(), controller_wheel_right(), set_wheel_left(), and set_wheel_right().