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

Digital button board hardware driver. More...

Modules

 A3BU_XPLAINED
 Board specific Buttons driver header for the Atmel XMEGA A3BU Xplained.
 
 ATAVRUSBRF01
 Board specific Buttons driver header for the Atmel ATAVRUSBRF01.
 
 B1_XPLAINED
 Board specific Buttons driver header for the Atmel XMEGA B1 Xplained.
 
 BENITO
 Board specific Buttons driver header for the Tempusdictum Benito.
 
 BUMBLEB
 Board specific Buttons driver header for the Fletchtronics BUMBLEB.
 
 CULV3
 Board specific Buttons driver header for the Busware CULV3.
 
 EVK1100
 Board specific Buttons driver header for the Atmel EVK1100.
 
 EVK1101
 Board specific Buttons driver header for the Atmel EVK1101.
 
 EVK1104
 Board specific Buttons driver header for the Atmel EVK1104.
 
 EVK527
 Board specific Buttons driver header for the Atmel EVK527.
 
 JMDBU2
 Board specific Buttons driver header for the Mattairtech JM-DB-U2.
 
 MICROPENDOUS_1
 Board specific Button driver header for the Micropendous 1 (https://code.google.com/p/micropendous/wiki/Micropendous1).
 
 MICROPENDOUS_2
 Board specific Button driver header for the Micropendous 2 (https://code.google.com/p/micropendous/wiki/Micropendous2).
 
 MICROPENDOUS_3
 Board specific Button driver header for the Micropendous 3 (https://code.google.com/p/micropendous/wiki/Micropendous3).
 
 MICROPENDOUS_32U2
 Board specific Buttons driver header for the Micropendous 32U2.
 
 MICROPENDOUS_4
 Board specific Button driver header for the Micropendous 4 (https://code.google.com/p/micropendous/wiki/Micropendous4).
 
 MICROPENDOUS_A
 Board specific Button driver header for the Micropendous A (https://code.google.com/p/micropendous/wiki/MicropendousA).
 
 MICROPENDOUS_DIP
 Board specific Button driver header for the Micropendous DIP (https://code.google.com/p/micropendous/wiki/MicropendousDIP).
 
 MICROPENDOUS_REV1
 Board specific Button driver header for the Micropendous Arduino-like Revision 1 (https://code.google.com/p/micropendous/wiki/Micropendous).
 
 MICROPENDOUS_REV2
 Board specific Button driver header for the Micropendous Arduino-like Revision 2 (https://code.google.com/p/micropendous/wiki/Micropendous).
 
 MICROSIN162
 Board specific Buttons driver header for the Microsin AVR-USB162 board.
 
 MINIMUS
 Board specific Buttons driver header for the MINIMUS.
 
 OLIMEX162
 Board specific Buttons driver header for the Olimex AVR-USB-162 Development Board.
 
 OLIMEX32U4
 Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board.
 
 OLIMEXISPMK2
 Board specific Buttons driver header for the Olimex AVR-ISP-MK2.
 
 OLIMEXT32U4
 Board specific Buttons driver header for the Olimex AVR-USB-32U4 Development Board.
 
 STANGE_ISP
 Board specific Buttons driver header for the Dimex Stange-ISP.
 
 STK525
 Board specific Buttons driver header for the Atmel STK525.
 
 STK526
 Board specific Buttons driver header for the Atmel STK526.
 
 TUL
 Board specific Buttons driver header for the TUL.
 
 UC3A3_XPLAINED
 Board specific Buttons driver header for the Atmel UC3-A3 Xplained.
 
 UDIP
 Board specific Buttons driver header for the UDIP.
 
 USB2AX
 Board specific Buttons driver header for the Xevelabs USB2AX revisions 1 and 2.
 
 USB2AX_V3
 Board specific Button driver header for the Xevelabs USB2AX revision 3.
 
 USB2AX_V31
 Board specific Button driver header for the Xevelabs USB2AX revision 3.1.
 
 USBFOO
 Board specific Buttons driver header for the Kernel Concepts USBFOO.
 
 USBKEY
 Board specific Buttons driver header for the Atmel USBKEY.
 
 USBTINYMKII
 Board specific Buttons driver header for Tom's USBTINY MKII.
 

Functions

static void Buttons_Disable (void)
 
static uint_reg_t Buttons_GetStatus (void) ATTR_WARN_UNUSED_RESULT
 
static void Buttons_Init (void)
 

Detailed Description

Module Source Dependencies

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

Module Description

Hardware buttons driver. This provides an easy to use driver for the hardware buttons present on many boards. It provides a way to easily configure and check the status of all the buttons on the board so that appropriate actions can be taken.

If the BOARD value is set to BOARD_USER, this will include the /Board/Buttons.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 button driver before first use
printf("Waiting for button press...\r\n");
// Loop until a board button has been pressed
uint8_t ButtonPress;
while (!(ButtonPress = Buttons_GetStatus())) {};
// Display which button was pressed (assuming two board buttons)
printf("Button pressed: %s\r\n", (ButtonPress == BUTTONS_BUTTON1) ? "Button 1" : "Button 2");

Function Documentation

static void Buttons_Disable ( void  )
inlinestatic

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

static uint_reg_t Buttons_GetStatus ( void  )
inlinestatic

Returns a mask indicating which board buttons are currently pressed.

Returns
Mask of BUTTONS_BUTTON* constants indicating which board buttons are currently pressed.
static void Buttons_Init ( void  )
inlinestatic

Initializes the buttons driver, so that the current button position can be read. This sets the appropriate I/O pins to an inputs with pull-ups enabled.

This must be called before any Button driver functions are used.