LUFA Library  120730
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Joystick Driver - LUFA/Drivers/Board/Joystick.h

Digital joystick board hardware driver. More...


 Board specific joystick driver header for the Fletchtronics BUMBLEB.
 Board specific joystick driver header for the Atmel EVK1100.
 Board specific joystick driver header for the Atmel EVK1101.
 Board specific joystick driver header for the Atmel EVK527.
 Board specific joystick driver header for the Atmel STK525.
 Board specific joystick driver header for the Atmel STK526.
 Board specific joystick driver header for the Atmel USBKEY.


static void Joystick_Init (void)
static void Joystick_Disable (void)
static uint_reg_t Joystick_GetStatus (void) ATTR_WARN_UNUSED_RESULT

Detailed Description

Module Source Dependencies

The following files must be built with any user project that uses this module:

Module Description

Hardware Joystick driver. This module provides an easy to use interface to control the hardware digital Joystick located on many boards.

If the BOARD value is set to BOARD_USER, this will include the /Board/Joystick.h file in the user project directory. Otherwise, it will include the appropriate built in board driver header file.

For possible BOARD makefile values, see Board Types.

Example Usage

The following snippet is an example of how this module may be used within a typical application.

// Initialize the board Joystick driver before first use
printf("Waiting for joystick movement...\r\n");
// Loop until a the joystick has been moved
uint8_t JoystickMovement;
while (!(JoystickMovement = Joystick_GetStatus())) {};
// Display which direction the joystick was moved in
printf("Joystick moved:\r\n");
if (JoystickMovement & (JOY_UP | JOY_DOWN))
printf("%s ", (JoystickMovement & JOY_UP) ? "Up" : "Down");
if (JoystickMovement & (JOY_LEFT | JOY_RIGHT))
printf("%s ", (JoystickMovement & JOY_LEFT) ? "Left" : "Right");
if (JoystickMovement & JOY_PRESS)

Function Documentation

static void Joystick_Disable ( void  )

Disables the joystick driver, releasing the I/O pins back to their default high-impedance input mode.

static uint_reg_t Joystick_GetStatus ( void  )

Returns the current status of the joystick, as a mask indicating the direction the joystick is currently facing in (multiple bits can be set).

Mask indicating the joystick direction - see corresponding board specific Joystick.h file for direction masks.
static void Joystick_Init ( void  )

Initializes the joystick driver so that the joystick position can be read. This sets the appropriate I/O pins to inputs with their pull-ups enabled.