Skip to content

Instantly share code, notes, and snippets.

@strider-
Created March 1, 2015 17:24
Show Gist options
  • Save strider-/09a226238753304863be to your computer and use it in GitHub Desktop.
Save strider-/09a226238753304863be to your computer and use it in GitHub Desktop.
#ifndef _KEYBOARD_H_
#define _KEYBOARD_H_
/* Includes: */
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include <avr/interrupt.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include "Descriptors.h"
#include <LUFA/Drivers/Board/Joystick.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Board/Buttons.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Platform/Platform.h>
/* Macros: */
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Function Prototypes: */
void SetupHardware(void);
void EVENT_USB_Device_Connect(void);
void EVENT_USB_Device_Disconnect(void);
void EVENT_USB_Device_ConfigurationChanged(void);
void EVENT_USB_Device_ControlRequest(void);
void EVENT_USB_Device_StartOfFrame(void);
bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
uint8_t* const ReportID,
const uint8_t ReportType,
void* ReportData,
uint16_t* const ReportSize);
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
const uint8_t ReportID,
const uint8_t ReportType,
const void* ReportData,
const uint16_t ReportSize);
typedef struct {
uint8_t ButtonIndex;
uint8_t Modifier;
uint8_t Scancodes[6];
} ATTR_PACKED ButtonData_t;
typedef struct
{
unsigned Play : 1;
unsigned Pause : 1;
unsigned FForward : 1;
unsigned Rewind : 1;
unsigned NextTrack : 1;
unsigned PreviousTrack : 1;
unsigned Stop : 1;
unsigned PlayPause : 1;
unsigned Mute : 1;
unsigned VolumeUp : 1;
unsigned VolumeDown : 1;
unsigned RESERVED : 5;
} ATTR_PACKED USB_MediaReport_Data_t;
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment