Microchip® Advanced Software Framework

applications/uc3-audio-player/user_interface/controller/qt60168_controller.c File Reference
#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,
  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 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().

anonymous enum
Enumerator
TOUCH_IDLE 
TOUCH_PRESS 
TOUCH_RELEASE 
Enumerator
STATE_IDLE 
STATE_CS1_PRESSED 
STATE_CS2_PRESSED 
STATE_CS3_PRESSED 
STATE_CS4_PRESSED 
STATE_CS1_RELEASED 
STATE_CS2_RELEASED 
STATE_CS3_RELEASED 
STATE_CS4_RELEASED 
STATE_WHEEL_LEFT 
STATE_WHEEL_RIGHT 
STATE_WHEEL_LEFT_RELEASED 
STATE_WHEEL_RIGHT_RELEASED 
STATE_WHEEL_UP_RELEASED 
STATE_WHEEL_DOWN_RELEASED 
STATE_IDLE 
STATE_CS1_PRESSED 
STATE_CS2_PRESSED 
STATE_CS3_PRESSED 
STATE_CS4_PRESSED 
STATE_CS1_RELEASED 
STATE_CS2_RELEASED 
STATE_CS3_RELEASED 
STATE_CS4_RELEASED 
STATE_WHEEL_LEFT 
STATE_WHEEL_RIGHT 
STATE_WHEEL_LEFT_RELEASED 
STATE_WHEEL_RIGHT_RELEASED 
STATE_WHEEL_UP_RELEASED 
STATE_WHEEL_DOWN_RELEASED 

void controller_clear ( void  )

Reset the key state.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Referenced by app_engine(), com_task(), and main().

bool controller_key_cs2 ( void  )
bool controller_key_pressed ( void  )
bool controller_key_released ( void  )
static void controller_keys_update ( int  all_keys)
static
bool controller_navigation_change_directory ( void  )

This function is called to check if the user has pressed the change directory key.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

References CLEAR_RELEASED_STATE, controller_state, and STATE_WHEEL_DOWN_RELEASED.

Referenced by playback_task().

bool controller_playback_ffw ( bool  new_track)

This function is called to check if the user has pressed the fast forward key.

Returns
true if the key has been pressed. false otherwise.

References controller_wheel_right().

Referenced by playback_task().

bool controller_playback_frw ( bool  new_track)

This function is called to check if the user has pressed the fast rewind key.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

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.

Returns
true if the key has been pressed. false otherwise.

References controller_key_cs3().

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.

Parameters
viewThe current view.
Returns
true if the key has been pressed. false otherwise.

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.

Parameters
viewThe current view.
Returns
true if the key has been pressed. false otherwise.

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.

Parameters
viewThe current view.
Returns
true if the key has been pressed. false otherwise.

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_pressed ( void  )
static bool is_key_pressed ( int  all_keys,
int  key_num 
)
inlinestatic

Referenced by controller_keys_update().

ISR ( rtc_irq  ,
AVR32_RTC_IRQ_GROUP  ,
AVR32_INTC_INT0   
)
void rtc_init_qt ( void  )

Referenced by controller_init().

static void set_wheel_left ( )
inlinestatic
static void set_wheel_right ( )
inlinestatic
static int special_qt60168_get_reply ( unsigned short *  data)
static
bool special_qt60168_get_reply60168_report_all_key ( unsigned short *  data)
static bool special_qt60168_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(), and rtc_irq().

static int special_qt60168_send_cmd ( unsigned char  cmd)
static

t_cpu_time cpu_time_clear_wheel
static
unsigned short Data
static

Referenced by ISR(), and special_qt60168_get_reply().

int Read_data = 0
static

Referenced by ISR(), and special_qt60168_send_cmd().

int report_state = 0
static
enum { ... } touch_states[QT60168_TOUCH_NUMBER_OF_SENSORS]