#include "compiler.h"
#include "controller.h"
#include "board.h"
#include "gpio.h"
#include "rtc.h"
#include "spi.h"
#include "qt60168.h"
#include "conf_qt60168.h"
#include "cycle_counter.h"
#include <includes.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 = (enum controller_state_t) ((controller_state & ~STATE_##x##_RELEASED) | STATE_##x##_PRESSED) |
#define | SET_RELEASED_STATE(x) controller_state = (enum controller_state_t) ((controller_state & ~STATE_##x##_PRESSED) | STATE_##x##_RELEASED) |
Enumerations | |
enum | { TOUCH_IDLE = 0, TOUCH_PRESS = 1, TOUCH_RELEASE = 2 } |
enum | controller_state_t { STATE_IDLE = 0x0000, STATE_CS1_PRESSED = 0x0001, STATE_CS2_PRESSED = 0x0002, STATE_CS3_PRESSED = 0x0004, STATE_CS4_PRESSED = 0x0008, STATE_CS1_RELEASED = 0x0010, STATE_CS2_RELEASED = 0x0020, STATE_CS3_RELEASED = 0x0040, STATE_CS4_RELEASED = 0x0080, STATE_WHEEL_LEFT = 0x0100, STATE_WHEEL_RIGHT = 0x0200, STATE_WHEEL_LEFT_RELEASED = 0x1000, STATE_WHEEL_RIGHT_RELEASED = 0x2000, STATE_WHEEL_UP_RELEASED = 0x4000, STATE_WHEEL_DOWN_RELEASED = 0x8000, STATE_IDLE = 0x0000, STATE_CS1_PRESSED = 0x0001, STATE_CS2_PRESSED = 0x0002, STATE_CS3_PRESSED = 0x0004, STATE_CS4_PRESSED = 0x0008, STATE_CS1_RELEASED = 0x0010, STATE_CS2_RELEASED = 0x0020, STATE_CS3_RELEASED = 0x0040, STATE_CS4_RELEASED = 0x0080, STATE_WHEEL_LEFT = 0x0100, STATE_WHEEL_RIGHT = 0x0200, STATE_WHEEL_LEFT_RELEASED = 0x1000, STATE_WHEEL_RIGHT_RELEASED = 0x2000, STATE_WHEEL_UP_RELEASED = 0x4000, STATE_WHEEL_DOWN_RELEASED = 0x8000 } |
Functions | |
CPU_INT32U | BSP_INTC_IntReg (CPU_FNCT_VOID handler, CPU_INT32U irq, CPU_INT32U int_level) |
void | controller_clear (void) |
Reset the key state. More... | |
bool | controller_connect (void) |
void | controller_init (U32 fcpu_hz, U32 fhsb_hz, U32 fpbb_hz, U32 fpba_hz) |
Initialization function of the controller interface. More... | |
bool | controller_inquiry (void) |
bool | controller_key_cs1 (void) |
bool | controller_key_cs2 (void) |
bool | controller_key_cs3 (void) |
bool | controller_key_cs4 (void) |
bool | controller_key_pressed (void) |
bool | controller_key_released (void) |
static void | controller_keys_update (int all_keys) |
bool | controller_select (void) |
bool | controller_send (void) |
void | controller_shutdown (void) |
Shutdown the controller. More... | |
void | controller_task (void) |
Refresh the controller. More... | |
bool | controller_wheel_pressed (void) |
static bool | is_key_pressed (int all_keys, int key_num) |
static void | qt60168_resources_init (U32 fpba_hz) |
Initialization. More... | |
void | rtc_init_qt (void) |
static void | rtc_irq (void) |
Interrupt. More... | |
static void | set_wheel_left () |
static void | set_wheel_right () |
Set key status. More... | |
static int | special_qt60168_get_reply (unsigned short *data) |
bool | special_qt60168_get_reply60168_report_all_key (unsigned short *data) |
static bool | special_qt60168_report_all_key (unsigned short *data) |
"Report all key" status handling More... | |
static int | special_qt60168_send_cmd (unsigned char cmd) |
static void | update_controller_state (void) |
Variables | |
enum controller_state_t | controller_state = STATE_IDLE |
static t_cpu_time | cpu_time_clear_wheel |
static unsigned short | Data |
static int | Read_data = 0 |
static int | report_state = 0 |
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_cs1(), controller_key_cs2(), controller_key_cs3(), and controller_key_cs4().
#define SET_PRESSED_STATE | ( | x | ) | controller_state = (enum controller_state_t) ((controller_state & ~STATE_##x##_RELEASED) | STATE_##x##_PRESSED) |
Referenced by update_controller_state().
#define SET_RELEASED_STATE | ( | x | ) | controller_state = (enum controller_state_t) ((controller_state & ~STATE_##x##_PRESSED) | STATE_##x##_RELEASED) |
Referenced by update_controller_state().
enum controller_state_t |
CPU_INT32U BSP_INTC_IntReg | ( | CPU_FNCT_VOID | handler, |
CPU_INT32U | irq, | ||
CPU_INT32U | int_level | ||
) |
Referenced by BSP_Init().
void controller_clear | ( | void | ) |
Reset the key state.
References controller_state, i, STATE_IDLE, TOUCH_IDLE, and touch_states.
bool controller_connect | ( | void | ) |
References controller_key_cs3().
Referenced by app_engine().
Initialization function of the controller interface.
fcpu_hz | CPU frequency. |
fhsb_hz | HSB frequency. |
fpbb_hz | PBB frequency. |
fpba_hz | PBA frequency. |
Initialization function of the controller interface.
References cpu_set_timeout(), gpio_enable_module(), qt60168_init(), qt60168_resources_init(), QT60168_SPI_BITS, QT60168_SPI_MASTER_SPEED, spi_options_t::reg, rtc_init_qt(), spi_enable(), spi_selectionMode(), and spi_setupChipReg().
bool controller_inquiry | ( | void | ) |
References controller_key_cs1().
Referenced by app_engine().
bool controller_key_cs1 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS1_RELEASED.
bool controller_key_cs2 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS2_RELEASED.
bool controller_key_cs3 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS3_RELEASED.
bool controller_key_cs4 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS4_RELEASED.
bool controller_key_pressed | ( | void | ) |
References controller_state, and STATE_IDLE.
bool controller_key_released | ( | void | ) |
References controller_state, STATE_CS1_RELEASED, STATE_CS2_RELEASED, STATE_CS3_RELEASED, and STATE_CS4_RELEASED.
|
static |
References i, is_key_pressed(), TOUCH_IDLE, TOUCH_PRESS, TOUCH_RELEASE, touch_states, and update_controller_state().
Referenced by rtc_irq().
bool controller_select | ( | void | ) |
References controller_key_cs2().
Referenced by app_engine().
bool controller_send | ( | void | ) |
References controller_key_cs4().
Referenced by app_engine().
void controller_shutdown | ( | void | ) |
Shutdown the controller.
References cpu_irq_disable, cpu_irq_enable, Disable_global_interrupt, Enable_global_interrupt, and rtc_disable().
void controller_task | ( | void | ) |
Refresh the controller.
Referenced by app_engine(), and main().
bool controller_wheel_pressed | ( | void | ) |
References controller_state, STATE_WHEEL_LEFT, and STATE_WHEEL_RIGHT.
|
inlinestatic |
Referenced by controller_keys_update().
|
static |
Initialization.
References FOSC0, gpio_enable_module(), spi_options_t::reg, spi_enable(), spi_initMaster(), spi_selectionMode(), and spi_setupChipReg().
Referenced by controller_init().
void rtc_init_qt | ( | void | ) |
|
static |
Interrupt.
References controller_keys_update(), Data, Read_data, rtc_clear_interrupt(), special_qt60168_report_all_key(), spi_read(), spi_selectChip(), and spi_unselectChip().
|
inlinestatic |
References controller_state, STATE_WHEEL_LEFT, STATE_WHEEL_RIGHT, and wheel_step_counter.
Referenced by update_controller_state().
|
inlinestatic |
Set key status.
References controller_state, STATE_WHEEL_LEFT, STATE_WHEEL_RIGHT, and wheel_step_counter.
Referenced by update_controller_state().
|
static |
References Data, QT60168_CMD_NULL_COMMAND, and special_qt60168_send_cmd().
bool special_qt60168_get_reply60168_report_all_key | ( | unsigned short * | data | ) |
|
static |
"Report all key" status handling
|
static |
References Read_data, spi_selectChip(), spi_unselectChip(), spi_write(), and state.
Referenced by special_qt60168_get_reply().
|
static |
References controller_state, cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), SET_PRESSED_STATE, SET_RELEASED_STATE, set_wheel_left(), set_wheel_right(), STATE_WHEEL_DOWN_RELEASED, STATE_WHEEL_LEFT, STATE_WHEEL_LEFT_RELEASED, STATE_WHEEL_RIGHT, STATE_WHEEL_RIGHT_RELEASED, STATE_WHEEL_UP_RELEASED, TOUCH_PRESS, TOUCH_RELEASE, touch_states, and wheel_step_counter.
Referenced by controller_keys_update().
enum controller_state_t controller_state = STATE_IDLE |
|
static |
|
static |
Referenced by rtc_irq(), and special_qt60168_get_reply().
|
static |
Referenced by rtc_irq(), and special_qt60168_send_cmd().
|
static |
enum { ... } touch_states[QT60168_TOUCH_NUMBER_OF_SENSORS] |
Referenced by controller_clear(), controller_keys_update(), and update_controller_state().
|
static |
Referenced by set_wheel_left(), set_wheel_right(), and update_controller_state().