Clean up excessive whitespace at the end of each line using the wspurify tool made by Laszlo Monda
This commit is contained in:
parent
a8871c7fba
commit
5a4def7478
760 changed files with 12883 additions and 12164 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the JoystickHostWithParser demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "JoystickHostWithParser.h"
|
||||
|
||||
/** Processed HID report descriptor items structure, containing information on each HID report element */
|
||||
|
|
@ -52,14 +52,14 @@ USB_ClassInfo_HID_Host_t Joystick_HID_Interface =
|
|||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
|
||||
|
||||
.HIDInterfaceProtocol = HID_BOOTP_NonBootProtocol,
|
||||
|
||||
|
||||
.HIDParserData = &HIDReportInfo
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -78,7 +78,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -115,7 +115,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Joystick Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
|
@ -131,7 +131,7 @@ int main(void)
|
|||
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
|
||||
{
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
||||
|
||||
/* Update the report item value if it is contained within the current report */
|
||||
if (!(USB_GetHIDReportItemInfo(JoystickReport, ReportItem)))
|
||||
continue;
|
||||
|
|
@ -149,7 +149,7 @@ int main(void)
|
|||
(ReportItem->ItemType == HID_REPORT_ITEM_In))
|
||||
{
|
||||
int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
|
||||
|
||||
|
||||
if (DeltaMovement)
|
||||
{
|
||||
if (ReportItem->Attributes.Usage.Usage == USAGE_X)
|
||||
|
|
@ -159,13 +159,13 @@ int main(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HID_Host_USBTask(&Joystick_HID_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -235,7 +235,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -277,3 +277,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
|||
return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) ||
|
||||
(CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -78,17 +78,18 @@
|
|||
|
||||
/** HID Report Descriptor Usage value for a Y axis movement. */
|
||||
#define USAGE_Y 0x31
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Joystick Host With HID Descriptor Parser Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,19 +41,19 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Joystick host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Joystick host, for USB joysticks using
|
||||
* the standard joystick HID profile. It uses a HID parser for the HID
|
||||
* reports, allowing for correct operation across all USB joysticks. This
|
||||
* demo supports joysticks with a single HID report.
|
||||
*
|
||||
*
|
||||
* Joystick movement and button presses are displayed on the board LEDs.
|
||||
* On connection to a USB joystick, the report items will be processed and
|
||||
* printed as a formatted list through the USART before the joystick is
|
||||
* fully enumerated.
|
||||
*
|
||||
*
|
||||
* Currently only single interface joysticks are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
|
|
@ -68,3 +68,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the KeyboardHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "KeyboardHost.h"
|
||||
|
||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||
|
|
@ -49,12 +49,12 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface =
|
|||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
|
||||
|
||||
.HIDInterfaceProtocol = HID_BOOTP_KeyboardBootProtocol,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -66,14 +66,14 @@ int main(void)
|
|||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
switch (USB_HostState)
|
||||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -110,7 +110,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Keyboard Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
|
@ -118,11 +118,11 @@ int main(void)
|
|||
case HOST_STATE_Configured:
|
||||
if (HID_Host_IsReportReceived(&Keyboard_HID_Interface))
|
||||
{
|
||||
USB_KeyboardReport_Data_t KeyboardReport;
|
||||
USB_KeyboardReport_Data_t KeyboardReport;
|
||||
HID_Host_ReceiveReport(&Keyboard_HID_Interface, &KeyboardReport);
|
||||
|
||||
LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0);
|
||||
|
||||
|
||||
uint8_t PressedKeyCode = KeyboardReport.KeyCode[0];
|
||||
|
||||
if (PressedKeyCode)
|
||||
|
|
@ -130,25 +130,25 @@ int main(void)
|
|||
char PressedKey = 0;
|
||||
|
||||
LEDs_ToggleLEDs(LEDS_LED2);
|
||||
|
||||
|
||||
/* Retrieve pressed key character if alphanumeric */
|
||||
if ((PressedKeyCode >= 0x04) && (PressedKeyCode <= 0x1D))
|
||||
PressedKey = (PressedKeyCode - 0x04) + 'A';
|
||||
else if ((PressedKeyCode >= 0x1E) && (PressedKeyCode <= 0x27))
|
||||
PressedKey = (PressedKeyCode - 0x1E) + '0';
|
||||
else if (PressedKeyCode == 0x2C)
|
||||
PressedKey = ' ';
|
||||
PressedKey = ' ';
|
||||
else if (PressedKeyCode == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HID_Host_USBTask(&Keyboard_HID_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -218,6 +218,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -63,15 +63,16 @@
|
|||
|
||||
/** 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_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Keyboard Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -39,21 +39,21 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Keyboard host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB keyboard, for USB keyboards using
|
||||
* the standard keyboard HID profile.
|
||||
*
|
||||
*
|
||||
* Pressed alpha-numeric, enter or space key is transmitted through the serial
|
||||
* USART at serial settings 9600, 8, N, 1.
|
||||
*
|
||||
*
|
||||
* This uses a naive method where the keyboard is set to Boot Protocol mode, so
|
||||
* that the report structure is fixed and known. A better implementation
|
||||
* uses the HID report parser for correct report data processing across
|
||||
* all compatible mice with advanced characteristics, as shown in the
|
||||
* KeyboardHostWithParser demo application.
|
||||
*
|
||||
*
|
||||
* Currently only single interface keyboards are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
|
|
@ -68,3 +68,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the KeyboardHostWithParser demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "KeyboardHostWithParser.h"
|
||||
|
||||
/** Processed HID report descriptor items structure, containing information on each HID report element */
|
||||
|
|
@ -52,14 +52,14 @@ USB_ClassInfo_HID_Host_t Keyboard_HID_Interface =
|
|||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
|
||||
|
||||
.HIDInterfaceProtocol = HID_BOOTP_NonBootProtocol,
|
||||
|
||||
|
||||
.HIDParserData = &HIDReportInfo
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -78,7 +78,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -115,7 +115,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Keyboard Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
|
@ -125,7 +125,7 @@ int main(void)
|
|||
{
|
||||
uint8_t KeyboardReport[Keyboard_HID_Interface.State.LargestReportSize];
|
||||
HID_Host_ReceiveReport(&Keyboard_HID_Interface, &KeyboardReport);
|
||||
|
||||
|
||||
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
|
||||
{
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
|
@ -157,24 +157,24 @@ int main(void)
|
|||
else if ((KeyCode >= 0x1E) && (KeyCode <= 0x27))
|
||||
PressedKey = (KeyCode - 0x1E) + '0';
|
||||
else if (KeyCode == 0x2C)
|
||||
PressedKey = ' ';
|
||||
PressedKey = ' ';
|
||||
else if (KeyCode == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
|
||||
/* Print the pressed key character out through the serial port if valid */
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
}
|
||||
|
||||
|
||||
/* Once a scan-code is found, stop scanning through the report items */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HID_Host_USBTask(&Keyboard_HID_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -265,3 +265,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
|||
*/
|
||||
return (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -63,20 +63,21 @@
|
|||
|
||||
/** 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)
|
||||
|
||||
|
||||
/** HID Report Descriptor Usage Page value for a desktop keyboard. */
|
||||
#define USAGE_PAGE_KEYBOARD 0x07
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Keyboard Host With HID Descriptor Parser Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,20 +41,20 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Keyboard host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Keyboard host, for USB keyboards using
|
||||
* the standard Keyboard HID profile. It uses a HID parser for the HID reports,
|
||||
* allowing for correct operation across all USB keyboards. This demo supports
|
||||
* keyboards with a single HID report.
|
||||
*
|
||||
*
|
||||
* Pressed alpha-numeric, enter or space key is transmitted through the serial
|
||||
* USART at serial settings 9600, 8, N, 1. On connection to a USB keyboard, the
|
||||
* report items will be processed and printed as a formatted list through the
|
||||
* USART before the keyboard is fully enumerated.
|
||||
*
|
||||
* Currently only single interface keyboards are supported.
|
||||
*
|
||||
* Currently only single interface keyboards are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
|
|
@ -68,3 +68,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the MIDIHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "MIDIHost.h"
|
||||
|
||||
/** LUFA MIDI Class driver interface configuration and state information. This structure is
|
||||
|
|
@ -46,13 +46,13 @@ USB_ClassInfo_MIDI_Host_t Keyboard_MIDI_Interface =
|
|||
{
|
||||
.DataINPipeNumber = 1,
|
||||
.DataINPipeDoubleBank = false,
|
||||
|
||||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -71,7 +71,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -100,20 +100,20 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("MIDI Device Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
break;
|
||||
case HOST_STATE_Configured:
|
||||
CheckJoystickMovement();
|
||||
|
||||
|
||||
MIDI_EventPacket_t MIDIEvent;
|
||||
if (MIDI_Host_ReceiveEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent))
|
||||
{
|
||||
bool NoteOnEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_ON >> 4));
|
||||
bool NoteOffEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_OFF >> 4));
|
||||
|
||||
|
||||
if (NoteOnEvent || NoteOffEvent)
|
||||
{
|
||||
printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off",
|
||||
|
|
@ -121,10 +121,10 @@ int main(void)
|
|||
MIDIEvent.Data2, MIDIEvent.Data3);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
MIDI_Host_USBTask(&Keyboard_MIDI_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -154,11 +154,11 @@ void CheckJoystickMovement(void)
|
|||
|
||||
uint8_t MIDICommand = 0;
|
||||
uint8_t MIDIPitch;
|
||||
|
||||
|
||||
/* Get current joystick mask, XOR with previous to detect joystick changes */
|
||||
uint8_t JoystickStatus = Joystick_GetStatus();
|
||||
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
|
||||
|
||||
|
||||
/* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
|
||||
uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
||||
|
||||
|
|
@ -179,7 +179,7 @@ void CheckJoystickMovement(void)
|
|||
MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3E;
|
||||
}
|
||||
|
||||
|
||||
if (JoystickChanges & JOY_DOWN)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
|
|
@ -191,19 +191,19 @@ void CheckJoystickMovement(void)
|
|||
MIDICommand = ((JoystickStatus & JOY_PRESS)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3B;
|
||||
}
|
||||
|
||||
|
||||
if (MIDICommand)
|
||||
{
|
||||
MIDI_EventPacket_t MIDIEvent = (MIDI_EventPacket_t)
|
||||
{
|
||||
.CableNumber = 0,
|
||||
.Command = (MIDICommand >> 4),
|
||||
|
||||
|
||||
.Data1 = MIDICommand | Channel,
|
||||
.Data2 = MIDIPitch,
|
||||
.Data3 = MIDI_STANDARD_VELOCITY,
|
||||
.Data3 = MIDI_STANDARD_VELOCITY,
|
||||
};
|
||||
|
||||
|
||||
MIDI_Host_SendEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent);
|
||||
MIDI_Host_Flush(&Keyboard_MIDI_Interface);
|
||||
}
|
||||
|
|
@ -259,6 +259,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
#include <LUFA/Drivers/Board/Joystick.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/MIDI.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -65,16 +65,17 @@
|
|||
|
||||
/** 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 CheckJoystickMovement(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage MIDI Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Audio Class Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>MIDI Subclass</td>
|
||||
* </tr>
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* MIDI host demonstration application. This demo will enumerate an attached USB-MIDI device, and print incoming MIDI note
|
||||
* on and off messages on any channel to the serial port. Pressing the board joystick will send note on and off messages to
|
||||
|
|
@ -57,3 +57,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the MassStorageHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "MassStorageHost.h"
|
||||
|
||||
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
|
||||
|
|
@ -46,13 +46,13 @@ USB_ClassInfo_MS_Host_t FlashDisk_MS_Interface =
|
|||
{
|
||||
.DataINPipeNumber = 1,
|
||||
.DataINPipeDoubleBank = false,
|
||||
|
||||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -71,7 +71,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -92,7 +92,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -100,14 +100,14 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Mass Storage Device Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
break;
|
||||
case HOST_STATE_Configured:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
|
||||
uint8_t MaxLUNIndex;
|
||||
if (MS_Host_GetMaxLUN(&FlashDisk_MS_Interface, &MaxLUNIndex))
|
||||
{
|
||||
|
|
@ -116,9 +116,9 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("Total LUNs: %d - Using first LUN in device.\r\n"), (MaxLUNIndex + 1));
|
||||
|
||||
|
||||
if (MS_Host_ResetMSInterface(&FlashDisk_MS_Interface))
|
||||
{
|
||||
puts_P(PSTR("Error resetting Mass Storage interface.\r\n"));
|
||||
|
|
@ -126,7 +126,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
SCSI_Request_Sense_Response_t SenseData;
|
||||
if (MS_Host_RequestSense(&FlashDisk_MS_Interface, 0, &SenseData) != 0)
|
||||
{
|
||||
|
|
@ -135,7 +135,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (MS_Host_PreventAllowMediumRemoval(&FlashDisk_MS_Interface, 0, true))
|
||||
{
|
||||
puts_P(PSTR("Error setting Prevent Device Removal bit.\r\n"));
|
||||
|
|
@ -150,17 +150,17 @@ int main(void)
|
|||
puts_P(PSTR("Error retrieving device Inquiry data.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
printf_P(PSTR("Vendor \"%.8s\", Product \"%.16s\"\r\n"), InquiryData.VendorID, InquiryData.ProductID);
|
||||
|
||||
|
||||
puts_P(PSTR("Waiting until ready...\r\n"));
|
||||
|
||||
for (;;)
|
||||
{
|
||||
uint8_t ErrorCode = MS_Host_TestUnitReady(&FlashDisk_MS_Interface, 0);
|
||||
|
||||
|
||||
if (!(ErrorCode))
|
||||
break;
|
||||
|
||||
|
|
@ -184,7 +184,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("%lu blocks of %lu bytes.\r\n"), DiskCapacity.Blocks, DiskCapacity.BlockSize);
|
||||
|
||||
uint8_t BlockBuffer[DiskCapacity.BlockSize];
|
||||
|
|
@ -196,20 +196,20 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("\r\nContents of first block:\r\n"));
|
||||
|
||||
for (uint16_t Chunk = 0; Chunk < (DiskCapacity.BlockSize >> 4); Chunk++)
|
||||
{
|
||||
uint8_t* ChunkPtr = &BlockBuffer[Chunk << 4];
|
||||
|
||||
|
||||
/* Print out the 16 bytes of the chunk in HEX format */
|
||||
for (uint8_t ByteOffset = 0; ByteOffset < (1 << 4); ByteOffset++)
|
||||
{
|
||||
char CurrByte = *(ChunkPtr + ByteOffset);
|
||||
printf_P(PSTR("%.2X "), CurrByte);
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR(" "));
|
||||
|
||||
/* Print out the 16 bytes of the chunk in ASCII format */
|
||||
|
|
@ -218,7 +218,7 @@ int main(void)
|
|||
char CurrByte = *(ChunkPtr + ByteOffset);
|
||||
putchar(isprint(CurrByte) ? CurrByte : '.');
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
|
|
@ -226,7 +226,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
MS_Host_USBTask(&FlashDisk_MS_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -296,6 +296,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -51,7 +51,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/MassStorage.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -64,18 +64,19 @@
|
|||
|
||||
/** 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)
|
||||
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Mass Storage Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Mass Storage Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Bulk Only</td>
|
||||
* </tr>
|
||||
|
|
@ -42,12 +42,12 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Mass Storage host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Mass Storage host, for USB storage devices
|
||||
* using the standard Mass Storage USB profile.
|
||||
*
|
||||
*
|
||||
* The first 512 bytes (boot sector) of an attached disk's memory will be dumped
|
||||
* out of the serial port in HEX and ASCII form when it is attached to the AT90USB1287
|
||||
* AVR. The device will then wait for HWB to be pressed, whereupon the entire ASCII contents
|
||||
|
|
@ -65,3 +65,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -134,7 +134,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -147,7 +147,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -505,11 +505,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -636,14 +636,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the MouseHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "MouseHost.h"
|
||||
|
||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||
|
|
@ -46,15 +46,15 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface =
|
|||
{
|
||||
.DataINPipeNumber = 1,
|
||||
.DataINPipeDoubleBank = false,
|
||||
|
||||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
|
||||
|
||||
.HIDInterfaceProtocol = HID_BOOTP_MouseBootProtocol,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -73,7 +73,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -110,7 +110,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Mouse Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
|
@ -119,10 +119,10 @@ int main(void)
|
|||
if (HID_Host_IsReportReceived(&Mouse_HID_Interface))
|
||||
{
|
||||
uint8_t LEDMask = LEDS_NO_LEDS;
|
||||
|
||||
|
||||
USB_MouseReport_Data_t MouseReport;
|
||||
HID_Host_ReceiveReport(&Mouse_HID_Interface, &MouseReport);
|
||||
|
||||
|
||||
printf_P(PSTR("dX:%2d dY:%2d Button:%d\r\n"), MouseReport.X,
|
||||
MouseReport.Y,
|
||||
MouseReport.Button);
|
||||
|
|
@ -130,7 +130,7 @@ int main(void)
|
|||
LEDMask |= LEDS_LED1;
|
||||
else if (MouseReport.X < 0)
|
||||
LEDMask |= LEDS_LED2;
|
||||
|
||||
|
||||
if (MouseReport.Y > 0)
|
||||
LEDMask |= LEDS_LED3;
|
||||
else if (MouseReport.Y < 0)
|
||||
|
|
@ -141,10 +141,10 @@ int main(void)
|
|||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HID_Host_USBTask(&Mouse_HID_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -214,6 +214,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -63,15 +63,16 @@
|
|||
|
||||
/** 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_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Mouse Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,23 +41,23 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Mouse host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Mouse host, for USB mice using
|
||||
* the standard mouse HID profile.
|
||||
*
|
||||
*
|
||||
* Mouse movement and button presses are displayed on the board LEDs,
|
||||
* as well as printed out the serial terminal as formatted dY, dY and
|
||||
* button status information.
|
||||
*
|
||||
*
|
||||
* This uses a naive method where the mouse is set to Boot Protocol mode, so
|
||||
* that the report structure is fixed and known. A better implementation
|
||||
* uses the HID report parser for correct report data processing across
|
||||
* all compatible mice with advanced characteristics, as shown in the
|
||||
* MouseHostWithParser demo application.
|
||||
*
|
||||
* Currently only single interface mice are supported.
|
||||
*
|
||||
* Currently only single interface mice are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
|
|
@ -71,3 +71,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the MouseHostWithParser demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "MouseHostWithParser.h"
|
||||
|
||||
/** Processed HID report descriptor items structure, containing information on each HID report element */
|
||||
|
|
@ -52,14 +52,14 @@ USB_ClassInfo_HID_Host_t Mouse_HID_Interface =
|
|||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
|
||||
|
||||
.HIDInterfaceProtocol = HID_BOOTP_NonBootProtocol,
|
||||
|
||||
|
||||
.HIDParserData = &HIDReportInfo
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -78,7 +78,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -115,7 +115,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Mouse Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
|
@ -131,11 +131,11 @@ int main(void)
|
|||
for (uint8_t ReportNumber = 0; ReportNumber < HIDReportInfo.TotalReportItems; ReportNumber++)
|
||||
{
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
||||
|
||||
/* Update the report item value if it is contained within the current report */
|
||||
if (!(USB_GetHIDReportItemInfo(MouseReport, ReportItem)))
|
||||
continue;
|
||||
|
||||
|
||||
/* Determine what report item is being tested, process updated value as needed */
|
||||
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) &&
|
||||
(ReportItem->ItemType == HID_REPORT_ITEM_In))
|
||||
|
|
@ -148,7 +148,7 @@ int main(void)
|
|||
(ReportItem->ItemType == HID_REPORT_ITEM_In))
|
||||
{
|
||||
int16_t WheelDelta = HID_ALIGN_DATA(ReportItem, int16_t);
|
||||
|
||||
|
||||
if (WheelDelta)
|
||||
LEDMask = (LEDS_LED1 | LEDS_LED2 | ((WheelDelta > 0) ? LEDS_LED3 : LEDS_LED4));
|
||||
}
|
||||
|
|
@ -158,7 +158,7 @@ int main(void)
|
|||
(ReportItem->ItemType == HID_REPORT_ITEM_In))
|
||||
{
|
||||
int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
|
||||
|
||||
|
||||
if (DeltaMovement)
|
||||
{
|
||||
if (ReportItem->Attributes.Usage.Usage == USAGE_X)
|
||||
|
|
@ -168,13 +168,13 @@ int main(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
HID_Host_USBTask(&Mouse_HID_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -244,7 +244,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -286,3 +286,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
|||
return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) ||
|
||||
(CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -78,20 +78,21 @@
|
|||
|
||||
/** HID Report Descriptor Usage value for a Y axis movement. */
|
||||
#define USAGE_Y 0x31
|
||||
|
||||
|
||||
/** HID Report Descriptor Usage value for a Scroll Wheel movement. */
|
||||
#define USAGE_SCROLL_WHEEL 0x38
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Mouse Host With HID Descriptor Parser Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,19 +41,19 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Mouse host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Mouse host, for USB mice using
|
||||
* the standard mouse HID profile. It uses a HID parser for the HID
|
||||
* reports, allowing for correct operation across all USB mice. This
|
||||
* demo supports mice with a single HID report.
|
||||
*
|
||||
*
|
||||
* Mouse and scroll wheel movement and button presses are displayed
|
||||
* on the board LEDs. On connection to a USB mouse, the report items
|
||||
* will be processed and printed as a formatted list through the USART
|
||||
* before the mouse is fully enumerated.
|
||||
*
|
||||
*
|
||||
* Currently only single interface mice are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
|
|
@ -68,3 +68,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the PrinterHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "PrinterHost.h"
|
||||
|
||||
/** LUFA Printer Class driver interface configuration and state information. This structure is
|
||||
|
|
@ -46,7 +46,7 @@ USB_ClassInfo_PRNT_Host_t Printer_PRNT_Interface =
|
|||
{
|
||||
.DataINPipeNumber = 1,
|
||||
.DataINPipeDoubleBank = false,
|
||||
|
||||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
},
|
||||
|
|
@ -70,7 +70,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (PRNT_Host_SetBidirectionalMode(&Printer_PRNT_Interface) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Bidirectional Mode.\r\n"));
|
||||
|
|
@ -107,16 +107,16 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Printer Device Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
break;
|
||||
case HOST_STATE_Configured:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
|
||||
puts_P(PSTR("Retrieving Device ID...\r\n"));
|
||||
|
||||
|
||||
char DeviceIDString[300];
|
||||
if (PRNT_Host_GetDeviceID(&Printer_PRNT_Interface, DeviceIDString,
|
||||
sizeof(DeviceIDString)) != HOST_SENDCONTROL_Successful)
|
||||
|
|
@ -126,12 +126,12 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("Device ID: %s.\r\n"), DeviceIDString);
|
||||
|
||||
|
||||
char TestPageData[] = "\033%-12345X\033E" "LUFA PCL Test Page" "\033E\033%-12345X";
|
||||
uint16_t TestPageLength = strlen(TestPageData);
|
||||
|
||||
|
||||
printf_P(PSTR("Sending Test Page (%d bytes)...\r\n"), TestPageLength);
|
||||
|
||||
if (PRNT_Host_SendString(&Printer_PRNT_Interface, &TestPageData, TestPageLength) != PIPE_RWSTREAM_NoError)
|
||||
|
|
@ -148,7 +148,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
PRNT_Host_USBTask(&Printer_PRNT_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -218,6 +218,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/Printer.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -63,18 +63,19 @@
|
|||
|
||||
/** 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)
|
||||
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Printer Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Printer Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Bidirectional Protocol</td>
|
||||
* </tr>
|
||||
|
|
@ -41,16 +41,16 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Printer host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Printer host, for USB printers using
|
||||
* the bidirectional data encapsulation protocol and PCL language.
|
||||
*
|
||||
*
|
||||
* Upon connection of a compatible printer, the printer's device ID is sent
|
||||
* to the AVR's serial port, and a simple test page is printed using the PCL
|
||||
* printer language.
|
||||
*
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
|
|
@ -63,3 +63,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the RNDISEthernetHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "RNDISEthernetHost.h"
|
||||
|
||||
/** Buffer to hold incoming and outgoing Ethernet packets. */
|
||||
|
|
@ -55,11 +55,11 @@ USB_ClassInfo_RNDIS_Host_t Ethernet_RNDIS_Interface =
|
|||
|
||||
.NotificationPipeNumber = 3,
|
||||
.NotificationPipeDoubleBank = false,
|
||||
|
||||
|
||||
.HostMaxPacketSize = sizeof(PacketBuffer),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -78,7 +78,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -99,7 +99,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -107,18 +107,18 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (RNDIS_Host_InitializeDevice(&Ethernet_RNDIS_Interface) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Initializing Device.\r\n"));
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("Device Max Transfer Size: %lu bytes.\r\n"), Ethernet_RNDIS_Interface.State.DeviceMaxPacketSize);
|
||||
|
||||
|
||||
uint32_t PacketFilter = (REMOTE_NDIS_PACKET_DIRECTED | REMOTE_NDIS_PACKET_BROADCAST | REMOTE_NDIS_PACKET_ALL_MULTICAST);
|
||||
if (RNDIS_Host_SetRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_CURRENT_PACKET_FILTER,
|
||||
&PacketFilter, sizeof(PacketFilter)) != HOST_SENDCONTROL_Successful)
|
||||
|
|
@ -129,7 +129,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
uint32_t VendorID;
|
||||
if (RNDIS_Host_QueryRNDISProperty(&Ethernet_RNDIS_Interface, OID_GEN_VENDOR_ID,
|
||||
&VendorID, sizeof(VendorID)) != HOST_SENDCONTROL_Successful)
|
||||
|
|
@ -140,7 +140,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("Device Vendor ID: 0x%08lX\r\n"), VendorID);
|
||||
|
||||
puts_P(PSTR("RNDIS Device Enumerated.\r\n"));
|
||||
|
|
@ -149,10 +149,10 @@ int main(void)
|
|||
break;
|
||||
case HOST_STATE_Configured:
|
||||
PrintIncomingPackets();
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
RNDIS_Host_USBTask(&Ethernet_RNDIS_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -167,14 +167,14 @@ void PrintIncomingPackets(void)
|
|||
|
||||
uint16_t PacketLength;
|
||||
RNDIS_Host_ReadPacket(&Ethernet_RNDIS_Interface, &PacketBuffer, &PacketLength);
|
||||
|
||||
|
||||
printf_P(PSTR("***PACKET (Size %d)***\r\n"), PacketLength);
|
||||
|
||||
|
||||
for (uint16_t i = 0; i < PacketLength; i++)
|
||||
printf("0x%02x ", PacketBuffer[i]);
|
||||
|
||||
printf_P(PSTR("\r\n\r\n"));
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
}
|
||||
|
|
@ -243,6 +243,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -63,19 +63,20 @@
|
|||
|
||||
/** 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)
|
||||
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void PrintIncomingPackets(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage RNDIS Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Communications Device Class (CDC)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Remote NDIS (Microsoft Proprietary CDC Class Networking Standard)</td>
|
||||
* </tr>
|
||||
|
|
@ -39,12 +39,12 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* RNDIS host demonstration application. This gives a simple reference
|
||||
* application for implementing a RNDIS Ethernet host, for USB devices such as
|
||||
* modems.
|
||||
*
|
||||
*
|
||||
* This demo will enumerate an attached USB RNDIS device, print out its vendor ID
|
||||
* and any received packets in raw form through the serial USART.
|
||||
*
|
||||
|
|
@ -60,3 +60,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the StillImageHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "StillImageHost.h"
|
||||
|
||||
/** LUFA Still Image Class driver interface configuration and state information. This structure is
|
||||
|
|
@ -46,10 +46,10 @@ USB_ClassInfo_SI_Host_t DigitalCamera_SI_Interface =
|
|||
{
|
||||
.DataINPipeNumber = 1,
|
||||
.DataINPipeDoubleBank = false,
|
||||
|
||||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
|
||||
|
||||
.EventsPipeNumber = 3,
|
||||
.EventsPipeDoubleBank = false,
|
||||
},
|
||||
|
|
@ -73,7 +73,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -102,14 +102,14 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Still Image Device Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
break;
|
||||
case HOST_STATE_Configured:
|
||||
puts_P(PSTR("Opening Session...\r\n"));
|
||||
|
||||
|
||||
if (SI_Host_OpenSession(&DigitalCamera_SI_Interface) != PIPE_RWSTREAM_NoError)
|
||||
{
|
||||
puts_P(PSTR("Could not open PIMA session.\r\n"));
|
||||
|
|
@ -124,7 +124,7 @@ int main(void)
|
|||
{
|
||||
puts_P(PSTR("Could not turn off device.\r\n"));
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
puts_P(PSTR("Device Off.\r\n"));
|
||||
|
|
@ -137,12 +137,12 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
SI_Host_USBTask(&DigitalCamera_SI_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -212,6 +212,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/StillImage.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -63,15 +63,16 @@
|
|||
|
||||
/** 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_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Still Image Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Still Image Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -40,12 +40,12 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Still Image host demonstration application. This gives a simple reference
|
||||
* application for implementing a Still Image host, for USB devices such as
|
||||
* digital cameras.
|
||||
*
|
||||
*
|
||||
* This demo will enumerate an attached USB Still Image device, print out its
|
||||
* information structure, open a session with the device and finally close the
|
||||
* session.
|
||||
|
|
@ -62,3 +62,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the VirtualSerialHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "VirtualSerialHost.h"
|
||||
|
||||
/** LUFA CDC Class driver interface configuration and state information. This structure is
|
||||
|
|
@ -54,7 +54,7 @@ USB_ClassInfo_CDC_Host_t VirtualSerial_CDC_Interface =
|
|||
.NotificationPipeDoubleBank = false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
* enters a loop to run the application tasks in sequence.
|
||||
*/
|
||||
|
|
@ -73,7 +73,7 @@ int main(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
|
@ -94,7 +94,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
puts_P(PSTR("Error Setting Device Configuration.\r\n"));
|
||||
|
|
@ -102,7 +102,7 @@ int main(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("CDC Device Enumerated.\r\n"));
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
|
@ -115,10 +115,10 @@ int main(void)
|
|||
if (!(ReceivedByte < 0))
|
||||
putchar(ReceivedByte);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
CDC_Host_USBTask(&VirtualSerial_CDC_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
|
@ -188,6 +188,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/CDC.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -63,15 +63,16 @@
|
|||
|
||||
/** 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_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
||||
const uint8_t SubErrorCode);
|
||||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage CDC Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Communications Device Class (CDC)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Abstract Control Model (ACM)</td>
|
||||
* </tr>
|
||||
|
|
@ -39,13 +39,13 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* CDC host demonstration application. This gives a simple reference application
|
||||
* for implementing a USB CDC host, for CDC devices using the standard ACM profile.
|
||||
*
|
||||
*
|
||||
* This demo prints out received CDC data through the serial port.
|
||||
*
|
||||
*
|
||||
* Not that this demo is only compatible with devices which report the correct CDC
|
||||
* and ACM class, subclass and protocol values. Most USB-Serial cables have vendor
|
||||
* specific features, thus use vendor-specific class/subclass/protocol codes to force
|
||||
|
|
@ -63,3 +63,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -133,7 +133,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -146,7 +146,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -260,7 +260,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -273,7 +273,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -285,7 +285,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -297,7 +297,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -320,7 +320,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -354,7 +354,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -388,7 +388,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -417,7 +417,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -436,10 +436,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -504,11 +504,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -535,9 +535,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -635,14 +635,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -664,7 +664,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -708,3 +708,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#
|
||||
# LUFA Library
|
||||
# Copyright (C) Dean Camera, 2010.
|
||||
#
|
||||
#
|
||||
# dean [at] fourwalledcubicle [dot] com
|
||||
# www.fourwalledcubicle.com
|
||||
#
|
||||
|
|
@ -15,7 +15,7 @@
|
|||
|
||||
all:
|
||||
$(MAKE) -C JoystickHostWithParser clean
|
||||
$(MAKE) -C JoystickHostWithParser all
|
||||
$(MAKE) -C JoystickHostWithParser all
|
||||
|
||||
$(MAKE) -C KeyboardHost clean
|
||||
$(MAKE) -C KeyboardHost all
|
||||
|
|
@ -45,8 +45,8 @@ all:
|
|||
$(MAKE) -C StillImageHost all
|
||||
|
||||
$(MAKE) -C VirtualSerialHost clean
|
||||
$(MAKE) -C VirtualSerialHost all
|
||||
|
||||
$(MAKE) -C VirtualSerialHost all
|
||||
|
||||
%:
|
||||
$(MAKE) -C JoystickHostWithParser $@
|
||||
$(MAKE) -C KeyboardHost $@
|
||||
|
|
@ -59,3 +59,4 @@ all:
|
|||
$(MAKE) -C RNDISEthernetHost $@
|
||||
$(MAKE) -C StillImageHost $@
|
||||
$(MAKE) -C VirtualSerialHost $@
|
||||
|
||||
|
|
|
|||
|
|
@ -191,3 +191,4 @@ void RFCOMM_ChannelSignalsReceived(RFCOMM_Channel_t* const RFCOMMChannel)
|
|||
{
|
||||
// Currently do nothing in response to the remote device sending new terminal control signals
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,3 +69,4 @@
|
|||
extern RFCOMM_Channel_t* SerialChannel_RFCOMM;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -52,14 +52,14 @@ int main(void)
|
|||
SetupHardware();
|
||||
|
||||
puts_P(PSTR(ESC_FG_CYAN "Bluetooth Host Demo running.\r\n" ESC_FG_WHITE));
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
RFCOMM_ServiceChannels(SerialChannel_ACL);
|
||||
|
||||
|
||||
Bluetooth_Host_Task();
|
||||
Bluetooth_Stack_USBTask();
|
||||
USB_USBTask();
|
||||
|
|
@ -130,7 +130,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -143,7 +143,7 @@ void Bluetooth_Host_Task(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
puts_P(PSTR("Getting Device Data.\r\n"));
|
||||
|
||||
|
||||
/* Get and process the configuration descriptor data */
|
||||
if ((ErrorCode = ProcessDeviceDescriptor()) != SuccessfulDeviceRead)
|
||||
{
|
||||
|
|
@ -153,7 +153,7 @@ void Bluetooth_Host_Task(void)
|
|||
puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
|
||||
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDS_LED1);
|
||||
|
||||
|
|
@ -177,9 +177,9 @@ void Bluetooth_Host_Task(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("Getting Config Data.\r\n"));
|
||||
|
||||
|
||||
/* Get and process the configuration descriptor data */
|
||||
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
||||
{
|
||||
|
|
@ -189,7 +189,7 @@ void Bluetooth_Host_Task(void)
|
|||
puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
|
||||
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDS_LED1);
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ void Bluetooth_Host_Task(void)
|
|||
}
|
||||
|
||||
puts_P(PSTR("Bluetooth Dongle Enumerated.\r\n"));
|
||||
|
||||
|
||||
/* Initialize the Bluetooth stack */
|
||||
Bluetooth_Stack_Init();
|
||||
|
||||
|
|
@ -207,3 +207,4 @@ void Bluetooth_Host_Task(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -54,7 +54,7 @@
|
|||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialStream.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
/* Task Definitions: */
|
||||
void Bluetooth_Host_Task(void);
|
||||
|
||||
|
||||
/* Event Handlers: */
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
|
|
@ -84,5 +84,6 @@
|
|||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
uint8_t ConfigDescriptorData[512];
|
||||
void* CurrConfigLocation = ConfigDescriptorData;
|
||||
uint16_t CurrConfigBytesRem;
|
||||
|
||||
|
||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
|
||||
USB_Descriptor_Endpoint_t* EventsEndpoint = NULL;
|
||||
|
|
@ -67,11 +67,11 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
default:
|
||||
return DevControlError;
|
||||
}
|
||||
|
||||
|
||||
/* The Bluetooth USB transport addendum mandates that the data (not streaming voice) endpoints
|
||||
be in the first interface descriptor (interface 0) */
|
||||
USB_GetNextDescriptorOfType(&CurrConfigBytesRem, &CurrConfigLocation, DTYPE_Interface);
|
||||
|
||||
|
||||
/* Ensure that an interface was found, and the end of the descriptor was not reached */
|
||||
if (!(CurrConfigBytesRem))
|
||||
return NoCompatibleInterfaceFound;
|
||||
|
|
@ -103,7 +103,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
DataOUTEndpoint = EndpointData;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Configure the Bluetooth data IN pipe */
|
||||
Pipe_ConfigurePipe(BLUETOOTH_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN,
|
||||
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
|
|
@ -125,7 +125,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
* configuration descriptor, to search for a specific sub descriptor. It can also be used to abort the configuration
|
||||
* descriptor processing if an incompatible descriptor configuration is found.
|
||||
*
|
||||
* This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the
|
||||
* This comparator searches for the next Endpoint descriptor inside the current interface descriptor, aborting the
|
||||
* search if another interface descriptor is found before the required endpoint.
|
||||
*
|
||||
* \return A value from the DSEARCH_Return_ErrorCodes_t enum
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
/* Macros: */
|
||||
#define BLUETOOTH_DATA_IN_PIPE 1
|
||||
#define BLUETOOTH_DATA_OUT_PIPE 2
|
||||
|
|
@ -54,10 +54,11 @@
|
|||
InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */
|
||||
NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */
|
||||
};
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint8_t ProcessConfigurationDescriptor(void);
|
||||
|
||||
|
||||
uint8_t DComp_NextInterfaceBluetoothDataEndpoint(void* CurrentDescriptor);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
/** \file
|
||||
*
|
||||
* USB Device Descriptor processing routines, to determine the overall device parameters. Descriptors are special
|
||||
* USB Device Descriptor processing routines, to determine the overall device parameters. Descriptors are special
|
||||
* computer-readable structures which the host requests upon device enumeration, to determine information about
|
||||
* the attached device.
|
||||
*/
|
||||
|
|
@ -50,11 +50,11 @@ uint8_t ProcessDeviceDescriptor(void)
|
|||
/* Send the request to retrieve the device descriptor */
|
||||
if (USB_Host_GetDeviceDescriptor(&DeviceDescriptor) != HOST_SENDCONTROL_Successful)
|
||||
return DevControlError;
|
||||
|
||||
|
||||
/* Validate returned data - ensure the returned data is a device descriptor */
|
||||
if (DeviceDescriptor.Header.Type != DTYPE_Device)
|
||||
return InvalidDeviceDataReturned;
|
||||
|
||||
|
||||
/* Validate returned device Class, SubClass and Protocol values against the Bluetooth spec values */
|
||||
if ((DeviceDescriptor.Class != BLUETOOTH_DEVICE_CLASS) ||
|
||||
(DeviceDescriptor.SubClass != BLUETOOTH_DEVICE_SUBCLASS) ||
|
||||
|
|
@ -62,6 +62,7 @@ uint8_t ProcessDeviceDescriptor(void)
|
|||
{
|
||||
return IncorrectBTDevice;
|
||||
}
|
||||
|
||||
|
||||
return SuccessfulDeviceRead;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,9 +38,9 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "BluetoothHost.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Device Class value for the Bluetooth Device class. */
|
||||
#define BLUETOOTH_DEVICE_CLASS 0xE0
|
||||
|
|
@ -62,6 +62,7 @@
|
|||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint8_t ProcessDeviceDescriptor(void);
|
||||
uint8_t ProcessDeviceDescriptor(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,14 +50,14 @@ void Bluetooth_ACLTask(void)
|
|||
{
|
||||
/* Process incoming ACL packets, if any */
|
||||
Bluetooth_ProcessIncomingACLPackets();
|
||||
|
||||
|
||||
/* Check for any half-open channels, send configuration details to the remote device if found */
|
||||
for (uint8_t i = 0; i < BLUETOOTH_MAX_OPEN_CHANNELS; i++)
|
||||
{
|
||||
Bluetooth_Channel_t* ChannelData = &Bluetooth_Connection.Channels[i];
|
||||
|
||||
|
||||
bool MustSendConfigReq = true;
|
||||
|
||||
|
||||
/* Check if we are in a channel state which requires a configuration request to be sent */
|
||||
switch (ChannelData->State)
|
||||
{
|
||||
|
|
@ -71,7 +71,7 @@ void Bluetooth_ACLTask(void)
|
|||
MustSendConfigReq = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Only send a configuration request if it the channel was in a state which required it */
|
||||
if (MustSendConfigReq)
|
||||
{
|
||||
|
|
@ -79,14 +79,14 @@ void Bluetooth_ACLTask(void)
|
|||
{
|
||||
BT_Signal_Header_t SignalCommandHeader;
|
||||
BT_Signal_ConfigurationReq_t ConfigurationRequest;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
BT_Config_Option_Header_t Header;
|
||||
uint16_t Value;
|
||||
} Option_LocalMTU;
|
||||
} PacketData;
|
||||
|
||||
|
||||
/* Fill out the Signal Command header in the response packet */
|
||||
PacketData.SignalCommandHeader.Code = BT_SIGNAL_CONFIGURATION_REQUEST;
|
||||
PacketData.SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignalingIdentifier;
|
||||
|
|
@ -101,7 +101,7 @@ void Bluetooth_ACLTask(void)
|
|||
PacketData.Option_LocalMTU.Value = ChannelData->LocalMTU;
|
||||
|
||||
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
|
||||
|
||||
|
||||
BT_ACL_DEBUG(1, ">> L2CAP Configuration Request");
|
||||
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.ConfigurationRequest.DestinationChannel);
|
||||
}
|
||||
|
|
@ -119,13 +119,13 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
|
|||
|
||||
Pipe_SelectPipe(BLUETOOTH_DATA_IN_PIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
|
||||
if (!(Pipe_IsReadWriteAllowed()))
|
||||
{
|
||||
Pipe_Freeze();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Read in the received ACL packet headers when it has been discovered that a packet has been received */
|
||||
Pipe_Read_Stream_LE(&ACLPacketHeader, sizeof(ACLPacketHeader));
|
||||
Pipe_Read_Stream_LE(&DataHeader, sizeof(DataHeader));
|
||||
|
|
@ -143,7 +143,7 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
|
|||
/* Read in the Signal Command header of the incoming packet */
|
||||
BT_Signal_Header_t SignalCommandHeader;
|
||||
Pipe_Read_Stream_LE(&SignalCommandHeader, sizeof(SignalCommandHeader));
|
||||
|
||||
|
||||
/* Dispatch to the appropriate handler function based on the Signal message code */
|
||||
switch (SignalCommandHeader.Code)
|
||||
{
|
||||
|
|
@ -173,20 +173,20 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
|
|||
break;
|
||||
case BT_SIGNAL_COMMAND_REJECT:
|
||||
BT_ACL_DEBUG(1, "<< Command Reject");
|
||||
|
||||
|
||||
uint16_t RejectReason;
|
||||
Pipe_Read_Stream_LE(&RejectReason, sizeof(RejectReason));
|
||||
Pipe_Discard_Stream(ACLPacketHeader.DataLength - sizeof(RejectReason));
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
Pipe_Freeze();
|
||||
|
||||
BT_ACL_DEBUG(2, "-- Reason: %d", RejectReason);
|
||||
break;
|
||||
default:
|
||||
BT_ACL_DEBUG(1, "<< Unknown Signaling Command 0x%02X", SignalCommandHeader.Code);
|
||||
|
||||
|
||||
Pipe_Discard_Stream(ACLPacketHeader.DataLength);
|
||||
Pipe_ClearIN();
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
break;
|
||||
}
|
||||
|
|
@ -198,7 +198,7 @@ static void Bluetooth_ProcessIncomingACLPackets(void)
|
|||
Pipe_Read_Stream_LE(PacketData, DataHeader.PayloadLength);
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
Bluetooth_PacketReceived(PacketData, DataHeader.PayloadLength,
|
||||
Bluetooth_GetChannelData(DataHeader.DestinationChannel, CHANNEL_SEARCH_LOCALNUMBER));
|
||||
}
|
||||
|
|
@ -221,9 +221,9 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue,
|
|||
/* Closed channels should be ignored as they are not considered valid data */
|
||||
if (ChannelData->State == BT_Channel_Closed)
|
||||
continue;
|
||||
|
||||
|
||||
bool FoundMatch = false;
|
||||
|
||||
|
||||
/* Search the current channel for the search key to see if it matches */
|
||||
switch (SearchKey)
|
||||
{
|
||||
|
|
@ -237,7 +237,7 @@ Bluetooth_Channel_t* Bluetooth_GetChannelData(const uint16_t SearchValue,
|
|||
FoundMatch = (SearchValue == ChannelData->PSM);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (FoundMatch)
|
||||
return ChannelData;
|
||||
}
|
||||
|
|
@ -285,9 +285,9 @@ uint8_t Bluetooth_SendPacket(void* Data,
|
|||
Pipe_Write_Stream_LE(&DataHeader, sizeof(DataHeader));
|
||||
Pipe_Write_Stream_LE(Data, DataLen);
|
||||
Pipe_ClearOUT();
|
||||
|
||||
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
BT_ACL_DEBUG(2, "");
|
||||
BT_ACL_DEBUG(2, "Packet Sent");
|
||||
BT_ACL_DEBUG(2, "-- Connection Handle: 0x%04X", (ACLPacketHeader.ConnectionHandle & 0x0FFF));
|
||||
|
|
@ -319,7 +319,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
|
|||
if (Bluetooth_Connection.Channels[i].State == BT_Channel_Closed)
|
||||
{
|
||||
ChannelData = &Bluetooth_Connection.Channels[i];
|
||||
|
||||
|
||||
/* Set the new channel structure's local channel number to a unique value within the connection orientated
|
||||
channel address space */
|
||||
ChannelData->LocalNumber = (BT_CHANNELNUMBER_BASEOFFSET + i);
|
||||
|
|
@ -336,7 +336,7 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
|
|||
ChannelData->PSM = PSM;
|
||||
ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU;
|
||||
ChannelData->State = BT_Channel_WaitConnectRsp;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
BT_Signal_Header_t SignalCommandHeader;
|
||||
|
|
@ -347,11 +347,11 @@ Bluetooth_Channel_t* Bluetooth_OpenChannel(const uint16_t PSM)
|
|||
PacketData.SignalCommandHeader.Code = BT_SIGNAL_CONNECTION_REQUEST;
|
||||
PacketData.SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignalingIdentifier;
|
||||
PacketData.SignalCommandHeader.Length = sizeof(PacketData.ConnectionRequest);
|
||||
|
||||
|
||||
/* Fill out the Connection Request in the response packet */
|
||||
PacketData.ConnectionRequest.PSM = PSM;
|
||||
PacketData.ConnectionRequest.SourceChannel = ChannelData->LocalNumber;
|
||||
|
||||
|
||||
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
|
||||
|
||||
BT_ACL_DEBUG(1, ">> L2CAP Connection Request");
|
||||
|
|
@ -385,7 +385,7 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel)
|
|||
BT_Signal_Header_t SignalCommandHeader;
|
||||
BT_Signal_DisconnectionReq_t DisconnectionRequest;
|
||||
} PacketData;
|
||||
|
||||
|
||||
/* Fill out the Signal Command header in the response packet */
|
||||
PacketData.SignalCommandHeader.Code = BT_SIGNAL_DISCONNECTION_REQUEST;
|
||||
PacketData.SignalCommandHeader.Identifier = ++Bluetooth_Connection.SignalingIdentifier;
|
||||
|
|
@ -396,10 +396,10 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel)
|
|||
PacketData.DisconnectionRequest.SourceChannel = ACLChannel->LocalNumber;
|
||||
|
||||
Bluetooth_SendPacket(&PacketData, sizeof(PacketData), NULL);
|
||||
|
||||
|
||||
BT_ACL_DEBUG(1, ">> L2CAP Disconnection Request");
|
||||
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel);
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel);
|
||||
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", PacketData.DisconnectionRequest.DestinationChannel);
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", PacketData.DisconnectionRequest.SourceChannel);
|
||||
}
|
||||
|
||||
/** Internal Bluetooth stack Signal Command processing routine for a Connection Request command.
|
||||
|
|
@ -409,12 +409,12 @@ void Bluetooth_CloseChannel(Bluetooth_Channel_t* const ACLChannel)
|
|||
static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* const SignalCommandHeader)
|
||||
{
|
||||
BT_Signal_ConnectionReq_t ConnectionRequest;
|
||||
|
||||
|
||||
Pipe_Read_Stream_LE(&ConnectionRequest, sizeof(ConnectionRequest));
|
||||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
BT_ACL_DEBUG(1, "<< L2CAP Connection Request");
|
||||
BT_ACL_DEBUG(2, "-- PSM: 0x%04X", ConnectionRequest.PSM);
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionRequest.SourceChannel);
|
||||
|
|
@ -439,7 +439,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
uint8_t ChannelStatus = BT_CONNECTION_REFUSED_RESOURCES;
|
||||
|
||||
/* Reset the channel item contents only if a channel entry was found for it */
|
||||
|
|
@ -452,15 +452,15 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
|
|||
ChannelData->PSM = ConnectionRequest.PSM;
|
||||
ChannelData->LocalMTU = MAXIMUM_CHANNEL_MTU;
|
||||
ChannelData->State = BT_Channel_Config_WaitConfig;
|
||||
|
||||
|
||||
ChannelStatus = BT_CONNECTION_SUCCESSFUL;
|
||||
}
|
||||
else
|
||||
{
|
||||
ChannelStatus = BT_CONNECTION_REFUSED_PSM;
|
||||
ChannelStatus = BT_CONNECTION_REFUSED_PSM;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
BT_Signal_Header_t SignalCommandHeader;
|
||||
|
|
@ -477,7 +477,7 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
|
|||
ResponsePacket.ConnectionResponse.SourceChannel = ChannelData->RemoteNumber;
|
||||
ResponsePacket.ConnectionResponse.Result = ChannelStatus;
|
||||
ResponsePacket.ConnectionResponse.Status = 0x00;
|
||||
|
||||
|
||||
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
|
||||
|
||||
BT_ACL_DEBUG(1, ">> L2CAP Connection Response");
|
||||
|
|
@ -493,16 +493,16 @@ static inline void Bluetooth_Signal_ConnectionReq(const BT_Signal_Header_t* cons
|
|||
static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* const SignalCommandHeader)
|
||||
{
|
||||
BT_Signal_ConnectionResp_t ConnectionResponse;
|
||||
|
||||
|
||||
Pipe_Read_Stream_LE(&ConnectionResponse, sizeof(ConnectionResponse));
|
||||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
BT_ACL_DEBUG(1, "<< L2CAP Connection Response");
|
||||
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result);
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);
|
||||
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);
|
||||
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConnectionResponse.Result);
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConnectionResponse.SourceChannel);
|
||||
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", ConnectionResponse.DestinationChannel);
|
||||
|
||||
/* Search for the referenced channel in the channel information list */
|
||||
Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConnectionResponse.SourceChannel, CHANNEL_SEARCH_LOCALNUMBER);
|
||||
|
|
@ -524,12 +524,12 @@ static inline void Bluetooth_Signal_ConnectionResp(const BT_Signal_Header_t* con
|
|||
static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* const SignalCommandHeader)
|
||||
{
|
||||
BT_Signal_ConfigurationReq_t ConfigurationRequest;
|
||||
|
||||
|
||||
/* Allocate a buffer large enough to hold the variable number of configuration options in the request */
|
||||
uint8_t OptionsLen = (SignalCommandHeader->Length - sizeof(ConfigurationRequest));
|
||||
uint8_t Options[OptionsLen];
|
||||
|
||||
Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));
|
||||
Pipe_Read_Stream_LE(&ConfigurationRequest, sizeof(ConfigurationRequest));
|
||||
Pipe_Read_Stream_LE(&Options, sizeof(Options));
|
||||
|
||||
Pipe_ClearIN();
|
||||
|
|
@ -554,7 +554,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
|
|||
|
||||
BT_ACL_DEBUG(2, "-- Option Type: 0x%04X", OptionHeader->Type);
|
||||
BT_ACL_DEBUG(2, "-- Option Length: 0x%04X", (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length));
|
||||
|
||||
|
||||
/* Store the remote MTU option's value if present */
|
||||
if (OptionHeader->Type == BT_CONFIG_OPTION_MTU)
|
||||
ChannelData->RemoteMTU = *((uint16_t*)OptionData);
|
||||
|
|
@ -563,7 +563,7 @@ static inline void Bluetooth_Signal_ConfigurationReq(const BT_Signal_Header_t* c
|
|||
OptionPos += (sizeof(BT_Config_Option_Header_t) + OptionHeader->Length);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
BT_Signal_Header_t SignalCommandHeader;
|
||||
|
|
@ -616,14 +616,14 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
|
|||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
BT_ACL_DEBUG(1, "<< L2CAP Configuration Response");
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", ConfigurationResponse.SourceChannel);
|
||||
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ConfigurationResponse.Result);
|
||||
|
||||
/* Search for the referenced channel in the channel information list */
|
||||
Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(ConfigurationResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
|
||||
|
||||
|
||||
/* Only update the channel's state if it was found in the channel list */
|
||||
if (ChannelData != NULL)
|
||||
{
|
||||
|
|
@ -639,7 +639,7 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
|
|||
ChannelData->State = BT_Channel_Open;
|
||||
Bluetooth_ChannelOpened(ChannelData);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -656,16 +656,16 @@ static inline void Bluetooth_Signal_ConfigurationResp(const BT_Signal_Header_t*
|
|||
static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* const SignalCommandHeader)
|
||||
{
|
||||
BT_Signal_DisconnectionReq_t DisconnectionRequest;
|
||||
|
||||
|
||||
Pipe_Read_Stream_LE(&DisconnectionRequest, sizeof(DisconnectionRequest));
|
||||
|
||||
BT_ACL_DEBUG(1, "<< L2CAP Disconnection Request");
|
||||
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionRequest.DestinationChannel);
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionRequest.SourceChannel);
|
||||
|
||||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
/* Search for the referenced channel in the channel information list */
|
||||
Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionRequest.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
|
||||
|
||||
|
|
@ -702,20 +702,20 @@ static inline void Bluetooth_Signal_DisconnectionReq(const BT_Signal_Header_t* c
|
|||
static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t* const SignalCommandHeader)
|
||||
{
|
||||
BT_Signal_DisconnectionResp_t DisconnectionResponse;
|
||||
|
||||
|
||||
Pipe_Read_Stream_LE(&DisconnectionResponse, sizeof(DisconnectionResponse));
|
||||
|
||||
BT_ACL_DEBUG(1, "<< L2CAP Disconnection Response");
|
||||
BT_ACL_DEBUG(2, "-- Destination Channel: 0x%04X", DisconnectionResponse.DestinationChannel);
|
||||
BT_ACL_DEBUG(2, "-- Source Channel: 0x%04X", DisconnectionResponse.SourceChannel);
|
||||
|
||||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
/* Search for the referenced channel in the channel information list */
|
||||
Bluetooth_Channel_t* ChannelData = Bluetooth_GetChannelData(DisconnectionResponse.SourceChannel, CHANNEL_SEARCH_REMOTENUMBER);
|
||||
|
||||
/* If the channel was found in the channel list, close it */
|
||||
|
||||
/* If the channel was found in the channel list, close it */
|
||||
if (ChannelData != NULL)
|
||||
ChannelData->State = BT_Channel_Closed;
|
||||
}
|
||||
|
|
@ -727,10 +727,10 @@ static inline void Bluetooth_Signal_DisconnectionResp(const BT_Signal_Header_t*
|
|||
static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader)
|
||||
{
|
||||
BT_ACL_DEBUG(1, "<< L2CAP Echo Request");
|
||||
|
||||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
BT_Signal_Header_t SignalCommandHeader;
|
||||
|
|
@ -740,7 +740,7 @@ static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const Sign
|
|||
ResponsePacket.SignalCommandHeader.Code = BT_SIGNAL_ECHO_RESPONSE;
|
||||
ResponsePacket.SignalCommandHeader.Identifier = SignalCommandHeader->Identifier;
|
||||
ResponsePacket.SignalCommandHeader.Length = 0;
|
||||
|
||||
|
||||
Bluetooth_SendPacket(&ResponsePacket, sizeof(ResponsePacket), NULL);
|
||||
|
||||
BT_ACL_DEBUG(1, ">> L2CAP Echo Response");
|
||||
|
|
@ -758,7 +758,7 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
|
|||
|
||||
BT_ACL_DEBUG(1, "<< L2CAP Information Request");
|
||||
BT_ACL_DEBUG(2, "-- Info Type: 0x%04X", InformationRequest.InfoType);
|
||||
|
||||
|
||||
Pipe_ClearIN();
|
||||
Pipe_Freeze();
|
||||
|
||||
|
|
@ -766,25 +766,25 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
|
|||
{
|
||||
BT_Signal_Header_t SignalCommandHeader;
|
||||
BT_Signal_InformationResp_t InformationResponse;
|
||||
|
||||
|
||||
uint8_t Data[4];
|
||||
} ResponsePacket;
|
||||
|
||||
|
||||
uint8_t DataLen = 0;
|
||||
|
||||
|
||||
/* Retrieve the requested information and store it in the outgoing packet, if found */
|
||||
switch (InformationRequest.InfoType)
|
||||
{
|
||||
case BT_INFOREQ_MTU:
|
||||
case BT_INFOREQ_MTU:
|
||||
ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
|
||||
DataLen = 2;
|
||||
|
||||
|
||||
*((uint16_t*)&ResponsePacket.Data) = MAXIMUM_CHANNEL_MTU;
|
||||
break;
|
||||
case BT_INFOREQ_EXTENDEDFEATURES:
|
||||
ResponsePacket.InformationResponse.Result = BT_INFORMATION_SUCCESSFUL;
|
||||
DataLen = 4;
|
||||
|
||||
|
||||
*((uint32_t*)&ResponsePacket.Data) = 0;
|
||||
break;
|
||||
default:
|
||||
|
|
@ -792,7 +792,7 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
|
|||
DataLen = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Fill out the Signal Command header in the response packet */
|
||||
ResponsePacket.SignalCommandHeader.Code = BT_SIGNAL_INFORMATION_RESPONSE;
|
||||
ResponsePacket.SignalCommandHeader.Identifier = SignalCommandHeader->Identifier;
|
||||
|
|
@ -800,9 +800,10 @@ static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* con
|
|||
|
||||
/* Fill out the Information Response in the response packet */
|
||||
ResponsePacket.InformationResponse.InfoType = InformationRequest.InfoType;
|
||||
|
||||
|
||||
Bluetooth_SendPacket(&ResponsePacket, (sizeof(ResponsePacket) - sizeof(ResponsePacket.Data) + DataLen), NULL);
|
||||
|
||||
BT_ACL_DEBUG(1, ">> L2CAP Information Response");
|
||||
BT_ACL_DEBUG(1, ">> L2CAP Information Response");
|
||||
BT_ACL_DEBUG(2, "-- Result: 0x%02X", ResponsePacket.InformationResponse.Result);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -44,13 +44,13 @@
|
|||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialStream.h>
|
||||
|
||||
|
||||
#include "BluetoothStack.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
#define BT_ACL_DEBUG(l, s, ...) do { if (ACL_DEBUG_LEVEL >= l) printf_P(PSTR("(ACL) " s "\r\n"), ##__VA_ARGS__); } while (0)
|
||||
#define ACL_DEBUG_LEVEL 0
|
||||
|
||||
|
||||
/** Lowest possible channel number for L2CAP data channels. */
|
||||
#define BT_CHANNELNUMBER_BASEOFFSET 0x0040
|
||||
|
||||
|
|
@ -59,7 +59,7 @@
|
|||
|
||||
/** Bluetooth specification defined channel number for connectionless data. */
|
||||
#define BT_CHANNEL_CONNECTIONLESS 0x0002
|
||||
|
||||
|
||||
#define BT_ACL_FIRST_AUTOFLUSH (1 << 13)
|
||||
|
||||
#define BT_SIGNAL_COMMAND_REJECT 0x01
|
||||
|
|
@ -73,23 +73,23 @@
|
|||
#define BT_SIGNAL_ECHO_RESPONSE 0x09
|
||||
#define BT_SIGNAL_INFORMATION_REQUEST 0x0A
|
||||
#define BT_SIGNAL_INFORMATION_RESPONSE 0x0B
|
||||
|
||||
|
||||
#define BT_INFOREQ_MTU 0x0001
|
||||
#define BT_INFOREQ_EXTENDEDFEATURES 0x0002
|
||||
|
||||
|
||||
#define BT_INFORMATION_SUCCESSFUL 0x0000
|
||||
#define BT_INFORMATION_NOTSUPPORTED 0x0001
|
||||
|
||||
|
||||
#define BT_CONNECTION_SUCCESSFUL 0x0000
|
||||
#define BT_CONNECTION_REFUSED_PSM 0x0002
|
||||
#define BT_CONNECTION_REFUSED_RESOURCES 0x0004
|
||||
|
||||
|
||||
#define BT_CONFIGURATION_SUCCESSFUL 0x0000
|
||||
#define BT_CONFIGURATION_REJECTED 0x0002
|
||||
#define BT_CONFIGURATION_UNKNOWNOPTIONS 0x0003
|
||||
|
||||
|
||||
#define BT_CONFIG_OPTION_MTU 1
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
/** Bluetooth ACL header structure, common to all ACL data packets. */
|
||||
typedef struct
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
uint16_t PayloadLength; /**< Size of the data payload, in bytes */
|
||||
uint16_t DestinationChannel; /**< Destination channel in the device the data is directed to */
|
||||
} BT_DataPacket_Header_t;
|
||||
|
||||
|
||||
/** Bluetooth signaling command header structure, for all ACL packets containing a signaling command. */
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -112,7 +112,7 @@
|
|||
uint8_t Identifier; /**< Unique signal command identifier to link requests and responses */
|
||||
uint16_t Length; /**< Length of the signaling command data, in bytes */
|
||||
} BT_Signal_Header_t;
|
||||
|
||||
|
||||
/** Connection Request signaling command structure, for channel connection requests. */
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -135,13 +135,13 @@
|
|||
uint16_t DestinationChannel; /**< Destination channel address which is to be disconnected */
|
||||
uint16_t SourceChannel; /**< Source channel address which is to be disconnected */
|
||||
} BT_Signal_DisconnectionReq_t;
|
||||
|
||||
|
||||
/** Disconnection response signaling command structure, for responses to channel disconnection requests. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t DestinationChannel; /**< Destination channel address which was disconnected */
|
||||
uint16_t SourceChannel; /**< Source channel address which was disconnected */
|
||||
} BT_Signal_DisconnectionResp_t;
|
||||
} BT_Signal_DisconnectionResp_t;
|
||||
|
||||
/** Configuration Request signaling command structure, for channel configuration requests. */
|
||||
typedef struct
|
||||
|
|
@ -163,14 +163,14 @@
|
|||
{
|
||||
uint16_t InfoType; /**< Data type that is being requested, a BT_INFOREQ_* mask value */
|
||||
} BT_Signal_InformationReq_t;
|
||||
|
||||
|
||||
/** Information Response signaling command structure, for responses to information requests. */
|
||||
typedef struct
|
||||
{
|
||||
uint16_t InfoType; /**< Data type that was requested, a BT_INFOREQ_* mask value */
|
||||
uint16_t Result; /**< Result of the request, a BT_INFORMATION_* mask value */
|
||||
} BT_Signal_InformationResp_t;
|
||||
|
||||
|
||||
/** Configuration Option header structure, placed at the start of each option in a Channel Configuration
|
||||
* request's options list.
|
||||
*/
|
||||
|
|
@ -182,7 +182,7 @@
|
|||
|
||||
/* Function Prototypes: */
|
||||
void Bluetooth_ACLTask(void);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_BLUETOOTH_ACLPACKETS_C)
|
||||
static void Bluetooth_ProcessIncomingACLPackets(void);
|
||||
|
||||
|
|
@ -195,5 +195,6 @@
|
|||
static inline void Bluetooth_Signal_EchoReq(const BT_Signal_Header_t* const SignalCommandHeader);
|
||||
static inline void Bluetooth_Signal_InformationReq(const BT_Signal_Header_t* const SignalCommandHeader);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -46,7 +46,7 @@
|
|||
#define DEVICE_CLASS_SERVICE_AUDIO (1UL << 21)
|
||||
#define DEVICE_CLASS_SERVICE_TELEPHONY (1UL << 22)
|
||||
#define DEVICE_CLASS_SERVICE_INFORMATION (1UL << 23)
|
||||
|
||||
|
||||
#define DEVICE_CLASS_MAJOR_MISC (0x00 << 8)
|
||||
#define DEVICE_CLASS_MAJOR_COMPUTER (0x01 << 8)
|
||||
#define DEVICE_CLASS_MAJOR_PHONE (0x02 << 8)
|
||||
|
|
@ -63,7 +63,7 @@
|
|||
#define DEVICE_CLASS_MINOR_COMPUTER_HANDHELD (0x04 << 2)
|
||||
#define DEVICE_CLASS_MINOR_COMPUTER_PALM (0x05 << 2)
|
||||
#define DEVICE_CLASS_MINOR_COMPUTER_WEARABLE (0x06 << 2)
|
||||
|
||||
|
||||
#define DEVICE_CLASS_MINOR_PHONE_UNCATEGORIZED (0x00 << 2)
|
||||
#define DEVICE_CLASS_MINOR_PHONE_CELLULAR (0x01 << 2)
|
||||
#define DEVICE_CLASS_MINOR_PHONE_CORDLESS (0x02 << 2)
|
||||
|
|
@ -79,7 +79,7 @@
|
|||
#define DEVICE_CLASS_MINOR_LAN_67_TO_83_PC_UTILIZED (0x05 << 5)
|
||||
#define DEVICE_CLASS_MINOR_LAN_83_TO_99_PC_UTILIZED (0x06 << 5)
|
||||
#define DEVICE_CLASS_MINOR_LAN_NO_SERVICE_AVAILABLE (0x07 << 5)
|
||||
|
||||
|
||||
#define DEVICE_CLASS_MINOR_AV_UNCATEGORIZED (0x00 << 2)
|
||||
#define DEVICE_CLASS_MINOR_AV_HEADSET (0x01 << 2)
|
||||
#define DEVICE_CLASS_MINOR_AV_HANDSFREE (0x02 << 2)
|
||||
|
|
@ -97,7 +97,7 @@
|
|||
#define DEVICE_CLASS_MINOR_AV_DISPLAY_AND_LOUDSPEAKER (0x0F << 2)
|
||||
#define DEVICE_CLASS_MINOR_AV_VIDEO_CONFERENCING (0x10 << 2)
|
||||
#define DEVICE_CLASS_MINOR_AV_GAMING_TOY (0x12 << 2)
|
||||
|
||||
|
||||
#define DEVICE_CLASS_MINOR_PERIPHERAL_KEYBOARD (0x01 << 6)
|
||||
#define DEVICE_CLASS_MINOR_PERIPHERAL_POINTING (0x02 << 6)
|
||||
#define DEVICE_CLASS_MINOR_PERIPHERAL_COMBO (0x03 << 6)
|
||||
|
|
@ -115,3 +115,4 @@
|
|||
#define DEVICE_CLASS_MINOR_IMAGING_PRINTER (1 << 7)
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -59,28 +59,28 @@ void Bluetooth_HCITask(void)
|
|||
case Bluetooth_ProcessEvents:
|
||||
Pipe_SelectPipe(BLUETOOTH_EVENTS_PIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
BT_HCIEvent_Header_t HCIEventHeader;
|
||||
|
||||
/* Read in the event header to fetch the event code and payload length */
|
||||
Pipe_Read_Stream_LE(&HCIEventHeader, sizeof(HCIEventHeader));
|
||||
|
||||
|
||||
/* Create a temporary buffer for the event parameters */
|
||||
uint8_t EventParams[HCIEventHeader.ParameterLength];
|
||||
|
||||
/* Read in the event parameters into the temporary buffer */
|
||||
Pipe_Read_Stream_LE(&EventParams, HCIEventHeader.ParameterLength);
|
||||
Pipe_ClearIN();
|
||||
|
||||
|
||||
BT_HCI_DEBUG(1, "Event Received (0x%02X)", HCIEventHeader.EventCode);
|
||||
|
||||
switch (HCIEventHeader.EventCode)
|
||||
{
|
||||
case EVENT_COMMAND_COMPLETE:
|
||||
BT_HCI_DEBUG(1, "<< Command Complete");
|
||||
|
||||
|
||||
/* Check which operation was completed in case we need to process the even parameters */
|
||||
switch (((BT_HCIEvent_CommandComplete_t*)&EventParams)->Opcode)
|
||||
{
|
||||
|
|
@ -91,7 +91,7 @@ void Bluetooth_HCITask(void)
|
|||
sizeof(Bluetooth_State.LocalBDADDR));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_State.NextHCIState;
|
||||
break;
|
||||
case EVENT_COMMAND_STATUS:
|
||||
|
|
@ -110,7 +110,7 @@ void Bluetooth_HCITask(void)
|
|||
memcpy(Bluetooth_TempDeviceAddress,
|
||||
&((BT_HCIEvent_ConnectionRequest_t*)&EventParams)->RemoteAddress,
|
||||
sizeof(Bluetooth_TempDeviceAddress));
|
||||
|
||||
|
||||
bool IsACLConnection = (((BT_HCIEvent_ConnectionRequest_t*)&EventParams)->LinkType == 0x01);
|
||||
|
||||
/* Only accept the connection if it is a ACL (data) connection, a device is not already connected
|
||||
|
|
@ -135,12 +135,12 @@ void Bluetooth_HCITask(void)
|
|||
break;
|
||||
case EVENT_LINK_KEY_REQUEST:
|
||||
BT_HCI_DEBUG(1, "<< Link Key Request");
|
||||
|
||||
|
||||
/* Need to store the remote device's BT address in a temporary buffer for later use */
|
||||
memcpy(Bluetooth_TempDeviceAddress,
|
||||
&((BT_HCIEvent_LinkKeyReq_t*)&EventParams)->RemoteAddress,
|
||||
sizeof(Bluetooth_TempDeviceAddress));
|
||||
|
||||
sizeof(Bluetooth_TempDeviceAddress));
|
||||
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_Conn_SendLinkKeyNAK;
|
||||
break;
|
||||
case EVENT_CONNECTION_COMPLETE:
|
||||
|
|
@ -155,22 +155,22 @@ void Bluetooth_HCITask(void)
|
|||
/* Store the created connection handle and indicate that the connection has been established */
|
||||
Bluetooth_Connection.ConnectionHandle = ((BT_HCIEvent_ConnectionComplete_t*)&EventParams)->ConnectionHandle;
|
||||
Bluetooth_Connection.IsConnected = true;
|
||||
|
||||
Bluetooth_ConnectionComplete();
|
||||
|
||||
Bluetooth_ConnectionComplete();
|
||||
break;
|
||||
case EVENT_DISCONNECTION_COMPLETE:
|
||||
BT_HCI_DEBUG(1, "<< Disconnection Complete");
|
||||
|
||||
/* Device disconnected, indicate connection information no longer valid */
|
||||
Bluetooth_Connection.IsConnected = false;
|
||||
|
||||
|
||||
Bluetooth_DisconnectionComplete();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
break;
|
||||
case Bluetooth_Init:
|
||||
BT_HCI_DEBUG(1, "# Init");
|
||||
|
|
@ -180,7 +180,7 @@ void Bluetooth_HCITask(void)
|
|||
/* Reset the connection information structure to destroy any previous connection state */
|
||||
memset(&Bluetooth_Connection, 0x00, sizeof(Bluetooth_Connection));
|
||||
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_Init_Reset;
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_Init_Reset;
|
||||
break;
|
||||
case Bluetooth_Init_Reset:
|
||||
BT_HCI_DEBUG(1, "# Reset");
|
||||
|
|
@ -193,13 +193,13 @@ void Bluetooth_HCITask(void)
|
|||
|
||||
/* Send the command to reset the Bluetooth dongle controller */
|
||||
Bluetooth_SendHCICommand(&HCICommandHeader, NULL, 0);
|
||||
|
||||
|
||||
Bluetooth_State.NextHCIState = Bluetooth_Init_ReadBufferSize;
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents;
|
||||
break;
|
||||
case Bluetooth_Init_ReadBufferSize:
|
||||
BT_HCI_DEBUG(1, "# Read Buffer Size");
|
||||
|
||||
|
||||
HCICommandHeader = (BT_HCICommand_Header_t)
|
||||
{
|
||||
OpCode: (OGF_CTRLR_INFORMATIONAL | OCF_CTRLR_INFORMATIONAL_READBUFFERSIZE),
|
||||
|
|
@ -214,7 +214,7 @@ void Bluetooth_HCITask(void)
|
|||
break;
|
||||
case Bluetooth_Init_GetBDADDR:
|
||||
BT_HCI_DEBUG(1, "# Get BDADDR");
|
||||
|
||||
|
||||
HCICommandHeader = (BT_HCICommand_Header_t)
|
||||
{
|
||||
OpCode: (OGF_CTRLR_INFORMATIONAL | OCF_CTRLR_INFORMATIONAL_READBDADDR),
|
||||
|
|
@ -267,10 +267,10 @@ void Bluetooth_HCITask(void)
|
|||
};
|
||||
|
||||
uint8_t Interval = BT_SCANMODE_InquiryAndPageScans;
|
||||
|
||||
|
||||
/* Send the command to set the remote device scanning mode */
|
||||
Bluetooth_SendHCICommand(&HCICommandHeader, &Interval, 1);
|
||||
|
||||
|
||||
Bluetooth_State.NextHCIState = Bluetooth_Init_FinalizeInit;
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents;
|
||||
break;
|
||||
|
|
@ -301,7 +301,7 @@ void Bluetooth_HCITask(void)
|
|||
|
||||
/* Send the command to accept the remote connection request */
|
||||
Bluetooth_SendHCICommand(&HCICommandHeader, &AcceptConnectionParams, sizeof(BT_HCICommand_AcceptConnectionReq_t));
|
||||
|
||||
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents;
|
||||
break;
|
||||
case Bluetooth_Conn_RejectConnection:
|
||||
|
|
@ -321,7 +321,7 @@ void Bluetooth_HCITask(void)
|
|||
|
||||
/* Send the command to reject the remote connection request */
|
||||
Bluetooth_SendHCICommand(&HCICommandHeader, &RejectConnectionParams, sizeof(BT_HCICommand_RejectConnectionReq_t));
|
||||
|
||||
|
||||
Bluetooth_State.CurrentHCIState = Bluetooth_ProcessEvents;
|
||||
break;
|
||||
case Bluetooth_Conn_SendPINCode:
|
||||
|
|
@ -339,7 +339,7 @@ void Bluetooth_HCITask(void)
|
|||
memcpy(PINCodeRequestParams.RemoteAddress, Bluetooth_TempDeviceAddress, sizeof(PINCodeRequestParams.RemoteAddress));
|
||||
PINCodeRequestParams.PINCodeLength = strlen(Bluetooth_DeviceConfiguration.PINCode);
|
||||
memcpy(PINCodeRequestParams.PINCode, Bluetooth_DeviceConfiguration.PINCode, sizeof(PINCodeRequestParams.PINCode));
|
||||
|
||||
|
||||
/* Send the command to transmit the device's local PIN number for authentication */
|
||||
Bluetooth_SendHCICommand(&HCICommandHeader, &PINCodeRequestParams, sizeof(BT_HCICommand_PinCodeResp_t));
|
||||
|
||||
|
|
@ -392,14 +392,15 @@ static uint8_t Bluetooth_SendHCICommand(const BT_HCICommand_Header_t* const HCIC
|
|||
|
||||
/* Copy over the HCI command header to the allocated buffer */
|
||||
memcpy(CommandBuffer, HCICommandHeader, sizeof(BT_HCICommand_Header_t));
|
||||
|
||||
|
||||
/* Zero out the parameter section of the response so that all padding bytes are known to be zero */
|
||||
memset(&CommandBuffer[sizeof(BT_HCICommand_Header_t)], 0x00, HCICommandHeader->ParameterLength);
|
||||
|
||||
/* Copy over the command parameters (if any) to the command buffer - note, the number of actual source parameter bytes
|
||||
may differ to those in the header; any difference in length is filled with 0x00 padding bytes */
|
||||
memcpy(&CommandBuffer[sizeof(BT_HCICommand_Header_t)], Parameters, ParameterLength);
|
||||
|
||||
|
||||
Pipe_SelectPipe(PIPE_CONTROLPIPE);
|
||||
return USB_Host_SendControlRequest(CommandBuffer);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -82,7 +82,7 @@
|
|||
#define OCF_CTRLR_BASEBAND_WRITE_AUTHENTICATION_ENABLE 0x0020
|
||||
#define OCF_CTRLR_INFORMATIONAL_READBUFFERSIZE 0x0005
|
||||
#define OCF_CTRLR_INFORMATIONAL_READBDADDR 0x0009
|
||||
|
||||
|
||||
#define EVENT_COMMAND_STATUS 0x0F
|
||||
#define EVENT_COMMAND_COMPLETE 0x0E
|
||||
#define EVENT_CONNECTION_COMPLETE 0x03
|
||||
|
|
@ -91,10 +91,10 @@
|
|||
#define EVENT_REMOTE_NAME_REQUEST_COMPLETE 0x07
|
||||
#define EVENT_PIN_CODE_REQUEST 0x16
|
||||
#define EVENT_LINK_KEY_REQUEST 0x17
|
||||
|
||||
|
||||
#define ERROR_LIMITED_RESOURCES 0x0D
|
||||
#define ERROR_UNACCEPTABLE_BDADDR 0x0F
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -115,7 +115,7 @@
|
|||
uint8_t Packets;
|
||||
uint16_t OpCode;
|
||||
} BT_HCIEvent_CommandStatus_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t HCIPacketsAllowable;
|
||||
|
|
@ -139,7 +139,7 @@
|
|||
uint8_t LinkType;
|
||||
uint8_t EncryptionEnabled;
|
||||
} BT_HCIEvent_ConnectionComplete_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t RemoteAddress[6];
|
||||
|
|
@ -149,7 +149,7 @@
|
|||
{
|
||||
uint8_t RemoteAddress[6];
|
||||
} BT_HCIEvent_LinkKeyReq_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t RemoteAddress[6];
|
||||
|
|
@ -161,18 +161,18 @@
|
|||
uint8_t PINCodeLength;
|
||||
char PINCode[16];
|
||||
} BT_HCICommand_PinCodeResp_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t RemoteAddress[6];
|
||||
uint8_t SlaveRole;
|
||||
} BT_HCICommand_AcceptConnectionReq_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t RemoteAddress[6];
|
||||
uint8_t Reason;
|
||||
} BT_HCICommand_RejectConnectionReq_t;
|
||||
} BT_HCICommand_RejectConnectionReq_t;
|
||||
|
||||
/* Enums: */
|
||||
enum BT_ScanEnable_Modes_t
|
||||
|
|
@ -199,14 +199,15 @@
|
|||
Bluetooth_Conn_SendPINCode = 11,
|
||||
Bluetooth_Conn_SendLinkKeyNAK = 12,
|
||||
};
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void Bluetooth_HCITask(void);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_BLUETOOTHHCICOMMANDS_C)
|
||||
static uint8_t Bluetooth_SendHCICommand(const BT_HCICommand_Header_t* const HCICommandHeader,
|
||||
const void* Parameters,
|
||||
const uint16_t ParameterLength);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -71,3 +71,4 @@ void Bluetooth_Stack_USBTask(void)
|
|||
Bluetooth_HCITask();
|
||||
Bluetooth_ACLTask();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,12 +38,12 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "../ConfigDescriptor.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
#define BLUETOOTH_MAX_OPEN_CHANNELS 6
|
||||
|
||||
|
||||
#define CHANNEL_PSM_SDP 0x0001
|
||||
#define CHANNEL_PSM_UDP 0x0002
|
||||
#define CHANNEL_PSM_RFCOMM 0x0003
|
||||
|
|
@ -53,13 +53,13 @@
|
|||
#define CHANNEL_PSM_HTTP 0x000C
|
||||
#define CHANNEL_PSM_UPNP 0x0010
|
||||
#define CHANNEL_PSM_HIDP 0x0011
|
||||
|
||||
|
||||
#define CHANNEL_SEARCH_LOCALNUMBER 0
|
||||
#define CHANNEL_SEARCH_REMOTENUMBER 1
|
||||
#define CHANNEL_SEARCH_PSM 2
|
||||
|
||||
|
||||
#define MAXIMUM_CHANNEL_MTU 255
|
||||
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the possible states for a Bluetooth ACL channel. */
|
||||
enum BT_ChannelStates_t
|
||||
|
|
@ -117,7 +117,7 @@
|
|||
Bluetooth_Channel_t Channels[BLUETOOTH_MAX_OPEN_CHANNELS]; /**< Channel information structures for the connection. */
|
||||
uint8_t SignalingIdentifier; /**< Next Signaling Channel unique command sequence identifier. */
|
||||
} Bluetooth_Connection_t;
|
||||
|
||||
|
||||
/** Local Bluetooth device information structure, for the defining of local device characteristics for the Bluetooth stack. */
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
char PINCode[16]; /**< Pin code required to send or receive in order to authenticate with a remote device. */
|
||||
char Name[]; /**< Name of the local Bluetooth device, up to 248 characters. */
|
||||
} Bluetooth_Device_t;
|
||||
|
||||
|
||||
/** Bluetooth stack state information structure, for the containment of the Bluetooth stack state. The values in
|
||||
* this structure are set by the Bluetooth stack internally, and should all be treated as read only by the user
|
||||
* application.
|
||||
|
|
@ -139,12 +139,12 @@
|
|||
*/
|
||||
uint8_t LocalBDADDR[6]; /**< Local Bluetooth adapter's BDADDR, valid when the stack is fully initialized. */
|
||||
} Bluetooth_Stack_State_t;
|
||||
|
||||
|
||||
/* Includes: */
|
||||
#include "BluetoothHCICommands.h"
|
||||
#include "BluetoothACLPackets.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
#include "BluetoothACLPackets.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
void Bluetooth_Stack_Init(void);
|
||||
void Bluetooth_Stack_USBTask(void);
|
||||
|
||||
|
|
@ -171,3 +171,4 @@
|
|||
extern Bluetooth_Stack_State_t Bluetooth_State;
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -124,7 +124,7 @@ void RFCOMM_ProcessPacket(void* Data,
|
|||
const RFCOMM_Header_t* FrameHeader = (const RFCOMM_Header_t*)Data;
|
||||
const uint8_t* FrameData = (const uint8_t*)Data + sizeof(RFCOMM_Header_t);
|
||||
uint16_t FrameDataLen = RFCOMM_GetVariableFieldValue(&FrameData);
|
||||
|
||||
|
||||
/* Decode the RFCOMM frame type from the header */
|
||||
switch (FrameHeader->Control & ~FRAME_POLL_FINAL)
|
||||
{
|
||||
|
|
@ -167,7 +167,7 @@ void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel,
|
|||
uint8_t Length;
|
||||
RFCOMM_MSC_Parameters_t Params;
|
||||
} MSCommand;
|
||||
|
||||
|
||||
MSCommand.CommandHeader = (RFCOMM_Command_t){.Command = RFCOMM_Control_ModemStatus, .EA = true, .CR = true};
|
||||
MSCommand.Length = (sizeof(MSCommand.Params) << 1) | 0x01;
|
||||
MSCommand.Params.Channel = (RFCOMM_Address_t){.DLCI = RFCOMMChannel->DLCI, .EA = true, .CR = true};
|
||||
|
|
@ -175,7 +175,7 @@ void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel,
|
|||
MSCommand.Params.BreakSignal = RFCOMMChannel->Local.BreakSignal;
|
||||
|
||||
/* Send the MSC command to the remote device */
|
||||
RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, true, RFCOMM_Frame_UIH, sizeof(MSCommand), &MSCommand, ACLChannel);
|
||||
RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, true, RFCOMM_Frame_UIH, sizeof(MSCommand), &MSCommand, ACLChannel);
|
||||
}
|
||||
|
||||
/** Sends new data through an open logical RFCOMM channel. This should be used to transmit data through a
|
||||
|
|
@ -193,12 +193,12 @@ void RFCOMM_SendData(const uint16_t DataLen,
|
|||
{
|
||||
if (RFCOMMChannel->State != RFCOMM_Channel_Open)
|
||||
return;
|
||||
|
||||
|
||||
BT_RFCOMM_DEBUG(1, ">> UIH Frame");
|
||||
BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", RFCOMMChannel->DLCI);
|
||||
|
||||
/* Send the MSC command to the remote device */
|
||||
RFCOMM_SendFrame(RFCOMMChannel->DLCI, false, RFCOMM_Frame_UIH, DataLen, Data, ACLChannel);
|
||||
RFCOMM_SendFrame(RFCOMMChannel->DLCI, false, RFCOMM_Frame_UIH, DataLen, Data, ACLChannel);
|
||||
}
|
||||
|
||||
RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI)
|
||||
|
|
@ -220,11 +220,11 @@ RFCOMM_Channel_t* RFCOMM_GetFreeChannelEntry(const uint8_t DLCI)
|
|||
RFCOMMChannel->Local.Signals = RFCOMM_SIGNAL_RTC | RFCOMM_SIGNAL_RTR | RFCOMM_SIGNAL_DV | (1 << 0);
|
||||
RFCOMMChannel->Local.BreakSignal = 0 | (1 << 0);
|
||||
RFCOMMChannel->ConfigFlags = 0;
|
||||
|
||||
|
||||
return RFCOMMChannel;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -234,7 +234,7 @@ RFCOMM_Channel_t* RFCOMM_GetChannelData(const uint8_t DLCI)
|
|||
for (uint8_t i = 0; i < RFCOMM_MAX_OPEN_CHANNELS; i++)
|
||||
{
|
||||
RFCOMM_Channel_t* CurrRFCOMMChannel = &RFCOMM_Channels[i];
|
||||
|
||||
|
||||
/* If the current non-closed channel's DLCI matches the search DLCI, return it to the caller */
|
||||
if ((CurrRFCOMMChannel->State != RFCOMM_Channel_Closed) && (CurrRFCOMMChannel->DLCI == DLCI))
|
||||
return CurrRFCOMMChannel;
|
||||
|
|
@ -248,10 +248,10 @@ uint16_t RFCOMM_GetVariableFieldValue(const uint8_t** BufferPos)
|
|||
{
|
||||
uint8_t FirstOctet;
|
||||
uint8_t SecondOctet = 0;
|
||||
|
||||
|
||||
FirstOctet = **BufferPos;
|
||||
(*BufferPos)++;
|
||||
|
||||
|
||||
/* If the field size is more than a single byte, fetch the next byte in the variable length field */
|
||||
if (!(FirstOctet & 0x01))
|
||||
{
|
||||
|
|
@ -281,30 +281,30 @@ void RFCOMM_SendFrame(const uint8_t DLCI,
|
|||
uint8_t Data[DataLen];
|
||||
uint8_t FCS;
|
||||
} ResponsePacket;
|
||||
|
||||
|
||||
/* Set the frame header values to the specified address and frame type */
|
||||
ResponsePacket.FrameHeader.Control = Control;
|
||||
ResponsePacket.FrameHeader.Address = (RFCOMM_Address_t){.DLCI = DLCI, .EA = true, .CR = CommandResponse};
|
||||
|
||||
|
||||
/* Set the lower 7 bits of the packet length */
|
||||
ResponsePacket.Size[0] = (DataLen << 1);
|
||||
|
||||
|
||||
/* Terminate the size field if size is 7 bits or lower, otherwise set the upper 8 bits of the length */
|
||||
if (DataLen < 128)
|
||||
ResponsePacket.Size[0] |= 0x01;
|
||||
else
|
||||
ResponsePacket.Size[1] = (DataLen >> 7);
|
||||
|
||||
|
||||
/* Copy over the packet data from the source buffer to the response packet buffer */
|
||||
memcpy(ResponsePacket.Data, Data, DataLen);
|
||||
|
||||
|
||||
/* Determine the length of the frame which is to be used to calculate the CRC value */
|
||||
uint8_t CRCLength = sizeof(ResponsePacket.FrameHeader);
|
||||
|
||||
/* UIH frames do not have the CRC calculated on the Size field in the response, all other frames do */
|
||||
if ((Control & ~FRAME_POLL_FINAL) != RFCOMM_Frame_UIH)
|
||||
CRCLength += sizeof(ResponsePacket.Size);
|
||||
|
||||
|
||||
/* Calculate the frame checksum from the appropriate fields */
|
||||
ResponsePacket.FCS = RFCOMM_GetFCSValue(&ResponsePacket, CRCLength);
|
||||
|
||||
|
|
@ -316,7 +316,7 @@ static uint8_t RFCOMM_GetFCSValue(const void* FrameStart,
|
|||
uint8_t Length)
|
||||
{
|
||||
uint8_t FCS = 0xFF;
|
||||
|
||||
|
||||
/* Calculate new Frame CRC value via the given data bytes and the CRC table */
|
||||
for (uint8_t i = 0; i < Length; i++)
|
||||
FCS = pgm_read_byte(&CRC8_Table[FCS ^ ((const uint8_t*)FrameStart)[i]]);
|
||||
|
|
@ -338,7 +338,7 @@ static void RFCOMM_ProcessDISC(const RFCOMM_Address_t* const FrameAddress,
|
|||
BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
|
||||
|
||||
RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(FrameAddress->DLCI);
|
||||
|
||||
|
||||
/* If the requested channel is currently open, destroy it */
|
||||
if (RFCOMMChannel != NULL)
|
||||
RFCOMMChannel->State = RFCOMM_Channel_Closed;
|
||||
|
|
@ -356,7 +356,7 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress,
|
|||
if (FrameAddress->DLCI == RFCOMM_CONTROL_DLCI)
|
||||
{
|
||||
BT_RFCOMM_DEBUG(1, ">> UA Sent");
|
||||
|
||||
|
||||
/* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */
|
||||
RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, ACLChannel);
|
||||
|
||||
|
|
@ -365,7 +365,7 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress,
|
|||
|
||||
/* Find the existing channel's entry in the channel table */
|
||||
RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(FrameAddress->DLCI);
|
||||
|
||||
|
||||
/* Existing entry not found, create a new entry for the channel */
|
||||
if (RFCOMMChannel == NULL)
|
||||
RFCOMMChannel = RFCOMM_GetFreeChannelEntry(FrameAddress->DLCI);
|
||||
|
|
@ -374,7 +374,7 @@ static void RFCOMM_ProcessSABM(const RFCOMM_Address_t* const FrameAddress,
|
|||
if (RFCOMMChannel != NULL)
|
||||
{
|
||||
BT_RFCOMM_DEBUG(1, ">> UA Sent");
|
||||
|
||||
|
||||
/* Free channel found, or request was to the control channel - accept SABM by sending a UA frame */
|
||||
RFCOMM_SendFrame(FrameAddress->DLCI, true, (RFCOMM_Frame_UA | FRAME_POLL_FINAL), 0, NULL, ACLChannel);
|
||||
}
|
||||
|
|
@ -395,7 +395,7 @@ static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress,
|
|||
}
|
||||
|
||||
static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress,
|
||||
const uint16_t FrameLength,
|
||||
const uint16_t FrameLength,
|
||||
const uint8_t* FrameData,
|
||||
Bluetooth_Channel_t* const ACLChannel)
|
||||
{
|
||||
|
|
@ -408,9 +408,10 @@ static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress,
|
|||
BT_RFCOMM_DEBUG(1, "<< UIH Received");
|
||||
BT_RFCOMM_DEBUG(2, "-- DLCI 0x%02X", FrameAddress->DLCI);
|
||||
BT_RFCOMM_DEBUG(2, "-- Length 0x%02X", FrameLength);
|
||||
|
||||
|
||||
RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(FrameAddress->DLCI);
|
||||
|
||||
|
||||
if (RFCOMMChannel != NULL)
|
||||
RFCOMM_DataReceived(RFCOMMChannel, FrameLength, FrameData);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -48,13 +48,13 @@
|
|||
|
||||
#include "BluetoothStack.h"
|
||||
#include "RFCOMMControl.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
#define BT_RFCOMM_DEBUG(l, s, ...) do { if (RFCOMM_DEBUG_LEVEL >= l) printf_P(PSTR("(RFCOMM) " s "\r\n"), ##__VA_ARGS__); } while (0)
|
||||
#define RFCOMM_DEBUG_LEVEL 0
|
||||
|
||||
|
||||
#define FRAME_POLL_FINAL (1 << 4)
|
||||
|
||||
|
||||
#define RFCOMM_CONTROL_DLCI 0
|
||||
#define RFCOMM_MAX_OPEN_CHANNELS 5
|
||||
|
||||
|
|
@ -68,14 +68,14 @@
|
|||
RFCOMM_Frame_UA = 0x63, /**< Unnumbered Acknowledgement Field */
|
||||
RFCOMM_Frame_UIH = 0xEF, /**< Unnumbered Information with Header check Field */
|
||||
};
|
||||
|
||||
|
||||
enum RFCOMM_Channel_States_t
|
||||
{
|
||||
RFCOMM_Channel_Closed = 0,
|
||||
RFCOMM_Channel_Configure = 1,
|
||||
RFCOMM_Channel_Open = 2,
|
||||
};
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -95,7 +95,7 @@
|
|||
uint8_t BreakSignal;
|
||||
} Local;
|
||||
} RFCOMM_Channel_t;
|
||||
|
||||
|
||||
/* External Variables: */
|
||||
extern RFCOMM_Channel_t RFCOMM_Channels[RFCOMM_MAX_OPEN_CHANNELS];
|
||||
|
||||
|
|
@ -104,7 +104,7 @@
|
|||
void RFCOMM_ServiceChannels(Bluetooth_Channel_t* const ACLChannel);
|
||||
void RFCOMM_ProcessPacket(void* Data,
|
||||
Bluetooth_Channel_t* const ACLChannel);
|
||||
|
||||
|
||||
void RFCOMM_SendChannelSignals(const RFCOMM_Channel_t* const RFCOMMChannel,
|
||||
Bluetooth_Channel_t* const ACLChannel);
|
||||
void RFCOMM_SendData(const uint16_t DataLen,
|
||||
|
|
@ -141,9 +141,10 @@
|
|||
static void RFCOMM_ProcessUA(const RFCOMM_Address_t* const FrameAddress,
|
||||
Bluetooth_Channel_t* const ACLChannel);
|
||||
static void RFCOMM_ProcessUIH(const RFCOMM_Address_t* const FrameAddress,
|
||||
const uint16_t FrameLength,
|
||||
const uint16_t FrameLength,
|
||||
const uint8_t* FrameData,
|
||||
Bluetooth_Channel_t* const ACLChannel);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -69,7 +69,7 @@ void RFCOMM_ProcessControlCommand(const uint8_t* Command,
|
|||
RFCOMM_ProcessDPNCommand(CommandHeader, CommandData, ACLChannel);
|
||||
break;
|
||||
default:
|
||||
BT_RFCOMM_DEBUG(1, "<< Unknown Command");
|
||||
BT_RFCOMM_DEBUG(1, "<< Unknown Command");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -82,7 +82,7 @@ static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeade
|
|||
const uint8_t* Params = (const uint8_t*)CommandData;
|
||||
|
||||
BT_RFCOMM_DEBUG(1, "<< TEST Command");
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
RFCOMM_Command_t CommandHeader;
|
||||
|
|
@ -94,7 +94,7 @@ static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeade
|
|||
TestResponse.CommandHeader = (RFCOMM_Command_t){.Command = RFCOMM_Control_Test, .EA = true, .CR = false};
|
||||
TestResponse.Length = (CommandDataLen << 1) | 0x01;
|
||||
memcpy(TestResponse.TestData, Params, CommandDataLen);
|
||||
|
||||
|
||||
BT_RFCOMM_DEBUG(1, ">> TEST Response");
|
||||
|
||||
/* Send the PDN response to acknowledge the command */
|
||||
|
|
@ -124,14 +124,14 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader
|
|||
|
||||
BT_RFCOMM_DEBUG(1, "<< MSC %s", (CommandHeader->CR) ? "Command" : "Response");
|
||||
BT_RFCOMM_DEBUG(2, "-- DLCI: 0x%02X", Params->Channel.DLCI);
|
||||
|
||||
|
||||
/* Ignore status flags sent to the control channel */
|
||||
if (Params->Channel.DLCI == RFCOMM_CONTROL_DLCI)
|
||||
return;
|
||||
|
||||
|
||||
/* Retrieve existing channel configuration data, if already opened */
|
||||
RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(Params->Channel.DLCI);
|
||||
|
||||
RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(Params->Channel.DLCI);
|
||||
|
||||
/* If the channel does not exist, abort */
|
||||
if (RFCOMMChannel == NULL)
|
||||
return;
|
||||
|
|
@ -140,16 +140,16 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader
|
|||
if (CommandHeader->CR)
|
||||
{
|
||||
/* Save the new channel signals to the channel state structure */
|
||||
RFCOMMChannel->Remote.Signals = Params->Signals;
|
||||
RFCOMMChannel->Remote.Signals = Params->Signals;
|
||||
RFCOMMChannel->ConfigFlags |= RFCOMM_CONFIG_REMOTESIGNALS;
|
||||
|
||||
|
||||
/* If the command contains the optional break signals field, store the value */
|
||||
if (CommandDataLen == sizeof(RFCOMM_MSC_Parameters_t))
|
||||
RFCOMMChannel->Remote.BreakSignal = Params->BreakSignal;
|
||||
|
||||
/* Notify the user application that the signals have been received */
|
||||
RFCOMM_ChannelSignalsReceived(RFCOMMChannel);
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
RFCOMM_Command_t CommandHeader;
|
||||
|
|
@ -172,7 +172,7 @@ static void RFCOMM_ProcessMSCCommand(const RFCOMM_Command_t* const CommandHeader
|
|||
{
|
||||
/* Indicate that the remote device has acknowledged the sent signals */
|
||||
RFCOMMChannel->ConfigFlags |= RFCOMM_CONFIG_LOCALSIGNALS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void RFCOMM_ProcessRPNCommand(const RFCOMM_Command_t* const CommandHeader,
|
||||
|
|
@ -197,20 +197,20 @@ static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader
|
|||
|
||||
BT_RFCOMM_DEBUG(1, "<< DPN Command");
|
||||
BT_RFCOMM_DEBUG(2, "-- DLCI: 0x%02X", Params->DLCI);
|
||||
|
||||
|
||||
/* Ignore parameter negotiations to the control channel */
|
||||
if (Params->DLCI == RFCOMM_CONTROL_DLCI)
|
||||
return;
|
||||
|
||||
|
||||
/* Retrieve existing channel configuration data, if already opened */
|
||||
RFCOMM_Channel_t* RFCOMMChannel = RFCOMM_GetChannelData(Params->DLCI);
|
||||
|
||||
|
||||
/* Check if the channel has no corresponding entry - remote did not open it first */
|
||||
if (RFCOMMChannel == NULL)
|
||||
{
|
||||
/* Create a new entry in the channel table for the new channel */
|
||||
RFCOMMChannel = RFCOMM_GetFreeChannelEntry(Params->DLCI);
|
||||
|
||||
|
||||
/* No free entry was found, discard the request */
|
||||
if (RFCOMMChannel == NULL)
|
||||
{
|
||||
|
|
@ -218,27 +218,28 @@ static void RFCOMM_ProcessDPNCommand(const RFCOMM_Command_t* const CommandHeader
|
|||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Save the new channel configuration */
|
||||
RFCOMMChannel->State = RFCOMM_Channel_Configure;
|
||||
RFCOMMChannel->Priority = Params->Priority;
|
||||
RFCOMMChannel->MTU = Params->MaximumFrameSize;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
RFCOMM_Command_t CommandHeader;
|
||||
uint8_t Length;
|
||||
RFCOMM_DPN_Parameters_t Params;
|
||||
} DPNResponse;
|
||||
|
||||
|
||||
/* Fill out the DPN response data */
|
||||
DPNResponse.CommandHeader = (RFCOMM_Command_t){.Command = RFCOMM_Control_DLCParameterNegotiation, .EA = true, .CR = false};
|
||||
DPNResponse.Length = (sizeof(DPNResponse.Params) << 1) | 0x01;
|
||||
memcpy(&DPNResponse.Params, Params, sizeof(RFCOMM_DPN_Parameters_t));
|
||||
DPNResponse.Params.ConvergenceLayer = 0x00; // TODO: Enable credit based transaction support
|
||||
|
||||
|
||||
BT_RFCOMM_DEBUG(1, ">> DPN Response");
|
||||
|
||||
/* Send the DPN response to acknowledge the command */
|
||||
RFCOMM_SendFrame(RFCOMM_CONTROL_DLCI, false, RFCOMM_Frame_UIH, sizeof(DPNResponse), &DPNResponse, ACLChannel);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -48,14 +48,14 @@
|
|||
|
||||
#include "BluetoothStack.h"
|
||||
#include "RFCOMM.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
#define RFCOMM_SIGNAL_FC (1 << 1)
|
||||
#define RFCOMM_SIGNAL_RTC (1 << 2)
|
||||
#define RFCOMM_SIGNAL_RTR (1 << 3)
|
||||
#define RFCOMM_SIGNAL_IC (1 << 6)
|
||||
#define RFCOMM_SIGNAL_DV (1 << 7)
|
||||
|
||||
|
||||
#define RFCOMM_CONFIG_REMOTESIGNALS (1 << 0)
|
||||
#define RFCOMM_CONFIG_LOCALSIGNALS (1 << 1)
|
||||
#define RFCOMM_CONFIG_LOCALSIGNALSSENT (1 << 2)
|
||||
|
|
@ -73,7 +73,7 @@
|
|||
RFCOMM_Control_DLCParameterNegotiation = (0x80 >> 2),
|
||||
RFCOMM_Control_NonSupportedCommand = (0x10 >> 2),
|
||||
};
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
|
|
@ -94,7 +94,7 @@
|
|||
unsigned char CR : 1;
|
||||
unsigned char Command : 6;
|
||||
} RFCOMM_Command_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t DLCI;
|
||||
|
|
@ -104,9 +104,9 @@
|
|||
uint8_t ACKTimerTicks;
|
||||
uint16_t MaximumFrameSize;
|
||||
uint8_t MaxRetransmissions;
|
||||
uint8_t RecoveryWindowSize;
|
||||
uint8_t RecoveryWindowSize;
|
||||
} RFCOMM_DPN_Parameters_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
RFCOMM_Address_t Channel;
|
||||
|
|
@ -120,7 +120,7 @@
|
|||
|
||||
#if defined(INCLUDE_FROM_RFCOMM_CONTROL_C)
|
||||
static void RFCOMM_ProcessTestCommand(const RFCOMM_Command_t* const CommandHeader,
|
||||
const uint8_t CommandDataLen,
|
||||
const uint8_t CommandDataLen,
|
||||
const uint8_t* CommandData,
|
||||
Bluetooth_Channel_t* const ACLChannel);
|
||||
static void RFCOMM_ProcessFCECommand(const RFCOMM_Command_t* const CommandHeader,
|
||||
|
|
@ -143,5 +143,6 @@
|
|||
const uint8_t* CommandData,
|
||||
Bluetooth_Channel_t* const ACLChannel);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -73,7 +73,7 @@ void SDP_ProcessPacket(void* Data, Bluetooth_Channel_t* const Channel)
|
|||
{
|
||||
case SDP_PDU_SERVICESEARCHREQUEST:
|
||||
SDP_ProcessServiceSearch(SDPHeader, Channel);
|
||||
break;
|
||||
break;
|
||||
case SDP_PDU_SERVICEATTRIBUTEREQUEST:
|
||||
SDP_ProcessServiceAttribute(SDPHeader, Channel);
|
||||
break;
|
||||
|
|
@ -99,11 +99,11 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader,
|
|||
uint8_t UUIDList[12][UUID_SIZE_BYTES];
|
||||
uint8_t TotalUUIDs = SDP_GetUUIDList(UUIDList, &CurrentParameter);
|
||||
BT_SDP_DEBUG(2, "-- Total UUIDs: %d", TotalUUIDs);
|
||||
|
||||
|
||||
/* Retrieve the maximum service record response count from the request */
|
||||
uint16_t MaxServiceRecordCount = SDP_ReadData16(&CurrentParameter);
|
||||
BT_SDP_DEBUG(2, "-- Max Return Service Count: 0x%04X", MaxServiceRecordCount);
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
SDP_PDUHeader_t SDPHeader;
|
||||
|
|
@ -111,7 +111,7 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader,
|
|||
uint16_t CurrentServiceRecordCount;
|
||||
uint8_t ResponseData[100];
|
||||
} ResponsePacket;
|
||||
|
||||
|
||||
uint8_t AddedServiceHandles = 0;
|
||||
|
||||
/* Create a pointer to the buffer to indicate the current location for response data to be added */
|
||||
|
|
@ -136,7 +136,7 @@ static void SDP_ProcessServiceSearch(const SDP_PDUHeader_t* const SDPHeader,
|
|||
uint8_t AttrSize = SDP_GetLocalAttributeContainerSize(AttributeValue, &AttrHeaderSize);
|
||||
memcpy_P(CurrResponsePos, AttributeValue + AttrHeaderSize, AttrSize);
|
||||
CurrResponsePos += AttrHeaderSize + AttrSize;
|
||||
|
||||
|
||||
AddedServiceHandles++;
|
||||
}
|
||||
|
||||
|
|
@ -180,11 +180,11 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader,
|
|||
/* Retrieve the service handle whose attributes are to be examined */
|
||||
uint32_t ServiceHandle = SDP_ReadData32(&CurrentParameter);
|
||||
BT_SDP_DEBUG(2, "-- Service Handle: 0x%08lX", ServiceHandle);
|
||||
|
||||
|
||||
/* Retrieve the maximum Attribute response size from the request */
|
||||
uint16_t MaxAttributeSize = SDP_ReadData16(&CurrentParameter);
|
||||
BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize);
|
||||
|
||||
|
||||
/* Retrieve the list of Attributes from the request */
|
||||
uint16_t AttributeList[8][2];
|
||||
uint8_t TotalAttributes = SDP_GetAttributeList(AttributeList, &CurrentParameter);
|
||||
|
|
@ -211,24 +211,24 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader,
|
|||
{
|
||||
/* Read in a pointer to the current UUID table entry's Attribute table */
|
||||
ServiceAttributeTable_t* CurrAttributeTable = pgm_read_ptr(&SDP_Services_Table[CurrTableItem]);
|
||||
|
||||
|
||||
/* Retrieve a PROGMEM pointer to the value of the Service Record Handle */
|
||||
const void* ServiceRecord = SDP_GetAttributeValue(CurrAttributeTable, SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE);
|
||||
|
||||
|
||||
/* Get the size of the header for the Service Record Handle */
|
||||
uint8_t AttrHeaderSize;
|
||||
SDP_GetLocalAttributeContainerSize(ServiceRecord, &AttrHeaderSize);
|
||||
|
||||
|
||||
/* Retrieve the endian-swapped service handle of the current service being examined */
|
||||
uint32_t CurrServiceHandle = SwapEndian_32(pgm_read_dword(ServiceRecord + AttrHeaderSize));
|
||||
|
||||
|
||||
/* Check if the current service in the service table has the requested service handle */
|
||||
if (ServiceHandle == CurrServiceHandle)
|
||||
{
|
||||
/* Add the listed attributes for the found UUID to the response */
|
||||
TotalResponseSize = SDP_AddListedAttributesToResponse(CurrAttributeTable, AttributeList, TotalAttributes,
|
||||
&CurrResponsePos);
|
||||
|
||||
|
||||
/* Requested service found, abort the search through the service table */
|
||||
break;
|
||||
}
|
||||
|
|
@ -243,7 +243,7 @@ static void SDP_ProcessServiceAttribute(const SDP_PDUHeader_t* const SDPHeader,
|
|||
/* Calculate the total parameter length that is to be sent, including the fixed return parameters, the created attribute
|
||||
value list and the SDP continuation state */
|
||||
uint16_t ParamLength = (sizeof(ResponsePacket.AttributeListByteCount) + TotalResponseSize + sizeof(uint8_t));
|
||||
|
||||
|
||||
/* Fill in the response packet's header */
|
||||
ResponsePacket.SDPHeader.PDU = SDP_PDU_SERVICEATTRIBUTERESPONSE;
|
||||
ResponsePacket.SDPHeader.TransactionID = SDPHeader->TransactionID;
|
||||
|
|
@ -265,30 +265,30 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe
|
|||
Bluetooth_Channel_t* const Channel)
|
||||
{
|
||||
const void* CurrentParameter = ((const void*)SDPHeader + sizeof(SDP_PDUHeader_t));
|
||||
|
||||
|
||||
BT_SDP_DEBUG(1, "<< Service Search Attribute");
|
||||
|
||||
/* Retrieve the list of search UUIDs from the request */
|
||||
uint8_t UUIDList[12][UUID_SIZE_BYTES];
|
||||
uint8_t TotalUUIDs = SDP_GetUUIDList(UUIDList, &CurrentParameter);
|
||||
BT_SDP_DEBUG(2, "-- Total UUIDs: %d", TotalUUIDs);
|
||||
|
||||
|
||||
/* Retrieve the maximum Attribute response size from the request */
|
||||
uint16_t MaxAttributeSize = SDP_ReadData16(&CurrentParameter);
|
||||
BT_SDP_DEBUG(2, "-- Max Return Attribute Bytes: 0x%04X", MaxAttributeSize);
|
||||
|
||||
|
||||
/* Retrieve the list of Attributes from the request */
|
||||
uint16_t AttributeList[8][2];
|
||||
uint8_t TotalAttributes = SDP_GetAttributeList(AttributeList, &CurrentParameter);
|
||||
BT_SDP_DEBUG(2, "-- Total Attributes: %d", TotalAttributes);
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
SDP_PDUHeader_t SDPHeader;
|
||||
uint16_t AttributeListByteCount;
|
||||
uint8_t ResponseData[100];
|
||||
} ResponsePacket;
|
||||
|
||||
|
||||
/* Create a pointer to the buffer to indicate the current location for response data to be added */
|
||||
void* CurrResponsePos = ResponsePacket.ResponseData;
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe
|
|||
|
||||
/* Add the outer Data Element Sequence header for all of the retrieved Attributes */
|
||||
uint16_t* TotalResponseSize = SDP_AddSequence16(&CurrResponsePos);
|
||||
|
||||
|
||||
/* Search through the global service list an item at a time */
|
||||
for (uint8_t CurrTableItem = 0; CurrTableItem < (sizeof(SDP_Services_Table) / sizeof(void*)); CurrTableItem++)
|
||||
{
|
||||
|
|
@ -307,14 +307,14 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe
|
|||
|
||||
if (!(SDP_SearchServiceTable(UUIDList, TotalUUIDs, CurrAttributeTable)))
|
||||
continue;
|
||||
|
||||
|
||||
BT_SDP_DEBUG(2, " -- Found search match in table");
|
||||
|
||||
/* Add the listed attributes for the found UUID to the response */
|
||||
*TotalResponseSize += SDP_AddListedAttributesToResponse(CurrAttributeTable, AttributeList, TotalAttributes,
|
||||
*TotalResponseSize += SDP_AddListedAttributesToResponse(CurrAttributeTable, AttributeList, TotalAttributes,
|
||||
&CurrResponsePos);
|
||||
}
|
||||
|
||||
|
||||
/* Continuation state - always zero */
|
||||
SDP_WriteData8(&CurrResponsePos, 0);
|
||||
|
||||
|
|
@ -323,7 +323,7 @@ static void SDP_ProcessServiceSearchAttribute(const SDP_PDUHeader_t* const SDPHe
|
|||
|
||||
/* Calculate the total parameter length that is to be sent, including the fixed return parameters, the created attribute
|
||||
value list and the SDP continuation state */
|
||||
uint16_t ParamLength = (sizeof(ResponsePacket.AttributeListByteCount) +
|
||||
uint16_t ParamLength = (sizeof(ResponsePacket.AttributeListByteCount) +
|
||||
(3 + *TotalResponseSize) +
|
||||
sizeof(uint8_t));
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t*
|
|||
{
|
||||
uint16_t* AttributeIDRange = AttributeList[CurrAttribute];
|
||||
void* AttributeValue;
|
||||
|
||||
|
||||
/* Look through the current service's attribute list, examining all the attributes */
|
||||
while ((AttributeValue = pgm_read_ptr(&AttributeTable->Data)) != NULL)
|
||||
{
|
||||
|
|
@ -377,9 +377,9 @@ static uint16_t SDP_AddListedAttributesToResponse(const ServiceAttributeTable_t*
|
|||
if ((CurrAttributeID >= AttributeIDRange[0]) && (CurrAttributeID <= AttributeIDRange[1]))
|
||||
{
|
||||
/* Increment the current UUID's returned Attribute container size by the number of added bytes */
|
||||
*AttributeListSize += SDP_AddAttributeToResponse(CurrAttributeID, AttributeValue, BufferPos);
|
||||
*AttributeListSize += SDP_AddAttributeToResponse(CurrAttributeID, AttributeValue, BufferPos);
|
||||
}
|
||||
|
||||
|
||||
AttributeTable++;
|
||||
}
|
||||
}
|
||||
|
|
@ -408,19 +408,19 @@ static uint16_t SDP_AddAttributeToResponse(const uint16_t AttributeID,
|
|||
/* Retrieve the size of the attribute value from its container header */
|
||||
uint8_t AttributeHeaderLength;
|
||||
uint16_t AttributeValueLength = SDP_GetLocalAttributeContainerSize(AttributeValue, &AttributeHeaderLength);
|
||||
|
||||
|
||||
BT_SDP_DEBUG(2, " -- Add Attribute (0x%04X) 0x%04X", (AttributeHeaderLength + AttributeValueLength), AttributeID);
|
||||
|
||||
/* Add a Data Element header to the response for the Attribute ID */
|
||||
SDP_WriteData8(ResponseBuffer, (SDP_DATATYPE_UnsignedInt | SDP_DATASIZE_16Bit));
|
||||
|
||||
|
||||
/* Add the Attribute ID to the created Data Element */
|
||||
SDP_WriteData16(ResponseBuffer, AttributeID);
|
||||
|
||||
|
||||
/* Copy over the Attribute value Data Element container to the response */
|
||||
memcpy_P(*ResponseBuffer, AttributeValue, AttributeHeaderLength + AttributeValueLength);
|
||||
*ResponseBuffer += AttributeHeaderLength + AttributeValueLength;
|
||||
|
||||
|
||||
return (sizeof(uint8_t) + sizeof(uint16_t) + AttributeHeaderLength + AttributeValueLength);
|
||||
}
|
||||
|
||||
|
|
@ -435,17 +435,17 @@ static void* SDP_GetAttributeValue(const ServiceAttributeTable_t* AttributeTable
|
|||
const uint16_t AttributeID)
|
||||
{
|
||||
void* CurrTableItemData;
|
||||
|
||||
|
||||
/* Search through the current Attribute table, abort when the terminator item has been reached */
|
||||
while ((CurrTableItemData = pgm_read_ptr(&AttributeTable->Data)) != NULL)
|
||||
{
|
||||
/* Check if the current Attribute ID matches the search ID - if so return a pointer to it */
|
||||
if (pgm_read_word(&AttributeTable->AttributeID) == AttributeID)
|
||||
return CurrTableItemData;
|
||||
|
||||
|
||||
AttributeTable++;
|
||||
}
|
||||
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
@ -463,7 +463,7 @@ static bool SDP_SearchServiceTable(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
{
|
||||
const void* CurrAttribute;
|
||||
uint16_t UUIDMatchFlags = 0;
|
||||
|
||||
|
||||
/* Search through the current attribute table, checking each attribute value for UUID matches */
|
||||
while ((CurrAttribute = pgm_read_ptr(&CurrAttributeTable->Data)) != NULL)
|
||||
{
|
||||
|
|
@ -475,7 +475,7 @@ static bool SDP_SearchServiceTable(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
uint8_t UUIDMatches;
|
||||
for (UUIDMatches = 0; UUIDMatchFlags; UUIDMatches++)
|
||||
UUIDMatchFlags &= (UUIDMatchFlags - 1);
|
||||
|
||||
|
||||
/* If all UUIDs have been matched to the current service, return true */
|
||||
return (UUIDMatches == TotalUUIDs);
|
||||
}
|
||||
|
|
@ -501,7 +501,7 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
if (CurrAttributeType == SDP_DATATYPE_UUID)
|
||||
{
|
||||
uint16_t CurrUUIDMatchMask = (1 << 0);
|
||||
|
||||
|
||||
/* Look for matches in the UUID list against the current attribute UUID value */
|
||||
for (uint8_t i = 0; i < TotalUUIDs; i++)
|
||||
{
|
||||
|
|
@ -512,7 +512,7 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
*UUIDMatchFlags |= CurrUUIDMatchMask;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
CurrUUIDMatchMask <<= 1;
|
||||
}
|
||||
}
|
||||
|
|
@ -520,15 +520,15 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
{
|
||||
uint8_t SequenceHeaderSize;
|
||||
uint16_t SequenceSize = SDP_GetLocalAttributeContainerSize(CurrAttribute, &SequenceHeaderSize);
|
||||
|
||||
|
||||
CurrAttribute += SequenceHeaderSize;
|
||||
|
||||
|
||||
/* Recursively unwrap the sequence container, and re-search its contents for UUIDs */
|
||||
while (SequenceSize)
|
||||
{
|
||||
uint8_t InnerHeaderSize;
|
||||
uint16_t InnerSize = SDP_GetLocalAttributeContainerSize(CurrAttribute, &InnerHeaderSize);
|
||||
|
||||
|
||||
/* Recursively search of the next element in the sequence, trying to match UUIDs with the UUID list */
|
||||
SDP_CheckUUIDMatch(UUIDList, TotalUUIDs, UUIDMatchFlags, CurrAttribute);
|
||||
|
||||
|
|
@ -536,10 +536,10 @@ static void SDP_CheckUUIDMatch(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
SequenceSize -= InnerHeaderSize + InnerSize;
|
||||
CurrAttribute += InnerHeaderSize + InnerSize;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Reads in the collection of Attribute ranges from the input buffer's Data Element Sequence container, into the given
|
||||
/** Reads in the collection of Attribute ranges from the input buffer's Data Element Sequence container, into the given
|
||||
* Attribute list for later use. Once complete, the input buffer pointer is advanced to the end of the Attribute container.
|
||||
*
|
||||
* \param[out] AttributeList Pointer to a buffer where the list of Attribute ranges are to be stored
|
||||
|
|
@ -561,10 +561,10 @@ static uint8_t SDP_GetAttributeList(uint16_t AttributeList[][2],
|
|||
/* Retrieve the size of the next Attribute in the container and get a pointer to the next free Attribute element in the list */
|
||||
uint16_t* CurrentAttributeRange = AttributeList[TotalAttributes++];
|
||||
uint8_t AttributeLength = SDP_GetDataElementSize(CurrentParameter, &ElementHeaderSize);
|
||||
|
||||
|
||||
/* Copy over the starting Attribute ID and (if it the current element is a range) the ending Attribute ID */
|
||||
memcpy(&CurrentAttributeRange[0], *CurrentParameter, AttributeLength);
|
||||
|
||||
|
||||
/* If the element is not an Attribute Range, copy over the starting ID to the ending ID to make a range of 1 */
|
||||
if (AttributeLength == 2)
|
||||
CurrentAttributeRange[1] = CurrentAttributeRange[0];
|
||||
|
|
@ -574,15 +574,15 @@ static uint8_t SDP_GetAttributeList(uint16_t AttributeList[][2],
|
|||
CurrentAttributeRange[1] = SwapEndian_16(CurrentAttributeRange[1]);
|
||||
|
||||
BT_SDP_DEBUG(2, "-- Attribute: 0x%04X-0x%04X", CurrentAttributeRange[0], CurrentAttributeRange[1]);
|
||||
|
||||
|
||||
AttributeIDListLength -= (AttributeLength + ElementHeaderSize);
|
||||
*CurrentParameter += AttributeLength;
|
||||
}
|
||||
|
||||
|
||||
return TotalAttributes;
|
||||
}
|
||||
|
||||
/** Reads in the collection of UUIDs from the input buffer's Data Element Sequence container, into the given
|
||||
/** Reads in the collection of UUIDs from the input buffer's Data Element Sequence container, into the given
|
||||
* UUID list for later use. Once complete, the input buffer pointer is advanced to the end of the UUID container.
|
||||
*
|
||||
* \param[out] UUIDList Pointer to a buffer where the list of UUIDs are to be stored
|
||||
|
|
@ -604,7 +604,7 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
/* Retrieve the size of the next UUID in the container and get a pointer to the next free UUID element in the list */
|
||||
uint8_t* CurrentUUID = UUIDList[TotalUUIDs++];
|
||||
uint8_t UUIDLength = SDP_GetDataElementSize(CurrentParameter, &ElementHeaderSize);
|
||||
|
||||
|
||||
/* Copy over UUID from the container to the free slot */
|
||||
if (UUIDLength <= 4)
|
||||
{
|
||||
|
|
@ -617,9 +617,9 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
else
|
||||
{
|
||||
/* Copy over full UUID */
|
||||
memcpy(CurrentUUID, *CurrentParameter, UUIDLength);
|
||||
memcpy(CurrentUUID, *CurrentParameter, UUIDLength);
|
||||
}
|
||||
|
||||
|
||||
BT_SDP_DEBUG(2, "-- UUID (%d): %02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
|
||||
UUIDLength,
|
||||
CurrentUUID[0], CurrentUUID[1], CurrentUUID[2], CurrentUUID[3],
|
||||
|
|
@ -631,7 +631,7 @@ static uint8_t SDP_GetUUIDList(uint8_t UUIDList[][UUID_SIZE_BYTES],
|
|||
ServicePatternLength -= (UUIDLength + ElementHeaderSize);
|
||||
*CurrentParameter += UUIDLength;
|
||||
}
|
||||
|
||||
|
||||
return TotalUUIDs;
|
||||
}
|
||||
|
||||
|
|
@ -647,7 +647,7 @@ static uint32_t SDP_GetLocalAttributeContainerSize(const void* const AttributeDa
|
|||
{
|
||||
/* Fetch the size of the Data Element structure from the header */
|
||||
uint8_t SizeIndex = (pgm_read_byte(AttributeData) & 0x07);
|
||||
|
||||
|
||||
uint32_t ElementValueSize;
|
||||
|
||||
/* Convert the Data Element size index into a size in bytes */
|
||||
|
|
@ -686,7 +686,7 @@ static uint32_t SDP_GetDataElementSize(const void** const DataElementHeader,
|
|||
uint8_t* const ElementHeaderSize)
|
||||
{
|
||||
/* Fetch the size of the Data Element structure from the header, increment the current buffer pos */
|
||||
uint8_t SizeIndex = (SDP_ReadData8(DataElementHeader) & 0x07);
|
||||
uint8_t SizeIndex = (SDP_ReadData8(DataElementHeader) & 0x07);
|
||||
|
||||
uint32_t ElementValueSize;
|
||||
|
||||
|
|
@ -710,6 +710,7 @@ static uint32_t SDP_GetDataElementSize(const void** const DataElementHeader,
|
|||
ElementValueSize = (1 << SizeIndex);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
return ElementValueSize;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -48,11 +48,11 @@
|
|||
|
||||
#include "BluetoothStack.h"
|
||||
#include "SDPServices.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
#define BT_SDP_DEBUG(l, s, ...) do { if (SDP_DEBUG_LEVEL >= l) printf_P(PSTR("(SDP) " s "\r\n"), ##__VA_ARGS__); } while (0)
|
||||
#define SDP_DEBUG_LEVEL 0
|
||||
|
||||
|
||||
#define SDP_PDU_ERRORRESPONSE 0x01
|
||||
#define SDP_PDU_SERVICESEARCHREQUEST 0x02
|
||||
#define SDP_PDU_SERVICESEARCHRESPONSE 0x03
|
||||
|
|
@ -103,7 +103,7 @@
|
|||
uint16_t TransactionID; /**< Unique transaction ID number to associate requests and responses */
|
||||
uint16_t ParameterLength; /**< Length of the data following the SDP header */
|
||||
} SDP_PDUHeader_t;
|
||||
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Writes 8 bits of raw data to the given buffer, incrementing the buffer position afterwards.
|
||||
*
|
||||
|
|
@ -116,7 +116,7 @@
|
|||
*((uint8_t*)*BufferPos) = Data;
|
||||
*BufferPos += sizeof(uint8_t);
|
||||
}
|
||||
|
||||
|
||||
/** Writes 16 bits of raw data to the given buffer, incrementing the buffer position afterwards.
|
||||
*
|
||||
* \param[in, out] BufferPos Current position in the buffer where the data is to be written to
|
||||
|
|
@ -127,7 +127,7 @@
|
|||
{
|
||||
*((uint16_t*)*BufferPos) = SwapEndian_16(Data);
|
||||
*BufferPos += sizeof(uint16_t);
|
||||
}
|
||||
}
|
||||
|
||||
/** Writes 32 bits of raw data to the given buffer, incrementing the buffer position afterwards.
|
||||
*
|
||||
|
|
@ -151,7 +151,7 @@
|
|||
{
|
||||
uint8_t Data = *((const uint8_t*)*BufferPos);
|
||||
*BufferPos += sizeof(uint8_t);
|
||||
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
|
|
@ -165,7 +165,7 @@
|
|||
{
|
||||
uint16_t Data = SwapEndian_16(*((const uint16_t*)*BufferPos));
|
||||
*BufferPos += sizeof(uint16_t);
|
||||
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
|
|
@ -179,13 +179,13 @@
|
|||
{
|
||||
uint32_t Data = SwapEndian_32(*((const uint32_t*)*BufferPos));
|
||||
*BufferPos += sizeof(uint32_t);
|
||||
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
/** Adds a new Data Element Sequence container with a 16-bit size header to the buffer. The buffer
|
||||
/** Adds a new Data Element Sequence container with a 16-bit size header to the buffer. The buffer
|
||||
* pointer's position is advanced past the added header once the element has been added. The returned
|
||||
* size header value is pre-zeroed out so that it can be incremented as data is placed into the Data
|
||||
* size header value is pre-zeroed out so that it can be incremented as data is placed into the Data
|
||||
* Element Sequence container.
|
||||
*
|
||||
* The total added size of the container header is three bytes, regardless of the size of its contents
|
||||
|
|
@ -199,12 +199,12 @@
|
|||
{
|
||||
SDP_WriteData8(BufferPos, (SDP_DATASIZE_Variable16Bit | SDP_DATATYPE_Sequence));
|
||||
|
||||
uint16_t* SizePos = *BufferPos;
|
||||
uint16_t* SizePos = *BufferPos;
|
||||
SDP_WriteData16(BufferPos, 0);
|
||||
|
||||
return SizePos;
|
||||
}
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SDP_ProcessPacket(void* Data,
|
||||
Bluetooth_Channel_t* const Channel);
|
||||
|
|
@ -247,3 +247,4 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -181,3 +181,4 @@ const ServiceAttributeTable_t PROGMEM SerialPort_Attribute_Table[] =
|
|||
|
||||
SERVICE_ATTRIBUTE_TABLE_TERMINATOR
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -35,22 +35,22 @@
|
|||
|
||||
#ifndef _SDPSERVICES_H_
|
||||
#define _SDPSERVICES_H_
|
||||
|
||||
|
||||
/* Includes: */
|
||||
#include "SDP.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Size of a full 128 bit UUID, in bytes. */
|
||||
#define UUID_SIZE_BYTES 16
|
||||
|
||||
|
||||
/** First 80 bits common to all standardized Bluetooth services. */
|
||||
#define BASE_80BIT_UUID 0x0000, 0x0010, 0x0080, {0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB}
|
||||
|
||||
|
||||
#define RFCOMM_UUID {SWAPENDIAN_32(0x00000003), BASE_80BIT_UUID}
|
||||
#define L2CAP_UUID {SWAPENDIAN_32(0x00000100), BASE_80BIT_UUID}
|
||||
#define SP_CLASS_UUID {SWAPENDIAN_32(0x00001101), BASE_80BIT_UUID}
|
||||
#define PUBLICBROWSEGROUP_CLASS_UUID {SWAPENDIAN_32(0x00001002), BASE_80BIT_UUID}
|
||||
|
||||
|
||||
#define SDP_ATTRIBUTE_ID_SERVICERECORDHANDLE 0x0000
|
||||
#define SDP_ATTRIBUTE_ID_SERVICECLASSIDS 0x0001
|
||||
#define SDP_ATTRIBUTE_ID_PROTOCOLDESCRIPTORLIST 0x0004
|
||||
|
|
@ -58,10 +58,10 @@
|
|||
#define SDP_ATTRIBUTE_ID_LANGUAGEBASEATTROFFSET 0x0006
|
||||
#define SDP_ATTRIBUTE_ID_SERVICENAME 0x0100
|
||||
#define SDP_ATTRIBUTE_ID_SERVICEDESCRIPTION 0x0101
|
||||
|
||||
|
||||
/** Terminator for a service attribute table of type \ref ServiceAttributeTable_t. */
|
||||
#define SERVICE_ATTRIBUTE_TABLE_TERMINATOR {.Data = NULL}
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a UUID value structure. This struct can be used to hold full 128-bit UUIDs. */
|
||||
typedef struct
|
||||
|
|
@ -72,7 +72,7 @@
|
|||
uint16_t D; /**< Bits 64-79 of the UUID. */
|
||||
uint8_t E[6]; /**< Bits 80-128 of the UUID. */
|
||||
} UUID_t;
|
||||
|
||||
|
||||
/** Structure for the association of attribute ID values to an attribute value in FLASH. A table of these
|
||||
* structures can then be built up for each supported UUID service within the device.
|
||||
*
|
||||
|
|
@ -111,7 +111,7 @@
|
|||
uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_UUID | SDP_DATASIZE_128Bit) */
|
||||
UUID_t UUID; /**< UUID to store in the list Data Element */
|
||||
} ItemUUID_t;
|
||||
|
||||
|
||||
/** Structure for a list of Data Elements Sequences containing UUID Data Elements, for service attributes requiring
|
||||
* protocol lists.
|
||||
*/
|
||||
|
|
@ -119,7 +119,7 @@
|
|||
{
|
||||
uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */
|
||||
uint8_t Size; /**< Size of the inner Data Element sequence */
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */
|
||||
|
|
@ -133,14 +133,14 @@
|
|||
{
|
||||
uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */
|
||||
uint8_t Size; /**< Size of the inner Data Element sequence */
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */
|
||||
Item8Bit_t Param; /**< 8-Bit Parameter associated with the service */
|
||||
} Protocol;
|
||||
} ItemProtocol_8BitParam_t;
|
||||
|
||||
|
||||
/** Structure for a list of Data Elements Sequences containing UUID Data Elements and an 16-bit param value, for service
|
||||
* attributes requiring extended protocol lists containing an 16-bit value.
|
||||
*/
|
||||
|
|
@ -148,7 +148,7 @@
|
|||
{
|
||||
uint8_t Header; /**< Data Element header, should be (SDP_DATATYPE_Sequence | SDP_DATASIZE_Variable8Bit) */
|
||||
uint8_t Size; /**< Size of the inner Data Element sequence */
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
ItemUUID_t UUID; /**< UUID to store in the protocol list Data Element sequence */
|
||||
|
|
@ -165,9 +165,10 @@
|
|||
Item16Bit_t EncodingID; /**< Encoding used for the current language */
|
||||
Item16Bit_t OffsetID; /**< Attribute offset added to all strings using this language within the service */
|
||||
} ItemLangEncoding_t;
|
||||
|
||||
|
||||
/* External Variables: */
|
||||
extern const ServiceAttributeTable_t SerialPort_Attribute_Table[];
|
||||
extern const ServiceAttributeTable_t PnP_Attribute_Table[];
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -143,7 +143,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -156,7 +156,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -270,7 +270,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -283,7 +283,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -295,7 +295,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -307,7 +307,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -330,7 +330,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -364,7 +364,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -398,7 +398,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -427,7 +427,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -446,10 +446,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -514,11 +514,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -545,9 +545,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -645,14 +645,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -674,7 +674,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -718,3 +718,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
uint8_t ConfigDescriptorData[512];
|
||||
void* CurrConfigLocation = ConfigDescriptorData;
|
||||
uint16_t CurrConfigBytesRem;
|
||||
|
||||
|
||||
USB_Descriptor_Interface_t* HIDInterface = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
|
||||
|
|
@ -79,7 +79,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
* but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */
|
||||
if (DataINEndpoint)
|
||||
break;
|
||||
|
||||
|
||||
/* Get the next HID interface from the configuration descriptor */
|
||||
if (USB_GetNextDescriptorComp(&CurrConfigBytesRem, &CurrConfigLocation,
|
||||
DComp_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
|
||||
|
|
@ -87,17 +87,17 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
/* Descriptor not found, error out */
|
||||
return NoCompatibleInterfaceFound;
|
||||
}
|
||||
|
||||
|
||||
/* Save the interface in case we need to refer back to it later */
|
||||
HIDInterface = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t);
|
||||
|
||||
/* Clear any found endpoints */
|
||||
DataOUTEndpoint = NULL;
|
||||
|
||||
|
||||
/* Skip the remainder of the loop as we have not found an endpoint yet */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the endpoint address from the endpoint descriptor */
|
||||
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t);
|
||||
|
||||
|
|
@ -107,20 +107,20 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
else
|
||||
DataOUTEndpoint = EndpointData;
|
||||
}
|
||||
|
||||
|
||||
/* Configure the HID data IN pipe */
|
||||
Pipe_ConfigurePipe(HID_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
|
||||
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS);
|
||||
|
||||
|
||||
/* Check if the HID interface contained an optional OUT data endpoint */
|
||||
if (DataOUTEndpoint)
|
||||
{
|
||||
/* Configure the HID data OUT pipe */
|
||||
Pipe_ConfigurePipe(HID_DATA_OUT_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT,
|
||||
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Valid data found, return success */
|
||||
return SuccessfulConfigRead;
|
||||
}
|
||||
|
|
@ -145,7 +145,7 @@ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
|
|||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
|
@ -176,3 +176,4 @@ uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor)
|
|||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,19 +38,19 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "GenericHIDHost.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Interface Class value for the Human Interface Device class. */
|
||||
#define HID_CLASS 0x03
|
||||
|
||||
/** Pipe number for the HID data IN pipe. */
|
||||
#define HID_DATA_IN_PIPE 1
|
||||
|
||||
|
||||
/** Pipe number for the HID data OUT pipe. */
|
||||
#define HID_DATA_OUT_PIPE 2
|
||||
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the possible return codes of the \ref ProcessConfigurationDescriptor() function. */
|
||||
enum GenericHIDHost_GetConfigDescriptorDataCodes_t
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
DescriptorTooLarge = 2, /**< The device's Configuration Descriptor is too large to process */
|
||||
InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */
|
||||
NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */
|
||||
};
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint8_t ProcessConfigurationDescriptor(void);
|
||||
|
|
@ -69,3 +69,4 @@
|
|||
uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the GenericHIDHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "GenericHIDHost.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
|
@ -137,10 +137,10 @@ void ReadNextReport(void)
|
|||
{
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Ensure pipe contains data before trying to read from it */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
|
|
@ -148,17 +148,17 @@ void ReadNextReport(void)
|
|||
|
||||
/* Read in HID report data */
|
||||
Pipe_Read_Stream_LE(&ReportINData, sizeof(ReportINData));
|
||||
|
||||
|
||||
/* Print report data through the serial port */
|
||||
for (uint16_t CurrByte = 0; CurrByte < sizeof(ReportINData); CurrByte++)
|
||||
printf_P(PSTR("0x%02X "), ReportINData[CurrByte]);
|
||||
|
||||
|
||||
puts_P(PSTR("\r\n"));
|
||||
}
|
||||
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
|
||||
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
}
|
||||
|
|
@ -177,7 +177,7 @@ void WriteNextReport(uint8_t* ReportOUTData,
|
|||
{
|
||||
/* Select the HID data OUT pipe */
|
||||
Pipe_SelectPipe(HID_DATA_OUT_PIPE);
|
||||
|
||||
|
||||
/* Not all HID devices have an OUT endpoint (some require OUT reports to be sent over the
|
||||
* control endpoint instead) - check to see if the OUT endpoint has been initialized */
|
||||
if (Pipe_IsConfigured() && (ReportType == REPORT_TYPE_OUT))
|
||||
|
|
@ -189,17 +189,17 @@ void WriteNextReport(uint8_t* ReportOUTData,
|
|||
{
|
||||
/* Refreeze the data OUT pipe */
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* If the report index is used, send it before the report data */
|
||||
if (ReportIndex)
|
||||
Pipe_Write_Byte(ReportIndex);
|
||||
|
||||
/* Write out HID report data */
|
||||
Pipe_Write_Stream_LE(ReportOUTData, ReportLength);
|
||||
|
||||
Pipe_Write_Stream_LE(ReportOUTData, ReportLength);
|
||||
|
||||
/* Clear the OUT endpoint, send last data packet */
|
||||
Pipe_ClearOUT();
|
||||
|
||||
|
|
@ -238,7 +238,7 @@ void HID_Host_Task(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
puts_P(PSTR("Getting Config Data.\r\n"));
|
||||
|
||||
|
||||
/* Get and process the configuration descriptor data */
|
||||
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
||||
{
|
||||
|
|
@ -248,7 +248,7 @@ void HID_Host_Task(void)
|
|||
puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
|
||||
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error status */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
|
@ -265,12 +265,12 @@ void HID_Host_Task(void)
|
|||
|
||||
/* Indicate error status */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
||||
/* Wait until USB device disconnected */
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
puts_P(PSTR("HID Device Enumerated.\r\n"));
|
||||
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
|
@ -281,3 +281,4 @@ void HID_Host_Task(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -49,9 +49,9 @@
|
|||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialStream.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
|
||||
#include "ConfigDescriptor.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** HID Class specific request to send a HID report to the device. */
|
||||
#define REQ_SetReport 0x09
|
||||
|
|
@ -67,7 +67,7 @@
|
|||
|
||||
/** 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)
|
||||
|
||||
|
||||
/** HID Report Type to indicate an IN report. */
|
||||
#define REPORT_TYPE_IN 1
|
||||
|
||||
|
|
@ -76,11 +76,11 @@
|
|||
|
||||
/** HID Report Type to indicate a FEATURE report. */
|
||||
#define REPORT_TYPE_FEATURE 3
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void HID_Host_Task(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
|
|
@ -93,5 +93,6 @@
|
|||
const uint8_t ReportIndex,
|
||||
const uint8_t ReportType,
|
||||
uint16_t ReportLength);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Generic HID Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,14 +41,14 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Generic HID host demonstration application. This gives a simple reference
|
||||
* application for implementing a Generic HID USB host, for any device implementing
|
||||
* the HID profile.
|
||||
*
|
||||
* Received reports from the attached device are printed to the serial port.
|
||||
*
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||
|
|
@ -61,3 +61,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -134,7 +134,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -147,7 +147,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -505,11 +505,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -636,14 +636,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
uint8_t ConfigDescriptorData[512];
|
||||
void* CurrConfigLocation = ConfigDescriptorData;
|
||||
uint16_t CurrConfigBytesRem;
|
||||
|
||||
|
||||
USB_Descriptor_Interface_t* HIDInterface = NULL;
|
||||
USB_Descriptor_HID_t* HIDDescriptor = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||
|
|
@ -95,12 +95,12 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
}
|
||||
|
||||
/* Save the HID descriptor for later use */
|
||||
HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t);
|
||||
HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t);
|
||||
|
||||
/* Skip the remainder of the loop as we have not found an endpoint yet */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the endpoint address from the endpoint descriptor */
|
||||
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t);
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
|
||||
DataINEndpoint = EndpointData;
|
||||
}
|
||||
|
||||
|
||||
/* Configure the HID data IN pipe */
|
||||
Pipe_ConfigurePipe(JOYSTICK_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
|
||||
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
|
|
@ -140,7 +140,7 @@ uint8_t DComp_NextJoystickInterface(void* CurrentDescriptor)
|
|||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
@ -181,5 +181,6 @@ uint8_t DComp_NextHID(void* CurrentDescriptor)
|
|||
if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_HID)
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
else
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,9 +38,9 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "HIDReport.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Interface Class value for the Human Interface Device class. */
|
||||
#define JOYSTICK_CLASS 0x03
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
/** Descriptor header type constant for a HID report descriptor. */
|
||||
#define DTYPE_Report 0x22
|
||||
|
||||
|
||||
/** Pipe number for the joystick report data pipe. */
|
||||
#define JOYSTICK_DATA_IN_PIPE 1
|
||||
|
||||
|
|
@ -78,3 +78,4 @@
|
|||
uint8_t DComp_NextHID(void* CurrentDescriptor);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -46,7 +46,7 @@ uint8_t GetHIDReportData(void)
|
|||
{
|
||||
/* Create a buffer big enough to hold the entire returned HID report */
|
||||
uint8_t HIDReportData[HIDReportSize];
|
||||
|
||||
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE),
|
||||
|
|
@ -66,7 +66,7 @@ uint8_t GetHIDReportData(void)
|
|||
/* Send the HID report to the parser for processing */
|
||||
if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful)
|
||||
return ParseError;
|
||||
|
||||
|
||||
return ParseSuccessful;
|
||||
}
|
||||
|
||||
|
|
@ -100,7 +100,7 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
|||
/* If a collection with the joystick usage was not found, indicate that we are not interested in this item */
|
||||
if (!IsJoystick)
|
||||
return false;
|
||||
|
||||
|
||||
/* Check the attributes of the current joystick item - see if we are interested in it or not;
|
||||
* only store BUTTON and GENERIC_DESKTOP_CONTROL items into the Processed HID Report
|
||||
* structure to save RAM and ignore the rest
|
||||
|
|
@ -108,3 +108,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
|||
return ((CurrentItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) ||
|
||||
(CurrentItem->Attributes.Usage.Page == USAGE_PAGE_GENERIC_DCTRL));
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/Host/HIDParser.h>
|
||||
|
||||
|
||||
#include "JoystickHostWithParser.h"
|
||||
|
||||
/* Macros: */
|
||||
|
|
@ -66,16 +66,16 @@
|
|||
ParseError = 1, /**< Failed to fully process the HID report descriptor */
|
||||
ParseControlError = 2, /**< Control error occurred while trying to read the device HID descriptor */
|
||||
};
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a HID descriptor. */
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
|
||||
|
||||
|
||||
uint16_t HIDSpec; /**< Implemented HID class specification, in BCD encoded format */
|
||||
uint8_t CountryCode; /**< Country code value for localized hardware */
|
||||
|
||||
|
||||
uint8_t TotalHIDDescriptors; /**< Total number of HID report descriptors in the current interface */
|
||||
|
||||
uint8_t HIDReportType; /**< HID report type of the first HID report descriptor */
|
||||
|
|
@ -88,7 +88,8 @@
|
|||
|
||||
/* Function Prototypes: */
|
||||
uint8_t GetHIDReportData(void);
|
||||
|
||||
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the JoystickHostWithParser demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "JoystickHostWithParser.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
|
@ -64,7 +64,7 @@ void SetupHardware(void)
|
|||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
|
||||
/* Hardware Initialization */
|
||||
SerialStream_Init(9600, false);
|
||||
LEDs_Init();
|
||||
|
|
@ -118,7 +118,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode, const uint8
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ void Joystick_HID_Task(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
puts_P(PSTR("Getting Config Data.\r\n"));
|
||||
|
||||
|
||||
/* Get and process the configuration descriptor data */
|
||||
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
||||
{
|
||||
|
|
@ -144,7 +144,7 @@ void Joystick_HID_Task(void)
|
|||
puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
|
||||
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
|
@ -152,7 +152,7 @@ void Joystick_HID_Task(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */
|
||||
if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
|
|
@ -161,12 +161,12 @@ void Joystick_HID_Task(void)
|
|||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
||||
/* Wait until USB device disconnected */
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("Processing HID Report (Size %d Bytes).\r\n"), HIDReportSize);
|
||||
|
||||
/* Get and process the device's first HID report descriptor */
|
||||
|
|
@ -178,21 +178,21 @@ void Joystick_HID_Task(void)
|
|||
puts_P(PSTR("Not a valid Joystick." ESC_FG_WHITE));
|
||||
else
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
||||
/* Wait until USB device disconnected */
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports);
|
||||
|
||||
for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++)
|
||||
{
|
||||
HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i];
|
||||
|
||||
|
||||
uint8_t ReportSizeInBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In];
|
||||
uint8_t ReportSizeOutBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out];
|
||||
uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature];
|
||||
|
|
@ -211,9 +211,9 @@ void Joystick_HID_Task(void)
|
|||
break;
|
||||
case HOST_STATE_Configured:
|
||||
/* Select and unfreeze joystick data pipe */
|
||||
Pipe_SelectPipe(JOYSTICK_DATA_IN_PIPE);
|
||||
Pipe_SelectPipe(JOYSTICK_DATA_IN_PIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
|
||||
/* Check to see if a packet has been received */
|
||||
if (Pipe_IsINReceived())
|
||||
{
|
||||
|
|
@ -225,11 +225,11 @@ void Joystick_HID_Task(void)
|
|||
|
||||
/* Load in the joystick report */
|
||||
Pipe_Read_Stream_LE(JoystickReport, Pipe_BytesInPipe());
|
||||
|
||||
|
||||
/* Process the read in joystick report from the device */
|
||||
ProcessJoystickReport(JoystickReport);
|
||||
}
|
||||
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
|
@ -254,7 +254,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
|
|||
{
|
||||
/* Create a temporary item pointer to the next report item */
|
||||
HID_ReportItem_t* ReportItem = &HIDReportInfo.ReportItems[ReportNumber];
|
||||
|
||||
|
||||
bool FoundData;
|
||||
|
||||
if ((ReportItem->Attributes.Usage.Page == USAGE_PAGE_BUTTON) &&
|
||||
|
|
@ -262,7 +262,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
|
|||
{
|
||||
/* Get the joystick button value */
|
||||
FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem);
|
||||
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
|
@ -278,13 +278,13 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
|
|||
{
|
||||
/* Get the joystick relative position value */
|
||||
FoundData = USB_GetHIDReportItemInfo(JoystickReport, ReportItem);
|
||||
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
|
||||
int16_t DeltaMovement = HID_ALIGN_DATA(ReportItem, int16_t);
|
||||
|
||||
|
||||
/* Check to see if a (non-zero) delta movement has been indicated */
|
||||
if (DeltaMovement)
|
||||
{
|
||||
|
|
@ -296,7 +296,7 @@ void ProcessJoystickReport(uint8_t* JoystickReport)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Display the button information on the board LEDs */
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -49,7 +49,7 @@
|
|||
#include <LUFA/Drivers/Peripheral/SerialStream.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "ConfigDescriptor.h"
|
||||
#include "HIDReport.h"
|
||||
|
||||
|
|
@ -69,7 +69,7 @@
|
|||
/* Function Prototypes: */
|
||||
void Joystick_HID_Task(void);
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
|
|
@ -80,3 +80,4 @@
|
|||
void ProcessJoystickReport(uint8_t* JoystickReport);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Joystick Host With HID Descriptor Parser Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,19 +41,19 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Joystick host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Joystick host, for USB joysticks using
|
||||
* the standard joystick HID profile. It uses a HID parser for the HID
|
||||
* reports, allowing for correct operation across all USB joysticks. This
|
||||
* demo supports joysticks with a single HID report.
|
||||
*
|
||||
*
|
||||
* Joystick movement and button presses are displayed on the board LEDs.
|
||||
* On connection to a USB joystick, the report items will be processed and
|
||||
* printed as a formatted list through the USART before the joystick is
|
||||
* fully enumerated.
|
||||
*
|
||||
*
|
||||
* Currently only single interface joysticks are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
|
|
@ -68,3 +68,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
uint8_t ConfigDescriptorData[512];
|
||||
void* CurrConfigLocation = ConfigDescriptorData;
|
||||
uint16_t CurrConfigBytesRem;
|
||||
|
||||
|
||||
USB_Descriptor_Interface_t* HIDInterface = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||
|
||||
|
|
@ -66,7 +66,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
default:
|
||||
return ControlError;
|
||||
}
|
||||
|
||||
|
||||
while (!(DataINEndpoint))
|
||||
{
|
||||
/* See if we've found a likely compatible interface, and if there is an endpoint within that interface */
|
||||
|
|
@ -88,7 +88,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
/* Skip the remainder of the loop as we have not found an endpoint yet */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the endpoint address from the endpoint descriptor */
|
||||
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t);
|
||||
|
||||
|
|
@ -96,7 +96,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
|
||||
DataINEndpoint = EndpointData;
|
||||
}
|
||||
|
||||
|
||||
/* Configure the HID data IN pipe */
|
||||
Pipe_ConfigurePipe(KEYBOARD_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
|
||||
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
|
|
@ -125,7 +125,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
|
|||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
@ -152,3 +152,4 @@ uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor)
|
|||
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,16 +38,16 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "KeyboardHost.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Interface Class value for the Human Interface Device class. */
|
||||
#define KEYBOARD_CLASS 0x03
|
||||
|
||||
/** Interface Protocol value for a Boot Protocol Keyboard compliant device. */
|
||||
#define KEYBOARD_PROTOCOL 0x01
|
||||
|
||||
|
||||
/** Pipe number for the keyboard data IN pipe. */
|
||||
#define KEYBOARD_DATA_IN_PIPE 1
|
||||
|
||||
|
|
@ -64,8 +64,9 @@
|
|||
|
||||
/* Function Prototypes: */
|
||||
uint8_t ProcessConfigurationDescriptor(void);
|
||||
|
||||
|
||||
uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor);
|
||||
uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the KeyboardHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "KeyboardHost.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
|
@ -129,9 +129,9 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
void ReadNextReport(void)
|
||||
{
|
||||
USB_KeyboardReport_Data_t KeyboardReport;
|
||||
|
||||
|
||||
/* Select keyboard data pipe */
|
||||
Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE);
|
||||
Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE);
|
||||
|
||||
/* Unfreeze keyboard data pipe */
|
||||
Pipe_Unfreeze();
|
||||
|
|
@ -141,10 +141,10 @@ void ReadNextReport(void)
|
|||
{
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Ensure pipe contains data before trying to read from it */
|
||||
if (Pipe_IsReadWriteAllowed())
|
||||
{
|
||||
|
|
@ -153,13 +153,13 @@ void ReadNextReport(void)
|
|||
|
||||
/* Indicate if the modifier byte is non-zero (special key such as shift is being pressed) */
|
||||
LEDs_ChangeLEDs(LEDS_LED1, (KeyboardReport.Modifier) ? LEDS_LED1 : 0);
|
||||
|
||||
|
||||
/* Check if a key has been pressed */
|
||||
if (KeyboardReport.KeyCode)
|
||||
{
|
||||
/* Toggle status LED to indicate keypress */
|
||||
LEDs_ToggleLEDs(LEDS_LED2);
|
||||
|
||||
|
||||
char PressedKey = 0;
|
||||
|
||||
/* Retrieve pressed key character if alphanumeric */
|
||||
|
|
@ -168,16 +168,16 @@ void ReadNextReport(void)
|
|||
else if ((KeyboardReport.KeyCode[0] >= 0x1E) && (KeyboardReport.KeyCode[0] <= 0x27))
|
||||
PressedKey = (KeyboardReport.KeyCode[0] - 0x1E) + '0';
|
||||
else if (KeyboardReport.KeyCode[0] == 0x2C)
|
||||
PressedKey = ' ';
|
||||
PressedKey = ' ';
|
||||
else if (KeyboardReport.KeyCode[0] == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
|
||||
/* Print the pressed key character out through the serial port if valid */
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
|
||||
|
|
@ -196,7 +196,7 @@ void Keyboard_HID_Task(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
puts_P(PSTR("Getting Config Data.\r\n"));
|
||||
|
||||
|
||||
/* Get and process the configuration descriptor data */
|
||||
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
||||
{
|
||||
|
|
@ -206,7 +206,7 @@ void Keyboard_HID_Task(void)
|
|||
puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
|
||||
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error status */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
|
@ -214,7 +214,7 @@ void Keyboard_HID_Task(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */
|
||||
if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
|
|
@ -228,7 +228,7 @@ void Keyboard_HID_Task(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* HID class request to set the keyboard protocol to the Boot Protocol */
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
|
|
@ -250,7 +250,7 @@ void Keyboard_HID_Task(void)
|
|||
|
||||
/* Indicate error status */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
||||
/* Wait until USB device disconnected */
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
|
|
@ -267,3 +267,4 @@ void Keyboard_HID_Task(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -49,9 +49,9 @@
|
|||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialStream.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
|
||||
#include "ConfigDescriptor.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** HID Class Specific request to set the report protocol mode. */
|
||||
#define REQ_SetProtocol 0x0B
|
||||
|
|
@ -76,11 +76,11 @@
|
|||
uint8_t Reserved; /**< Reserved for OEM use, always set to 0 */
|
||||
uint8_t KeyCode[6]; /**< Key codes of the currently pressed keys */
|
||||
} USB_KeyboardReport_Data_t;
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void Keyboard_HID_Task(void);
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_HostError(const uint8_t ErrorCode);
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
|
|
@ -89,5 +89,6 @@
|
|||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
void ReadNextReport(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Keyboard Host Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,21 +41,21 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Keyboard host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB keyboard, for USB keyboards using
|
||||
* the standard keyboard HID profile.
|
||||
*
|
||||
*
|
||||
* Pressed alpha-numeric, enter or space key is transmitted through the serial
|
||||
* USART at serial settings 9600, 8, N, 1.
|
||||
*
|
||||
*
|
||||
* This uses a naive method where the keyboard is set to Boot Protocol mode, so
|
||||
* that the report structure is fixed and known. A better implementation
|
||||
* uses the HID report parser for correct report data processing across
|
||||
* all compatible mice with advanced characteristics, as shown in the
|
||||
* KeyboardHostWithParser demo application.
|
||||
*
|
||||
*
|
||||
* Currently only single interface keyboards are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
|
|
@ -70,3 +70,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -134,7 +134,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -147,7 +147,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -261,7 +261,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -274,7 +274,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -286,7 +286,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -298,7 +298,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -321,7 +321,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -355,7 +355,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -389,7 +389,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -418,7 +418,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -437,10 +437,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -505,11 +505,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -536,9 +536,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -636,14 +636,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -665,7 +665,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -709,3 +709,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
uint8_t ConfigDescriptorData[512];
|
||||
void* CurrConfigLocation = ConfigDescriptorData;
|
||||
uint16_t CurrConfigBytesRem;
|
||||
|
||||
|
||||
USB_Descriptor_Interface_t* HIDInterface = NULL;
|
||||
USB_Descriptor_HID_t* HIDDescriptor = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||
|
|
@ -82,7 +82,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
/* Descriptor not found, error out */
|
||||
return NoCompatibleInterfaceFound;
|
||||
}
|
||||
|
||||
|
||||
/* Save the interface in case we need to refer back to it later */
|
||||
HIDInterface = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t);
|
||||
|
||||
|
|
@ -93,14 +93,14 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
/* Descriptor not found, error out */
|
||||
return NoCompatibleInterfaceFound;
|
||||
}
|
||||
|
||||
|
||||
/* Save the HID descriptor for later use */
|
||||
HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t);
|
||||
|
||||
HIDDescriptor = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_HID_t);
|
||||
|
||||
/* Skip the remainder of the loop as we have not found an endpoint yet */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the endpoint address from the endpoint descriptor */
|
||||
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t);
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
if (EndpointData->EndpointAddress & ENDPOINT_DESCRIPTOR_DIR_IN)
|
||||
DataINEndpoint = EndpointData;
|
||||
}
|
||||
|
||||
|
||||
/* Configure the HID data IN pipe */
|
||||
Pipe_ConfigurePipe(KEYBOARD_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
|
||||
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
|
|
@ -140,7 +140,7 @@ uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor)
|
|||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
@ -183,5 +183,6 @@ uint8_t DComp_NextHID(void* CurrentDescriptor)
|
|||
else if (DESCRIPTOR_TYPE(CurrentDescriptor) == DTYPE_Interface)
|
||||
return DESCRIPTOR_SEARCH_Fail;
|
||||
else
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,9 +38,9 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "HIDReport.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Interface Class value for the Human Interface Device class. */
|
||||
#define KEYBOARD_CLASS 0x03
|
||||
|
|
@ -53,7 +53,7 @@
|
|||
|
||||
/** Descriptor header type constant for a HID report descriptor. */
|
||||
#define DTYPE_Report 0x22
|
||||
|
||||
|
||||
/** Pipe number for the keyboard report data pipe. */
|
||||
#define KEYBOARD_DATA_IN_PIPE 1
|
||||
|
||||
|
|
@ -74,5 +74,6 @@
|
|||
uint8_t DComp_NextKeyboardInterface(void* CurrentDescriptor);
|
||||
uint8_t DComp_NextKeyboardInterfaceDataEndpoint(void* CurrentDescriptor);
|
||||
uint8_t DComp_NextHID(void* CurrentDescriptor);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -46,7 +46,7 @@ uint8_t GetHIDReportData(void)
|
|||
{
|
||||
/* Create a buffer big enough to hold the entire returned HID report */
|
||||
uint8_t HIDReportData[HIDReportSize];
|
||||
|
||||
|
||||
USB_ControlRequest = (USB_Request_Header_t)
|
||||
{
|
||||
.bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_INTERFACE),
|
||||
|
|
@ -66,7 +66,7 @@ uint8_t GetHIDReportData(void)
|
|||
/* Send the HID report to the parser for processing */
|
||||
if (USB_ProcessHIDReport(HIDReportData, HIDReportSize, &HIDReportInfo) != HID_PARSE_Successful)
|
||||
return ParseError;
|
||||
|
||||
|
||||
return ParseSuccessful;
|
||||
}
|
||||
|
||||
|
|
@ -87,3 +87,4 @@ bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem)
|
|||
*/
|
||||
return (CurrentItem->Attributes.Usage.Page == USAGE_PAGE_KEYBOARD);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/Host/HIDParser.h>
|
||||
|
||||
|
||||
#include "KeyboardHostWithParser.h"
|
||||
|
||||
/* Macros: */
|
||||
|
|
@ -54,16 +54,16 @@
|
|||
ParseError = 1, /**< Failed to fully process the HID report descriptor */
|
||||
ParseControlError = 2, /**< Control error occurred while trying to read the device HID descriptor */
|
||||
};
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a HID descriptor. */
|
||||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Header_t Header; /**< Regular descriptor header containing the descriptor's type and length */
|
||||
|
||||
|
||||
uint16_t HIDSpec; /**< Implemented HID class specification, in BCD encoded format */
|
||||
uint8_t CountryCode; /**< Country code value for localized hardware */
|
||||
|
||||
|
||||
uint8_t TotalHIDDescriptors; /**< Total number of HID report descriptors in the current interface */
|
||||
|
||||
uint8_t HIDReportType; /**< HID report type of the first HID report descriptor */
|
||||
|
|
@ -78,5 +78,6 @@
|
|||
uint8_t GetHIDReportData(void);
|
||||
|
||||
bool CALLBACK_HIDParser_FilterHIDReportItem(HID_ReportItem_t* const CurrentItem);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the KeyboardHostWithParser demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "KeyboardHostWithParser.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
|
@ -119,7 +119,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -134,7 +134,7 @@ void Keyboard_HID_Task(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
puts_P(PSTR("Getting Config Data.\r\n"));
|
||||
|
||||
|
||||
/* Get and process the configuration descriptor data */
|
||||
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
||||
{
|
||||
|
|
@ -144,7 +144,7 @@ void Keyboard_HID_Task(void)
|
|||
puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
|
||||
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
|
@ -167,9 +167,9 @@ void Keyboard_HID_Task(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
printf_P(PSTR("Processing HID Report (Size %d Bytes).\r\n"), HIDReportSize);
|
||||
|
||||
|
||||
/* Get and process the device's first HID report descriptor */
|
||||
if ((ErrorCode = GetHIDReportData()) != ParseSuccessful)
|
||||
{
|
||||
|
|
@ -179,13 +179,13 @@ void Keyboard_HID_Task(void)
|
|||
puts_P(PSTR("Not a valid Keyboard." ESC_FG_WHITE));
|
||||
else
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
||||
/* Wait until USB device disconnected */
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
printf("Total Reports: %d\r\n", HIDReportInfo.TotalDeviceReports);
|
||||
|
|
@ -193,7 +193,7 @@ void Keyboard_HID_Task(void)
|
|||
for (uint8_t i = 0; i < HIDReportInfo.TotalDeviceReports; i++)
|
||||
{
|
||||
HID_ReportSizeInfo_t* CurrReportIDInfo = &HIDReportInfo.ReportIDSizes[i];
|
||||
|
||||
|
||||
uint8_t ReportSizeInBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_In];
|
||||
uint8_t ReportSizeOutBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Out];
|
||||
uint8_t ReportSizeFeatureBits = CurrReportIDInfo->ReportSizeBits[HID_REPORT_ITEM_Feature];
|
||||
|
|
@ -212,7 +212,7 @@ void Keyboard_HID_Task(void)
|
|||
break;
|
||||
case HOST_STATE_Configured:
|
||||
/* Select and unfreeze keyboard data pipe */
|
||||
Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE);
|
||||
Pipe_SelectPipe(KEYBOARD_DATA_IN_PIPE);
|
||||
Pipe_Unfreeze();
|
||||
|
||||
/* Check to see if a packet has been received */
|
||||
|
|
@ -226,11 +226,11 @@ void Keyboard_HID_Task(void)
|
|||
|
||||
/* Load in the keyboard report */
|
||||
Pipe_Read_Stream_LE(KeyboardReport, Pipe_BytesInPipe());
|
||||
|
||||
|
||||
/* Process the read in keyboard report from the device */
|
||||
ProcessKeyboardReport(KeyboardReport);
|
||||
}
|
||||
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
|
@ -262,11 +262,11 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport)
|
|||
{
|
||||
/* Retrieve the keyboard scan-code from the report data retrieved from the device */
|
||||
bool FoundData = USB_GetHIDReportItemInfo(KeyboardReport, ReportItem);
|
||||
|
||||
|
||||
/* For multi-report devices - if the requested data was not in the issued report, continue */
|
||||
if (!(FoundData))
|
||||
continue;
|
||||
|
||||
|
||||
/* Key code is an unsigned char in length, cast to the appropriate type */
|
||||
uint8_t KeyCode = (uint8_t)ReportItem->Value;
|
||||
|
||||
|
|
@ -284,17 +284,18 @@ void ProcessKeyboardReport(uint8_t* KeyboardReport)
|
|||
else if ((KeyCode >= 0x1E) && (KeyCode <= 0x27))
|
||||
PressedKey = (KeyCode - 0x1E) + '0';
|
||||
else if (KeyCode == 0x2C)
|
||||
PressedKey = ' ';
|
||||
PressedKey = ' ';
|
||||
else if (KeyCode == 0x28)
|
||||
PressedKey = '\n';
|
||||
|
||||
|
||||
/* Print the pressed key character out through the serial port if valid */
|
||||
if (PressedKey)
|
||||
putchar(PressedKey);
|
||||
}
|
||||
|
||||
|
||||
/* Once a scan-code is found, stop scanning through the report items */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -44,7 +44,7 @@
|
|||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialStream.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
|
||||
#include "ConfigDescriptor.h"
|
||||
#include "HIDReport.h"
|
||||
|
||||
|
|
@ -60,7 +60,7 @@
|
|||
|
||||
/** 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 Keyboard_HID_Task(void);
|
||||
void SetupHardware(void);
|
||||
|
|
@ -73,5 +73,6 @@
|
|||
void EVENT_USB_Host_DeviceEnumerationComplete(void);
|
||||
|
||||
void ProcessKeyboardReport(uint8_t* KeyboardReport);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||
* documentation pages. It is not a project source file.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Keyboard Host With HID Descriptor Parser Demo
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
|
@ -41,20 +41,20 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Keyboard host demonstration application. This gives a simple reference
|
||||
* application for implementing a USB Keyboard host, for USB keyboards using
|
||||
* the standard Keyboard HID profile. It uses a HID parser for the HID reports,
|
||||
* allowing for correct operation across all USB keyboards. This demo supports
|
||||
* keyboards with a single HID report.
|
||||
*
|
||||
*
|
||||
* Pressed alpha-numeric, enter or space key is transmitted through the serial
|
||||
* USART at serial settings 9600, 8, N, 1. On connection to a USB keyboard, the
|
||||
* report items will be processed and printed as a formatted list through the
|
||||
* USART before the keyboard is fully enumerated.
|
||||
*
|
||||
* Currently only single interface keyboards are supported.
|
||||
*
|
||||
* Currently only single interface keyboards are supported.
|
||||
*
|
||||
* \section SSec_Options Project Options
|
||||
*
|
||||
|
|
@ -68,3 +68,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -34,7 +34,7 @@
|
|||
* needed to communication with an attached USB device. Descriptors are special computer-readable structures
|
||||
* which the host requests upon device enumeration, to determine the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
|
||||
#include "ConfigDescriptor.h"
|
||||
|
||||
/** Reads and processes an attached device's descriptors, to determine compatibility and pipe configurations. This
|
||||
|
|
@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
uint8_t ConfigDescriptorData[512];
|
||||
void* CurrConfigLocation = ConfigDescriptorData;
|
||||
uint16_t CurrConfigBytesRem;
|
||||
|
||||
|
||||
USB_Descriptor_Interface_t* MIDIInterface = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
|
||||
|
|
@ -67,7 +67,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
default:
|
||||
return ControlError;
|
||||
}
|
||||
|
||||
|
||||
while (!(DataINEndpoint) || !(DataOUTEndpoint))
|
||||
{
|
||||
/* See if we've found a likely compatible interface, and if there is an endpoint within that interface */
|
||||
|
|
@ -93,7 +93,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
/* Skip the remainder of the loop as we have not found an endpoint yet */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the endpoint address from the endpoint descriptor */
|
||||
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t);
|
||||
|
||||
|
|
@ -103,7 +103,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
else
|
||||
DataOUTEndpoint = EndpointData;
|
||||
}
|
||||
|
||||
|
||||
/* Configure the MIDI data IN pipe */
|
||||
Pipe_ConfigurePipe(MIDI_DATA_IN_PIPE, EP_TYPE_BULK, PIPE_TOKEN_IN,
|
||||
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
|
|
@ -136,7 +136,7 @@ uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor)
|
|||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor)
|
|||
{
|
||||
uint8_t EndpointType = (DESCRIPTOR_CAST(CurrentDescriptor,
|
||||
USB_Descriptor_Endpoint_t).Attributes & EP_TYPE_MASK);
|
||||
|
||||
|
||||
/* Check the endpoint type, break out if correct BULK type endpoint found */
|
||||
if (EndpointType == EP_TYPE_BULK)
|
||||
return DESCRIPTOR_SEARCH_Found;
|
||||
|
|
@ -167,3 +167,4 @@ uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor)
|
|||
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -38,19 +38,19 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "MIDIHost.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Interface Class value for the MIDI Audio class. */
|
||||
#define MIDI_STREAMING_CLASS 0x01
|
||||
|
||||
|
||||
/** Interface Class value for the MIDI Audio Streaming subclass. */
|
||||
#define MIDI_STREAMING_SUBCLASS 0x03
|
||||
|
||||
/** Interface Class value for the MIDI Audio Streaming protocol. */
|
||||
#define MIDI_STREAMING_PROTOCOL 0x00
|
||||
|
||||
|
||||
/** Pipe number for the MIDI data IN pipe. */
|
||||
#define MIDI_DATA_IN_PIPE 1
|
||||
|
||||
|
|
@ -69,9 +69,10 @@
|
|||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint8_t ProcessConfigurationDescriptor(void);
|
||||
|
||||
uint8_t ProcessConfigurationDescriptor(void);
|
||||
|
||||
uint8_t DComp_NextMIDIStreamingInterface(void* CurrentDescriptor);
|
||||
uint8_t DComp_NextMIDIStreamingDataEndpoint(void* CurrentDescriptor);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the MIDIHost demo. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "MIDIHost.h"
|
||||
|
||||
/** Main program entry point. This routine configures the hardware required by the application, then
|
||||
|
|
@ -121,7 +121,7 @@ void EVENT_USB_Host_DeviceEnumerationFailed(const uint8_t ErrorCode,
|
|||
" -- Error Code %d\r\n"
|
||||
" -- Sub Error Code %d\r\n"
|
||||
" -- In State %d\r\n" ESC_FG_WHITE), ErrorCode, SubErrorCode, USB_HostState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
|
|
@ -137,7 +137,7 @@ void MIDI_Host_Task(void)
|
|||
{
|
||||
case HOST_STATE_Addressed:
|
||||
puts_P(PSTR("Getting Config Data.\r\n"));
|
||||
|
||||
|
||||
/* Get and process the configuration descriptor data */
|
||||
if ((ErrorCode = ProcessConfigurationDescriptor()) != SuccessfulConfigRead)
|
||||
{
|
||||
|
|
@ -147,7 +147,7 @@ void MIDI_Host_Task(void)
|
|||
puts_P(PSTR(ESC_FG_RED "Invalid Device.\r\n"));
|
||||
|
||||
printf_P(PSTR(" -- Error Code: %d\r\n" ESC_FG_WHITE), ErrorCode);
|
||||
|
||||
|
||||
/* Indicate error via status LEDs */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
|
@ -155,7 +155,7 @@ void MIDI_Host_Task(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Set the device configuration to the first configuration (rarely do devices use multiple configurations) */
|
||||
if ((ErrorCode = USB_Host_SetDeviceConfiguration(1)) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
|
|
@ -176,16 +176,16 @@ void MIDI_Host_Task(void)
|
|||
break;
|
||||
case HOST_STATE_Configured:
|
||||
Pipe_SelectPipe(MIDI_DATA_IN_PIPE);
|
||||
|
||||
|
||||
if (Pipe_IsINReceived())
|
||||
{
|
||||
USB_MIDI_EventPacket_t MIDIEvent;
|
||||
|
||||
|
||||
Pipe_Read_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
|
||||
|
||||
bool NoteOnEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_ON >> 4));
|
||||
bool NoteOffEvent = ((MIDIEvent.Command & 0x0F) == (MIDI_COMMAND_NOTE_OFF >> 4));
|
||||
|
||||
|
||||
if (NoteOnEvent || NoteOffEvent)
|
||||
{
|
||||
printf_P(PSTR("MIDI Note %s - Channel %d, Pitch %d, Velocity %d\r\n"), NoteOnEvent ? "On" : "Off",
|
||||
|
|
@ -195,19 +195,19 @@ void MIDI_Host_Task(void)
|
|||
|
||||
Pipe_ClearIN();
|
||||
}
|
||||
|
||||
|
||||
Pipe_SelectPipe(MIDI_DATA_OUT_PIPE);
|
||||
|
||||
|
||||
static uint8_t PrevJoystickStatus;
|
||||
|
||||
if (Pipe_IsOUTReady())
|
||||
{
|
||||
uint8_t MIDICommand = 0;
|
||||
uint8_t MIDIPitch;
|
||||
|
||||
|
||||
uint8_t JoystickStatus = Joystick_GetStatus();
|
||||
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
|
||||
|
||||
|
||||
/* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
|
||||
uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
||||
|
||||
|
|
@ -228,7 +228,7 @@ void MIDI_Host_Task(void)
|
|||
MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
MIDIPitch = 0x3E;
|
||||
}
|
||||
|
||||
|
||||
if (JoystickChanges & JOY_DOWN)
|
||||
{
|
||||
MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||
|
|
@ -248,19 +248,19 @@ void MIDI_Host_Task(void)
|
|||
{
|
||||
.CableNumber = 0,
|
||||
.Command = (MIDICommand >> 4),
|
||||
|
||||
|
||||
.Data1 = MIDICommand | Channel,
|
||||
.Data2 = MIDIPitch,
|
||||
.Data3 = MIDI_STANDARD_VELOCITY,
|
||||
.Data3 = MIDI_STANDARD_VELOCITY,
|
||||
};
|
||||
|
||||
|
||||
/* Write the MIDI event packet to the pipe */
|
||||
Pipe_Write_Stream_LE(&MIDIEvent, sizeof(MIDIEvent));
|
||||
|
||||
|
||||
/* Send the data in the pipe to the device */
|
||||
Pipe_ClearOUT();
|
||||
}
|
||||
|
||||
|
||||
/* Save previous joystick value for next joystick change detection */
|
||||
PrevJoystickStatus = JoystickStatus;
|
||||
}
|
||||
|
|
@ -268,3 +268,4 @@ void MIDI_Host_Task(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue