Changed HWB board driver to Buttons driver, to allow for the support of future boards with more than one mounted GPIO button.

pull/1469/head
Dean Camera 16 years ago
parent f11f69fd29
commit 63a8f66d92

@ -58,7 +58,7 @@ int main(void)
/* Hardware Initialization */ /* Hardware Initialization */
Joystick_Init(); Joystick_Init();
LEDs_Init(); LEDs_Init();
HWB_Init(); Buttons_Init();
/* Indicate USB not ready */ /* Indicate USB not ready */
UpdateStatus(Status_USBNotReady); UpdateStatus(Status_USBNotReady);
@ -173,7 +173,7 @@ bool GetNextReport(USB_JoystickReport_Data_t* ReportData)
if (JoyStatus_LCL & JOY_PRESS) if (JoyStatus_LCL & JOY_PRESS)
ReportData->Button = (1 << 1); ReportData->Button = (1 << 1);
if (HWB_GetStatus()) if (Buttons_GetStatus() & BUTTONS_BUTTON1)
ReportData->Button |= (1 << 0); ReportData->Button |= (1 << 0);
/* Check if the new report is different to the previous report */ /* Check if the new report is different to the previous report */

@ -48,7 +48,7 @@
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
/* Task Definitions: */ /* Task Definitions: */

