Conversion of old incomplete SideShow demo to new APIs.

pull/1469/head
Dean Camera 15 years ago
parent bf041e8bbf
commit f51017f8fb

@ -154,7 +154,7 @@ USB_OSCompatibleIDDescriptor_t PROGMEM DevCompatIDs =
SubCompatibleID: "UNIV1"}
};
uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
{
const uint8_t DescriptorType = (wValue >> 8);
const uint8_t DescriptorNumber = (wValue & 0xFF);
@ -165,30 +165,30 @@ uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** c
switch (DescriptorType)
{
case DTYPE_Device:
Address = DESCRIPTOR_ADDRESS(DeviceDescriptor);
Address = (void*)&DeviceDescriptor;
Size = sizeof(USB_Descriptor_Device_t);
break;
case DTYPE_Configuration:
Address = DESCRIPTOR_ADDRESS(ConfigurationDescriptor);
Address = (void*)&ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
break;
case DTYPE_String:
switch (DescriptorNumber)
{
case 0x00:
Address = DESCRIPTOR_ADDRESS(LanguageString);
Address = (void*)&LanguageString;
Size = pgm_read_byte(&LanguageString.Header.Size);
break;
case 0x01:
Address = DESCRIPTOR_ADDRESS(ManufacturerString);
Address = (void*)&ManufacturerString;
Size = pgm_read_byte(&ManufacturerString.Header.Size);
break;
case 0x02:
Address = DESCRIPTOR_ADDRESS(ProductString);
Address = (void*)&ProductString;
Size = pgm_read_byte(&ProductString.Header.Size);
break;
case 0x03:
Address = DESCRIPTOR_ADDRESS(SerialNumberString);
Address = (void*)&SerialNumberString;
Size = pgm_read_byte(&SerialNumberString.Header.Size);
break;
case 0xEE:
@ -197,7 +197,7 @@ uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** c
our device is Sideshow compatible. Most people would be happy using the normal
0xFF 0x?? 0x?? Class/Subclass/Protocol values like the USBIF intended. */
Address = DESCRIPTOR_ADDRESS(OSDescriptorString);
Address = (void*)&OSDescriptorString;
Size = pgm_read_byte(&OSDescriptorString.Header.Size);
break;
}
@ -221,7 +221,7 @@ bool USB_GetOSFeatureDescriptor(const uint16_t wValue, const uint8_t wIndex,
/* Only the Extended Device Compatibility descriptor is supported */
if (wIndex == EXTENDED_COMPAT_ID_DESCRIPTOR)
{
Address = DESCRIPTOR_ADDRESS(DevCompatIDs);
Address = (void*)&DevCompatIDs;
Size = sizeof(USB_OSCompatibleIDDescriptor_t);
}
}

@ -85,8 +85,8 @@
} USB_OSCompatibleIDDescriptor_t;
/* Function Prototypes: */
uint16_t USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
ATTR_WARN_UNUSED_RESULT ATTR_WEAK ATTR_NON_NULL_PTR_ARG(3);
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex, void** const DescriptorAddress)
ATTR_WARN_UNUSED_RESULT ATTR_WEAK ATTR_NON_NULL_PTR_ARG(3);
bool USB_GetOSFeatureDescriptor(const uint16_t wValue, const uint8_t wIndex,
void** const DescriptorAddress, uint16_t* const DescriptorSize)

