#include "board.h"
#include "gpio.h"
#include "intc.h"
#include "controller.h"
#include "qt1081.h"
#include "cycle_counter.h"
#include "conf_audio_player.h"
Enumerations | |
enum | joystick_status_t { JOYSTICK_STATUS_IDLE = 0x00000000, JOYSTICK_STATUS_UP = 0x00000001, JOYSTICK_STATUS_DOWN = 0x00000002, JOYSTICK_STATUS_RIGHT = 0x00000004, JOYSTICK_STATUS_LEFT = 0x00000008, JOYSTICK_STATUS_PRESSED = 0x00000010, JOYSTICK_STATUS_SLIDING_LEFT = 0x00000020, JOYSTICK_STATUS_SLIDE_LEFT = 0x00000040, JOYSTICK_STATUS_SLIDING_RIGHT = 0x00000080, JOYSTICK_STATUS_SLIDE_RIGHT = 0x00000100, JOYSTICK_STATUS_PRESSED_MASK = 0x0000FFFF, JOYSTICK_STATUS_RELEASED_UP = 0x00010000, JOYSTICK_STATUS_RELEASED_DOWN = 0x00020000, JOYSTICK_STATUS_RELEASED_RIGHT = 0x00040000, JOYSTICK_STATUS_RELEASED_LEFT = 0x00080000, JOYSTICK_STATUS_RELEASED_PRESSED = 0x00100000, JOYSTICK_STATUS_RELEASED_MASK = 0xFFFF0000 } |
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 function of the controller interface. More... | |
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_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... | |
static bool | is_joystick_down (void) |
static bool | is_joystick_released_down (void) |
static bool | is_joystick_released_left (void) |
static bool | is_joystick_released_pressed (void) |
static bool | is_joystick_released_right (void) |
static bool | is_joystick_released_up (void) |
static bool | is_joystick_up (void) |
static void | manage_button_isr (int pin, enum joystick_status_t status_pressed, enum joystick_status_t status_released) |
void | touch_button_isr (void) |
Variables | |
static bool | fast_mode = false |
static t_cpu_time | joystick_key_sensibility_timer |
static enum joystick_status_t | joystick_status = JOYSTICK_STATUS_IDLE |
static uint32_t | static_fcpu_hz |
#define CLEAR_JOYSTICK_KEY_ALL | ( | ) | (joystick_status = JOYSTICK_STATUS_IDLE) |
#define CLEAR_JOYSTICK_KEY_DOWN | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_DOWN) |
#define CLEAR_JOYSTICK_KEY_LEFT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_LEFT) |
Referenced by touch_button_isr().
#define CLEAR_JOYSTICK_KEY_PRESSED | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_PRESSED) |
#define CLEAR_JOYSTICK_KEY_RIGHT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_RIGHT) |
Referenced by touch_button_isr().
#define CLEAR_JOYSTICK_KEY_SLIDE_LEFT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_SLIDE_LEFT) |
#define CLEAR_JOYSTICK_KEY_SLIDE_RIGHT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_SLIDE_RIGHT) |
#define CLEAR_JOYSTICK_KEY_SLIDING_LEFT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_SLIDING_LEFT) |
Referenced by touch_button_isr().
#define CLEAR_JOYSTICK_KEY_SLIDING_RIGHT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_SLIDING_RIGHT) |
Referenced by touch_button_isr().
#define CLEAR_JOYSTICK_KEY_UP | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_UP) |
#define CLEAR_JOYSTICK_RELEASED_KEY_DOWN | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_RELEASED_DOWN) |
Referenced by controller_config_next_option().
#define CLEAR_JOYSTICK_RELEASED_KEY_LEFT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_RELEASED_LEFT) |
#define CLEAR_JOYSTICK_RELEASED_KEY_PRESSED | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_RELEASED_PRESSED) |
#define CLEAR_JOYSTICK_RELEASED_KEY_RIGHT | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_RELEASED_RIGHT) |
Referenced by controller_navigation_change_directory(), controller_playback_next_track(), and touch_button_isr().
#define CLEAR_JOYSTICK_RELEASED_KEY_UP | ( | ) | (joystick_status &= ~JOYSTICK_STATUS_RELEASED_UP) |
Referenced by controller_config_previous_option().
#define IS_JOYSTICK_KEY_DOWN | ( | ) | (joystick_status & JOYSTICK_STATUS_DOWN) |
Referenced by controller_config_next_option(), and is_joystick_down().
#define IS_JOYSTICK_KEY_LEFT | ( | ) | (joystick_status & JOYSTICK_STATUS_LEFT) |
Referenced by controller_playback_frw(), and touch_button_isr().
#define IS_JOYSTICK_KEY_PRESSED | ( | ) | (joystick_status & JOYSTICK_STATUS_PRESSED) |
#define IS_JOYSTICK_KEY_RIGHT | ( | ) | (joystick_status & JOYSTICK_STATUS_RIGHT) |
Referenced by controller_playback_ffw(), and touch_button_isr().
#define IS_JOYSTICK_KEY_SLIDE_LEFT | ( | ) | (joystick_status & JOYSTICK_STATUS_SLIDE_LEFT) |
Referenced by controller_switch_to_navigation_view(), and controller_switch_to_playback_view().
#define IS_JOYSTICK_KEY_SLIDE_RIGHT | ( | ) | (joystick_status & JOYSTICK_STATUS_SLIDE_RIGHT) |
Referenced by controller_switch_to_config_view(), and controller_switch_to_playback_view().
#define IS_JOYSTICK_KEY_SLIDING_LEFT | ( | ) | (joystick_status & JOYSTICK_STATUS_SLIDING_LEFT) |
Referenced by touch_button_isr().
#define IS_JOYSTICK_KEY_SLIDING_RIGHT | ( | ) | (joystick_status & JOYSTICK_STATUS_SLIDING_RIGHT) |
Referenced by controller_navigation_change_directory(), and touch_button_isr().
#define IS_JOYSTICK_KEY_UP | ( | ) | (joystick_status & JOYSTICK_STATUS_UP) |
Referenced by controller_config_previous_option(), and is_joystick_up().
#define IS_JOYSTICK_ONLY_KEY_DOWN | ( | ) | ((joystick_status == JOYSTICK_STATUS_DOWN) & JOYSTICK_STATUS_PRESSED_MASK) |
#define IS_JOYSTICK_ONLY_KEY_LEFT | ( | ) | ((joystick_status == JOYSTICK_STATUS_LEFT) & JOYSTICK_STATUS_PRESSED_MASK) |
#define IS_JOYSTICK_ONLY_KEY_PRESSED | ( | ) | ((joystick_status == JOYSTICK_STATUS_PRESSED) & JOYSTICK_STATUS_PRESSED_MASK) |
#define IS_JOYSTICK_ONLY_KEY_RIGHT | ( | ) | ((joystick_status == JOYSTICK_STATUS_RIGHT) & JOYSTICK_STATUS_PRESSED_MASK) |
#define IS_JOYSTICK_ONLY_KEY_UP | ( | ) | ((joystick_status == JOYSTICK_STATUS_UP) & JOYSTICK_STATUS_PRESSED_MASK) |
#define IS_JOYSTICK_RELEASED_KEY_DOWN | ( | ) | (joystick_status & JOYSTICK_STATUS_RELEASED_DOWN) |
Referenced by is_joystick_released_down().
#define IS_JOYSTICK_RELEASED_KEY_LEFT | ( | ) | (joystick_status & JOYSTICK_STATUS_RELEASED_LEFT) |
Referenced by controller_playback_previous_track(), is_joystick_released_left(), and touch_button_isr().
#define IS_JOYSTICK_RELEASED_KEY_PRESSED | ( | ) | (joystick_status & JOYSTICK_STATUS_RELEASED_PRESSED) |
Referenced by controller_playback_toggle_play_pause(), is_joystick_released_pressed(), and touch_button_isr().
#define IS_JOYSTICK_RELEASED_KEY_RIGHT | ( | ) | (joystick_status & JOYSTICK_STATUS_RELEASED_RIGHT) |
Referenced by controller_playback_next_track(), is_joystick_released_right(), and touch_button_isr().
#define IS_JOYSTICK_RELEASED_KEY_UP | ( | ) | (joystick_status & JOYSTICK_STATUS_RELEASED_UP) |
Referenced by is_joystick_released_up().
#define JOYSTICK_KEY_DEBOUNCE_MS 200 |
enum joystick_status_t |
void controller_clear | ( | void | ) |
Reset the key state.
References joystick_status, and JOYSTICK_STATUS_IDLE.
Referenced by config_task(), navigation_task(), and playback_task().
bool controller_config_change_mode | ( | void | ) |
This function is called to check if the user has pressed the configuration change key.
References CLEAR_JOYSTICK_RELEASED_KEY_PRESSED, and is_joystick_released_pressed().
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 CLEAR_JOYSTICK_RELEASED_KEY_DOWN, IS_JOYSTICK_KEY_DOWN, and is_joystick_released_down().
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 CLEAR_JOYSTICK_RELEASED_KEY_UP, IS_JOYSTICK_KEY_UP, and is_joystick_released_up().
Referenced by config_task().
void controller_init | ( | uint32_t | fcpu_hz, |
uint32_t | fhsb_hz, | ||
uint32_t | fpbb_hz, | ||
uint32_t | fpba_hz | ||
) |
Initialization function of the controller interface.
fcpu_hz | CPU frequency. |
fhsb_hz | HSB frequency. |
fpbb_hz | PBB frequency. |
fpba_hz | PBA frequency. |
References cpu_ms_2_cy(), cpu_set_timeout(), Disable_global_interrupt, Enable_global_interrupt, gpio_enable_pin_interrupt(), GPIO_PIN_CHANGE, INTC_register_interrupt(), JOYSTICK_KEY_DEBOUNCE_MS, QT1081_TOUCH_SENSOR_DOWN, QT1081_TOUCH_SENSOR_ENTER, QT1081_TOUCH_SENSOR_LEFT, QT1081_TOUCH_SENSOR_RIGHT, QT1081_TOUCH_SENSOR_UP, static_fcpu_hz, and touch_button_isr().
Referenced by com_task().
bool controller_navigation_change_directory | ( | void | ) |
This function is called to check if the user has pressed the change directory key.
References CLEAR_JOYSTICK_RELEASED_KEY_RIGHT, IS_JOYSTICK_KEY_PRESSED, IS_JOYSTICK_KEY_SLIDING_RIGHT, and is_joystick_released_right().
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 is_joystick_down().
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 is_joystick_up().
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_JOYSTICK_RELEASED_KEY_LEFT, IS_JOYSTICK_KEY_PRESSED, and is_joystick_released_left().
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 CLEAR_JOYSTICK_RELEASED_KEY_PRESSED, and is_joystick_released_pressed().
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 is_joystick_down().
Referenced by playback_task().
This function is called to check if the user has pressed the fast forward key.
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), fast_mode, IS_JOYSTICK_KEY_RIGHT, and static_fcpu_hz.
Referenced by playback_task().
This function is called to check if the user has pressed the fast rewind key.
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), fast_mode, IS_JOYSTICK_KEY_LEFT, and static_fcpu_hz.
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 is_joystick_up().
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_JOYSTICK_RELEASED_KEY_RIGHT, cpu_is_timeout(), fast_mode, IS_JOYSTICK_KEY_PRESSED, and IS_JOYSTICK_RELEASED_KEY_RIGHT.
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_JOYSTICK_RELEASED_KEY_LEFT, cpu_is_timeout(), fast_mode, IS_JOYSTICK_KEY_PRESSED, and IS_JOYSTICK_RELEASED_KEY_LEFT.
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 CLEAR_JOYSTICK_RELEASED_KEY_PRESSED, and IS_JOYSTICK_RELEASED_KEY_PRESSED.
Referenced by playback_task().
void controller_shutdown | ( | void | ) |
Shutdown the controller.
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 CLEAR_JOYSTICK_KEY_ALL, GUI_UPDATE_VIEW_PLAYBACK, and IS_JOYSTICK_KEY_SLIDE_RIGHT.
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 CLEAR_JOYSTICK_KEY_ALL, GUI_UPDATE_VIEW_PLAYBACK, and IS_JOYSTICK_KEY_SLIDE_LEFT.
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 CLEAR_JOYSTICK_KEY_ALL, GUI_UPDATE_VIEW_CONFIG, GUI_UPDATE_VIEW_NAVIGATION, IS_JOYSTICK_KEY_SLIDE_LEFT, and IS_JOYSTICK_KEY_SLIDE_RIGHT.
Referenced by config_task(), and navigation_task().
|
static |
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), IS_JOYSTICK_KEY_DOWN, JOYSTICK_KEY_DEBOUNCE_MS, and static_fcpu_hz.
Referenced by controller_navigation_cursor_next(), and controller_playback_decrease_volume().
|
static |
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), IS_JOYSTICK_RELEASED_KEY_DOWN, JOYSTICK_KEY_DEBOUNCE_MS, and static_fcpu_hz.
Referenced by controller_config_next_option().
|
static |
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), IS_JOYSTICK_RELEASED_KEY_LEFT, JOYSTICK_KEY_DEBOUNCE_MS, and static_fcpu_hz.
Referenced by controller_navigation_go_to_parent_directory().
|
static |
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), IS_JOYSTICK_RELEASED_KEY_PRESSED, JOYSTICK_KEY_DEBOUNCE_MS, and static_fcpu_hz.
Referenced by controller_config_change_mode(), and controller_navigation_play().
|
static |
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), IS_JOYSTICK_RELEASED_KEY_RIGHT, JOYSTICK_KEY_DEBOUNCE_MS, and static_fcpu_hz.
Referenced by controller_navigation_change_directory().
|
static |
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), IS_JOYSTICK_RELEASED_KEY_UP, JOYSTICK_KEY_DEBOUNCE_MS, and static_fcpu_hz.
Referenced by controller_config_previous_option().
|
static |
References cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), IS_JOYSTICK_KEY_UP, JOYSTICK_KEY_DEBOUNCE_MS, and static_fcpu_hz.
Referenced by controller_navigation_cursor_previous(), and controller_playback_increase_volume().
|
inlinestatic |
References gpio_clear_pin_interrupt_flag(), gpio_get_pin_interrupt_flag(), gpio_get_pin_value(), and joystick_status.
Referenced by touch_button_isr().
void touch_button_isr | ( | void | ) |
References CLEAR_JOYSTICK_KEY_LEFT, CLEAR_JOYSTICK_KEY_RIGHT, CLEAR_JOYSTICK_KEY_SLIDING_LEFT, CLEAR_JOYSTICK_KEY_SLIDING_RIGHT, CLEAR_JOYSTICK_RELEASED_KEY_LEFT, CLEAR_JOYSTICK_RELEASED_KEY_PRESSED, CLEAR_JOYSTICK_RELEASED_KEY_RIGHT, cpu_is_timeout(), fast_mode, gpio_tgl_gpio_pin(), IS_JOYSTICK_KEY_LEFT, IS_JOYSTICK_KEY_RIGHT, IS_JOYSTICK_KEY_SLIDING_LEFT, IS_JOYSTICK_KEY_SLIDING_RIGHT, IS_JOYSTICK_RELEASED_KEY_LEFT, IS_JOYSTICK_RELEASED_KEY_PRESSED, IS_JOYSTICK_RELEASED_KEY_RIGHT, joystick_status, JOYSTICK_STATUS_DOWN, JOYSTICK_STATUS_LEFT, JOYSTICK_STATUS_PRESSED, JOYSTICK_STATUS_RELEASED_DOWN, JOYSTICK_STATUS_RELEASED_LEFT, JOYSTICK_STATUS_RELEASED_PRESSED, JOYSTICK_STATUS_RELEASED_RIGHT, JOYSTICK_STATUS_RELEASED_UP, JOYSTICK_STATUS_RIGHT, JOYSTICK_STATUS_SLIDE_LEFT, JOYSTICK_STATUS_SLIDE_RIGHT, JOYSTICK_STATUS_SLIDING_LEFT, JOYSTICK_STATUS_SLIDING_RIGHT, JOYSTICK_STATUS_UP, LED0_GPIO, manage_button_isr(), QT1081_TOUCH_SENSOR_DOWN, QT1081_TOUCH_SENSOR_ENTER, QT1081_TOUCH_SENSOR_LEFT, QT1081_TOUCH_SENSOR_RIGHT, and QT1081_TOUCH_SENSOR_UP.
Referenced by controller_init().
|
static |
|
static |
Referenced by controller_clear(), manage_button_isr(), and touch_button_isr().
|
static |