qt60168_controller.c File Reference


Detailed Description

QTouch Controller.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file qt60168_controller.c.

#include "board.h"
#include "gpio.h"
#include "intc.h"
#include "qt60168_controller_init.h"
#include "controller.h"
#include "cycle_counter.h"
#include "spi.h"
#include "conf_qt60168.h"

Go to the source code of this file.

Defines

#define JOYSTICK_STATUS_DOWN   0x00000002
#define JOYSTICK_STATUS_IDLE   0x00000000
#define JOYSTICK_STATUS_LEFT   0x00000008
#define JOYSTICK_STATUS_PRESSED   0x00000010
#define JOYSTICK_STATUS_RIGHT   0x00000004
#define JOYSTICK_STATUS_UP   0x00000001

Functions

void controller_init (U32 fcpu_hz, U32 fhsb_hz, U32 fpbb_hz, U32 fpba_hz)
 Initialization function of the controller interface.
void evaluate_detect_status (Bool status, int status_pressed)
Bool is_joystick_down (void)
 check if down is pressed.
Bool is_joystick_left (void)
 check if left is pressed.
Bool is_joystick_pressed (void)
 check if pressed is pressed.
Bool is_joystick_right (void)
 check if right is pressed.
Bool is_joystick_up (void)
 check if up is pressed.
void update_joystick_status (unsigned short new_status)

Variables

static int qwheel_status = JOYSTICK_STATUS_IDLE


Define Documentation

#define JOYSTICK_STATUS_DOWN   0x00000002

Definition at line 64 of file qt60168_controller.c.

Referenced by is_joystick_down(), and update_joystick_status().

#define JOYSTICK_STATUS_IDLE   0x00000000

Definition at line 62 of file qt60168_controller.c.

#define JOYSTICK_STATUS_LEFT   0x00000008

Definition at line 66 of file qt60168_controller.c.

Referenced by is_joystick_left(), and update_joystick_status().

#define JOYSTICK_STATUS_PRESSED   0x00000010

Definition at line 67 of file qt60168_controller.c.

Referenced by is_joystick_pressed(), and update_joystick_status().

#define JOYSTICK_STATUS_RIGHT   0x00000004

Definition at line 65 of file qt60168_controller.c.

Referenced by is_joystick_right(), and update_joystick_status().

#define JOYSTICK_STATUS_UP   0x00000001

Definition at line 63 of file qt60168_controller.c.

Referenced by is_joystick_up(), and update_joystick_status().


Function Documentation

void controller_init ( U32  fcpu_hz,
U32  fhsb_hz,
U32  fpbb_hz,
U32  fpba_hz 
)

Initialization function of the controller interface.

Parameters:
fcpu_hz CPU frequency.
fhsb_hz HSB frequency.
fpbb_hz PBB frequency.
fpba_hz PBA frequency.

Definition at line 108 of file qt60168_controller.c.

References QT60168_SPI_BITS, QT60168_SPI_MASTER_SPEED, and rtc_init_qt().

Referenced by main().

00109 {
00110    static const gpio_map_t QT60168_SPI_GPIO_MAP = { { QT60168_SPI_SCK_PIN,
00111       QT60168_SPI_SCK_FUNCTION }, // SPI Clock.
00112       { QT60168_SPI_MISO_PIN, QT60168_SPI_MISO_FUNCTION }, // MISO.
00113       { QT60168_SPI_MOSI_PIN, QT60168_SPI_MOSI_FUNCTION }, // MOSI.
00114       { QT60168_SPI_NPCS0_PIN, QT60168_SPI_NPCS0_FUNCTION } // Chip Select NPCS.
00115   };
00116 
00117   // SPI options.
00118   spi_options_t spiOptions = {
00119       .reg = QT60168_SPI_NCPS,
00120       .baudrate = QT60168_SPI_MASTER_SPEED, // Defined in conf_qt60168.h.
00121       .bits = QT60168_SPI_BITS, // Defined in conf_qt60168.h.
00122       .spck_delay = 0, 
00123       .trans_delay = 0, 
00124       .stay_act = 0, 
00125       .spi_mode = 3,
00126       .modfdis = 1 };
00127 
00128   // Assign I/Os to SPI.
00129   gpio_enable_module(QT60168_SPI_GPIO_MAP, sizeof(QT60168_SPI_GPIO_MAP)
00130       / sizeof(QT60168_SPI_GPIO_MAP[0]));
00131 
00132    // Initialize as master.
00133   spi_initMaster(QT60168_SPI, &spiOptions);
00134   
00135   // Set selection mode: variable_ps, pcs_decode, delay.
00136   spi_selectionMode(QT60168_SPI, 0, 0, 0);
00137 
00138   // Enable SPI.
00139   spi_enable(QT60168_SPI);
00140 
00141   // Initialize QT60168 with SPI clock Osc0.
00142   spi_setupChipReg(QT60168_SPI, &spiOptions, fpba_hz);
00143   
00144   // Initialize QT60168 component.  
00145   qt60168_init(fpba_hz);
00146   
00147   rtc_init_qt();
00148 }

void evaluate_detect_status ( Bool  status,
int  status_pressed 
)

Definition at line 70 of file qt60168_controller.c.

References qwheel_status.

Referenced by update_joystick_status().

00071 {
00072     //pressed
00073     if (status == 1) {
00074       qwheel_status |= status_pressed;
00075     }
00076     // release
00077     else {
00078       qwheel_status &= ~status_pressed;   
00079     }
00080 }

Bool is_joystick_down ( void   ) 

check if down is pressed.

Definition at line 156 of file qt60168_controller.c.

References JOYSTICK_STATUS_DOWN, and qwheel_status.

Referenced by is_usb_hid_event().

00157 {    return (qwheel_status&JOYSTICK_STATUS_DOWN)?TRUE:FALSE;
00158 
00159 }

Bool is_joystick_left ( void   ) 

check if left is pressed.

Definition at line 166 of file qt60168_controller.c.

References JOYSTICK_STATUS_LEFT, and qwheel_status.

Referenced by is_usb_hid_event().

00167 {
00168     return (qwheel_status&JOYSTICK_STATUS_LEFT)?TRUE:FALSE;
00169 }

Bool is_joystick_pressed ( void   ) 

check if pressed is pressed.

Definition at line 171 of file qt60168_controller.c.

References JOYSTICK_STATUS_PRESSED, and qwheel_status.

Referenced by device_audio_task(), and is_usb_hid_event().

00172 {
00173     return (qwheel_status&JOYSTICK_STATUS_PRESSED)?TRUE:FALSE;
00174 }

Bool is_joystick_right ( void   ) 

check if right is pressed.

Definition at line 161 of file qt60168_controller.c.

References JOYSTICK_STATUS_RIGHT, and qwheel_status.

Referenced by is_usb_hid_event().

00162 {
00163     return (qwheel_status&JOYSTICK_STATUS_RIGHT)?TRUE:FALSE;
00164 }

Bool is_joystick_up ( void   ) 

check if up is pressed.

Definition at line 151 of file qt60168_controller.c.

References JOYSTICK_STATUS_UP, and qwheel_status.

Referenced by is_usb_hid_event().

00152 {
00153   return (qwheel_status&JOYSTICK_STATUS_UP)?TRUE:FALSE;
00154 }

void update_joystick_status ( unsigned short  new_status  ) 

Definition at line 83 of file qt60168_controller.c.

References evaluate_detect_status(), JOYSTICK_STATUS_DOWN, JOYSTICK_STATUS_LEFT, JOYSTICK_STATUS_PRESSED, JOYSTICK_STATUS_RIGHT, and JOYSTICK_STATUS_UP.

Referenced by rtc_irq().

00084 {
00085   Bool status;   
00086     
00087   status = (new_status & (1<<QT60168_TOUCH_SENSOR_WHEEL_UP))?TRUE:FALSE;
00088   evaluate_detect_status(status, JOYSTICK_STATUS_UP);
00089   
00090   
00091   status =(new_status & (1<<QT60168_TOUCH_SENSOR_WHEEL_DOWN))?TRUE:FALSE;  
00092   evaluate_detect_status(status, JOYSTICK_STATUS_DOWN);
00093   
00094   
00095   status = (new_status & (1<<QT60168_TOUCH_SENSOR_WHEEL_RIGHT))?TRUE:FALSE;
00096   evaluate_detect_status(status, JOYSTICK_STATUS_RIGHT);
00097   
00098   
00099   status = (new_status & (1<<QT60168_TOUCH_SENSOR_WHEEL_LEFT))?TRUE:FALSE;
00100   evaluate_detect_status(status, JOYSTICK_STATUS_LEFT);
00101   
00102   
00103   status = (new_status & (1<<QT60168_TOUCH_SENSOR_BUTTON_0))?TRUE:FALSE;
00104   evaluate_detect_status(status, JOYSTICK_STATUS_PRESSED);
00105       
00106 }


Variable Documentation

int qwheel_status = JOYSTICK_STATUS_IDLE [static]


Generated on Fri Feb 19 02:32:11 2010 for AVR32 - USB AUDIO Example by  doxygen 1.5.5