@ -48,162 +48,98 @@
constraints, new content can be requested as needed.
*/
/*
USB Mode: Device
USB Class: Sideshow Device (Microsoft Only)
USB Subclass: Bulk Only
Relevant Standards: Microsoft Sideshow Specification
Microsoft OS Descriptors Specification
XML Specification
Usable Speeds: Full Speed Mode
*/
#include "Sideshow.h"
/* Project Tags, for reading out using the ButtLoad project */
BUTTLOADTAG(ProjName, "LUFA Sideshow App");
BUTTLOADTAG(BuildTime, __TIME__);
BUTTLOADTAG(BuildDate, __DATE__);
BUTTLOADTAG(LUFAVersion, "LUFA V" LUFA_VERSION_STRING);
/* Scheduler Task List */
TASK_LIST
/** Main program entry point. This routine contains the overall program flow, including initial
* setup of all components and the main program loop.
*/
int main(void)
{
{ Task: USB_USBTask , TaskStatus: TASK_STOP },
{ Task: USB_Sideshow , TaskStatus: TASK_STOP },
};
SetupHardware();
int main(void)
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
for (;;)
{
SideShow_Task();
USB_USBTask();
}
}
/** Configures the board hardware and chip peripherals for the demo's functionality. */
void SetupHardware(void)
{
/* Disable watchdog if enabled by bootloader/fuses */
MCUSR &= ~(1 << WDRF);
wdt_disable();
/* Disable Clock Division */
SetSystemClockPrescaler(0);
/* Disable clock division */
clock_prescale_set(clock_div_1);
/* Hardware Initialization */
SerialStream_Init(9600, false);
LEDs_Init();
HWB_Init();
/* Indicate USB not ready */
LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED3);
/* Initialize Scheduler so that it can be used */
Scheduler_Init();
/* Initialize USB Subsystem */
USB_Init();
/* Scheduling - routine never returns, so put this last in the main function */
Scheduler_Start();
SerialStream_Init(9600, false);
}
EVENT_HANDLER(USB_Connect)
void EVENT_USB_Connect(void)
{
/* Start USB management task */
Scheduler_SetTaskMode(USB_USBTask, TASK_RUN);
/* Indicate USB enumerating */
LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED4);
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
}
EVENT_HANDLER(USB_Disconnect)
void EVENT_USB_Disconnect(void)
{
/* Stop running mass storage and USB management tasks */
Scheduler_SetTaskMode(USB_Sideshow, TASK_STOP);
Scheduler_SetTaskMode(USB_USBTask, TASK_STOP);
/* Indicate USB not ready */
LEDs_SetAllLEDs(LEDS_LED1 | LEDS_LED3);
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
}
EVENT_HANDLER(USB_ConfigurationChanged)
void EVENT_USB_ConfigurationChanged(void)
{
/* Setup Sideshow In and Out Endpoints */
Endpoint_ConfigureEndpoint(SIDESHOW_IN_EPNUM, EP_TYPE_BULK,
ENDPOINT_DIR_IN, SIDESHOW_IO_EPSIZE,
ENDPOINT_BANK_SINGLE);
LEDs_SetAllLEDs(LEDMASK_USB_READY);
Endpoint_ConfigureEndpoint(SIDESHOW_OUT_EPNUM, EP_TYPE_BULK,
ENDPOINT_DIR_OUT, SIDESHOW_IO_EPSIZE,
ENDPOINT_BANK_SINGLE);
/* Setup Sideshow In and Out Endpoints */
if (!(Endpoint_ConfigureEndpoint(SIDESHOW_IN_EPNUM, EP_TYPE_BULK,
ENDPOINT_DIR_IN, SIDESHOW_IO_EPSIZE,
ENDPOINT_BANK_SINGLE)))
{
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
}
/* Indicate USB connected and ready */
LEDs_SetAllLEDs(LEDS_LED2 | LEDS_LED4);
/* Start Sideshow task */
Scheduler_SetTaskMode(USB_Sideshow, TASK_RUN);
if (!(Endpoint_ConfigureEndpoint(SIDESHOW_OUT_EPNUM, EP_TYPE_BULK,
ENDPOINT_DIR_OUT, SIDESHOW_IO_EPSIZE,
ENDPOINT_BANK_SINGLE)))
{
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
}
}
EVENT_HANDLER(USB_UnhandledControlPacket)
void EVENT_USB_UnhandledControlPacket(void)
{
/* Process UFI specific control requests */
switch (bRequest)
switch (USB_ControlRequest.bRequest)
{
case REQ_GetOSFeatureDescriptor:
if (bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE))
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE))
{
uint16_t wValue = Endpoint_Read_Word_LE();
uint16_t wIndex = Endpoint_Read_Word_LE();
uint16_t wLength = Endpoint_Read_Word_LE();
void* DescriptorPointer;
uint16_t DescriptorSize;
bool SendZLP = true;
if (!(USB_GetOSFeatureDescriptor(wValue, wIndex, &DescriptorPointer, &DescriptorSize)))
return;
Endpoint_ClearSetupReceived();
if (wLength > DescriptorSize)
wLength = DescriptorSize;
while (wLength && (!(Endpoint_IsSetupOUTReceived())))
{
while (!(Endpoint_IsSetupINReady()));
while (wLength && (Endpoint_BytesInEndpoint() < USB_ControlEndpointSize))
{
#if defined(USE_RAM_DESCRIPTORS)
Endpoint_Write_Byte(*((uint8_t*)DescriptorPointer++));
#elif defined (USE_EEPROM_DESCRIPTORS)
Endpoint_Write_Byte(eeprom_read_byte(DescriptorPointer++));
#else
Endpoint_Write_Byte(pgm_read_byte(DescriptorPointer++));
#endif
wLength--;
}
SendZLP = (Endpoint_BytesInEndpoint() == USB_ControlEndpointSize);
Endpoint_ClearSetupIN();
}
if (Endpoint_IsSetupOUTReceived())
if (!(USB_GetOSFeatureDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex,
&DescriptorPointer, &DescriptorSize)))
{
Endpoint_ClearSetupOUT();
return;
}
if (SendZLP)
{
while (!(Endpoint_IsSetupINReady()));
Endpoint_ClearSetupIN();
}
while (!(Endpoint_IsSetupOUTReceived()));
Endpoint_ClearSetupOUT();
Endpoint_ClearSETUP();
Endpoint_Write_Control_Stream_LE(DescriptorPointer, DescriptorSize);
Endpoint_ClearOUT();
}
break;
}
}
TASK(USB_Sideshow)
void SideShow_Task(void)
{
/* Check if the USB System is connected to a Host */
if (USB_IsConnected)
@ -212,7 +148,7 @@ TASK(USB_Sideshow)
Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM);
/* Check to see if a new SideShow message has been received */
if (Endpoint_ReadWriteAllowed())
if (Endpoint_IsReadWriteAllowed())
{
/* Process the received SideShow message */
Sideshow_ProcessCommandPacket();

@ -34,31 +34,40 @@
/* Includes: */
#include <avr/io.h>
#include <avr/wdt.h>
#include <avr/power.h>
#include "Descriptors.h"
#include "SideshowCommands.h"
#include <LUFA/Version.h> // Library Version Information
#include <LUFA/Common/ButtLoadTag.h> // PROGMEM tags readable by the ButtLoad project
#include <LUFA/Drivers/USB/USB.h> // USB Functionality
#include <LUFA/Drivers/Board/HWB.h> // HWB button driver
#include <LUFA/Drivers/Board/LEDs.h> // LEDs driver
#include <LUFA/Drivers/Board/Dataflash.h> // Dataflash chip driver
#include <LUFA/Scheduler/Scheduler.h> // Simple scheduler for task management
#include <LUFA/Drivers/AT90USBXXX/Serial_Stream.h> // Serial stream driver
#include <LUFA/Version.h>
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
#include <LUFA/Drivers/Peripheral/SerialStream.h>
/* Macros: */
#define REQ_GetOSFeatureDescriptor 0x01
#define EXTENDED_COMPAT_ID_DESCRIPTOR 0x0004
/* Task Definitions: */
TASK(USB_Sideshow);
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
#define LEDMASK_USB_NOTREADY LEDS_LED1
/** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */
#define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3)
/** LED mask for the library LED driver, to indicate that the USB interface is ready. */
#define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4)
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
/* Event Handlers: */
HANDLES_EVENT(USB_Connect);
HANDLES_EVENT(USB_Disconnect);
HANDLES_EVENT(USB_ConfigurationChanged);
HANDLES_EVENT(USB_UnhandledControlPacket);
/* Function Prototypes: */
void SetupHardware(void);
void SideShow_Task(void);
void EVENT_USB_Connect(void);
void EVENT_USB_Disconnect(void);
void EVENT_USB_ConfigurationChanged(void);
void EVENT_USB_UnhandledControlPacket(void);
#endif

@ -105,14 +105,14 @@ void Sideshow_ProcessCommandPacket(void)
PacketHeader.Length -= sizeof(SideShow_PacketHeader_t);
Endpoint_Discard_Stream(PacketHeader.Length);
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader.Length = sizeof(SideShow_PacketHeader_t);
PacketHeader.Type.NAK = true;
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
printf(" UNK");
}
@ -120,11 +120,11 @@ void Sideshow_ProcessCommandPacket(void)
static void SideShow_Ping(SideShow_PacketHeader_t* PacketHeader)
{
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_Sync(SideShow_PacketHeader_t* PacketHeader)
@ -132,7 +132,7 @@ static void SideShow_Sync(SideShow_PacketHeader_t* PacketHeader)
GUID_t ProtocolGUID;
Endpoint_Read_Stream_LE(&ProtocolGUID, sizeof(GUID_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
if (memcmp(&ProtocolGUID, (uint32_t[])STANDARD_PROTOCOL_GUID, sizeof(GUID_t)) != 0)
PacketHeader->Type.NAK = true;
@ -140,31 +140,31 @@ static void SideShow_Sync(SideShow_PacketHeader_t* PacketHeader)
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_Write_Stream_LE(&ProtocolGUID, sizeof(GUID_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* PacketHeader)
{
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + sizeof(uint32_t) + UserSID.LengthInBytes;
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
SideShow_Write_Unicode_String(&UserSID);
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* PacketHeader)
{
SideShow_Read_Unicode_String(&UserSID, sizeof(UserSID.UnicodeString));
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_GetCapabilities(SideShow_PacketHeader_t* PacketHeader)
@ -173,7 +173,7 @@ static void SideShow_GetCapabilities(SideShow_PacketHeader_t* PacketHeader)
SideShow_PropertyData_t PropertyData;
Endpoint_Read_Stream_LE(&Property, sizeof(SideShow_PropertyKey_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
printf(" ID: %lu", Property.PropertyID);
@ -276,13 +276,13 @@ static void SideShow_GetCapabilities(SideShow_PacketHeader_t* PacketHeader)
}
}
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
return;
}
static void SideShow_GetString(SideShow_PacketHeader_t* PacketHeader, void* UnicodeStruct)
{
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) +
sizeof(uint32_t) + ((Unicode_String_t*)UnicodeStruct)->LengthInBytes;
@ -290,7 +290,7 @@ static void SideShow_GetString(SideShow_PacketHeader_t* PacketHeader, void* Unic
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
SideShow_Write_Unicode_String(UnicodeStruct);
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* PacketHeader)
@ -298,7 +298,7 @@ static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* PacketHeader)
uint8_t TotalInstalledApplications = SideShow_GetTotalApplications();
uint16_t GadgetGUIDBytes = (TotalInstalledApplications * sizeof(GUID_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) +
sizeof(uint32_t) + GadgetGUIDBytes;
@ -313,14 +313,14 @@ static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* PacketHeader)
Endpoint_Write_Stream_LE(&InstalledApplications[App].ApplicationID, sizeof(GUID_t));
}
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* PacketHeader)
{
GUID_t SupportedEndpointGUID = (GUID_t){Chunks: SIMPLE_CONTENT_FORMAT_GUID};
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + sizeof(uint32_t) + sizeof(GUID_t);
@ -328,7 +328,7 @@ static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* PacketHeader
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_Write_DWord_LE(1);
Endpoint_Write_Stream_LE(&SupportedEndpointGUID, sizeof(GUID_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_AddApplication(SideShow_PacketHeader_t* PacketHeader)
@ -348,7 +348,7 @@ static void SideShow_AddApplication(SideShow_PacketHeader_t* PacketHeader)
PacketHeader->Length -= sizeof(SideShow_PacketHeader_t) + sizeof(GUID_t);
Endpoint_Discard_Stream(PacketHeader->Length);
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader->Type.NAK = true;
}
@ -362,7 +362,7 @@ static void SideShow_AddApplication(SideShow_PacketHeader_t* PacketHeader)
SideShow_Discard_Byte_Stream();
SideShow_Discard_Byte_Stream();
SideShow_Discard_Byte_Stream();
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
CurrApp->InUse = true;
CurrApp->HaveContent = false;
@ -373,7 +373,7 @@ static void SideShow_AddApplication(SideShow_PacketHeader_t* PacketHeader)
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_DeleteApplication(SideShow_PacketHeader_t* PacketHeader)
@ -381,7 +381,7 @@ static void SideShow_DeleteApplication(SideShow_PacketHeader_t* PacketHeader)
GUID_t ApplicationGUID;
Endpoint_Read_Stream_LE(&ApplicationGUID, sizeof(GUID_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
SideShow_Application_t* AppToDelete = SideShow_GetApplicationFromGUID(&ApplicationGUID);
@ -396,19 +396,19 @@ static void SideShow_DeleteApplication(SideShow_PacketHeader_t* PacketHeader)
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* PacketHeader)
{
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
for (uint8_t App = 0; App < MAX_APPLICATIONS; App++)
InstalledApplications[App].InUse = false;
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_AddContent(SideShow_PacketHeader_t* PacketHeader)
@ -432,13 +432,13 @@ static void SideShow_AddContent(SideShow_PacketHeader_t* PacketHeader)
PacketHeader->Type.NAK = true;
}
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
PacketHeader->Length = sizeof(SideShow_PacketHeader_t);
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_DeleteContent(SideShow_PacketHeader_t* PacketHeader)
@ -450,7 +450,7 @@ static void SideShow_DeleteContent(SideShow_PacketHeader_t* PacketHeader)
Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t));
Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t));
Endpoint_Read_Stream_LE(&ContentID, sizeof(uint32_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID);
@ -463,7 +463,7 @@ static void SideShow_DeleteContent(SideShow_PacketHeader_t* PacketHeader)
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}
static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* PacketHeader)
@ -473,7 +473,7 @@ static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* PacketHeader)
Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t));
Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearOUT();
SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID);
@ -486,5 +486,5 @@ static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* PacketHeader)
Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM);
Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t));
Endpoint_ClearCurrentBank();
Endpoint_ClearIN();
}