@ -240,8 +240,8 @@ TASK(USB_Keyboard)
{ {
uint8_t JoyStatus_LCL = Joystick_GetStatus(); uint8_t JoyStatus_LCL = Joystick_GetStatus();
/* Check if HWB is not pressed, if so mouse mode enabled */ /* Check if board button is not pressed, if so mouse mode enabled */
if (!(HWB_GetStatus())) if (!(Buttons_GetStatus() & BUTTONS_BUTTON1))
{ {
if (JoyStatus_LCL & JOY_UP) if (JoyStatus_LCL & JOY_UP)
KeyboardReportData.KeyCode[0] = 0x04; // A KeyboardReportData.KeyCode[0] = 0x04; // A
@ -311,8 +311,8 @@ TASK(USB_Mouse)
{ {
uint8_t JoyStatus_LCL = Joystick_GetStatus(); uint8_t JoyStatus_LCL = Joystick_GetStatus();
/* Check if HWB is pressed, if so mouse mode enabled */ /* Check if board button is pressed, if so mouse mode enabled */
if (HWB_GetStatus()) if (Buttons_GetStatus() & BUTTONS_BUTTON1)
{ {
if (JoyStatus_LCL & JOY_UP) if (JoyStatus_LCL & JOY_UP)
MouseReportData.Y = 1; MouseReportData.Y = 1;

@ -45,7 +45,7 @@
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
/* Task Definitions: */ /* Task Definitions: */

@ -58,7 +58,7 @@ int main(void)
/* Hardware Initialization */ /* Hardware Initialization */
Joystick_Init(); Joystick_Init();
LEDs_Init(); LEDs_Init();
HWB_Init(); Buttons_Init();
/* Indicate USB not ready */ /* Indicate USB not ready */
UpdateStatus(Status_USBNotReady); UpdateStatus(Status_USBNotReady);
@ -134,8 +134,8 @@ TASK(USB_MIDI_Task)
uint8_t JoystickStatus = Joystick_GetStatus(); uint8_t JoystickStatus = Joystick_GetStatus();
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus); uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
/* Get HWB status - if set use channel 10 (percussion), otherwise use channel 1 */ /* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
uint8_t Channel = ((HWB_GetStatus()) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1)); uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
if (JoystickChanges & JOY_LEFT) if (JoystickChanges & JOY_LEFT)
SendMIDINoteChange(0x3C, (JoystickStatus & JOY_LEFT), 0, Channel); SendMIDINoteChange(0x3C, (JoystickStatus & JOY_LEFT), 0, Channel);

@ -48,7 +48,7 @@
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
/* Macros: */ /* Macros: */

@ -81,7 +81,7 @@ int main(void)
/* Hardware Initialization */ /* Hardware Initialization */
Joystick_Init(); Joystick_Init();
LEDs_Init(); LEDs_Init();
HWB_Init(); Buttons_Init();
/* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */ /* Millisecond timer initialization, with output compare interrupt enabled for the idle timing */
OCR0A = 0x7D; OCR0A = 0x7D;
@ -305,7 +305,7 @@ void CreateMouseReport(USB_MouseReport_Data_t* ReportData)
if (JoyStatus_LCL & JOY_PRESS) if (JoyStatus_LCL & JOY_PRESS)
ReportData->Button = (1 << 0); ReportData->Button = (1 << 0);
if (HWB_GetStatus()) if (Buttons_GetStatus() & BUTTONS_BUTTON1)
ReportData->Button |= (1 << 1); ReportData->Button |= (1 << 1);
} }

@ -50,7 +50,7 @@
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
/* Task Definitions: */ /* Task Definitions: */

@ -63,7 +63,7 @@ int main(void)
/* Hardware Initialization */ /* Hardware Initialization */
SerialStream_Init(9600, false); SerialStream_Init(9600, false);
LEDs_Init(); LEDs_Init();
HWB_Init(); Buttons_Init();
/* Indicate USB not ready */ /* Indicate USB not ready */
UpdateStatus(Status_USBNotReady); UpdateStatus(Status_USBNotReady);
@ -319,10 +319,10 @@ TASK(USB_MassStore_Host)
puts_P(PSTR("\r\n")); puts_P(PSTR("\r\n"));
} }
puts_P(PSTR("\r\n\r\nPress HWB to read entire ASCII contents of disk...\r\n\r\n")); puts_P(PSTR("\r\n\r\nPress board button to read entire ASCII contents of disk...\r\n\r\n"));
/* Wait for HWB to be pressed */ /* Wait for the board button to be pressed */
while (!(HWB_GetStatus())) while (!(Buttons_GetStatus() & BUTTONS_BUTTON1))
{ {
/* Abort if device removed */ /* Abort if device removed */
if (!(USB_IsConnected)) if (!(USB_IsConnected))

@ -52,7 +52,7 @@
#include <LUFA/Drivers/USB/USB.h> // USB Functionality #include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Peripheral/SerialStream.h> // Serial stream driver #include <LUFA/Drivers/Peripheral/SerialStream.h> // Serial stream driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver #include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management #include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
/* Enums: */ /* Enums: */

@ -40,7 +40,7 @@
TASK_LIST TASK_LIST
{ {
{ .Task = TestApp_CheckJoystick, .TaskStatus = TASK_RUN }, { .Task = TestApp_CheckJoystick, .TaskStatus = TASK_RUN },
{ .Task = TestApp_CheckHWB , .TaskStatus = TASK_RUN }, { .Task = TestApp_CheckButton , .TaskStatus = TASK_RUN },
{ .Task = TestApp_CheckTemp , .TaskStatus = TASK_RUN }, { .Task = TestApp_CheckTemp , .TaskStatus = TASK_RUN },
{ .Task = USB_USBTask , .TaskStatus = TASK_RUN }, { .Task = USB_USBTask , .TaskStatus = TASK_RUN },
}; };
@ -63,7 +63,7 @@ int main(void)
Temperature_Init(); Temperature_Init();
Joystick_Init(); Joystick_Init();
LEDs_Init(); LEDs_Init();
HWB_Init(); Buttons_Init();
/* Millisecond timer initialization, with output compare interrupt enabled */ /* Millisecond timer initialization, with output compare interrupt enabled */
OCR0A = 0x7D; OCR0A = 0x7D;
@ -137,17 +137,17 @@ TASK(TestApp_CheckTemp)
} }
} }
/** Task responsible for checking the HWB button position, and start-stopping other tasks and the USB /** Task responsible for checking the board's first button' position, and start-stopping other tasks and the USB
* interface in response to user joystick movements. * interface in response to user joystick movements.
*/ */
TASK(TestApp_CheckHWB) TASK(TestApp_CheckButton)
{ {
static SchedulerDelayCounter_t DelayCounter = 0; static SchedulerDelayCounter_t DelayCounter = 0;
static bool IsPressed; static bool IsPressed;
static bool BlockingJoystickTask; static bool BlockingJoystickTask;
/* Check if HWB pressed (start USB) */ /* Check if board button pressed (start USB) */
if (HWB_GetStatus() == true) if (Buttons_GetStatus() & BUTTONS_BUTTON1)
{ {
/* Debounce - check 100 ticks later to see if button is still being pressed */ /* Debounce - check 100 ticks later to see if button is still being pressed */
if ((IsPressed == false) && (Scheduler_HasDelayElapsed(100, &DelayCounter))) if ((IsPressed == false) && (Scheduler_HasDelayElapsed(100, &DelayCounter)))
@ -185,7 +185,7 @@ TASK(TestApp_CheckHWB)
} }
else else
{ {
/* HWB not pressed - reset debounce interval counter and press handled flag */ /* Board button not pressed - reset debounce interval counter and press handled flag */
Scheduler_ResetDelay(&DelayCounter); Scheduler_ResetDelay(&DelayCounter);
IsPressed = false; IsPressed = false;
} }

@ -51,12 +51,12 @@
#include <LUFA/Drivers/Peripheral/SerialStream.h> // USART Stream driver #include <LUFA/Drivers/Peripheral/SerialStream.h> // USART Stream driver
#include <LUFA/Drivers/Board/Joystick.h> // Joystick driver #include <LUFA/Drivers/Board/Joystick.h> // Joystick driver
#include <LUFA/Drivers/Board/LEDs.h> // LED driver #include <LUFA/Drivers/Board/LEDs.h> // LED driver
#include <LUFA/Drivers/Board/HWB.h> // Hardware Button driver #include <LUFA/Drivers/Board/Buttons.h> // Board Buttons driver
#include <LUFA/Drivers/Board/Temperature.h> // Temperature sensor driver #include <LUFA/Drivers/Board/Temperature.h> // Temperature sensor driver
/* Task Definitions: */ /* Task Definitions: */
TASK(TestApp_CheckJoystick); TASK(TestApp_CheckJoystick);
TASK(TestApp_CheckHWB); TASK(TestApp_CheckButton);
TASK(TestApp_CheckTemp); TASK(TestApp_CheckTemp);
#endif #endif

File diff suppressed because one or more lines are too long

@ -77,6 +77,7 @@
* - Fixed missing semicolon in the ATAVRUSBRF01 LED board driver code (thanks to Morten Lund) * - Fixed missing semicolon in the ATAVRUSBRF01 LED board driver code (thanks to Morten Lund)
* - Changed LED board driver code to define dummy LED masks for the first four board LEDs, so that user code can be compiled for boards * - Changed LED board driver code to define dummy LED masks for the first four board LEDs, so that user code can be compiled for boards
* with less than four LEDs without code modifications (thanks to Morten Lund) * with less than four LEDs without code modifications (thanks to Morten Lund)
* - Changed HWB board driver to Buttons driver, to allow for the support of future boards with more than one mounted GPIO button
* *
* *
* \section Sec_ChangeLog090401 Version 090401 * \section Sec_ChangeLog090401 Version 090401

@ -35,13 +35,12 @@
driver file should be completed and copied into the "/Board/" folder driver file should be completed and copied into the "/Board/" folder
inside the application's folder. inside the application's folder.
This stub is for the board-specific component of the LUFA HWB (Hardware This stub is for the board-specific component of the LUFA Buttons driver,
Button, a physical button on most Atmel USB boards) driver. This could for the control of physical board-mounted GPIO pushbuttons.
alternately be driven from any button connected to the USB AVR.
*/ */
#ifndef __HWB_USER_H__ #ifndef __BUTTONS_USER_H__
#define __HWB_USER_H__ #define __BUTTONS_USER_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #include <avr/io.h>
@ -57,20 +56,24 @@
#endif #endif
/* Preprocessor Checks: */ /* Preprocessor Checks: */
#if !defined(INCLUDE_FROM_HWB_H) #if !defined(INCLUDE_FROM_BUTTONS_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead. #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
#endif #endif
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */
/** Button mask for the first button on the board. */
#define BUTTONS_BUTTON1 // TODO: Add mask for first board buton here
/* Inline Functions: */ /* Inline Functions: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
static inline void HWB_Init(void) static inline void Buttons_Init(void)
{ {
// TODO: Initialize the appropriate port pin as an input here, with pull-up // TODO: Initialize the appropriate port pins as an inputs here, with pull-ups
} }
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline bool HWB_GetStatus(void) static inline uint8_t Buttons_GetStatus(void)
{ {
// TODO: Return current button status here, debounced if required // TODO: Return current button status here, debounced if required
} }

@ -30,14 +30,14 @@
/** \file /** \file
* *
* Board specific HWB driver header for the ATAVRUSBRF01. * Board specific Buttons driver header for the ATAVRUSBRF01.
* *
* \note This file should not be included directly. It is automatically included as needed by the HWB driver * \note This file should not be included directly. It is automatically included as needed by the Buttons driver
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/Buttons.h.
*/ */
#ifndef __HWB_ATAVRUSBRF01_H__ #ifndef __BUTTONS_ATAVRUSBRF01_H__
#define __HWB_ATAVRUSBRF01_H__ #define __BUTTONS_ATAVRUSBRF01_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #include <avr/io.h>
@ -51,23 +51,27 @@
#endif #endif
/* Preprocessor Checks: */ /* Preprocessor Checks: */
#if !defined(INCLUDE_FROM_HWB_H) #if !defined(INCLUDE_FROM_BUTTONS_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead. #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
#endif #endif
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */
/** Button mask for the first button on the board. */
#define BUTTONS_BUTTON1 (1 << 7)
/* Inline Functions: */ /* Inline Functions: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
static inline void HWB_Init(void) static inline void Buttons_Init(void)
{ {
DDRD &= ~(1 << 7); DDRD &= ~BUTTONS_BUTTON1;
PORTD |= (1 << 7); PORTD |= BUTTONS_BUTTON1;
} }
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline bool HWB_GetStatus(void) static inline uint8_t Buttons_GetStatus(void)
{ {
return (!(PIND & (1 << 7))); return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
} }
#endif #endif

@ -30,25 +30,25 @@
/** \file /** \file
* *
* This file is the master dispatch header file for the board-specific HWB driver, for boards containing a * This file is the master dispatch header file for the board-specific Buttons driver, for boards containing
* physical pushbutton connected to the AVR's HWB IO pin. * physical pushbuttons connected to the AVR's GPIO pins.
* *
* User code should include this file, which will in turn include the correct HWB driver header file for the * User code should include this file, which will in turn include the correct Button driver header file for the
* currently selected board. * currently selected board.
* *
* If the BOARD value is set to BOARD_USER, this will include the /Board/HWB.h file in the user project * If the BOARD value is set to BOARD_USER, this will include the /Board/Buttons.h file in the user project
* directory. * directory.
*/ */
/** \ingroup Group_BoardDrivers /** \ingroup Group_BoardDrivers
* @defgroup Group_HWB HWB Driver - LUFA/Drivers/Board/HWB.h * @defgroup Group_Buttons Buttons Driver - LUFA/Drivers/Board/Buttons.h
* *
* \section Sec_Dependencies Module Source Dependencies * \section Sec_Dependencies Module Source Dependencies
* The following files must be built with any user project that uses this module: * The following files must be built with any user project that uses this module:
* - None * - None
* *
* \section Module Description * \section Module Description
* Functions, macros, variables, enums and types related to the control of board HWB. * Functions, macros, variables, enums and types related to the control of physical board GPIO buttons.
* *
* If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project * If the BOARD value is set to BOARD_USER, this will include the /Board/Dataflash.h file in the user project
* directory. Otherwise, it will include the appropriate built in board driver header file. * directory. Otherwise, it will include the appropriate built in board driver header file.
@ -56,12 +56,12 @@
* @{ * @{
*/ */
#ifndef __HWB_H__ #ifndef __BUTTONS_H__
#define __HWB_H__ #define __BUTTONS_H__
/* Macros: */ /* Macros: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
#define INCLUDE_FROM_HWB_H #define INCLUDE_FROM_BUTTONS_H
#define INCLUDE_FROM_BOARD_DRIVER #define INCLUDE_FROM_BOARD_DRIVER
#endif #endif
@ -71,33 +71,33 @@
#if !defined(BOARD) #if !defined(BOARD)
#error BOARD must be set in makefile to a value specified in BoardTypes.h. #error BOARD must be set in makefile to a value specified in BoardTypes.h.
#elif (BOARD == BOARD_USBKEY) #elif (BOARD == BOARD_USBKEY)
#include "USBKEY/HWB.h" #include "USBKEY/BUTTONS.h"
#elif (BOARD == BOARD_STK525) #elif (BOARD == BOARD_STK525)
#include "STK525/HWB.h" #include "STK525/BUTTONS.h"
#elif (BOARD == BOARD_STK526) #elif (BOARD == BOARD_STK526)
#include "STK526/HWB.h" #include "STK526/BUTTONS.h"
#elif (BOARD == BOARD_ATAVRUSBRF01) #elif (BOARD == BOARD_ATAVRUSBRF01)
#include "ATAVRUSBRF01/HWB.h" #include "ATAVRUSBRF01/BUTTONS.h"
#elif (BOARD == BOARD_USER) #elif (BOARD == BOARD_USER)
#include "Board/HWB.h" #include "Board/BUTTONS.h"
#else #else
#error The selected board does not contain a HWB. #error The selected board does not contain any GPIO buttons.
#endif #endif
/* Pseudo-Functions for Doxygen: */ /* Pseudo-Functions for Doxygen: */
#if defined(__DOXYGEN__) #if defined(__DOXYGEN__)
/** Initializes the HWB driver, so that the current button position can be read. This sets the appropriate /** Initializes the BUTTONS driver, so that the current button position can be read. This sets the appropriate
* I/O pin to an input with pull-up enabled. * I/O pins to an inputs with pull-ups enabled.
* *
* This must be called before any HWB functions are used. * This must be called before any Button driver functions are used.
*/ */
static inline void HWB_Init(void); static inline void Buttons_Init(void);
/** Returns the current position of the HWB button on the board. /** Returns a mask indicating which board buttons are currently pressed.
* *
* \return Boolean true if the button is currently pressed, false otherwise * \return Mask indicating which board buttons are currently pressed
*/ */
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
#endif #endif
#endif #endif

@ -30,14 +30,20 @@
/** \file /** \file
* *
* Board specific HWB driver header for the STK526. * Board specific Buttons driver header for the STK525.
* *
* \note This file should not be included directly. It is automatically included as needed by the HWB driver * \note This file should not be included directly. It is automatically included as needed by the Buttons driver
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/Buttons.h.
*/ */
#ifndef __HWB_STK526_H__ #ifndef __BUTTONS_STK525_H__
#define __HWB_STK526_H__ #define __BUTTONS_STK525_H__
/* Includes: */
#include <avr/io.h>
#include <stdbool.h>
#include "../../../Common/Common.h"
/* Includes: */ /* Includes: */
#include <avr/io.h> #include <avr/io.h>
@ -51,23 +57,27 @@
#endif #endif
/* Preprocessor Checks: */ /* Preprocessor Checks: */
#if !defined(INCLUDE_FROM_HWB_H) #if !defined(INCLUDE_FROM_BUTTONS_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead. #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
#endif #endif
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */
/** Button mask for the first button on the board. */
#define BUTTONS_BUTTON1 (1 << 2)
/* Inline Functions: */ /* Inline Functions: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
static inline void HWB_Init(void) static inline void Buttons_Init(void)
{ {
DDRD &= ~(1 << 7); DDRE &= ~BUTTONS_BUTTON1;
PORTD |= (1 << 7); PORTE |= BUTTONS_BUTTON1;
} }
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline bool HWB_GetStatus(void) static inline uint8_t Buttons_GetStatus(void)
{ {
return (!(PIND & (1 << 7))); return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
} }
#endif #endif

@ -30,7 +30,7 @@
/** \file /** \file
* *
* Board specific HWB driver header for the STK525. * Board specific Dataflash driver header for the STK525.
* *
* \note This file should not be included directly. It is automatically included as needed by the dataflash driver * \note This file should not be included directly. It is automatically included as needed by the dataflash driver
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.

@ -30,14 +30,20 @@
/** \file /** \file
* *
* Board specific HWB driver header for the STK525. * Board specific Buttons driver header for the STK526.
* *
* \note This file should not be included directly. It is automatically included as needed by the HWB driver * \note This file should not be included directly. It is automatically included as needed by the Buttons driver
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/Buttons.h.
*/ */
#ifndef __HWB_STK525_H__ #ifndef __BUTTONS_STK526_H__
#define __HWB_STK525_H__ #define __BUTTONS_STK526_H__
/* Includes: */
#include <avr/io.h>
#include <stdbool.h>
#include "../../../Common/Common.h"
/* Includes: */ /* Includes: */
#include <avr/io.h> #include <avr/io.h>
@ -51,23 +57,27 @@
#endif #endif
/* Preprocessor Checks: */ /* Preprocessor Checks: */
#if !defined(INCLUDE_FROM_HWB_H) #if !defined(INCLUDE_FROM_BUTTONS_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead. #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
#endif #endif
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */
/** Button mask for the first button on the board. */
#define BUTTONS_BUTTON1 (1 << 2)
/* Inline Functions: */ /* Inline Functions: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
static inline void HWB_Init(void) static inline void Buttons_Init(void)
{ {
DDRE &= ~(1 << 2); DDRD &= ~BUTTONS_BUTTON1;
PORTE |= (1 << 2); PORTD |= BUTTONS_BUTTON1;
} }
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline bool HWB_GetStatus(void) static inline uint8_t Buttons_GetStatus(void)
{ {
return (!(PINE & (1 << 2))); return ((PIND & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
} }
#endif #endif
@ -77,4 +87,3 @@
#endif #endif
#endif #endif

@ -30,7 +30,7 @@
/** \file /** \file
* *
* Board specific HWB driver header for the STK525. * Board specific Dataflash driver header for the STK525.
* *
* \note This file should not be included directly. It is automatically included as needed by the dataflash driver * \note This file should not be included directly. It is automatically included as needed by the dataflash driver
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.

@ -30,14 +30,14 @@
/** \file /** \file
* *
* Board specific HWB driver header for the USBKEY. * Board specific Buttons driver header for the USBKEY.
* *
* \note This file should not be included directly. It is automatically included as needed by the HWB driver * \note This file should not be included directly. It is automatically included as needed by the Buttons driver
* dispatch header located in LUFA/Drivers/Board/HWB.h. * dispatch header located in LUFA/Drivers/Board/Buttons.h.
*/ */
#ifndef __HWB_USBKEY_H__ #ifndef __BUTTONS_USBKEY_H__
#define __HWB_USBKEY_H__ #define __BUTTONS_USBKEY_H__
/* Includes: */ /* Includes: */
#include <avr/io.h> #include <avr/io.h>
@ -51,23 +51,27 @@
#endif #endif
/* Preprocessor Checks: */ /* Preprocessor Checks: */
#if !defined(INCLUDE_FROM_HWB_H) #if !defined(INCLUDE_FROM_BUTTONS_H)
#error Do not include this file directly. Include LUFA/Drivers/Board/HWB.h instead. #error Do not include this file directly. Include LUFA/Drivers/Board/Buttons.h instead.
#endif #endif
/* Public Interface - May be used in end-application: */ /* Public Interface - May be used in end-application: */
/* Macros: */
/** Button mask for the first button on the board. */
#define BUTTONS_BUTTON1 (1 << 2)
/* Inline Functions: */ /* Inline Functions: */
#if !defined(__DOXYGEN__) #if !defined(__DOXYGEN__)
static inline void HWB_Init(void) static inline void Buttons_Init(void)
{ {
DDRE &= ~(1 << 2); DDRE &= ~BUTTONS_BUTTON1;
PORTE |= (1 << 2); PORTE |= BUTTONS_BUTTON1;
} }
static inline bool HWB_GetStatus(void) ATTR_WARN_UNUSED_RESULT; static inline uint8_t Buttons_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline bool HWB_GetStatus(void) static inline uint8_t Buttons_GetStatus(void)
{ {
return (!(PINE & (1 << 2))); return ((PINE & BUTTONS_BUTTON1) ^ BUTTONS_BUTTON1);
} }
#endif #endif

@ -30,7 +30,7 @@
/** \file /** \file
* *
* Board specific HWB driver header for the STK525. * Board specific Dataflash driver header for the STK525.
* *
* \note This file should not be included directly. It is automatically included as needed by the dataflash driver * \note This file should not be included directly. It is automatically included as needed by the dataflash driver
* dispatch header located in LUFA/Drivers/Board/Dataflash.h. * dispatch header located in LUFA/Drivers/Board/Dataflash.h.

@ -15,15 +15,15 @@
* microcontrollers, released under the MIT license. * microcontrollers, released under the MIT license.
* *
* Currently supported AVR models: * Currently supported AVR models:
* - AT90USB1286 * - AT90USB1286 (USB Host and Device)
* - AT90USB1287 * - AT90USB1287 (USB Host and Device)
* - AT90USB646 * - AT90USB646 (USB Device Only)
* - AT90USB647 * - AT90USB647 (USB Device Only)
* - AT90USB162 * - AT90USB162 (USB Device Only)
* - AT90USB82 * - AT90USB82 (USB Device Only)
* - ATMEGA16U4 * - ATMEGA16U4 (USB Device Only)
* - ATMEGA32U6 * - ATMEGA32U6 (USB Device Only)
* - ATMEGA32U4 * - ATMEGA32U4 (USB Device Only)
* *
* Currently supported Atmel boards: * Currently supported Atmel boards:
* - AT90USBKEY * - AT90USBKEY

@ -17,6 +17,7 @@
* BUTTLOADTAG elements, or download and extract ButtLoadTag.h header from the ButtLoad project. * BUTTLOADTAG elements, or download and extract ButtLoadTag.h header from the ButtLoad project.
* - The Drivers/AT90USBXXX directory has been renamed to Drivers/Peripheral. * - The Drivers/AT90USBXXX directory has been renamed to Drivers/Peripheral.
* - The Serial_Stream driver has been renamed to SerialStream to remain consistent with the rest of the library naming scheme. * - The Serial_Stream driver has been renamed to SerialStream to remain consistent with the rest of the library naming scheme.
* - The HWB driver has changed to the Buttons driver. See the board Buttons driver documentation for the new API.
* *
* <b>Dual Role Mode</b> * <b>Dual Role Mode</b>
* - The USB_PowerOnFail even has been renamed to USB_InitFailure. * - The USB_PowerOnFail even has been renamed to USB_InitFailure.

Loading…
Cancel
Save