From 071e02c6b6b4837fa9cf0b6d4c749994e02638d7 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Sat, 8 May 2010 03:12:14 +0000 Subject: Add svn:eol-style property to source files, so that the line endings are correctly converted to the target system's native end of line style. --- Demos/Device/Incomplete/Sideshow/Descriptors.c | 470 +++---- Demos/Device/Incomplete/Sideshow/Descriptors.h | 190 +-- .../Incomplete/Sideshow/Lib/SideshowApplications.c | 118 +- .../Incomplete/Sideshow/Lib/SideshowApplications.h | 124 +- .../Incomplete/Sideshow/Lib/SideshowCommands.c | 986 ++++++------- .../Incomplete/Sideshow/Lib/SideshowCommands.h | 330 ++--- .../Incomplete/Sideshow/Lib/SideshowCommon.c | 140 +- .../Incomplete/Sideshow/Lib/SideshowCommon.h | 204 +-- .../Incomplete/Sideshow/Lib/SideshowContent.c | 152 +- .../Incomplete/Sideshow/Lib/SideshowContent.h | 248 ++-- Demos/Device/Incomplete/Sideshow/Sideshow.c | 316 ++--- Demos/Device/Incomplete/Sideshow/Sideshow.h | 156 +- Demos/Device/Incomplete/Sideshow/makefile | 1484 ++++++++++---------- 13 files changed, 2459 insertions(+), 2459 deletions(-) (limited to 'Demos/Device/Incomplete/Sideshow') diff --git a/Demos/Device/Incomplete/Sideshow/Descriptors.c b/Demos/Device/Incomplete/Sideshow/Descriptors.c index 8f36caec3..f6d16c841 100644 --- a/Demos/Device/Incomplete/Sideshow/Descriptors.c +++ b/Demos/Device/Incomplete/Sideshow/Descriptors.c @@ -1,236 +1,236 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#include "Descriptors.h" - -USB_Descriptor_Device_t PROGMEM DeviceDescriptor = -{ - Header: {Size: sizeof(USB_Descriptor_Device_t), Type: DTYPE_Device}, - - USBSpecification: VERSION_BCD(02.00), - Class: 0x00, - SubClass: 0x00, - Protocol: 0x00, - - Endpoint0Size: 8, - - VendorID: 0x03EB, - ProductID: 0x2040, - ReleaseNumber: 0x0001, - - ManufacturerStrIndex: 0x01, - ProductStrIndex: 0x02, - SerialNumStrIndex: 0x03, - - NumberOfConfigurations: 1 -}; - -USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = -{ - .Config = - { - Header: {Size: sizeof(USB_Descriptor_Configuration_Header_t), Type: DTYPE_Configuration}, - - TotalConfigurationSize: sizeof(USB_Descriptor_Configuration_t), - TotalInterfaces: 1, - - ConfigurationNumber: 1, - ConfigurationStrIndex: NO_DESCRIPTOR, - - ConfigAttributes: (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), - - MaxPowerConsumption: USB_CONFIG_POWER_MA(100) - }, - - .SSHOW_Interface = - { - Header: {Size: sizeof(USB_Descriptor_Interface_t), Type: DTYPE_Interface}, - - InterfaceNumber: 0, - AlternateSetting: 0, - - TotalEndpoints: 2, - - Class: 0xFF, - SubClass: 0x00, - Protocol: 0x00, - - InterfaceStrIndex: NO_DESCRIPTOR - }, - - .SSHOW_DataInEndpoint = - { - Header: {Size: sizeof(USB_Descriptor_Endpoint_t), Type: DTYPE_Endpoint}, - - EndpointAddress: (ENDPOINT_DESCRIPTOR_DIR_IN | SIDESHOW_IN_EPNUM), - Attributes: EP_TYPE_BULK, - EndpointSize: SIDESHOW_IO_EPSIZE, - PollingIntervalMS: 0x00 - }, - - .SSHOW_DataOutEndpoint = - { - Header: {Size: sizeof(USB_Descriptor_Endpoint_t), Type: DTYPE_Endpoint}, - - EndpointAddress: (ENDPOINT_DESCRIPTOR_DIR_OUT | SIDESHOW_OUT_EPNUM), - Attributes: EP_TYPE_BULK, - EndpointSize: SIDESHOW_IO_EPSIZE, - PollingIntervalMS: 0x00 - } -}; - -USB_Descriptor_String_t PROGMEM LanguageString = -{ - Header: {Size: USB_STRING_LEN(1), Type: DTYPE_String}, - - UnicodeString: {LANGUAGE_ID_ENG} -}; - -USB_Descriptor_String_t PROGMEM ManufacturerString = -{ - Header: {Size: USB_STRING_LEN(11), Type: DTYPE_String}, - - UnicodeString: L"Dean Camera" -}; - -USB_Descriptor_String_t PROGMEM ProductString = -{ - Header: {Size: USB_STRING_LEN(22), Type: DTYPE_String}, - - UnicodeString: L"LUFA Sideshow Demo" -}; - -USB_Descriptor_String_t PROGMEM SerialNumberString = -{ - Header: {Size: USB_STRING_LEN(12), Type: DTYPE_String}, - - UnicodeString: L"000000000000" -}; - -USB_OSDescriptor_t PROGMEM OSDescriptorString = -{ - Header: {Size: sizeof(USB_OSDescriptor_t), Type: DTYPE_String}, - - Signature: L"MSFT100", - VendorCode: REQ_GetOSFeatureDescriptor -}; - -USB_OSCompatibleIDDescriptor_t PROGMEM DevCompatIDs = -{ - TotalLength: sizeof(USB_OSCompatibleIDDescriptor_t), - Version: 0x0100, - Index: EXTENDED_COMPAT_ID_DESCRIPTOR, - TotalSections: 1, - - SideshowCompatID: {FirstInterfaceNumber: 0x00, - CompatibleID: "SIDESHW", - SubCompatibleID: "UNIV1"} -}; - -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); - - void* Address = NULL; - uint16_t Size = NO_DESCRIPTOR; - - switch (DescriptorType) - { - case DTYPE_Device: - Address = (void*)&DeviceDescriptor; - Size = sizeof(USB_Descriptor_Device_t); - break; - case DTYPE_Configuration: - Address = (void*)&ConfigurationDescriptor; - Size = sizeof(USB_Descriptor_Configuration_t); - break; - case DTYPE_String: - switch (DescriptorNumber) - { - case 0x00: - Address = (void*)&LanguageString; - Size = pgm_read_byte(&LanguageString.Header.Size); - break; - case 0x01: - Address = (void*)&ManufacturerString; - Size = pgm_read_byte(&ManufacturerString.Header.Size); - break; - case 0x02: - Address = (void*)&ProductString; - Size = pgm_read_byte(&ProductString.Header.Size); - break; - case 0x03: - Address = (void*)&SerialNumberString; - Size = pgm_read_byte(&SerialNumberString.Header.Size); - break; - case 0xEE: - /* A Microsoft-proprietary extention. String address 0xEE is used by Windows for - "OS Descriptors", which in this case allows us to indicate that our device is - Sideshow compatible regardless of VID/PID values. */ - Address = (void*)&OSDescriptorString; - Size = pgm_read_byte(&OSDescriptorString.Header.Size); - break; - } - - break; - } - - *DescriptorAddress = Address; - return Size; -} - -bool USB_GetOSFeatureDescriptor(const uint16_t wValue, const uint8_t wIndex, - void** const DescriptorAddress, uint16_t* const DescriptorSize) -{ - void* Address = NULL; - uint16_t Size = 0; - - /* Check if a device level OS feature descriptor is being requested */ - if (wValue == 0x0000) - { - /* Only the Extended Device Compatibility descriptor is supported */ - if (wIndex == EXTENDED_COMPAT_ID_DESCRIPTOR) - { - Address = (void*)&DevCompatIDs; - Size = sizeof(USB_OSCompatibleIDDescriptor_t); - } - } - - if (Address != NULL) - { - *DescriptorAddress = Address; - *DescriptorSize = Size; - - return true; - } - - return false; +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "Descriptors.h" + +USB_Descriptor_Device_t PROGMEM DeviceDescriptor = +{ + Header: {Size: sizeof(USB_Descriptor_Device_t), Type: DTYPE_Device}, + + USBSpecification: VERSION_BCD(02.00), + Class: 0x00, + SubClass: 0x00, + Protocol: 0x00, + + Endpoint0Size: 8, + + VendorID: 0x03EB, + ProductID: 0x2040, + ReleaseNumber: 0x0001, + + ManufacturerStrIndex: 0x01, + ProductStrIndex: 0x02, + SerialNumStrIndex: 0x03, + + NumberOfConfigurations: 1 +}; + +USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = +{ + .Config = + { + Header: {Size: sizeof(USB_Descriptor_Configuration_Header_t), Type: DTYPE_Configuration}, + + TotalConfigurationSize: sizeof(USB_Descriptor_Configuration_t), + TotalInterfaces: 1, + + ConfigurationNumber: 1, + ConfigurationStrIndex: NO_DESCRIPTOR, + + ConfigAttributes: (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), + + MaxPowerConsumption: USB_CONFIG_POWER_MA(100) + }, + + .SSHOW_Interface = + { + Header: {Size: sizeof(USB_Descriptor_Interface_t), Type: DTYPE_Interface}, + + InterfaceNumber: 0, + AlternateSetting: 0, + + TotalEndpoints: 2, + + Class: 0xFF, + SubClass: 0x00, + Protocol: 0x00, + + InterfaceStrIndex: NO_DESCRIPTOR + }, + + .SSHOW_DataInEndpoint = + { + Header: {Size: sizeof(USB_Descriptor_Endpoint_t), Type: DTYPE_Endpoint}, + + EndpointAddress: (ENDPOINT_DESCRIPTOR_DIR_IN | SIDESHOW_IN_EPNUM), + Attributes: EP_TYPE_BULK, + EndpointSize: SIDESHOW_IO_EPSIZE, + PollingIntervalMS: 0x00 + }, + + .SSHOW_DataOutEndpoint = + { + Header: {Size: sizeof(USB_Descriptor_Endpoint_t), Type: DTYPE_Endpoint}, + + EndpointAddress: (ENDPOINT_DESCRIPTOR_DIR_OUT | SIDESHOW_OUT_EPNUM), + Attributes: EP_TYPE_BULK, + EndpointSize: SIDESHOW_IO_EPSIZE, + PollingIntervalMS: 0x00 + } +}; + +USB_Descriptor_String_t PROGMEM LanguageString = +{ + Header: {Size: USB_STRING_LEN(1), Type: DTYPE_String}, + + UnicodeString: {LANGUAGE_ID_ENG} +}; + +USB_Descriptor_String_t PROGMEM ManufacturerString = +{ + Header: {Size: USB_STRING_LEN(11), Type: DTYPE_String}, + + UnicodeString: L"Dean Camera" +}; + +USB_Descriptor_String_t PROGMEM ProductString = +{ + Header: {Size: USB_STRING_LEN(22), Type: DTYPE_String}, + + UnicodeString: L"LUFA Sideshow Demo" +}; + +USB_Descriptor_String_t PROGMEM SerialNumberString = +{ + Header: {Size: USB_STRING_LEN(12), Type: DTYPE_String}, + + UnicodeString: L"000000000000" +}; + +USB_OSDescriptor_t PROGMEM OSDescriptorString = +{ + Header: {Size: sizeof(USB_OSDescriptor_t), Type: DTYPE_String}, + + Signature: L"MSFT100", + VendorCode: REQ_GetOSFeatureDescriptor +}; + +USB_OSCompatibleIDDescriptor_t PROGMEM DevCompatIDs = +{ + TotalLength: sizeof(USB_OSCompatibleIDDescriptor_t), + Version: 0x0100, + Index: EXTENDED_COMPAT_ID_DESCRIPTOR, + TotalSections: 1, + + SideshowCompatID: {FirstInterfaceNumber: 0x00, + CompatibleID: "SIDESHW", + SubCompatibleID: "UNIV1"} +}; + +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); + + void* Address = NULL; + uint16_t Size = NO_DESCRIPTOR; + + switch (DescriptorType) + { + case DTYPE_Device: + Address = (void*)&DeviceDescriptor; + Size = sizeof(USB_Descriptor_Device_t); + break; + case DTYPE_Configuration: + Address = (void*)&ConfigurationDescriptor; + Size = sizeof(USB_Descriptor_Configuration_t); + break; + case DTYPE_String: + switch (DescriptorNumber) + { + case 0x00: + Address = (void*)&LanguageString; + Size = pgm_read_byte(&LanguageString.Header.Size); + break; + case 0x01: + Address = (void*)&ManufacturerString; + Size = pgm_read_byte(&ManufacturerString.Header.Size); + break; + case 0x02: + Address = (void*)&ProductString; + Size = pgm_read_byte(&ProductString.Header.Size); + break; + case 0x03: + Address = (void*)&SerialNumberString; + Size = pgm_read_byte(&SerialNumberString.Header.Size); + break; + case 0xEE: + /* A Microsoft-proprietary extention. String address 0xEE is used by Windows for + "OS Descriptors", which in this case allows us to indicate that our device is + Sideshow compatible regardless of VID/PID values. */ + Address = (void*)&OSDescriptorString; + Size = pgm_read_byte(&OSDescriptorString.Header.Size); + break; + } + + break; + } + + *DescriptorAddress = Address; + return Size; +} + +bool USB_GetOSFeatureDescriptor(const uint16_t wValue, const uint8_t wIndex, + void** const DescriptorAddress, uint16_t* const DescriptorSize) +{ + void* Address = NULL; + uint16_t Size = 0; + + /* Check if a device level OS feature descriptor is being requested */ + if (wValue == 0x0000) + { + /* Only the Extended Device Compatibility descriptor is supported */ + if (wIndex == EXTENDED_COMPAT_ID_DESCRIPTOR) + { + Address = (void*)&DevCompatIDs; + Size = sizeof(USB_OSCompatibleIDDescriptor_t); + } + } + + if (Address != NULL) + { + *DescriptorAddress = Address; + *DescriptorSize = Size; + + return true; + } + + return false; } \ No newline at end of file diff --git a/Demos/Device/Incomplete/Sideshow/Descriptors.h b/Demos/Device/Incomplete/Sideshow/Descriptors.h index 564b44cfe..83c683be5 100644 --- a/Demos/Device/Incomplete/Sideshow/Descriptors.h +++ b/Demos/Device/Incomplete/Sideshow/Descriptors.h @@ -1,95 +1,95 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#ifndef _DESCRIPTORS_H_ -#define _DESCRIPTORS_H_ - - /* Includes: */ - #include - - #include - - #include "Sideshow.h" - - /* Macros: */ - #define SIDESHOW_IN_EPNUM 3 - #define SIDESHOW_OUT_EPNUM 4 - #define SIDESHOW_IO_EPSIZE 64 - - /* Type Defines: */ - typedef struct - { - USB_Descriptor_Configuration_Header_t Config; - USB_Descriptor_Interface_t SSHOW_Interface; - USB_Descriptor_Endpoint_t SSHOW_DataInEndpoint; - USB_Descriptor_Endpoint_t SSHOW_DataOutEndpoint; - } USB_Descriptor_Configuration_t; - - typedef struct - { - USB_Descriptor_Header_t Header; - - int Signature[7]; - uint16_t VendorCode; - } USB_OSDescriptor_t; - - typedef struct - { - uint8_t FirstInterfaceNumber; - - uint8_t RESERVED; - - uint8_t CompatibleID[8]; - uint8_t SubCompatibleID[8]; - - uint8_t RESERVED2[6]; - } USB_OSCompatibleSection_t; - - typedef struct - { - uint32_t TotalLength; - uint16_t Version; - uint16_t Index; - uint8_t TotalSections; - - uint8_t RESERVED[7]; - - USB_OSCompatibleSection_t SideshowCompatID; - } USB_OSCompatibleIDDescriptor_t; - - /* Function Prototypes: */ - 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) - ATTR_WARN_UNUSED_RESULT ATTR_WEAK ATTR_NON_NULL_PTR_ARG(3) ATTR_NON_NULL_PTR_ARG(4); - -#endif +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#ifndef _DESCRIPTORS_H_ +#define _DESCRIPTORS_H_ + + /* Includes: */ + #include + + #include + + #include "Sideshow.h" + + /* Macros: */ + #define SIDESHOW_IN_EPNUM 3 + #define SIDESHOW_OUT_EPNUM 4 + #define SIDESHOW_IO_EPSIZE 64 + + /* Type Defines: */ + typedef struct + { + USB_Descriptor_Configuration_Header_t Config; + USB_Descriptor_Interface_t SSHOW_Interface; + USB_Descriptor_Endpoint_t SSHOW_DataInEndpoint; + USB_Descriptor_Endpoint_t SSHOW_DataOutEndpoint; + } USB_Descriptor_Configuration_t; + + typedef struct + { + USB_Descriptor_Header_t Header; + + int Signature[7]; + uint16_t VendorCode; + } USB_OSDescriptor_t; + + typedef struct + { + uint8_t FirstInterfaceNumber; + + uint8_t RESERVED; + + uint8_t CompatibleID[8]; + uint8_t SubCompatibleID[8]; + + uint8_t RESERVED2[6]; + } USB_OSCompatibleSection_t; + + typedef struct + { + uint32_t TotalLength; + uint16_t Version; + uint16_t Index; + uint8_t TotalSections; + + uint8_t RESERVED[7]; + + USB_OSCompatibleSection_t SideshowCompatID; + } USB_OSCompatibleIDDescriptor_t; + + /* Function Prototypes: */ + 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) + ATTR_WARN_UNUSED_RESULT ATTR_WEAK ATTR_NON_NULL_PTR_ARG(3) ATTR_NON_NULL_PTR_ARG(4); + +#endif diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c index e7b0ad8bd..a6c529e69 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.c @@ -1,59 +1,59 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#include "SideshowApplications.h" - -SideShow_Application_t InstalledApplications[MAX_APPLICATIONS]; - - -SideShow_Application_t* SideShow_GetFreeApplication(void) -{ - for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++) - { - if (!(InstalledApplications[App].InUse)) - return &InstalledApplications[App]; - } - - return NULL; -} - -SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* GUID) -{ - for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++) - { - if (InstalledApplications[App].InUse) - { - if (GUID_COMPARE(&InstalledApplications[App].ApplicationID, GUID)) - return &InstalledApplications[App]; - } - } - - return NULL; -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "SideshowApplications.h" + +SideShow_Application_t InstalledApplications[MAX_APPLICATIONS]; + + +SideShow_Application_t* SideShow_GetFreeApplication(void) +{ + for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++) + { + if (!(InstalledApplications[App].InUse)) + return &InstalledApplications[App]; + } + + return NULL; +} + +SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* GUID) +{ + for (uint8_t App = 0; App < ARRAY_ELEMENTS(InstalledApplications); App++) + { + if (InstalledApplications[App].InUse) + { + if (GUID_COMPARE(&InstalledApplications[App].ApplicationID, GUID)) + return &InstalledApplications[App]; + } + } + + return NULL; +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h index de8983ed2..ed885d40d 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowApplications.h @@ -1,62 +1,62 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#ifndef _SIDESHOW_APPLICATIONS_H_ -#define _SIDESHOW_APPLICATIONS_H_ - - /* Includes: */ - #include - #include - #include - - #include "SideshowCommon.h" - - /* Type Defines: */ - typedef struct - { - bool InUse; - GUID_t ApplicationID; - GUID_t EndpointID; - UNICODE_STRING_t(50) ApplicationName; - uint32_t CachePolicy; - uint32_t OnlineOnly; - bool HaveContent; - uint32_t CurrentContentID; - uint8_t CurrentContent[MAX_CONTENTBUFFER_PER_APP]; - } SideShow_Application_t; - - /* External Variables: */ - extern SideShow_Application_t InstalledApplications[MAX_APPLICATIONS]; - - /* Function Prototypes: */ - SideShow_Application_t* SideShow_GetFreeApplication(void); - SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* GUID); - -#endif +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#ifndef _SIDESHOW_APPLICATIONS_H_ +#define _SIDESHOW_APPLICATIONS_H_ + + /* Includes: */ + #include + #include + #include + + #include "SideshowCommon.h" + + /* Type Defines: */ + typedef struct + { + bool InUse; + GUID_t ApplicationID; + GUID_t EndpointID; + UNICODE_STRING_t(50) ApplicationName; + uint32_t CachePolicy; + uint32_t OnlineOnly; + bool HaveContent; + uint32_t CurrentContentID; + uint8_t CurrentContent[MAX_CONTENTBUFFER_PER_APP]; + } SideShow_Application_t; + + /* External Variables: */ + extern SideShow_Application_t InstalledApplications[MAX_APPLICATIONS]; + + /* Function Prototypes: */ + SideShow_Application_t* SideShow_GetFreeApplication(void); + SideShow_Application_t* SideShow_GetApplicationFromGUID(GUID_t* GUID); + +#endif diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c index c0f7096b2..5bce088c8 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c @@ -1,493 +1,493 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define INCLUDE_FROM_SIDESHOWCOMMANDS_H -#include "SideshowCommands.h" - -UNICODE_STRING_t(80) UserSID = {LengthInBytes: sizeof(SECURITY_INTERACTIVE_RID_SID), - UnicodeString: SECURITY_INTERACTIVE_RID_SID}; - -Unicode_String_t DeviceName = {LengthInBytes: sizeof(L"LUFA Sideshow Device"), - UnicodeString: L"LUFA Sideshow Device"}; - -Unicode_String_t Manufacturer = {LengthInBytes: sizeof(L"Dean Camera"), - UnicodeString: L"Dean Camera"}; - -Unicode_String_t SupportedLanguage = {LengthInBytes: sizeof(L"en-US:1"), - UnicodeString: L"en-US:1"}; - -void Sideshow_ProcessCommandPacket(void) -{ - SideShow_PacketHeader_t PacketHeader; - - Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM); - Endpoint_Read_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t)); - - PacketHeader.Type.Response = true; - - printf("\r\nCmd: %lX", (PacketHeader.Type.TypeLong & 0x00FFFFFF)); - - switch (PacketHeader.Type.TypeLong & 0x00FFFFFF) - { - case SIDESHOW_CMD_PING: - SideShow_Ping(&PacketHeader); - break; - case SIDESHOW_CMD_SYNC: - SideShow_Sync(&PacketHeader); - break; - case SIDESHOW_CMD_GET_CURRENT_USER: - SideShow_GetCurrentUser(&PacketHeader); - break; - case SIDESHOW_CMD_SET_CURRENT_USER: - SideShow_SetCurrentUser(&PacketHeader); - break; - case SIDESHOW_CMD_GET_CAPABILITIES: - SideShow_GetCapabilities(&PacketHeader); - break; - case SIDESHOW_CMD_GET_DEVICE_NAME: - SideShow_GetString(&PacketHeader, &DeviceName); - break; - case SIDESHOW_CMD_GET_MANUFACTURER: - SideShow_GetString(&PacketHeader, &Manufacturer); - break; - case SIDESHOW_CMD_GET_APPLICATION_ORDER: - SideShow_GetApplicationOrder(&PacketHeader); - break; - case SIDESHOW_CMD_GET_SUPPORTED_ENDPOINTS: - SideShow_GetSupportedEndpoints(&PacketHeader); - break; - case SIDESHOW_CMD_ADD_APPLICATION: - SideShow_AddApplication(&PacketHeader); - break; - case SIDESHOW_CMD_ADD_CONTENT: - SideShow_AddContent(&PacketHeader); - break; - case SIDESHOW_CMD_DELETE_CONTENT: - SideShow_DeleteContent(&PacketHeader); - break; - case SIDESHOW_CMD_DELETE_ALL_CONTENT: - SideShow_DeleteAllContent(&PacketHeader); - break; - case SIDESHOW_CMD_DELETE_APPLICATION: - SideShow_DeleteApplication(&PacketHeader); - break; - case SIDESHOW_CMD_DELETE_ALL_APPLICATIONS: - SideShow_DeleteAllApplications(&PacketHeader); - break; - default: - PacketHeader.Length -= sizeof(SideShow_PacketHeader_t); - - Endpoint_Discard_Stream(PacketHeader.Length); - 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_ClearIN(); - - printf(" UNK"); - } -} - -static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader) -{ - Endpoint_ClearOUT(); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t ProtocolGUID; - - Endpoint_Read_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); - Endpoint_ClearOUT(); - - if (!(GUID_COMPARE(&ProtocolGUID, (uint32_t[])STANDARD_PROTOCOL_GUID))) - PacketHeader->Type.NAK = true; - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_Write_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); - Endpoint_ClearIN(); -} - -static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* const PacketHeader) -{ - 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_ClearIN(); -} - -static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* const PacketHeader) -{ - SideShow_Read_Unicode_String(&UserSID, sizeof(UserSID.UnicodeString)); - Endpoint_ClearOUT(); - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_GetCapabilities(SideShow_PacketHeader_t* const PacketHeader) -{ - SideShow_PropertyKey_t Property; - SideShow_PropertyData_t PropertyData; - - Endpoint_Read_Stream_LE(&Property, sizeof(SideShow_PropertyKey_t)); - Endpoint_ClearOUT(); - - printf(" ID: %lu", Property.PropertyID); - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - if (GUID_COMPARE(&Property.PropertyGUID, (uint32_t[])SIDESHOW_PROPERTY_GUID)) - { - switch (Property.PropertyID) - { - case PROPERTY_SIDESHOW_SCREENTYPE: - PropertyData.DataType = VT_I4; - PropertyData.Data.Data32 = ScreenText; - PacketHeader->Length += sizeof(uint32_t); - - break; - case PROPERTY_SIDESHOW_SCREENWIDTH: - case PROPERTY_SIDESHOW_CLIENTWIDTH: - PropertyData.DataType = VT_UI2; - PropertyData.Data.Data16 = 16; - PacketHeader->Length += sizeof(uint16_t); - - break; - case PROPERTY_SIDESHOW_SCREENHEIGHT: - case PROPERTY_SIDESHOW_CLIENTHEIGHT: - PropertyData.DataType = VT_UI2; - PropertyData.Data.Data16 = 2; - PacketHeader->Length += sizeof(uint16_t); - - break; - case PROPERTY_SIDESHOW_COLORDEPTH: - PropertyData.DataType = VT_UI2; - PropertyData.Data.Data16 = 1; - PacketHeader->Length += sizeof(uint16_t); - - break; - case PROPERTY_SIDESHOW_COLORTYPE: - PropertyData.DataType = VT_UI2; - PropertyData.Data.Data16 = BlackAndWhiteDisplay; - PacketHeader->Length += sizeof(uint16_t); - - break; - case PROPERTY_SIDESHOW_DATACACHE: - PropertyData.DataType = VT_BOOL; - PropertyData.Data.Data16 = false; - PacketHeader->Length += sizeof(uint16_t); - - break; - case PROPERTY_SIDESHOW_SUPPORTEDLANGS: - case PROPERTY_SIDESHOW_CURRENTLANG: - PropertyData.DataType = VT_LPWSTR; - PropertyData.Data.DataPointer = &SupportedLanguage; - PacketHeader->Length += SupportedLanguage.LengthInBytes; - - break; - default: - PropertyData.DataType = VT_EMPTY; - break; - } - } - else if (GUID_COMPARE(&Property.PropertyGUID, (uint32_t[])DEVICE_PROPERTY_GUID)) - { - switch (Property.PropertyID) - { - case PROPERTY_DEVICE_DEVICETYPE: - PropertyData.DataType = VT_UI4; - PropertyData.Data.Data32 = GenericDevice; - PacketHeader->Length += sizeof(uint32_t); - - break; - } - } - else - { - PacketHeader->Type.NAK = true; - - printf(" WRONG GUID"); - printf(" %lX %lX %lX %lX", Property.PropertyGUID.Chunks[0], Property.PropertyGUID.Chunks[1], - Property.PropertyGUID.Chunks[2], Property.PropertyGUID.Chunks[3]); - } - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - - if (!(PacketHeader->Type.NAK)) - { - switch (PropertyData.DataType) - { - case VT_UI4: - case VT_I4: - Endpoint_Write_Stream_LE(&PropertyData.Data.Data32, sizeof(uint32_t)); - break; - case VT_UI2: - case VT_I2: - case VT_BOOL: - Endpoint_Write_Stream_LE(&PropertyData.Data.Data16, sizeof(uint16_t)); - break; - case VT_LPWSTR: - SideShow_Write_Unicode_String((Unicode_String_t*)PropertyData.Data.Data16); - break; - } - } - - Endpoint_ClearIN(); - return; -} - -static void SideShow_GetString(SideShow_PacketHeader_t* const PacketHeader, void* const UnicodeStruct) -{ - Endpoint_ClearOUT(); - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + - sizeof(uint32_t) + ((Unicode_String_t*)UnicodeStruct)->LengthInBytes; - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - SideShow_Write_Unicode_String(UnicodeStruct); - Endpoint_ClearIN(); -} - -static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* const PacketHeader) -{ - uint8_t TotalApplications = 0; - - Endpoint_ClearOUT(); - - for (uint8_t App = 0; App < MAX_APPLICATIONS; App++) - { - if (InstalledApplications[App].InUse) - TotalApplications++; - } - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + - sizeof(uint32_t) + (TotalApplications * sizeof(GUID_t)); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_Write_DWord_LE(TotalApplications); - - for (uint8_t App = 0; App < MAX_APPLICATIONS; App++) - { - if (InstalledApplications[App].InUse) - Endpoint_Write_Stream_LE(&InstalledApplications[App].ApplicationID, sizeof(GUID_t)); - } - - Endpoint_ClearIN(); -} - -static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t SupportedEndpointGUID = (GUID_t){Chunks: SIMPLE_CONTENT_FORMAT_GUID}; - - Endpoint_ClearOUT(); - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + sizeof(uint32_t) + sizeof(GUID_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_Write_DWord_LE(1); - Endpoint_Write_Stream_LE(&SupportedEndpointGUID, sizeof(GUID_t)); - Endpoint_ClearIN(); -} - -static void SideShow_AddApplication(SideShow_PacketHeader_t* const PacketHeader) -{ - SideShow_Application_t* CurrApp; - GUID_t ApplicationID; - - Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t)); - - CurrApp = SideShow_GetApplicationFromGUID(&ApplicationID); - - if (CurrApp == NULL) - CurrApp = SideShow_GetFreeApplication(); - - if (CurrApp == NULL) - { - PacketHeader->Length -= sizeof(SideShow_PacketHeader_t) + sizeof(GUID_t); - - Endpoint_Discard_Stream(PacketHeader->Length); - Endpoint_ClearOUT(); - - PacketHeader->Type.NAK = true; - } - else - { - CurrApp->ApplicationID = ApplicationID; - Endpoint_Read_Stream_LE(&CurrApp->EndpointID, sizeof(GUID_t)); - SideShow_Read_Unicode_String(&CurrApp->ApplicationName, sizeof(CurrApp->ApplicationName.UnicodeString)); - Endpoint_Read_Stream_LE(&CurrApp->CachePolicy, sizeof(uint32_t)); - Endpoint_Read_Stream_LE(&CurrApp->OnlineOnly, sizeof(uint32_t)); - SideShow_Discard_Byte_Stream(); - SideShow_Discard_Byte_Stream(); - SideShow_Discard_Byte_Stream(); - Endpoint_ClearOUT(); - - CurrApp->InUse = true; - CurrApp->HaveContent = false; - CurrApp->CurrentContentID = 1; - } - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t ApplicationGUID; - - Endpoint_Read_Stream_LE(&ApplicationGUID, sizeof(GUID_t)); - Endpoint_ClearOUT(); - - SideShow_Application_t* AppToDelete = SideShow_GetApplicationFromGUID(&ApplicationGUID); - - if (AppToDelete != NULL) - AppToDelete->InUse = false; - else - PacketHeader->Type.NAK = true; - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* const PacketHeader) -{ - 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_ClearIN(); -} - -static void SideShow_AddContent(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t ApplicationID; - GUID_t EndpointID; - SideShow_Application_t* Application; - - Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t)); - Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); - - Application = SideShow_GetApplicationFromGUID(&ApplicationID); - - if (Application == NULL) - { - SideShow_Discard_Byte_Stream(); - PacketHeader->Type.NAK = true; - } - else if (!(SideShow_AddSimpleContent(PacketHeader, Application))) - { - PacketHeader->Type.NAK = true; - } - - Endpoint_ClearOUT(); - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_DeleteContent(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t ApplicationID; - GUID_t EndpointID; - uint32_t ContentID; - - 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_ClearOUT(); - - SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); - - if ((Application != NULL) && (Application->CurrentContentID == ContentID)) - Application->HaveContent = false; - else - PacketHeader->Type.NAK = true; - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} - -static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* const PacketHeader) -{ - GUID_t ApplicationID; - GUID_t EndpointID; - - Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t)); - Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); - Endpoint_ClearOUT(); - - SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); - - if (Application != NULL) - Application->HaveContent = false; - else - PacketHeader->Type.NAK = true; - - PacketHeader->Length = sizeof(SideShow_PacketHeader_t); - - Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); - Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); - Endpoint_ClearIN(); -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define INCLUDE_FROM_SIDESHOWCOMMANDS_H +#include "SideshowCommands.h" + +UNICODE_STRING_t(80) UserSID = {LengthInBytes: sizeof(SECURITY_INTERACTIVE_RID_SID), + UnicodeString: SECURITY_INTERACTIVE_RID_SID}; + +Unicode_String_t DeviceName = {LengthInBytes: sizeof(L"LUFA Sideshow Device"), + UnicodeString: L"LUFA Sideshow Device"}; + +Unicode_String_t Manufacturer = {LengthInBytes: sizeof(L"Dean Camera"), + UnicodeString: L"Dean Camera"}; + +Unicode_String_t SupportedLanguage = {LengthInBytes: sizeof(L"en-US:1"), + UnicodeString: L"en-US:1"}; + +void Sideshow_ProcessCommandPacket(void) +{ + SideShow_PacketHeader_t PacketHeader; + + Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM); + Endpoint_Read_Stream_LE(&PacketHeader, sizeof(SideShow_PacketHeader_t)); + + PacketHeader.Type.Response = true; + + printf("\r\nCmd: %lX", (PacketHeader.Type.TypeLong & 0x00FFFFFF)); + + switch (PacketHeader.Type.TypeLong & 0x00FFFFFF) + { + case SIDESHOW_CMD_PING: + SideShow_Ping(&PacketHeader); + break; + case SIDESHOW_CMD_SYNC: + SideShow_Sync(&PacketHeader); + break; + case SIDESHOW_CMD_GET_CURRENT_USER: + SideShow_GetCurrentUser(&PacketHeader); + break; + case SIDESHOW_CMD_SET_CURRENT_USER: + SideShow_SetCurrentUser(&PacketHeader); + break; + case SIDESHOW_CMD_GET_CAPABILITIES: + SideShow_GetCapabilities(&PacketHeader); + break; + case SIDESHOW_CMD_GET_DEVICE_NAME: + SideShow_GetString(&PacketHeader, &DeviceName); + break; + case SIDESHOW_CMD_GET_MANUFACTURER: + SideShow_GetString(&PacketHeader, &Manufacturer); + break; + case SIDESHOW_CMD_GET_APPLICATION_ORDER: + SideShow_GetApplicationOrder(&PacketHeader); + break; + case SIDESHOW_CMD_GET_SUPPORTED_ENDPOINTS: + SideShow_GetSupportedEndpoints(&PacketHeader); + break; + case SIDESHOW_CMD_ADD_APPLICATION: + SideShow_AddApplication(&PacketHeader); + break; + case SIDESHOW_CMD_ADD_CONTENT: + SideShow_AddContent(&PacketHeader); + break; + case SIDESHOW_CMD_DELETE_CONTENT: + SideShow_DeleteContent(&PacketHeader); + break; + case SIDESHOW_CMD_DELETE_ALL_CONTENT: + SideShow_DeleteAllContent(&PacketHeader); + break; + case SIDESHOW_CMD_DELETE_APPLICATION: + SideShow_DeleteApplication(&PacketHeader); + break; + case SIDESHOW_CMD_DELETE_ALL_APPLICATIONS: + SideShow_DeleteAllApplications(&PacketHeader); + break; + default: + PacketHeader.Length -= sizeof(SideShow_PacketHeader_t); + + Endpoint_Discard_Stream(PacketHeader.Length); + 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_ClearIN(); + + printf(" UNK"); + } +} + +static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader) +{ + Endpoint_ClearOUT(); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t ProtocolGUID; + + Endpoint_Read_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); + Endpoint_ClearOUT(); + + if (!(GUID_COMPARE(&ProtocolGUID, (uint32_t[])STANDARD_PROTOCOL_GUID))) + PacketHeader->Type.NAK = true; + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_Write_Stream_LE(&ProtocolGUID, sizeof(GUID_t)); + Endpoint_ClearIN(); +} + +static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* const PacketHeader) +{ + 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_ClearIN(); +} + +static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* const PacketHeader) +{ + SideShow_Read_Unicode_String(&UserSID, sizeof(UserSID.UnicodeString)); + Endpoint_ClearOUT(); + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_GetCapabilities(SideShow_PacketHeader_t* const PacketHeader) +{ + SideShow_PropertyKey_t Property; + SideShow_PropertyData_t PropertyData; + + Endpoint_Read_Stream_LE(&Property, sizeof(SideShow_PropertyKey_t)); + Endpoint_ClearOUT(); + + printf(" ID: %lu", Property.PropertyID); + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + if (GUID_COMPARE(&Property.PropertyGUID, (uint32_t[])SIDESHOW_PROPERTY_GUID)) + { + switch (Property.PropertyID) + { + case PROPERTY_SIDESHOW_SCREENTYPE: + PropertyData.DataType = VT_I4; + PropertyData.Data.Data32 = ScreenText; + PacketHeader->Length += sizeof(uint32_t); + + break; + case PROPERTY_SIDESHOW_SCREENWIDTH: + case PROPERTY_SIDESHOW_CLIENTWIDTH: + PropertyData.DataType = VT_UI2; + PropertyData.Data.Data16 = 16; + PacketHeader->Length += sizeof(uint16_t); + + break; + case PROPERTY_SIDESHOW_SCREENHEIGHT: + case PROPERTY_SIDESHOW_CLIENTHEIGHT: + PropertyData.DataType = VT_UI2; + PropertyData.Data.Data16 = 2; + PacketHeader->Length += sizeof(uint16_t); + + break; + case PROPERTY_SIDESHOW_COLORDEPTH: + PropertyData.DataType = VT_UI2; + PropertyData.Data.Data16 = 1; + PacketHeader->Length += sizeof(uint16_t); + + break; + case PROPERTY_SIDESHOW_COLORTYPE: + PropertyData.DataType = VT_UI2; + PropertyData.Data.Data16 = BlackAndWhiteDisplay; + PacketHeader->Length += sizeof(uint16_t); + + break; + case PROPERTY_SIDESHOW_DATACACHE: + PropertyData.DataType = VT_BOOL; + PropertyData.Data.Data16 = false; + PacketHeader->Length += sizeof(uint16_t); + + break; + case PROPERTY_SIDESHOW_SUPPORTEDLANGS: + case PROPERTY_SIDESHOW_CURRENTLANG: + PropertyData.DataType = VT_LPWSTR; + PropertyData.Data.DataPointer = &SupportedLanguage; + PacketHeader->Length += SupportedLanguage.LengthInBytes; + + break; + default: + PropertyData.DataType = VT_EMPTY; + break; + } + } + else if (GUID_COMPARE(&Property.PropertyGUID, (uint32_t[])DEVICE_PROPERTY_GUID)) + { + switch (Property.PropertyID) + { + case PROPERTY_DEVICE_DEVICETYPE: + PropertyData.DataType = VT_UI4; + PropertyData.Data.Data32 = GenericDevice; + PacketHeader->Length += sizeof(uint32_t); + + break; + } + } + else + { + PacketHeader->Type.NAK = true; + + printf(" WRONG GUID"); + printf(" %lX %lX %lX %lX", Property.PropertyGUID.Chunks[0], Property.PropertyGUID.Chunks[1], + Property.PropertyGUID.Chunks[2], Property.PropertyGUID.Chunks[3]); + } + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + + if (!(PacketHeader->Type.NAK)) + { + switch (PropertyData.DataType) + { + case VT_UI4: + case VT_I4: + Endpoint_Write_Stream_LE(&PropertyData.Data.Data32, sizeof(uint32_t)); + break; + case VT_UI2: + case VT_I2: + case VT_BOOL: + Endpoint_Write_Stream_LE(&PropertyData.Data.Data16, sizeof(uint16_t)); + break; + case VT_LPWSTR: + SideShow_Write_Unicode_String((Unicode_String_t*)PropertyData.Data.Data16); + break; + } + } + + Endpoint_ClearIN(); + return; +} + +static void SideShow_GetString(SideShow_PacketHeader_t* const PacketHeader, void* const UnicodeStruct) +{ + Endpoint_ClearOUT(); + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + + sizeof(uint32_t) + ((Unicode_String_t*)UnicodeStruct)->LengthInBytes; + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + SideShow_Write_Unicode_String(UnicodeStruct); + Endpoint_ClearIN(); +} + +static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* const PacketHeader) +{ + uint8_t TotalApplications = 0; + + Endpoint_ClearOUT(); + + for (uint8_t App = 0; App < MAX_APPLICATIONS; App++) + { + if (InstalledApplications[App].InUse) + TotalApplications++; + } + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + + sizeof(uint32_t) + (TotalApplications * sizeof(GUID_t)); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_Write_DWord_LE(TotalApplications); + + for (uint8_t App = 0; App < MAX_APPLICATIONS; App++) + { + if (InstalledApplications[App].InUse) + Endpoint_Write_Stream_LE(&InstalledApplications[App].ApplicationID, sizeof(GUID_t)); + } + + Endpoint_ClearIN(); +} + +static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t SupportedEndpointGUID = (GUID_t){Chunks: SIMPLE_CONTENT_FORMAT_GUID}; + + Endpoint_ClearOUT(); + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t) + sizeof(uint32_t) + sizeof(GUID_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_Write_DWord_LE(1); + Endpoint_Write_Stream_LE(&SupportedEndpointGUID, sizeof(GUID_t)); + Endpoint_ClearIN(); +} + +static void SideShow_AddApplication(SideShow_PacketHeader_t* const PacketHeader) +{ + SideShow_Application_t* CurrApp; + GUID_t ApplicationID; + + Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t)); + + CurrApp = SideShow_GetApplicationFromGUID(&ApplicationID); + + if (CurrApp == NULL) + CurrApp = SideShow_GetFreeApplication(); + + if (CurrApp == NULL) + { + PacketHeader->Length -= sizeof(SideShow_PacketHeader_t) + sizeof(GUID_t); + + Endpoint_Discard_Stream(PacketHeader->Length); + Endpoint_ClearOUT(); + + PacketHeader->Type.NAK = true; + } + else + { + CurrApp->ApplicationID = ApplicationID; + Endpoint_Read_Stream_LE(&CurrApp->EndpointID, sizeof(GUID_t)); + SideShow_Read_Unicode_String(&CurrApp->ApplicationName, sizeof(CurrApp->ApplicationName.UnicodeString)); + Endpoint_Read_Stream_LE(&CurrApp->CachePolicy, sizeof(uint32_t)); + Endpoint_Read_Stream_LE(&CurrApp->OnlineOnly, sizeof(uint32_t)); + SideShow_Discard_Byte_Stream(); + SideShow_Discard_Byte_Stream(); + SideShow_Discard_Byte_Stream(); + Endpoint_ClearOUT(); + + CurrApp->InUse = true; + CurrApp->HaveContent = false; + CurrApp->CurrentContentID = 1; + } + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t ApplicationGUID; + + Endpoint_Read_Stream_LE(&ApplicationGUID, sizeof(GUID_t)); + Endpoint_ClearOUT(); + + SideShow_Application_t* AppToDelete = SideShow_GetApplicationFromGUID(&ApplicationGUID); + + if (AppToDelete != NULL) + AppToDelete->InUse = false; + else + PacketHeader->Type.NAK = true; + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* const PacketHeader) +{ + 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_ClearIN(); +} + +static void SideShow_AddContent(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t ApplicationID; + GUID_t EndpointID; + SideShow_Application_t* Application; + + Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t)); + Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); + + Application = SideShow_GetApplicationFromGUID(&ApplicationID); + + if (Application == NULL) + { + SideShow_Discard_Byte_Stream(); + PacketHeader->Type.NAK = true; + } + else if (!(SideShow_AddSimpleContent(PacketHeader, Application))) + { + PacketHeader->Type.NAK = true; + } + + Endpoint_ClearOUT(); + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_DeleteContent(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t ApplicationID; + GUID_t EndpointID; + uint32_t ContentID; + + 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_ClearOUT(); + + SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); + + if ((Application != NULL) && (Application->CurrentContentID == ContentID)) + Application->HaveContent = false; + else + PacketHeader->Type.NAK = true; + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} + +static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* const PacketHeader) +{ + GUID_t ApplicationID; + GUID_t EndpointID; + + Endpoint_Read_Stream_LE(&ApplicationID, sizeof(GUID_t)); + Endpoint_Read_Stream_LE(&EndpointID, sizeof(GUID_t)); + Endpoint_ClearOUT(); + + SideShow_Application_t* Application = SideShow_GetApplicationFromGUID(&ApplicationID); + + if (Application != NULL) + Application->HaveContent = false; + else + PacketHeader->Type.NAK = true; + + PacketHeader->Length = sizeof(SideShow_PacketHeader_t); + + Endpoint_SelectEndpoint(SIDESHOW_IN_EPNUM); + Endpoint_Write_Stream_LE(PacketHeader, sizeof(SideShow_PacketHeader_t)); + Endpoint_ClearIN(); +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h index 0d8727d29..6d4ad4c26 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.h @@ -1,165 +1,165 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#ifndef _SIDESHOW_COMMANDS_H_ -#define _SIDESHOW_COMMANDS_H_ - - /* Includes: */ - #include - #include - #include - - #include "Sideshow.h" - #include "SideshowCommon.h" - #include "SideshowApplications.h" - #include "SideshowContent.h" - - /* Enumerations: */ - enum SideShow_PropertyKey_Types_t - { - VT_EMPTY = 0, - VT_NULL = 1, - VT_I2 = 2, - VT_I4 = 3, - VT_R4 = 4, - VT_R8 = 5, - VT_CY = 6, - VT_DATE = 7, - VT_BSTR = 8, - VT_DISPATCH = 9, - VT_ERROR = 10, - VT_BOOL = 11, - VT_VARIANT = 12, - VT_UNKNOWN = 13, - VT_UI1 = 17, - VT_UI2 = 18, - VT_UI4 = 19, - VT_LPWSTR = 31, - }; - - enum SideShow_ScreenTypeText_t - { - ScreenBitmap = 0, - ScreenText = 1, - }; - - enum SideShow_ColorTypes_t - { - ColorDisplay = 0, - GrayscaleDisplay = 1, - BlackAndWhiteDisplay = 2, - }; - - enum SideShow_DeviceTypes_t - { - GenericDevice = 0, - CameraDevice = 1, - MediaPlayerDevice = 2, - PhoneDevice = 3, - VideoDevice = 4, - PIMDevice = 5, - AudioRecorderDevice = 6 - }; - - /* Type Defines: */ - typedef struct - { - GUID_t PropertyGUID; - uint32_t PropertyID; - } SideShow_PropertyKey_t; - - typedef struct - { - uint32_t DataType; - - union - { - void* DataPointer; - uint8_t Data8; - uint16_t Data16; - uint32_t Data32; - } Data; - } SideShow_PropertyData_t; - - /* Macros: */ - #define SIDESHOW_CMD_PING 0x001 - #define SIDESHOW_CMD_SET_CURRENT_USER 0x100 - #define SIDESHOW_CMD_GET_CURRENT_USER 0x101 - #define SIDESHOW_CMD_GET_CAPABILITIES 0x103 - #define SIDESHOW_CMD_GET_APPLICATION_ORDER 0x104 - #define SIDESHOW_CMD_ADD_APPLICATION 0x10D - #define SIDESHOW_CMD_DELETE_APPLICATION 0x10E - #define SIDESHOW_CMD_DELETE_ALL_APPLICATIONS 0x10F - #define SIDESHOW_CMD_ADD_CONTENT 0x114 - #define SIDESHOW_CMD_DELETE_CONTENT 0x115 - #define SIDESHOW_CMD_DELETE_ALL_CONTENT 0x116 - #define SIDESHOW_CMD_GET_SUPPORTED_ENDPOINTS 0x117 - #define SIDESHOW_CMD_GET_DEVICE_NAME 0x500 - #define SIDESHOW_CMD_GET_MANUFACTURER 0x501 - #define SIDESHOW_CMD_SYNC 0x502 - - #define PROPERTY_SIDESHOW_DEVICEID 1 - #define PROPERTY_SIDESHOW_SCREENTYPE 2 - #define PROPERTY_SIDESHOW_SCREENWIDTH 3 - #define PROPERTY_SIDESHOW_SCREENHEIGHT 4 - #define PROPERTY_SIDESHOW_COLORDEPTH 5 - #define PROPERTY_SIDESHOW_COLORTYPE 6 - #define PROPERTY_SIDESHOW_DATACACHE 7 - #define PROPERTY_SIDESHOW_SUPPORTEDLANGS 8 - #define PROPERTY_SIDESHOW_CURRENTLANG 9 - #define PROPERTY_SIDESHOW_SUPPORTEDTHEMES 10 - #define PROPERTY_SIDESHOW_IMAGEFORMAT 14 - #define PROPERTY_SIDESHOW_CLIENTWIDTH 15 - #define PROPERTY_SIDESHOW_CLIENTHEIGHT 16 - #define PROPERTY_SIDESHOW_DEVICEICON 17 - - #define PROPERTY_DEVICE_DEVICETYPE 15 - - /* Function Prototypes: */ - void Sideshow_ProcessCommandPacket(void); - - #if defined(INCLUDE_FROM_SIDESHOWCOMMANDS_H) - static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_GetCapabilities(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_GetString(SideShow_PacketHeader_t* const PacketHeader, void* const UnicodeStruct); - static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_AddApplication(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_AddContent(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_DeleteContent(SideShow_PacketHeader_t* const PacketHeader); - static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* const PacketHeader); - #endif - -#endif +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#ifndef _SIDESHOW_COMMANDS_H_ +#define _SIDESHOW_COMMANDS_H_ + + /* Includes: */ + #include + #include + #include + + #include "Sideshow.h" + #include "SideshowCommon.h" + #include "SideshowApplications.h" + #include "SideshowContent.h" + + /* Enumerations: */ + enum SideShow_PropertyKey_Types_t + { + VT_EMPTY = 0, + VT_NULL = 1, + VT_I2 = 2, + VT_I4 = 3, + VT_R4 = 4, + VT_R8 = 5, + VT_CY = 6, + VT_DATE = 7, + VT_BSTR = 8, + VT_DISPATCH = 9, + VT_ERROR = 10, + VT_BOOL = 11, + VT_VARIANT = 12, + VT_UNKNOWN = 13, + VT_UI1 = 17, + VT_UI2 = 18, + VT_UI4 = 19, + VT_LPWSTR = 31, + }; + + enum SideShow_ScreenTypeText_t + { + ScreenBitmap = 0, + ScreenText = 1, + }; + + enum SideShow_ColorTypes_t + { + ColorDisplay = 0, + GrayscaleDisplay = 1, + BlackAndWhiteDisplay = 2, + }; + + enum SideShow_DeviceTypes_t + { + GenericDevice = 0, + CameraDevice = 1, + MediaPlayerDevice = 2, + PhoneDevice = 3, + VideoDevice = 4, + PIMDevice = 5, + AudioRecorderDevice = 6 + }; + + /* Type Defines: */ + typedef struct + { + GUID_t PropertyGUID; + uint32_t PropertyID; + } SideShow_PropertyKey_t; + + typedef struct + { + uint32_t DataType; + + union + { + void* DataPointer; + uint8_t Data8; + uint16_t Data16; + uint32_t Data32; + } Data; + } SideShow_PropertyData_t; + + /* Macros: */ + #define SIDESHOW_CMD_PING 0x001 + #define SIDESHOW_CMD_SET_CURRENT_USER 0x100 + #define SIDESHOW_CMD_GET_CURRENT_USER 0x101 + #define SIDESHOW_CMD_GET_CAPABILITIES 0x103 + #define SIDESHOW_CMD_GET_APPLICATION_ORDER 0x104 + #define SIDESHOW_CMD_ADD_APPLICATION 0x10D + #define SIDESHOW_CMD_DELETE_APPLICATION 0x10E + #define SIDESHOW_CMD_DELETE_ALL_APPLICATIONS 0x10F + #define SIDESHOW_CMD_ADD_CONTENT 0x114 + #define SIDESHOW_CMD_DELETE_CONTENT 0x115 + #define SIDESHOW_CMD_DELETE_ALL_CONTENT 0x116 + #define SIDESHOW_CMD_GET_SUPPORTED_ENDPOINTS 0x117 + #define SIDESHOW_CMD_GET_DEVICE_NAME 0x500 + #define SIDESHOW_CMD_GET_MANUFACTURER 0x501 + #define SIDESHOW_CMD_SYNC 0x502 + + #define PROPERTY_SIDESHOW_DEVICEID 1 + #define PROPERTY_SIDESHOW_SCREENTYPE 2 + #define PROPERTY_SIDESHOW_SCREENWIDTH 3 + #define PROPERTY_SIDESHOW_SCREENHEIGHT 4 + #define PROPERTY_SIDESHOW_COLORDEPTH 5 + #define PROPERTY_SIDESHOW_COLORTYPE 6 + #define PROPERTY_SIDESHOW_DATACACHE 7 + #define PROPERTY_SIDESHOW_SUPPORTEDLANGS 8 + #define PROPERTY_SIDESHOW_CURRENTLANG 9 + #define PROPERTY_SIDESHOW_SUPPORTEDTHEMES 10 + #define PROPERTY_SIDESHOW_IMAGEFORMAT 14 + #define PROPERTY_SIDESHOW_CLIENTWIDTH 15 + #define PROPERTY_SIDESHOW_CLIENTHEIGHT 16 + #define PROPERTY_SIDESHOW_DEVICEICON 17 + + #define PROPERTY_DEVICE_DEVICETYPE 15 + + /* Function Prototypes: */ + void Sideshow_ProcessCommandPacket(void); + + #if defined(INCLUDE_FROM_SIDESHOWCOMMANDS_H) + static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_GetCapabilities(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_GetString(SideShow_PacketHeader_t* const PacketHeader, void* const UnicodeStruct); + static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_AddApplication(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_AddContent(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_DeleteContent(SideShow_PacketHeader_t* const PacketHeader); + static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* const PacketHeader); + #endif + +#endif diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c index 68a819509..29f768ecc 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.c @@ -1,70 +1,70 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#include "SideshowCommon.h" - -uint16_t SideShow_Read_Unicode_String(void* const UnicodeString, const uint16_t MaxBytes) -{ - Unicode_String_t* const UnicodeStruct = (Unicode_String_t*)UnicodeString; - uint32_t UnicodeCharsToRead; - - Endpoint_Read_Stream_LE(&UnicodeCharsToRead, sizeof(uint32_t)); - - int UnicodeData[UnicodeCharsToRead]; - - UnicodeStruct->LengthInBytes = (UnicodeCharsToRead << 1); - - Endpoint_Read_Stream_LE(&UnicodeData, UnicodeStruct->LengthInBytes); - - if (UnicodeStruct->LengthInBytes > MaxBytes) - UnicodeStruct->LengthInBytes = MaxBytes; - - memcpy(&UnicodeStruct->UnicodeString, &UnicodeData, UnicodeStruct->LengthInBytes); - - return ((UnicodeCharsToRead << 1) + sizeof(uint32_t)); -} - -void SideShow_Write_Unicode_String(void* const UnicodeString) -{ - Unicode_String_t* const UnicodeStruct = (Unicode_String_t*)UnicodeString; - - uint32_t StringSizeInCharacters = (UnicodeStruct->LengthInBytes >> 1); - - Endpoint_Write_Stream_LE(&StringSizeInCharacters, sizeof(uint32_t)); - Endpoint_Write_Stream_LE(&UnicodeStruct->UnicodeString, UnicodeStruct->LengthInBytes); -} - -void SideShow_Discard_Byte_Stream(void) -{ - uint32_t StreamSize; - - Endpoint_Read_Stream_LE(&StreamSize, sizeof(uint32_t)); - Endpoint_Discard_Stream(StreamSize); -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#include "SideshowCommon.h" + +uint16_t SideShow_Read_Unicode_String(void* const UnicodeString, const uint16_t MaxBytes) +{ + Unicode_String_t* const UnicodeStruct = (Unicode_String_t*)UnicodeString; + uint32_t UnicodeCharsToRead; + + Endpoint_Read_Stream_LE(&UnicodeCharsToRead, sizeof(uint32_t)); + + int UnicodeData[UnicodeCharsToRead]; + + UnicodeStruct->LengthInBytes = (UnicodeCharsToRead << 1); + + Endpoint_Read_Stream_LE(&UnicodeData, UnicodeStruct->LengthInBytes); + + if (UnicodeStruct->LengthInBytes > MaxBytes) + UnicodeStruct->LengthInBytes = MaxBytes; + + memcpy(&UnicodeStruct->UnicodeString, &UnicodeData, UnicodeStruct->LengthInBytes); + + return ((UnicodeCharsToRead << 1) + sizeof(uint32_t)); +} + +void SideShow_Write_Unicode_String(void* const UnicodeString) +{ + Unicode_String_t* const UnicodeStruct = (Unicode_String_t*)UnicodeString; + + uint32_t StringSizeInCharacters = (UnicodeStruct->LengthInBytes >> 1); + + Endpoint_Write_Stream_LE(&StringSizeInCharacters, sizeof(uint32_t)); + Endpoint_Write_Stream_LE(&UnicodeStruct->UnicodeString, UnicodeStruct->LengthInBytes); +} + +void SideShow_Discard_Byte_Stream(void) +{ + uint32_t StreamSize; + + Endpoint_Read_Stream_LE(&StreamSize, sizeof(uint32_t)); + Endpoint_Discard_Stream(StreamSize); +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h index 9bda6acaf..7c632b3c4 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommon.h @@ -1,103 +1,103 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#ifndef _SIDESHOW_COMMON_H_ -#define _SIDESHOW_COMMON_H_ - - /* Includes: */ - #include - #include - - #include - - /* Macros: */ - #define GUID_COMPARE(a, b) (memcmp(a, b, sizeof(GUID_t)) == 0) - - #define ARRAY_ELEMENTS(x) (sizeof(x) / sizeof(x[0])) - - #define UNICODE_STRING_t(x) struct \ - { \ - uint16_t LengthInBytes; \ - int UnicodeString[x]; \ - } - - // {A33F248B-882F-4531-82C2-ED3B90C5C520} - #define STANDARD_PROTOCOL_GUID {0xA33F248B, 0x4531882F, 0x3BEDC282, 0x20C5C590} - // {A9A5353F-2D4B-47CE-93EE-759F3A7DDA4F} - #define SIMPLE_CONTENT_FORMAT_GUID {0xA9A5353F, 0x47CE2D4B, 0x9F75EE93, 0x4FDA7D3A} - // {8ABC88A8-857B-4ad7-A35A-B5942F492B99} - #define SIDESHOW_PROPERTY_GUID {0x8ABC88A8, 0x4AD7857B, 0x94B55AA3, 0x992B492F} - // {26D4979A-E643-4626-9E2B-736DC0C92FDC} - #define DEVICE_PROPERTY_GUID {0x26D4979A, 0x4626E643, 0x6D732B9E, 0xDC2FC9C0} - - #define SECURITY_INTERACTIVE_RID_SID L"S-1-5-4" - - #define MAX_APPLICATIONS 4 - #define MAX_CONTENTBUFFER_PER_APP 1024 - - /* Type Defines: */ - typedef struct - { - uint32_t Chunks[4]; - } GUID_t; - - typedef struct - { - uint16_t LengthInBytes; - int UnicodeString[]; - } Unicode_String_t; - - typedef union - { - uint32_t TypeLong; - - struct - { - uint8_t TypeBytes[3]; - - int ErrorCode : 6; - int NAK : 1; - int Response : 1; - }; - } SideShowPacketType_t; - - typedef struct - { - uint32_t Length; - SideShowPacketType_t Type; - uint16_t Number; - } SideShow_PacketHeader_t; - - /* Function Prototypes: */ - uint16_t SideShow_Read_Unicode_String(void* UnicodeString, const uint16_t MaxBytes); - void SideShow_Write_Unicode_String(void* UnicodeString); - void SideShow_Discard_Byte_Stream(void); - +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#ifndef _SIDESHOW_COMMON_H_ +#define _SIDESHOW_COMMON_H_ + + /* Includes: */ + #include + #include + + #include + + /* Macros: */ + #define GUID_COMPARE(a, b) (memcmp(a, b, sizeof(GUID_t)) == 0) + + #define ARRAY_ELEMENTS(x) (sizeof(x) / sizeof(x[0])) + + #define UNICODE_STRING_t(x) struct \ + { \ + uint16_t LengthInBytes; \ + int UnicodeString[x]; \ + } + + // {A33F248B-882F-4531-82C2-ED3B90C5C520} + #define STANDARD_PROTOCOL_GUID {0xA33F248B, 0x4531882F, 0x3BEDC282, 0x20C5C590} + // {A9A5353F-2D4B-47CE-93EE-759F3A7DDA4F} + #define SIMPLE_CONTENT_FORMAT_GUID {0xA9A5353F, 0x47CE2D4B, 0x9F75EE93, 0x4FDA7D3A} + // {8ABC88A8-857B-4ad7-A35A-B5942F492B99} + #define SIDESHOW_PROPERTY_GUID {0x8ABC88A8, 0x4AD7857B, 0x94B55AA3, 0x992B492F} + // {26D4979A-E643-4626-9E2B-736DC0C92FDC} + #define DEVICE_PROPERTY_GUID {0x26D4979A, 0x4626E643, 0x6D732B9E, 0xDC2FC9C0} + + #define SECURITY_INTERACTIVE_RID_SID L"S-1-5-4" + + #define MAX_APPLICATIONS 4 + #define MAX_CONTENTBUFFER_PER_APP 1024 + + /* Type Defines: */ + typedef struct + { + uint32_t Chunks[4]; + } GUID_t; + + typedef struct + { + uint16_t LengthInBytes; + int UnicodeString[]; + } Unicode_String_t; + + typedef union + { + uint32_t TypeLong; + + struct + { + uint8_t TypeBytes[3]; + + int ErrorCode : 6; + int NAK : 1; + int Response : 1; + }; + } SideShowPacketType_t; + + typedef struct + { + uint32_t Length; + SideShowPacketType_t Type; + uint16_t Number; + } SideShow_PacketHeader_t; + + /* Function Prototypes: */ + uint16_t SideShow_Read_Unicode_String(void* UnicodeString, const uint16_t MaxBytes); + void SideShow_Write_Unicode_String(void* UnicodeString); + void SideShow_Discard_Byte_Stream(void); + #endif \ No newline at end of file diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c index d77dc4a4e..0d1dd80fb 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.c @@ -1,76 +1,76 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#define INCLUDE_FROM_SIDESHOWCONTENT_C -#include "SideshowContent.h" - -bool SideShow_AddSimpleContent(SideShow_PacketHeader_t* const PacketHeader, SideShow_Application_t* const Application) -{ - uint32_t ContentSize; - uint32_t ContentID; - - Endpoint_Read_Stream_LE(&ContentID, sizeof(uint32_t)); - - PacketHeader->Length -= sizeof(uint32_t); - - if (Application->CurrentContentID != ContentID) - { - Endpoint_Discard_Stream(PacketHeader->Length); - - return false; - } - - Endpoint_Read_Stream_LE(&ContentSize, sizeof(uint32_t)); - Endpoint_Read_Stream_LE(&Application->CurrentContent, sizeof(XML_START_TAG) - 1); - - PacketHeader->Length -= sizeof(uint32_t) + (sizeof(XML_START_TAG) - 1); - - if (!(memcmp(&Application->CurrentContent, XML_START_TAG, (sizeof(XML_START_TAG) - 1)))) - { - SideShow_ProcessXMLContent(&Application->CurrentContent, (ContentSize - (sizeof(XML_END_TAG) - 1))); - - Endpoint_Discard_Stream(sizeof(XML_END_TAG) - 1); - - Application->HaveContent = true; - } - else - { - printf(" BINARY"); - Endpoint_Discard_Stream(ContentSize); - } - - return true; -} - -static void SideShow_ProcessXMLContent(void* ContentData, uint32_t ContentSize) -{ - printf(" XML"); - Endpoint_Discard_Stream(ContentSize); -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#define INCLUDE_FROM_SIDESHOWCONTENT_C +#include "SideshowContent.h" + +bool SideShow_AddSimpleContent(SideShow_PacketHeader_t* const PacketHeader, SideShow_Application_t* const Application) +{ + uint32_t ContentSize; + uint32_t ContentID; + + Endpoint_Read_Stream_LE(&ContentID, sizeof(uint32_t)); + + PacketHeader->Length -= sizeof(uint32_t); + + if (Application->CurrentContentID != ContentID) + { + Endpoint_Discard_Stream(PacketHeader->Length); + + return false; + } + + Endpoint_Read_Stream_LE(&ContentSize, sizeof(uint32_t)); + Endpoint_Read_Stream_LE(&Application->CurrentContent, sizeof(XML_START_TAG) - 1); + + PacketHeader->Length -= sizeof(uint32_t) + (sizeof(XML_START_TAG) - 1); + + if (!(memcmp(&Application->CurrentContent, XML_START_TAG, (sizeof(XML_START_TAG) - 1)))) + { + SideShow_ProcessXMLContent(&Application->CurrentContent, (ContentSize - (sizeof(XML_END_TAG) - 1))); + + Endpoint_Discard_Stream(sizeof(XML_END_TAG) - 1); + + Application->HaveContent = true; + } + else + { + printf(" BINARY"); + Endpoint_Discard_Stream(ContentSize); + } + + return true; +} + +static void SideShow_ProcessXMLContent(void* ContentData, uint32_t ContentSize) +{ + printf(" XML"); + Endpoint_Discard_Stream(ContentSize); +} diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h index 47c15fb88..97a6bee81 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowContent.h @@ -1,125 +1,125 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#ifndef _SIDESHOW_CONTENT_H_ -#define _SIDESHOW_CONTENT_H_ - - /* Includes: */ - #include - #include - #include - #include - - #include "SideshowCommon.h" - #include "SideshowApplications.h" - - /* Enums: */ - enum SideShow_ContentTypes_t - { - Content_Menu = 0, - Content_Content = 1, - Content_MenuItem = 2, - Content_Button = 3, - Content_Text = 4, - Content_EndOfContent = 5 - }; - - enum SideShow_ActionTypes_t - { - TODO - }; - - enum SideShow_AlignmentTypes_t - { - TODO2 - }; - - /* Type Defines: */ - typedef struct - { - uint8_t ContentType; - uint8_t ContentSize; - } SideShow_Content_Header_t; - - typedef struct - { - SideShow_Content_Header_t Header; - - uint32_t ItemID; - uint8_t ActionType; - char Title[]; - } SideShow_Content_Menu_t; - - typedef struct - { - SideShow_Content_Header_t Header; - - uint32_t ItemID; - uint32_t Target; - bool IsSelected; - char Text[]; - } SideShow_Content_MenuItem_t; - - typedef struct - { - SideShow_Content_Header_t Header; - - uint8_t Key; - uint32_t Target; - } SideShow_Content_Button_t; - - typedef struct - { - SideShow_Content_Header_t Header; - - uint32_t ItemID; - uint32_t AssociatedMenuID; - char Title[]; - } SideShow_Content_Content_t; - - typedef struct - { - SideShow_Content_Header_t Header; - - char Text[]; - } SideShow_Content_Text_t; - - /* Defines: */ - #define XML_START_TAG "" - #define XML_END_TAG "" - - /* Function Prototypes: */ - bool SideShow_AddSimpleContent(SideShow_PacketHeader_t* const PacketHeader, SideShow_Application_t* const Application); - - #if defined(INCLUDE_FROM_SIDESHOWCONTENT_C) - static void SideShow_ProcessXMLContent(void* ContentData, uint32_t ContentSize); - #endif - +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#ifndef _SIDESHOW_CONTENT_H_ +#define _SIDESHOW_CONTENT_H_ + + /* Includes: */ + #include + #include + #include + #include + + #include "SideshowCommon.h" + #include "SideshowApplications.h" + + /* Enums: */ + enum SideShow_ContentTypes_t + { + Content_Menu = 0, + Content_Content = 1, + Content_MenuItem = 2, + Content_Button = 3, + Content_Text = 4, + Content_EndOfContent = 5 + }; + + enum SideShow_ActionTypes_t + { + TODO + }; + + enum SideShow_AlignmentTypes_t + { + TODO2 + }; + + /* Type Defines: */ + typedef struct + { + uint8_t ContentType; + uint8_t ContentSize; + } SideShow_Content_Header_t; + + typedef struct + { + SideShow_Content_Header_t Header; + + uint32_t ItemID; + uint8_t ActionType; + char Title[]; + } SideShow_Content_Menu_t; + + typedef struct + { + SideShow_Content_Header_t Header; + + uint32_t ItemID; + uint32_t Target; + bool IsSelected; + char Text[]; + } SideShow_Content_MenuItem_t; + + typedef struct + { + SideShow_Content_Header_t Header; + + uint8_t Key; + uint32_t Target; + } SideShow_Content_Button_t; + + typedef struct + { + SideShow_Content_Header_t Header; + + uint32_t ItemID; + uint32_t AssociatedMenuID; + char Title[]; + } SideShow_Content_Content_t; + + typedef struct + { + SideShow_Content_Header_t Header; + + char Text[]; + } SideShow_Content_Text_t; + + /* Defines: */ + #define XML_START_TAG "" + #define XML_END_TAG "" + + /* Function Prototypes: */ + bool SideShow_AddSimpleContent(SideShow_PacketHeader_t* const PacketHeader, SideShow_Application_t* const Application); + + #if defined(INCLUDE_FROM_SIDESHOWCONTENT_C) + static void SideShow_ProcessXMLContent(void* ContentData, uint32_t ContentSize); + #endif + #endif \ No newline at end of file diff --git a/Demos/Device/Incomplete/Sideshow/Sideshow.c b/Demos/Device/Incomplete/Sideshow/Sideshow.c index 5f70b34c6..3e9778e29 100644 --- a/Demos/Device/Incomplete/Sideshow/Sideshow.c +++ b/Demos/Device/Incomplete/Sideshow/Sideshow.c @@ -1,158 +1,158 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -/* - SideShow Class demonstration application. This give a reference - for implementing Microsoft SideShow compatible devices in an - embedded environment. SideShow allows for gadget data displayed - on a Windows Vista or later machine to also be displayed on an - externally connected interactive display. Upon enumeration, this will - appear as a new SideShow device which can have gadgets loaded onto - it. - - Note that while the incoming content is buffered in packet struct - form, the data is not actually displayed. It is left to the user to - write sufficient code to read out the packed data for display to a - screen. - - Installed gadgets can be accessed through the InstalledApplications - array, with entries that have their InUse flag set being active. As - only the active content is displayed on the device due to memory - constraints, new content can be requested as needed. -*/ - -#include "Sideshow.h" - -/** 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) -{ - SetupHardware(); - - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); - sei(); - - 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 */ - clock_prescale_set(clock_div_1); - - /* Hardware Initialization */ - LEDs_Init(); - USB_Init(); - SerialStream_Init(9600, false); -} - -void EVENT_USB_Device_Connect(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); -} - -void EVENT_USB_Device_Disconnect(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); -} - -void EVENT_USB_Device_ConfigurationChanged(void) -{ - LEDs_SetAllLEDs(LEDMASK_USB_READY); - - /* 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); - } - - if (!(Endpoint_ConfigureEndpoint(SIDESHOW_OUT_EPNUM, EP_TYPE_BULK, - ENDPOINT_DIR_OUT, SIDESHOW_IO_EPSIZE, - ENDPOINT_BANK_SINGLE))) - { - LEDs_SetAllLEDs(LEDMASK_USB_ERROR); - } -} - -void EVENT_USB_Device_UnhandledControlRequest(void) -{ - /* Process UFI specific control requests */ - switch (USB_ControlRequest.bRequest) - { - case REQ_GetOSFeatureDescriptor: - if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE)) - { - void* DescriptorPointer; - uint16_t DescriptorSize; - - if (!(USB_GetOSFeatureDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, - &DescriptorPointer, &DescriptorSize))) - { - return; - } - - Endpoint_ClearSETUP(); - - Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); - Endpoint_ClearOUT(); - } - - break; - } -} - -void SideShow_Task(void) -{ - /* Device must be connected and configured for the task to run */ - if (USB_DeviceState != DEVICE_STATE_Configured) - return; - - /* Select the SideShow data out endpoint */ - Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM); - - /* Check to see if a new SideShow message has been received */ - if (Endpoint_IsReadWriteAllowed()) - { - /* Process the received SideShow message */ - Sideshow_ProcessCommandPacket(); - } -} +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +/* + SideShow Class demonstration application. This give a reference + for implementing Microsoft SideShow compatible devices in an + embedded environment. SideShow allows for gadget data displayed + on a Windows Vista or later machine to also be displayed on an + externally connected interactive display. Upon enumeration, this will + appear as a new SideShow device which can have gadgets loaded onto + it. + + Note that while the incoming content is buffered in packet struct + form, the data is not actually displayed. It is left to the user to + write sufficient code to read out the packed data for display to a + screen. + + Installed gadgets can be accessed through the InstalledApplications + array, with entries that have their InUse flag set being active. As + only the active content is displayed on the device due to memory + constraints, new content can be requested as needed. +*/ + +#include "Sideshow.h" + +/** 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) +{ + SetupHardware(); + + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); + sei(); + + 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 */ + clock_prescale_set(clock_div_1); + + /* Hardware Initialization */ + LEDs_Init(); + USB_Init(); + SerialStream_Init(9600, false); +} + +void EVENT_USB_Device_Connect(void) +{ + LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING); +} + +void EVENT_USB_Device_Disconnect(void) +{ + LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY); +} + +void EVENT_USB_Device_ConfigurationChanged(void) +{ + LEDs_SetAllLEDs(LEDMASK_USB_READY); + + /* 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); + } + + if (!(Endpoint_ConfigureEndpoint(SIDESHOW_OUT_EPNUM, EP_TYPE_BULK, + ENDPOINT_DIR_OUT, SIDESHOW_IO_EPSIZE, + ENDPOINT_BANK_SINGLE))) + { + LEDs_SetAllLEDs(LEDMASK_USB_ERROR); + } +} + +void EVENT_USB_Device_UnhandledControlRequest(void) +{ + /* Process UFI specific control requests */ + switch (USB_ControlRequest.bRequest) + { + case REQ_GetOSFeatureDescriptor: + if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_VENDOR | REQREC_DEVICE)) + { + void* DescriptorPointer; + uint16_t DescriptorSize; + + if (!(USB_GetOSFeatureDescriptor(USB_ControlRequest.wValue, USB_ControlRequest.wIndex, + &DescriptorPointer, &DescriptorSize))) + { + return; + } + + Endpoint_ClearSETUP(); + + Endpoint_Write_Control_PStream_LE(DescriptorPointer, DescriptorSize); + Endpoint_ClearOUT(); + } + + break; + } +} + +void SideShow_Task(void) +{ + /* Device must be connected and configured for the task to run */ + if (USB_DeviceState != DEVICE_STATE_Configured) + return; + + /* Select the SideShow data out endpoint */ + Endpoint_SelectEndpoint(SIDESHOW_OUT_EPNUM); + + /* Check to see if a new SideShow message has been received */ + if (Endpoint_IsReadWriteAllowed()) + { + /* Process the received SideShow message */ + Sideshow_ProcessCommandPacket(); + } +} diff --git a/Demos/Device/Incomplete/Sideshow/Sideshow.h b/Demos/Device/Incomplete/Sideshow/Sideshow.h index 871e47706..0f09e6489 100644 --- a/Demos/Device/Incomplete/Sideshow/Sideshow.h +++ b/Demos/Device/Incomplete/Sideshow/Sideshow.h @@ -1,78 +1,78 @@ -/* - LUFA Library - Copyright (C) Dean Camera, 2010. - - dean [at] fourwalledcubicle [dot] com - www.fourwalledcubicle.com -*/ - -/* - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - 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 - 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 - software without specific, written prior permission. - - The author disclaim all warranties with regard to this - software, including all implied warranties of merchantability - and fitness. In no event shall the author be liable for any - special, indirect or consequential damages or any damages - whatsoever resulting from loss of use, data or profits, whether - in an action of contract, negligence or other tortious action, - arising out of or in connection with the use or performance of - this software. -*/ - -#ifndef _SIDESHOW_H_ -#define _SIDESHOW_H_ - - /* Includes: */ - #include - #include - #include - #include - - #include "Descriptors.h" - #include "Lib/SideshowCommands.h" - - #include - #include - #include - #include - - /* Macros: */ - /** Device control request for used in the Microsoft OS Descriptor for retrieving the OS Feature - * descriptors of the device - */ - #define REQ_GetOSFeatureDescriptor 0x01 - - /** Descriptor index for a Microsoft Proprietary Extended Device Compatibility descriptor */ - #define EXTENDED_COMPAT_ID_DESCRIPTOR 0x0004 - - /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ - #define LEDMASK_USB_NOTREADY LEDS_LED1 - - /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ - #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) - - /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ - #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) - - /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ - #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) - - /* Function Prototypes: */ - void SetupHardware(void); - void SideShow_Task(void); - - void EVENT_USB_Device_Connect(void); - void EVENT_USB_Device_Disconnect(void); - void EVENT_USB_Device_ConfigurationChanged(void); - void EVENT_USB_Device_UnhandledControlRequest(void); - -#endif +/* + LUFA Library + Copyright (C) Dean Camera, 2010. + + dean [at] fourwalledcubicle [dot] com + www.fourwalledcubicle.com +*/ + +/* + Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) + + 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 + 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 + software without specific, written prior permission. + + The author disclaim all warranties with regard to this + software, including all implied warranties of merchantability + and fitness. In no event shall the author be liable for any + special, indirect or consequential damages or any damages + whatsoever resulting from loss of use, data or profits, whether + in an action of contract, negligence or other tortious action, + arising out of or in connection with the use or performance of + this software. +*/ + +#ifndef _SIDESHOW_H_ +#define _SIDESHOW_H_ + + /* Includes: */ + #include + #include + #include + #include + + #include "Descriptors.h" + #include "Lib/SideshowCommands.h" + + #include + #include + #include + #include + + /* Macros: */ + /** Device control request for used in the Microsoft OS Descriptor for retrieving the OS Feature + * descriptors of the device + */ + #define REQ_GetOSFeatureDescriptor 0x01 + + /** Descriptor index for a Microsoft Proprietary Extended Device Compatibility descriptor */ + #define EXTENDED_COMPAT_ID_DESCRIPTOR 0x0004 + + /** LED mask for the library LED driver, to indicate that the USB interface is not ready. */ + #define LEDMASK_USB_NOTREADY LEDS_LED1 + + /** LED mask for the library LED driver, to indicate that the USB interface is enumerating. */ + #define LEDMASK_USB_ENUMERATING (LEDS_LED2 | LEDS_LED3) + + /** LED mask for the library LED driver, to indicate that the USB interface is ready. */ + #define LEDMASK_USB_READY (LEDS_LED2 | LEDS_LED4) + + /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ + #define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3) + + /* Function Prototypes: */ + void SetupHardware(void); + void SideShow_Task(void); + + void EVENT_USB_Device_Connect(void); + void EVENT_USB_Device_Disconnect(void); + void EVENT_USB_Device_ConfigurationChanged(void); + void EVENT_USB_Device_UnhandledControlRequest(void); + +#endif diff --git a/Demos/Device/Incomplete/Sideshow/makefile b/Demos/Device/Incomplete/Sideshow/makefile index 0c61122b7..f558b08c3 100644 --- a/Demos/Device/Incomplete/Sideshow/makefile +++ b/Demos/Device/Incomplete/Sideshow/makefile @@ -1,743 +1,743 @@ -# 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 -# -# Additional material for this makefile was written by: -# Peter Fleury -# Tim Henigan -# Colin O'Flynn -# Reiner Patommel -# Markus Pfaff -# Sander Pool -# Frederik Rouleau -# Carlos Lamas -# Dean Camera -# Opendous Inc. -# Denver Gingerich -# -#---------------------------------------------------------------------------- -# On command line: -# -# make all = Make software. -# -# make clean = Clean out built project files. -# -# make coff = Convert ELF to AVR COFF. -# -# make extcoff = Convert ELF to AVR Extended COFF. -# -# 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. -# -# make filename.s = Just compile filename.c into the assembler code only. -# -# make filename.i = Create a preprocessed source file for use in submitting -# bug reports to the GCC project. -# -# To rebuild project do "make clean" then "make all". -#---------------------------------------------------------------------------- - - -# MCU name -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 -# "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 -# 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. -# -# This will be an integer division of F_CLOCK below, as it is sourced by -# F_CLOCK after it has run through any CPU prescalers. Note that this value -# does not *change* the processor frequency - it should merely be updated to -# reflect the processor speed set externally so that the code can use accurate -# software delays. -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) 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 -# 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 = $(F_CPU) - - -# Output format. (can be srec, ihex, binary) -FORMAT = ihex - - -# Target file name (without extension). -TARGET = SideShow - - -# Object files directory -# To put object files in current directory, use a dot (.), do NOT make -# this an empty or blank macro! -OBJDIR = . - - -# Path to the LUFA library -LUFA_PATH = ../../../.. - - -# LUFA library compile-time options -LUFA_OPTS = -D NO_STREAM_CALLBACKS -LUFA_OPTS += -D USB_DEVICE_ONLY -LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 -LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 -LUFA_OPTS += -D USE_FLASH_DESCRIPTORS -LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" - - -# List C source files here. (C dependencies are automatically generated.) -SRC = $(TARGET).c \ - Descriptors.c \ - Lib/SideshowCommon.c \ - Lib/SideshowCommands.c \ - Lib/SideshowApplications.c \ - Lib/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/LowLevel/USBInterrupt.c \ - $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \ - $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \ - $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.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 = - - -# List Assembler source files here. -# Make them always end in a capital .S. Files ending in a lowercase .s -# will not be considered source files but generated files (assembler -# output from the compiler), and will be deleted upon "make clean"! -# Even though the DOS/Win* filesystem matches both .s and .S the same, -# it will preserve the spelling of the filenames, and gcc itself does -# care about how the name is spelled on its command-line. -ASRC = - - -# 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 - - -# Debugging format. -# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. -# AVR Studio 4.10 requires dwarf-2. -# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. -DEBUG = dwarf-2 - - -# List any extra directories to look for include files here. -# 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 = $(LUFA_PATH)/ - - -# Compiler flag to set the C Standard level. -# c89 = "ANSI" C -# gnu89 = c89 plus GCC extensions -# c99 = ISO C99 standard (not yet fully implemented) -# gnu99 = c99 plus GCC extensions -CSTANDARD = -std=gnu99 - - -# Place -D or -U options here for C sources -CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS) - - -# Place -D or -U options here for ASM sources -ADEFS = -DF_CPU=$(F_CPU) - - -# Place -D or -U options here for C++ sources -CPPDEFS = -DF_CPU=$(F_CPU)UL -#CPPDEFS += -D__STDC_LIMIT_MACROS -#CPPDEFS += -D__STDC_CONSTANT_MACROS - - - -#---------------- Compiler Options C ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CFLAGS = -g$(DEBUG) -CFLAGS += $(CDEFS) -CFLAGS += -O$(OPT) -CFLAGS += -funsigned-char -CFLAGS += -funsigned-bitfields -CFLAGS += -ffunction-sections -CFLAGS += -fno-inline-small-functions -CFLAGS += -fpack-struct -CFLAGS += -fshort-enums -CFLAGS += -Wall -CFLAGS += -Wstrict-prototypes -CFLAGS += -Wundef -#CFLAGS += -fno-unit-at-a-time -#CFLAGS += -Wunreachable-code -#CFLAGS += -Wsign-compare -CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) -CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -CFLAGS += $(CSTANDARD) - - -#---------------- Compiler Options C++ ---------------- -# -g*: generate debugging information -# -O*: optimization level -# -f...: tuning, see GCC manual and avr-libc documentation -# -Wall...: warning level -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns...: create assembler listing -CPPFLAGS = -g$(DEBUG) -CPPFLAGS += $(CPPDEFS) -CPPFLAGS += -O$(OPT) -CPPFLAGS += -funsigned-char -CPPFLAGS += -funsigned-bitfields -CPPFLAGS += -fpack-struct -CPPFLAGS += -fshort-enums -CPPFLAGS += -fno-exceptions -CPPFLAGS += -Wall -CFLAGS += -Wundef -#CPPFLAGS += -mshort-calls -#CPPFLAGS += -fno-unit-at-a-time -#CPPFLAGS += -Wstrict-prototypes -#CPPFLAGS += -Wunreachable-code -#CPPFLAGS += -Wsign-compare -CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) -CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) -#CPPFLAGS += $(CSTANDARD) - - -#---------------- Assembler Options ---------------- -# -Wa,...: tell GCC to pass this to the assembler. -# -adhlns: create listing -# -gstabs: have the assembler create line number information; note that -# 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 -# 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 - - -#---------------- Library Options ---------------- -# Minimalistic printf version -PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min - -# Floating point printf version (requires MATH_LIB = -lm below) -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_MIN) -#PRINTF_LIB = $(PRINTF_LIB_FLOAT) - - -# Minimalistic scanf version -SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min - -# Floating point + %[ scanf version (requires MATH_LIB = -lm below) -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_MIN) -#SCANF_LIB = $(SCANF_LIB_FLOAT) - - -MATH_LIB = -lm - - -# List any extra directories to look for libraries here. -# 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 = - - - -#---------------- External Memory Options ---------------- - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# used for variables (.data/.bss) and heap (malloc()). -#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff - -# 64 KB of external RAM, starting after internal RAM (ATmega128!), -# only used for heap (malloc()). -#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff - -EXTMEMOPTS = - - - -#---------------- Linker Options ---------------- -# -Wl,...: tell GCC to pass this to linker. -# -Map: create map file -# --cref: add cross reference to map file -LDFLAGS = -Wl,-Map=$(TARGET).map,--cref -LDFLAGS += -Wl,--relax -LDFLAGS += -Wl,--gc-sections -LDFLAGS += $(EXTMEMOPTS) -LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) -LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) -#LDFLAGS += -T linker_script.x - - - -#---------------- Programming Options (avrdude) ---------------- - -# Programming hardware: alf avr910 avrisp bascom bsd -# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 -# -# Type: avrdude -c ? -# to get a full listing. -# -AVRDUDE_PROGRAMMER = jtagmkII - -# com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = usb - -AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex -#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep - - -# Uncomment the following if you want avrdude's erase cycle counter. -# Note that this counter needs to be initialized first using -Yn, -# see avrdude manual. -#AVRDUDE_ERASE_COUNTER = -y - -# Uncomment the following if you do /not/ wish a verification to be -# performed after programming the device. -#AVRDUDE_NO_VERIFY = -V - -# Increase verbosity level. Please use this when submitting bug -# reports about avrdude. See -# to submit bug reports. -#AVRDUDE_VERBOSE = -v -v - -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) -AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) -AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) -AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) - - - -#---------------- Debugging Options ---------------- - -# For simulavr only - target MCU frequency. -DEBUG_MFREQ = $(F_CPU) - -# Set the DEBUG_UI to either gdb or insight. -# DEBUG_UI = gdb -DEBUG_UI = insight - -# Set the debugging back-end to either avarice, simulavr. -DEBUG_BACKEND = avarice -#DEBUG_BACKEND = simulavr - -# GDB Init Filename. -GDBINIT_FILE = __avr_gdbinit - -# When using avarice settings for the JTAG -JTAG_DEV = /dev/com1 - -# Debugging port used to communicate between GDB / avarice / simulavr. -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 -# avarice is running on a different computer. -DEBUG_HOST = localhost - - - -#============================================================================ - - -# Define programs and commands. -SHELL = sh -CC = avr-gcc -OBJCOPY = avr-objcopy -OBJDUMP = avr-objdump -SIZE = avr-size -AR = avr-ar rcs -NM = avr-nm -AVRDUDE = avrdude -REMOVE = rm -f -REMOVEDIR = rm -rf -COPY = cp -WINSHELL = cmd - -# Define Messages -# English -MSG_ERRORS_NONE = Errors: none -MSG_BEGIN = -------- begin -------- -MSG_END = -------- end -------- -MSG_SIZE_BEFORE = Size before: -MSG_SIZE_AFTER = Size after: -MSG_COFF = Converting to AVR COFF: -MSG_EXTENDED_COFF = Converting to AVR Extended COFF: -MSG_FLASH = Creating load file for Flash: -MSG_EEPROM = Creating load file for EEPROM: -MSG_EXTENDED_LISTING = Creating Extended Listing: -MSG_SYMBOL_TABLE = Creating Symbol Table: -MSG_LINKING = Linking: -MSG_COMPILING = Compiling C: -MSG_COMPILING_CPP = Compiling C++: -MSG_ASSEMBLING = Assembling: -MSG_CLEANING = Cleaning project: -MSG_CREATING_LIBRARY = Creating library: - - - - -# Define all object files. -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) - - -# Compiler flags to generate dependency files. -GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d - - -# Combine all necessary flags and optional flags. -# Add target processor to flags. -ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) -ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) -ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) - - - - - -# Default target. -all: begin gccversion sizebefore build checkinvalidevents showliboptions showtarget sizeafter end - -# Change the build target to build a HEX file or a library. -build: elf hex eep lss sym -#build: lib - - -elf: $(TARGET).elf -hex: $(TARGET).hex -eep: $(TARGET).eep -lss: $(TARGET).lss -sym: $(TARGET).sym -LIBNAME=lib$(TARGET).a -lib: $(LIBNAME) - - - -# Eye candy. -# AVR Studio 3.x does not check make's exit code but relies on -# the following magic strings to be generated by the compile job. -begin: - @echo - @echo $(MSG_BEGIN) - -end: - @echo $(MSG_END) - @echo - - -# Display size of file. -HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex -ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf -MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) -FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) - -sizebefore: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -sizeafter: - @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ - 2>/dev/null; echo; fi - -$(LUFA_PATH)/LUFA/LUFA_Events.lst: - @$(MAKE) -C $(LUFA_PATH)/LUFA/ LUFA_Events.lst - -checkinvalidevents: $(LUFA_PATH)/LUFA/LUFA_Events.lst - @echo - @echo Checking for invalid events... - @$(shell) avr-nm $(OBJ) | sed -n -e 's/^.*EVENT_/EVENT_/p' | \ - grep -F -v --file=$(LUFA_PATH)/LUFA/LUFA_Events.lst > InvalidEvents.tmp || true - @sed -n -e 's/^/ WARNING - INVALID EVENT NAME: /p' InvalidEvents.tmp - @if test -s InvalidEvents.tmp; then exit 1; fi - -showliboptions: - @echo - @echo ---- Compile Time Library Options ---- - @for i in $(LUFA_OPTS:-D%=%); do \ - echo $$i; \ - done - @echo -------------------------------------- - -showtarget: - @echo - @echo --------- Target Information --------- - @echo AVR Model: $(MCU) - @echo Board: $(BOARD) - @echo Clock: $(F_CPU)Hz CPU, $(F_CLOCK)Hz Master - @echo -------------------------------------- - - -# Display compiler version information. -gccversion : - @$(CC) --version - - -# Program the device. -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 - $(REMOVE) $(TARGET)eep.hex - -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 -# a breakpoint at main(). -gdb-config: - @$(REMOVE) $(GDBINIT_FILE) - @echo define reset >> $(GDBINIT_FILE) - @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) - @echo end >> $(GDBINIT_FILE) - @echo file $(TARGET).elf >> $(GDBINIT_FILE) - @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) -ifeq ($(DEBUG_BACKEND),simulavr) - @echo load >> $(GDBINIT_FILE) -endif - @echo break main >> $(GDBINIT_FILE) - -debug: gdb-config $(TARGET).elf -ifeq ($(DEBUG_BACKEND), avarice) - @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. - @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ - $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) - @$(WINSHELL) /c pause - -else - @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ - $(DEBUG_MFREQ) --port $(DEBUG_PORT) -endif - @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) - - - - -# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. -COFFCONVERT = $(OBJCOPY) --debugging -COFFCONVERT += --change-section-address .data-0x800000 -COFFCONVERT += --change-section-address .bss-0x800000 -COFFCONVERT += --change-section-address .noinit-0x800000 -COFFCONVERT += --change-section-address .eeprom-0x810000 - - - -coff: $(TARGET).elf - @echo - @echo $(MSG_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-avr $< $(TARGET).cof - - -extcoff: $(TARGET).elf - @echo - @echo $(MSG_EXTENDED_COFF) $(TARGET).cof - $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof - - - -# Create final output files (.hex, .eep) from ELF output file. -%.hex: %.elf - @echo - @echo $(MSG_FLASH) $@ - $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ - -%.eep: %.elf - @echo - @echo $(MSG_EEPROM) $@ - -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ - --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 - -# Create extended listing file from ELF output file. -%.lss: %.elf - @echo - @echo $(MSG_EXTENDED_LISTING) $@ - $(OBJDUMP) -h -z -S $< > $@ - -# Create a symbol table from ELF output file. -%.sym: %.elf - @echo - @echo $(MSG_SYMBOL_TABLE) $@ - $(NM) -n $< > $@ - - - -# Create library from object files. -.SECONDARY : $(TARGET).a -.PRECIOUS : $(OBJ) -%.a: $(OBJ) - @echo - @echo $(MSG_CREATING_LIBRARY) $@ - $(AR) $@ $(OBJ) - - -# Link: create ELF output file from object files. -.SECONDARY : $(TARGET).elf -.PRECIOUS : $(OBJ) -%.elf: $(OBJ) - @echo - @echo $(MSG_LINKING) $@ - $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) - - -# Compile: create object files from C source files. -$(OBJDIR)/%.o : %.c - @echo - @echo $(MSG_COMPILING) $< - $(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 $@ - - -# Compile: create assembler files from C source files. -%.s : %.c - $(CC) -S $(ALL_CFLAGS) $< -o $@ - - -# Compile: create assembler files from C++ source files. -%.s : %.cpp - $(CC) -S $(ALL_CPPFLAGS) $< -o $@ - - -# Assemble: create object files from assembler source files. -$(OBJDIR)/%.o : %.S - @echo - @echo $(MSG_ASSEMBLING) $< - $(CC) -c $(ALL_ASFLAGS) $< -o $@ - - -# Create preprocessed source for use in sending a bug report. -%.i : %.c - $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ - - -# Target: clean project. -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 - $(REMOVE) $(TARGET).sym - $(REMOVE) $(TARGET).lss - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) - $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) - $(REMOVE) $(SRC:.c=.s) - $(REMOVE) $(SRC:.c=.d) - $(REMOVE) $(SRC:.c=.i) - $(REMOVE) InvalidEvents.tmp - $(REMOVEDIR) .dep - -doxygen: - @echo Generating Project Documentation... - @doxygen Doxygen.conf - @echo Documentation Generation Complete. - -clean_doxygen: - rm -rf Documentation - -# Create object files directory -$(shell mkdir $(OBJDIR) 2>/dev/null) - - -# Include the dependency files. --include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) - - -# Listing of phony targets. -.PHONY : all checkinvalidevents showliboptions \ -showtarget begin finish end sizebefore sizeafter \ -gccversion build elf hex eep lss sym coff extcoff \ -program dfu flip flip-ee dfu-ee clean debug \ +# 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 +# +# Additional material for this makefile was written by: +# Peter Fleury +# Tim Henigan +# Colin O'Flynn +# Reiner Patommel +# Markus Pfaff +# Sander Pool +# Frederik Rouleau +# Carlos Lamas +# Dean Camera +# Opendous Inc. +# Denver Gingerich +# +#---------------------------------------------------------------------------- +# On command line: +# +# make all = Make software. +# +# make clean = Clean out built project files. +# +# make coff = Convert ELF to AVR COFF. +# +# make extcoff = Convert ELF to AVR Extended COFF. +# +# 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. +# +# make filename.s = Just compile filename.c into the assembler code only. +# +# make filename.i = Create a preprocessed source file for use in submitting +# bug reports to the GCC project. +# +# To rebuild project do "make clean" then "make all". +#---------------------------------------------------------------------------- + + +# MCU name +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 +# "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 +# 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. +# +# This will be an integer division of F_CLOCK below, as it is sourced by +# F_CLOCK after it has run through any CPU prescalers. Note that this value +# does not *change* the processor frequency - it should merely be updated to +# reflect the processor speed set externally so that the code can use accurate +# software delays. +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) 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 +# 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 = $(F_CPU) + + +# Output format. (can be srec, ihex, binary) +FORMAT = ihex + + +# Target file name (without extension). +TARGET = SideShow + + +# Object files directory +# To put object files in current directory, use a dot (.), do NOT make +# this an empty or blank macro! +OBJDIR = . + + +# Path to the LUFA library +LUFA_PATH = ../../../.. + + +# LUFA library compile-time options +LUFA_OPTS = -D NO_STREAM_CALLBACKS +LUFA_OPTS += -D USB_DEVICE_ONLY +LUFA_OPTS += -D FIXED_CONTROL_ENDPOINT_SIZE=8 +LUFA_OPTS += -D FIXED_NUM_CONFIGURATIONS=1 +LUFA_OPTS += -D USE_FLASH_DESCRIPTORS +LUFA_OPTS += -D USE_STATIC_OPTIONS="(USB_DEVICE_OPT_FULLSPEED | USB_OPT_REG_ENABLED | USB_OPT_AUTO_PLL)" + + +# List C source files here. (C dependencies are automatically generated.) +SRC = $(TARGET).c \ + Descriptors.c \ + Lib/SideshowCommon.c \ + Lib/SideshowCommands.c \ + Lib/SideshowApplications.c \ + Lib/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/LowLevel/USBInterrupt.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/Events.c \ + $(LUFA_PATH)/LUFA/Drivers/USB/HighLevel/USBTask.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 = + + +# List Assembler source files here. +# Make them always end in a capital .S. Files ending in a lowercase .s +# will not be considered source files but generated files (assembler +# output from the compiler), and will be deleted upon "make clean"! +# Even though the DOS/Win* filesystem matches both .s and .S the same, +# it will preserve the spelling of the filenames, and gcc itself does +# care about how the name is spelled on its command-line. +ASRC = + + +# 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 + + +# Debugging format. +# Native formats for AVR-GCC's -g are dwarf-2 [default] or stabs. +# AVR Studio 4.10 requires dwarf-2. +# AVR [Extended] COFF format requires stabs, plus an avr-objcopy run. +DEBUG = dwarf-2 + + +# List any extra directories to look for include files here. +# 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 = $(LUFA_PATH)/ + + +# Compiler flag to set the C Standard level. +# c89 = "ANSI" C +# gnu89 = c89 plus GCC extensions +# c99 = ISO C99 standard (not yet fully implemented) +# gnu99 = c99 plus GCC extensions +CSTANDARD = -std=gnu99 + + +# Place -D or -U options here for C sources +CDEFS = -DF_CPU=$(F_CPU)UL -DF_CLOCK=$(F_CLOCK)UL -DBOARD=BOARD_$(BOARD) $(LUFA_OPTS) + + +# Place -D or -U options here for ASM sources +ADEFS = -DF_CPU=$(F_CPU) + + +# Place -D or -U options here for C++ sources +CPPDEFS = -DF_CPU=$(F_CPU)UL +#CPPDEFS += -D__STDC_LIMIT_MACROS +#CPPDEFS += -D__STDC_CONSTANT_MACROS + + + +#---------------- Compiler Options C ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CFLAGS = -g$(DEBUG) +CFLAGS += $(CDEFS) +CFLAGS += -O$(OPT) +CFLAGS += -funsigned-char +CFLAGS += -funsigned-bitfields +CFLAGS += -ffunction-sections +CFLAGS += -fno-inline-small-functions +CFLAGS += -fpack-struct +CFLAGS += -fshort-enums +CFLAGS += -Wall +CFLAGS += -Wstrict-prototypes +CFLAGS += -Wundef +#CFLAGS += -fno-unit-at-a-time +#CFLAGS += -Wunreachable-code +#CFLAGS += -Wsign-compare +CFLAGS += -Wa,-adhlns=$(<:%.c=$(OBJDIR)/%.lst) +CFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +CFLAGS += $(CSTANDARD) + + +#---------------- Compiler Options C++ ---------------- +# -g*: generate debugging information +# -O*: optimization level +# -f...: tuning, see GCC manual and avr-libc documentation +# -Wall...: warning level +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns...: create assembler listing +CPPFLAGS = -g$(DEBUG) +CPPFLAGS += $(CPPDEFS) +CPPFLAGS += -O$(OPT) +CPPFLAGS += -funsigned-char +CPPFLAGS += -funsigned-bitfields +CPPFLAGS += -fpack-struct +CPPFLAGS += -fshort-enums +CPPFLAGS += -fno-exceptions +CPPFLAGS += -Wall +CFLAGS += -Wundef +#CPPFLAGS += -mshort-calls +#CPPFLAGS += -fno-unit-at-a-time +#CPPFLAGS += -Wstrict-prototypes +#CPPFLAGS += -Wunreachable-code +#CPPFLAGS += -Wsign-compare +CPPFLAGS += -Wa,-adhlns=$(<:%.cpp=$(OBJDIR)/%.lst) +CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS)) +#CPPFLAGS += $(CSTANDARD) + + +#---------------- Assembler Options ---------------- +# -Wa,...: tell GCC to pass this to the assembler. +# -adhlns: create listing +# -gstabs: have the assembler create line number information; note that +# 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 +# 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 + + +#---------------- Library Options ---------------- +# Minimalistic printf version +PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min + +# Floating point printf version (requires MATH_LIB = -lm below) +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_MIN) +#PRINTF_LIB = $(PRINTF_LIB_FLOAT) + + +# Minimalistic scanf version +SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min + +# Floating point + %[ scanf version (requires MATH_LIB = -lm below) +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_MIN) +#SCANF_LIB = $(SCANF_LIB_FLOAT) + + +MATH_LIB = -lm + + +# List any extra directories to look for libraries here. +# 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 = + + + +#---------------- External Memory Options ---------------- + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# used for variables (.data/.bss) and heap (malloc()). +#EXTMEMOPTS = -Wl,-Tdata=0x801100,--defsym=__heap_end=0x80ffff + +# 64 KB of external RAM, starting after internal RAM (ATmega128!), +# only used for heap (malloc()). +#EXTMEMOPTS = -Wl,--section-start,.data=0x801100,--defsym=__heap_end=0x80ffff + +EXTMEMOPTS = + + + +#---------------- Linker Options ---------------- +# -Wl,...: tell GCC to pass this to linker. +# -Map: create map file +# --cref: add cross reference to map file +LDFLAGS = -Wl,-Map=$(TARGET).map,--cref +LDFLAGS += -Wl,--relax +LDFLAGS += -Wl,--gc-sections +LDFLAGS += $(EXTMEMOPTS) +LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS)) +LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) +#LDFLAGS += -T linker_script.x + + + +#---------------- Programming Options (avrdude) ---------------- + +# Programming hardware: alf avr910 avrisp bascom bsd +# dt006 pavr picoweb pony-stk200 sp12 stk200 stk500 +# +# Type: avrdude -c ? +# to get a full listing. +# +AVRDUDE_PROGRAMMER = jtagmkII + +# com1 = serial port. Use lpt1 to connect to parallel port. +AVRDUDE_PORT = usb + +AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex +#AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep + + +# Uncomment the following if you want avrdude's erase cycle counter. +# Note that this counter needs to be initialized first using -Yn, +# see avrdude manual. +#AVRDUDE_ERASE_COUNTER = -y + +# Uncomment the following if you do /not/ wish a verification to be +# performed after programming the device. +#AVRDUDE_NO_VERIFY = -V + +# Increase verbosity level. Please use this when submitting bug +# reports about avrdude. See +# to submit bug reports. +#AVRDUDE_VERBOSE = -v -v + +AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) +AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) +AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) + + + +#---------------- Debugging Options ---------------- + +# For simulavr only - target MCU frequency. +DEBUG_MFREQ = $(F_CPU) + +# Set the DEBUG_UI to either gdb or insight. +# DEBUG_UI = gdb +DEBUG_UI = insight + +# Set the debugging back-end to either avarice, simulavr. +DEBUG_BACKEND = avarice +#DEBUG_BACKEND = simulavr + +# GDB Init Filename. +GDBINIT_FILE = __avr_gdbinit + +# When using avarice settings for the JTAG +JTAG_DEV = /dev/com1 + +# Debugging port used to communicate between GDB / avarice / simulavr. +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 +# avarice is running on a different computer. +DEBUG_HOST = localhost + + + +#============================================================================ + + +# Define programs and commands. +SHELL = sh +CC = avr-gcc +OBJCOPY = avr-objcopy +OBJDUMP = avr-objdump +SIZE = avr-size +AR = avr-ar rcs +NM = avr-nm +AVRDUDE = avrdude +REMOVE = rm -f +REMOVEDIR = rm -rf +COPY = cp +WINSHELL = cmd + +# Define Messages +# English +MSG_ERRORS_NONE = Errors: none +MSG_BEGIN = -------- begin -------- +MSG_END = -------- end -------- +MSG_SIZE_BEFORE = Size before: +MSG_SIZE_AFTER = Size after: +MSG_COFF = Converting to AVR COFF: +MSG_EXTENDED_COFF = Converting to AVR Extended COFF: +MSG_FLASH = Creating load file for Flash: +MSG_EEPROM = Creating load file for EEPROM: +MSG_EXTENDED_LISTING = Creating Extended Listing: +MSG_SYMBOL_TABLE = Creating Symbol Table: +MSG_LINKING = Linking: +MSG_COMPILING = Compiling C: +MSG_COMPILING_CPP = Compiling C++: +MSG_ASSEMBLING = Assembling: +MSG_CLEANING = Cleaning project: +MSG_CREATING_LIBRARY = Creating library: + + + + +# Define all object files. +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) + + +# Compiler flags to generate dependency files. +GENDEPFLAGS = -MMD -MP -MF .dep/$(@F).d + + +# Combine all necessary flags and optional flags. +# Add target processor to flags. +ALL_CFLAGS = -mmcu=$(MCU) -I. $(CFLAGS) $(GENDEPFLAGS) +ALL_CPPFLAGS = -mmcu=$(MCU) -I. -x c++ $(CPPFLAGS) $(GENDEPFLAGS) +ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS) + + + + + +# Default target. +all: begin gccversion sizebefore build checkinvalidevents showliboptions showtarget sizeafter end + +# Change the build target to build a HEX file or a library. +build: elf hex eep lss sym +#build: lib + + +elf: $(TARGET).elf +hex: $(TARGET).hex +eep: $(TARGET).eep +lss: $(TARGET).lss +sym: $(TARGET).sym +LIBNAME=lib$(TARGET).a +lib: $(LIBNAME) + + + +# Eye candy. +# AVR Studio 3.x does not check make's exit code but relies on +# the following magic strings to be generated by the compile job. +begin: + @echo + @echo $(MSG_BEGIN) + +end: + @echo $(MSG_END) + @echo + + +# Display size of file. +HEXSIZE = $(SIZE) --target=$(FORMAT) $(TARGET).hex +ELFSIZE = $(SIZE) $(MCU_FLAG) $(FORMAT_FLAG) $(TARGET).elf +MCU_FLAG = $(shell $(SIZE) --help | grep -- --mcu > /dev/null && echo --mcu=$(MCU) ) +FORMAT_FLAG = $(shell $(SIZE) --help | grep -- --format=.*avr > /dev/null && echo --format=avr ) + +sizebefore: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_BEFORE); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +sizeafter: + @if test -f $(TARGET).elf; then echo; echo $(MSG_SIZE_AFTER); $(ELFSIZE); \ + 2>/dev/null; echo; fi + +$(LUFA_PATH)/LUFA/LUFA_Events.lst: + @$(MAKE) -C $(LUFA_PATH)/LUFA/ LUFA_Events.lst + +checkinvalidevents: $(LUFA_PATH)/LUFA/LUFA_Events.lst + @echo + @echo Checking for invalid events... + @$(shell) avr-nm $(OBJ) | sed -n -e 's/^.*EVENT_/EVENT_/p' | \ + grep -F -v --file=$(LUFA_PATH)/LUFA/LUFA_Events.lst > InvalidEvents.tmp || true + @sed -n -e 's/^/ WARNING - INVALID EVENT NAME: /p' InvalidEvents.tmp + @if test -s InvalidEvents.tmp; then exit 1; fi + +showliboptions: + @echo + @echo ---- Compile Time Library Options ---- + @for i in $(LUFA_OPTS:-D%=%); do \ + echo $$i; \ + done + @echo -------------------------------------- + +showtarget: + @echo + @echo --------- Target Information --------- + @echo AVR Model: $(MCU) + @echo Board: $(BOARD) + @echo Clock: $(F_CPU)Hz CPU, $(F_CLOCK)Hz Master + @echo -------------------------------------- + + +# Display compiler version information. +gccversion : + @$(CC) --version + + +# Program the device. +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 + $(REMOVE) $(TARGET)eep.hex + +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 +# a breakpoint at main(). +gdb-config: + @$(REMOVE) $(GDBINIT_FILE) + @echo define reset >> $(GDBINIT_FILE) + @echo SIGNAL SIGHUP >> $(GDBINIT_FILE) + @echo end >> $(GDBINIT_FILE) + @echo file $(TARGET).elf >> $(GDBINIT_FILE) + @echo target remote $(DEBUG_HOST):$(DEBUG_PORT) >> $(GDBINIT_FILE) +ifeq ($(DEBUG_BACKEND),simulavr) + @echo load >> $(GDBINIT_FILE) +endif + @echo break main >> $(GDBINIT_FILE) + +debug: gdb-config $(TARGET).elf +ifeq ($(DEBUG_BACKEND), avarice) + @echo Starting AVaRICE - Press enter when "waiting to connect" message displays. + @$(WINSHELL) /c start avarice --jtag $(JTAG_DEV) --erase --program --file \ + $(TARGET).elf $(DEBUG_HOST):$(DEBUG_PORT) + @$(WINSHELL) /c pause + +else + @$(WINSHELL) /c start simulavr --gdbserver --device $(MCU) --clock-freq \ + $(DEBUG_MFREQ) --port $(DEBUG_PORT) +endif + @$(WINSHELL) /c start avr-$(DEBUG_UI) --command=$(GDBINIT_FILE) + + + + +# Convert ELF to COFF for use in debugging / simulating in AVR Studio or VMLAB. +COFFCONVERT = $(OBJCOPY) --debugging +COFFCONVERT += --change-section-address .data-0x800000 +COFFCONVERT += --change-section-address .bss-0x800000 +COFFCONVERT += --change-section-address .noinit-0x800000 +COFFCONVERT += --change-section-address .eeprom-0x810000 + + + +coff: $(TARGET).elf + @echo + @echo $(MSG_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-avr $< $(TARGET).cof + + +extcoff: $(TARGET).elf + @echo + @echo $(MSG_EXTENDED_COFF) $(TARGET).cof + $(COFFCONVERT) -O coff-ext-avr $< $(TARGET).cof + + + +# Create final output files (.hex, .eep) from ELF output file. +%.hex: %.elf + @echo + @echo $(MSG_FLASH) $@ + $(OBJCOPY) -O $(FORMAT) -R .eeprom $< $@ + +%.eep: %.elf + @echo + @echo $(MSG_EEPROM) $@ + -$(OBJCOPY) -j .eeprom --set-section-flags=.eeprom="alloc,load" \ + --change-section-lma .eeprom=0 --no-change-warnings -O $(FORMAT) $< $@ || exit 0 + +# Create extended listing file from ELF output file. +%.lss: %.elf + @echo + @echo $(MSG_EXTENDED_LISTING) $@ + $(OBJDUMP) -h -z -S $< > $@ + +# Create a symbol table from ELF output file. +%.sym: %.elf + @echo + @echo $(MSG_SYMBOL_TABLE) $@ + $(NM) -n $< > $@ + + + +# Create library from object files. +.SECONDARY : $(TARGET).a +.PRECIOUS : $(OBJ) +%.a: $(OBJ) + @echo + @echo $(MSG_CREATING_LIBRARY) $@ + $(AR) $@ $(OBJ) + + +# Link: create ELF output file from object files. +.SECONDARY : $(TARGET).elf +.PRECIOUS : $(OBJ) +%.elf: $(OBJ) + @echo + @echo $(MSG_LINKING) $@ + $(CC) $(ALL_CFLAGS) $^ --output $@ $(LDFLAGS) + + +# Compile: create object files from C source files. +$(OBJDIR)/%.o : %.c + @echo + @echo $(MSG_COMPILING) $< + $(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 $@ + + +# Compile: create assembler files from C source files. +%.s : %.c + $(CC) -S $(ALL_CFLAGS) $< -o $@ + + +# Compile: create assembler files from C++ source files. +%.s : %.cpp + $(CC) -S $(ALL_CPPFLAGS) $< -o $@ + + +# Assemble: create object files from assembler source files. +$(OBJDIR)/%.o : %.S + @echo + @echo $(MSG_ASSEMBLING) $< + $(CC) -c $(ALL_ASFLAGS) $< -o $@ + + +# Create preprocessed source for use in sending a bug report. +%.i : %.c + $(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@ + + +# Target: clean project. +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 + $(REMOVE) $(TARGET).sym + $(REMOVE) $(TARGET).lss + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.o) + $(REMOVE) $(SRC:%.c=$(OBJDIR)/%.lst) + $(REMOVE) $(SRC:.c=.s) + $(REMOVE) $(SRC:.c=.d) + $(REMOVE) $(SRC:.c=.i) + $(REMOVE) InvalidEvents.tmp + $(REMOVEDIR) .dep + +doxygen: + @echo Generating Project Documentation... + @doxygen Doxygen.conf + @echo Documentation Generation Complete. + +clean_doxygen: + rm -rf Documentation + +# Create object files directory +$(shell mkdir $(OBJDIR) 2>/dev/null) + + +# Include the dependency files. +-include $(shell mkdir .dep 2>/dev/null) $(wildcard .dep/*) + + +# Listing of phony targets. +.PHONY : all checkinvalidevents showliboptions \ +showtarget begin finish end sizebefore sizeafter \ +gccversion build elf hex eep lss sym coff extcoff \ +program dfu flip flip-ee dfu-ee clean debug \ clean_list clean_binary gdb-config doxygen \ No newline at end of file -- cgit v1.2.3