@ -1,6 +1,7 @@
# Hey Emacs, this is a -*- makefile -*-
#----------------------------------------------------------------------------
# WinAVR Makefile Template written by Eric B. Weddington, Jörg Wunsch, et al.
# >> Modified for use with the LUFA project. <<
#
# Released to the Public Domain
#
@ -13,6 +14,9 @@
# Sander Pool
# Frederik Rouleau
# Carlos Lamas
# Dean Camera
# Opendous Inc.
# Denver Gingerich
#
#----------------------------------------------------------------------------
# On command line:
@ -28,6 +32,21 @@
# make program = Download the hex file to the device, using avrdude.
# Please customize the avrdude settings below first!
#
# make dfu = Download the hex file to the device, using dfu-programmer (must
# have dfu-programmer installed).
#
# make flip = Download the hex file to the device, using Atmel FLIP (must
# have Atmel FLIP installed).
#
# make dfu-ee = Download the eeprom file to the device, using dfu-programmer
# (must have dfu-programmer installed).
#
# make flip-ee = Download the eeprom file to the device, using Atmel FLIP
# (must have Atmel FLIP installed).
#
# make doxygen = Generate DoxyGen documentation for the project (must have
# DoxyGen installed)
#
# make debug = Start either simulavr or avarice as specified for debugging,
# with avr-gdb or avr-insight as the front end for debugging.
#
@ -44,7 +63,7 @@
MCU = at90usb1287
# Target board (see library BoardTypes.h documentation, USER or blank for projects not requiring
# Target board (see library "Board Types" documentation, USER or blank for projects not requiring
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
# "Board" inside the application directory.
BOARD = USBKEY
@ -71,12 +90,26 @@ BOARD = USBKEY
F_CPU = 8000000
# Input clock frequency.
# This will define a symbol, F_CLOCK, in all source code files equal to the
# input clock frequency (before any prescaling is performed). 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
# clock generation for the USB and other AVR subsections. Do NOT tack on a 'UL'
# at the end, this will be done automatically to create a 32-bit value in your
# source code.
#
# If no clock division is performed on the input clock inside the AVR (via the
# CPU clock adjust registers or the clock division fuses), this will be equal to F_CPU.
F_CLOCK = 8000000
# Output format. (can be srec, ihex, binary)
FORMAT = ihex
# Target file name (without extension).
TARGET = Sideshow
TARGET = SideShow
# Object files directory
@ -85,25 +118,31 @@ TARGET = Sideshow
OBJDIR = .
# Path to the LUFA library
LUFA_PATH = ../../../..
# List C source files here. (C dependencies are automatically generated.)
SRC = $(TARGET).c \
Descriptors.c \
SideshowCommon.c \
SideshowCommands.c \
SideshowApplications.c \
SideshowContent.c \
../../LUFA/Scheduler/Scheduler.c \
../../LUFA/Drivers/USB/LowLevel/LowLevel.c \
../../LUFA/Drivers/USB/LowLevel/Endpoint.c \
../../LUFA/Drivers/USB/LowLevel/DevChapter9.c \
../../LUFA/Drivers/USB/HighLevel/USBTask.c \
../../LUFA/Drivers/USB/HighLevel/USBInterrupt.c \
../../LUFA/Drivers/USB/HighLevel/Events.c \
../../LUFA/Drivers/USB/HighLevel/StdDescriptors.c \
../../LUFA/Drivers/AT90USBXXX/Serial_Stream.c \
../../LUFA/Drivers/AT90USBXXX/Serial.c \
SRC = $(TARGET).c \
Descriptors.c \
SideshowCommon.c \
SideshowCommands.c \
SideshowApplications.c \
SideshowContent.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/DevChapter9.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Endpoint.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Host.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/HostChapter9.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/LowLevel.c \
$(LUFA_PATH)/LUFA/Drivers/USB/LowLevel/Pipe.c \
$(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \
$(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBInterrupt.c \
$(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.c \
$(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/SerialStream.c \
$(LUFA_PATH)/LUFA/Drivers/Peripheral/Serial.c \
# List C++ source files here. (C dependencies are automatically generated.)
CPPSRC =
@ -135,7 +174,7 @@ DEBUG = dwarf-2
# Each directory must be seperated by a space.
# Use forward slashes for directory separators.
# For a directory that has spaces, enclose it in quotes.
EXTRAINCDIRS = ../../
EXTRAINCDIRS = $(LUFA_PATH)/
# Compiler flag to set the C Standard level.
@ -147,9 +186,10 @@ CSTANDARD = -std=gnu99
# Place -D or -U options here for C sources
CDEFS = -DF_CPU=$(F_CPU)UL -DBOARD=BOARD_$(BOARD) -DUSE_NONSTANDARD_DESCRIPTOR_NAMES
CDEFS += -DUSB_DEVICE_ONLY -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
CDEFS += -DNO_STREAM_CALLBACKS
CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD)
CDEFS += -DUSE_NONSTANDARD_DESCRIPTOR_NAMES -DNO_STREAM_CALLBACKS -DUSB_DEVICE_ONLY
CDEFS += -DFIXED_CONTROL_ENDPOINT_SIZE=8 -DUSE_SINGLE_DEVICE_CONFIGURATION
CDEFS += -DUSE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)"
# Place -D or -U options here for ASM sources
@ -284,7 +324,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))
@ -422,7 +462,7 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
# Default target.
all: begin gccversion sizebefore build checkhooks checklibmode sizeafter end
all: begin gccversion sizebefore build checkhooks checklibmode checkboard sizeafter end
# Change the build target to build a HEX file or a library.
build: elf hex eep lss sym
@ -468,11 +508,11 @@ sizeafter:
checkhooks: build
@echo
@echo ------- Unhooked LUFA Events -------
@$(shell) (grep -s '^Event.*LUFA/.*\\.o' $(TARGET).map | \
@$(shell) (grep -s '^EVENT_.*LUFA/.*\\.o' $(TARGET).map | \
cut -d' ' -f1 | cut -d'_' -f2- | grep ".*") || \
echo "(None)"
@echo ----- End Unhooked LUFA Events -----
@echo ------------------------------------
checklibmode:
@echo
@echo ----------- Library Mode -----------
@ -481,6 +521,12 @@ checklibmode:
|| echo "No specific mode (both device and host mode allowable)."
@echo ------------------------------------
checkboard:
@echo
@echo ---------- Selected Board ----------
@echo Selected board model is $(BOARD).
@echo ------------------------------------
# Display compiler version information.
gccversion :
@$(CC) --version
@ -491,6 +537,26 @@ gccversion :
program: $(TARGET).hex $(TARGET).eep
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
flip: $(TARGET).hex
batchisp -hardware usb -device $(MCU) -operation erase f
batchisp -hardware usb -device $(MCU) -operation loadbuffer $(TARGET).hex program
batchisp -hardware usb -device $(MCU) -operation start reset 0
dfu: $(TARGET).hex
dfu-programmer $(MCU) erase
dfu-programmer $(MCU) flash --debug 1 $(TARGET).hex
dfu-programmer $(MCU) reset
flip-ee: $(TARGET).hex $(TARGET).eep
copy $(TARGET).eep $(TARGET)eep.hex
batchisp -hardware usb -device $(MCU) -operation memory EEPROM erase
batchisp -hardware usb -device $(MCU) -operation memory EEPROM loadbuffer $(TARGET)eep.hex program
batchisp -hardware usb -device $(MCU) -operation start reset 0
dfu-ee: $(TARGET).hex $(TARGET).eep
dfu-programmer $(MCU) flash-eeprom --debug 1 --suppress-bootloader-mem $(TARGET).eep
dfu-programmer $(MCU) reset
# Generate avr-gdb config/init file which does the following:
# define the reset signal, load the target file, connect to target, and set
@ -630,10 +696,11 @@ clean: begin clean_list clean_binary end
clean_binary:
$(REMOVE) $(TARGET).hex
clean_list:
@echo $(MSG_CLEANING)
$(REMOVE) $(TARGET).eep
$(REMOVE) $(TARGET)eep.hex
$(REMOVE) $(TARGET).cof
$(REMOVE) $(TARGET).elf
$(REMOVE) $(TARGET).map
@ -652,6 +719,9 @@ doxygen:
@doxygen Doxygen.conf
@echo Documentation Generation Complete.
clean_doxygen:
rm -rf Documentation
# Create object files directory
$(shell mkdir $(OBJDIR) 2>/dev/null)
@ -661,8 +731,8 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
# Listing of phony targets.
.PHONY : all checkhooks checklibmode begin \
finish end sizebefore sizeafter gccversion \
build elf hex eep lss sym coff extcoff \
clean clean_list clean_binary program debug \
gdb-config doxygen
.PHONY : all checkhooks checklibmode checkboard \
begin finish end sizebefore sizeafter gccversion \
build elf hex eep lss sym coff extcoff clean \
clean_list clean_binary program debug gdb-config \
doxygen dfu flip flip-ee dfu-ee

@ -5,9 +5,13 @@
*/
========== TODO: ===========
- Document new class drivers (in progress)
- Add standardized descriptor names to class driver structures, controlled by USE_NONSTANDARD_DESCRIPTOR_NAMES
- Document new device class drivers (in progress)
- Made new host class drivers
- Document new host class drivers
- Convert Host mode demos to class drivers
- Add in old Host mode demos, convert to schedulerless
- Add in incomplete host mode demos
- Add standardized descriptor names to class driver structures, controlled by USE_NONSTANDARD_DESCRIPTOR_NAMES
- Remake AVRStudio projects to reflect file structure changes
============================

Loading…
Cancel
Save