#include "compiler.h"
#include "controller.h"
#include "board.h"
#include "gpio.h"
#include "rtc.h"
#include "spi.h"
#include "intc.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 = (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 } |
Functions | |
void | controller_clear (void) |
Reset the key state. More... | |
bool | controller_config_change_mode (void) |
This function is called to check if the user has pressed the configuration change key. More... | |
bool | controller_config_next_option (void) |
This function is called to check if the user has pressed the next option key. More... | |
bool | controller_config_previous_option (void) |
This function is called to check if the user has pressed the previous option key. More... | |
void | controller_init (uint32_t fcpu_hz, uint32_t fhsb_hz, uint32_t fpbb_hz, uint32_t fpba_hz) |
Initialization. More... | |
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_navigation_change_directory (void) |
This function is called to check if the user has pressed the change directory key. More... | |
bool | controller_navigation_cursor_next (void) |
This function is called to check if the user has pressed the next file selection key. More... | |
bool | controller_navigation_cursor_previous (void) |
This function is called to check if the user has pressed the previous file selection key. More... | |
bool | controller_navigation_go_to_parent_directory (void) |
This function is called to check if the user has pressed the go to parent directory key. More... | |
bool | controller_navigation_play (void) |
This function is called to check if the user has pressed the play selected file key. More... | |
bool | controller_playback_decrease_volume (void) |
This function is called to check if the user has pressed the decrease volume key. More... | |
bool | controller_playback_ffw (bool new_track) |
This function is called to check if the user has pressed the fast forward key. More... | |
bool | controller_playback_frw (bool new_track) |
This function is called to check if the user has pressed the fast rewind key. More... | |
bool | controller_playback_increase_volume (void) |
This function is called to check if the user has pressed the increase volume key. More... | |
bool | controller_playback_next_track (void) |
This function is called to check if the user has pressed the next track key. More... | |
bool | controller_playback_previous_track (void) |
This function is called to check if the user has pressed the previous track key. More... | |
bool | controller_playback_toggle_play_pause (void) |
This function is called to check if the user has pressed the play/pause key. More... | |
void | controller_reset (void) |
void | controller_shutdown (void) |
Shutdown the controller. More... | |
bool | controller_switch_to_config_view (enum gui_update_view view) |
This function is called to check if the user has requested to move to the configuration view. More... | |
bool | controller_switch_to_navigation_view (enum gui_update_view view) |
This function is called to check if the user has requested to move to the navigation view. More... | |
bool | controller_switch_to_playback_view (enum gui_update_view view) |
This function is called to check if the user has requested to move to the playback view. More... | |
bool | controller_wheel_left (int wheel_inc) |
bool | controller_wheel_pressed (void) |
bool | controller_wheel_right (int wheel_inc) |
static bool | is_key_pressed (int all_keys, int key_num) |
ISR (rtc_irq, AVR32_RTC_IRQ_GROUP, AVR32_INTC_INT0) | |
Interrupt. More... | |
void | rtc_init_qt (void) |
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(), controller_key_cs4(), controller_navigation_change_directory(), controller_navigation_cursor_next(), controller_navigation_cursor_previous(), controller_navigation_go_to_parent_directory(), controller_playback_decrease_volume(), controller_playback_increase_volume(), controller_playback_next_track(), and controller_playback_previous_track().
#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 |
void controller_clear | ( | void | ) |
Reset the key state.
References controller_state, QT60168_TOUCH_NUMBER_OF_SENSORS, STATE_IDLE, TOUCH_IDLE, and touch_states.
Referenced by config_task(), navigation_task(), playback_task(), and rtc_init_qt().
bool controller_config_change_mode | ( | void | ) |
This function is called to check if the user has pressed the configuration change key.
References controller_key_cs2(), and controller_key_cs3().
Referenced by config_task().
bool controller_config_next_option | ( | void | ) |
This function is called to check if the user has pressed the next option key.
References controller_wheel_right().
Referenced by config_task().
bool controller_config_previous_option | ( | void | ) |
This function is called to check if the user has pressed the previous option key.
References controller_wheel_left().
Referenced by config_task().
void controller_init | ( | uint32_t | fcpu_hz, |
uint32_t | fhsb_hz, | ||
uint32_t | fpbb_hz, | ||
uint32_t | fpba_hz | ||
) |
Initialization.
Initialization function of the controller interface.
References cpu_set_timeout(), gpio_enable_module(), qt60168_init(), 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, rtc_init_qt(), spi_enable(), spi_selectionMode(), and spi_setupChipReg().
Referenced by com_task().
bool controller_key_cs1 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS1_RELEASED.
Referenced by controller_switch_to_navigation_view(), and controller_switch_to_playback_view().
bool controller_key_cs2 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS2_RELEASED.
Referenced by controller_config_change_mode().
bool controller_key_cs3 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS3_RELEASED.
Referenced by controller_config_change_mode(), controller_navigation_play(), and controller_playback_toggle_play_pause().
bool controller_key_cs4 | ( | void | ) |
References CLEAR_RELEASED_STATE, controller_state, and STATE_CS4_RELEASED.
Referenced by controller_switch_to_config_view(), and controller_switch_to_playback_view().
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 is_key_pressed(), QT60168_TOUCH_NUMBER_OF_SENSORS, TOUCH_IDLE, TOUCH_PRESS, TOUCH_RELEASE, touch_states, and update_controller_state().
Referenced by ISR().
bool controller_navigation_change_directory | ( | void | ) |
This function is called to check if the user has pressed the change directory key.
References CLEAR_RELEASED_STATE, controller_state, and STATE_WHEEL_RIGHT_RELEASED.
Referenced by navigation_task().
bool controller_navigation_cursor_next | ( | void | ) |
This function is called to check if the user has pressed the next file selection key.
References CLEAR_RELEASED_STATE, controller_state, controller_wheel_right(), and STATE_WHEEL_DOWN_RELEASED.
Referenced by navigation_task().
bool controller_navigation_cursor_previous | ( | void | ) |
This function is called to check if the user has pressed the previous file selection key.
References CLEAR_RELEASED_STATE, controller_state, controller_wheel_left(), and STATE_WHEEL_UP_RELEASED.
Referenced by navigation_task().
bool controller_navigation_go_to_parent_directory | ( | void | ) |
This function is called to check if the user has pressed the go to parent directory key.
References CLEAR_RELEASED_STATE, controller_state, and STATE_WHEEL_LEFT_RELEASED.
Referenced by navigation_task().
bool controller_navigation_play | ( | void | ) |
This function is called to check if the user has pressed the play selected file key.
References controller_key_cs3().
Referenced by navigation_task().
bool controller_playback_decrease_volume | ( | void | ) |
This function is called to check if the user has pressed the decrease volume key.
References CLEAR_RELEASED_STATE, controller_state, and STATE_WHEEL_DOWN_RELEASED.
Referenced by playback_task().
This function is called to check if the user has pressed the fast forward key.
References controller_wheel_right().
Referenced by playback_task().
This function is called to check if the user has pressed the fast rewind key.
References controller_wheel_left().
Referenced by playback_task().
bool controller_playback_increase_volume | ( | void | ) |
This function is called to check if the user has pressed the increase volume key.
References CLEAR_RELEASED_STATE, controller_state, and STATE_WHEEL_UP_RELEASED.
Referenced by playback_task().
bool controller_playback_next_track | ( | void | ) |
This function is called to check if the user has pressed the next track key.
References CLEAR_RELEASED_STATE, controller_state, and STATE_WHEEL_RIGHT_RELEASED.
Referenced by playback_task().
bool controller_playback_previous_track | ( | void | ) |
This function is called to check if the user has pressed the previous track key.
References CLEAR_RELEASED_STATE, controller_state, and STATE_WHEEL_LEFT_RELEASED.
Referenced by playback_task().
bool controller_playback_toggle_play_pause | ( | void | ) |
This function is called to check if the user has pressed the play/pause key.
References controller_key_cs3().
Referenced by playback_task().
void controller_reset | ( | void | ) |
References controller_state, STATE_IDLE, and wheel_step_counter.
void controller_shutdown | ( | void | ) |
Shutdown the controller.
References cpu_irq_disable, cpu_irq_enable, and rtc_disable().
Referenced by com_task().
bool controller_switch_to_config_view | ( | enum gui_update_view | view | ) |
This function is called to check if the user has requested to move to the configuration view.
view | The current view. |
References controller_key_cs4(), and GUI_UPDATE_VIEW_PLAYBACK.
Referenced by navigation_task(), and playback_task().
bool controller_switch_to_navigation_view | ( | enum gui_update_view | view | ) |
This function is called to check if the user has requested to move to the navigation view.
view | The current view. |
References controller_key_cs1(), and GUI_UPDATE_VIEW_PLAYBACK.
Referenced by config_task(), and playback_task().
bool controller_switch_to_playback_view | ( | enum gui_update_view | view | ) |
This function is called to check if the user has requested to move to the playback view.
view | The current view. |
References controller_key_cs1(), controller_key_cs4(), GUI_UPDATE_VIEW_CONFIG, and GUI_UPDATE_VIEW_NAVIGATION.
Referenced by config_task(), and navigation_task().
bool controller_wheel_left | ( | int | wheel_inc | ) |
References controller_state, STATE_WHEEL_LEFT, and wheel_step_counter.
Referenced by controller_config_previous_option(), controller_navigation_cursor_previous(), and controller_playback_frw().
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 controller_config_next_option(), controller_navigation_cursor_next(), and controller_playback_ffw().
|
inlinestatic |
Referenced by controller_keys_update().
ISR | ( | rtc_irq | , |
AVR32_RTC_IRQ_GROUP | , | ||
AVR32_INTC_INT0 | |||
) |
Interrupt.
References controller_keys_update(), Data, QT60168_SPI, QT60168_SPI_NCPS, Read_data, rtc_clear_interrupt(), special_qt60168_report_all_key(), spi_read(), spi_selectChip(), and spi_unselectChip().
void rtc_init_qt | ( | void | ) |
References controller_clear(), cpu_irq_disable, cpu_irq_enable, irq_register_handler, rtc_enable(), rtc_enable_interrupt(), rtc_init(), RTC_OSC_32KHZ, and rtc_set_top_value().
Referenced by controller_init().
|
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().
Referenced by special_qt60168_report_all_key().
bool special_qt60168_get_reply60168_report_all_key | ( | unsigned short * | data | ) |
|
static |
"Report all key" status handling
References QT60168_CMD_REPORT_ALL_KEYS, report_state, special_qt60168_get_reply(), and special_qt60168_send_cmd().
Referenced by ISR().
|
static |
References QT60168_SPI, QT60168_SPI_NCPS, Read_data, spi_selectChip(), spi_unselectChip(), and spi_write().
Referenced by special_qt60168_get_reply(), and special_qt60168_report_all_key().
|
static |
References controller_state, cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), FCPU_HZ, 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_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 |
Referenced by controller_clear(), controller_key_cs1(), controller_key_cs2(), controller_key_cs3(), controller_key_cs4(), controller_key_pressed(), controller_key_released(), controller_navigation_change_directory(), controller_navigation_cursor_next(), controller_navigation_cursor_previous(), controller_navigation_go_to_parent_directory(), controller_playback_decrease_volume(), controller_playback_increase_volume(), controller_playback_next_track(), controller_playback_previous_track(), controller_reset(), controller_wheel_left(), controller_wheel_pressed(), controller_wheel_right(), set_wheel_left(), set_wheel_right(), and update_controller_state().
|
static |
|
static |
Referenced by ISR(), and special_qt60168_get_reply().
|
static |
Referenced by ISR(), and special_qt60168_send_cmd().
|
static |
Referenced by special_qt60168_report_all_key().
enum { ... } touch_states[QT60168_TOUCH_NUMBER_OF_SENSORS] |
Referenced by controller_clear(), controller_keys_update(), and update_controller_state().
|
static |