X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/bf50959b8016adbf6b295178b26b8173514dd060..fc8e4837a936bb1b4bd19bdd54660878b3efe02c:/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c?ds=inline diff --git a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c index 8dc0b6246..c0f7096b2 100644 --- a/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c +++ b/Demos/Device/Incomplete/Sideshow/Lib/SideshowCommands.c @@ -1,21 +1,21 @@ /* LUFA Library - Copyright (C) Dean Camera, 2009. + Copyright (C) Dean Camera, 2010. dean [at] fourwalledcubicle [dot] com www.fourwalledcubicle.com */ /* - Copyright 2009 Dean Camera (dean [at] fourwalledcubicle [dot] com) - - Permission to use, copy, modify, and distribute this software - and its documentation for any purpose and without fee is hereby - granted, 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 + 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 @@ -118,7 +118,7 @@ void Sideshow_ProcessCommandPacket(void) } } -static void SideShow_Ping(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_Ping(SideShow_PacketHeader_t* const PacketHeader) { Endpoint_ClearOUT(); @@ -127,7 +127,7 @@ static void SideShow_Ping(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_Sync(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_Sync(SideShow_PacketHeader_t* const PacketHeader) { GUID_t ProtocolGUID; @@ -143,7 +143,7 @@ static void SideShow_Sync(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* const PacketHeader) { Endpoint_ClearOUT(); @@ -155,7 +155,7 @@ static void SideShow_GetCurrentUser(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* const PacketHeader) { SideShow_Read_Unicode_String(&UserSID, sizeof(UserSID.UnicodeString)); Endpoint_ClearOUT(); @@ -167,7 +167,7 @@ static void SideShow_SetCurrentUser(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_GetCapabilities(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_GetCapabilities(SideShow_PacketHeader_t* const PacketHeader) { SideShow_PropertyKey_t Property; SideShow_PropertyData_t PropertyData; @@ -280,7 +280,7 @@ static void SideShow_GetCapabilities(SideShow_PacketHeader_t* PacketHeader) return; } -static void SideShow_GetString(SideShow_PacketHeader_t* PacketHeader, void* UnicodeStruct) +static void SideShow_GetString(SideShow_PacketHeader_t* const PacketHeader, void* const UnicodeStruct) { Endpoint_ClearOUT(); @@ -293,30 +293,35 @@ static void SideShow_GetString(SideShow_PacketHeader_t* PacketHeader, void* Unic Endpoint_ClearIN(); } -static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_GetApplicationOrder(SideShow_PacketHeader_t* const PacketHeader) { - uint8_t TotalInstalledApplications = SideShow_GetTotalApplications(); - uint16_t GadgetGUIDBytes = (TotalInstalledApplications * sizeof(GUID_t)); - + 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) + GadgetGUIDBytes; + 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(TotalInstalledApplications); + Endpoint_Write_DWord_LE(TotalApplications); for (uint8_t App = 0; App < MAX_APPLICATIONS; App++) { - if (InstalledApplications[App].InUse == true) + if (InstalledApplications[App].InUse) Endpoint_Write_Stream_LE(&InstalledApplications[App].ApplicationID, sizeof(GUID_t)); } Endpoint_ClearIN(); } -static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* const PacketHeader) { GUID_t SupportedEndpointGUID = (GUID_t){Chunks: SIMPLE_CONTENT_FORMAT_GUID}; @@ -331,7 +336,7 @@ static void SideShow_GetSupportedEndpoints(SideShow_PacketHeader_t* PacketHeader Endpoint_ClearIN(); } -static void SideShow_AddApplication(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_AddApplication(SideShow_PacketHeader_t* const PacketHeader) { SideShow_Application_t* CurrApp; GUID_t ApplicationID; @@ -376,7 +381,7 @@ static void SideShow_AddApplication(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_DeleteApplication(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_DeleteApplication(SideShow_PacketHeader_t* const PacketHeader) { GUID_t ApplicationGUID; @@ -386,9 +391,7 @@ static void SideShow_DeleteApplication(SideShow_PacketHeader_t* PacketHeader) SideShow_Application_t* AppToDelete = SideShow_GetApplicationFromGUID(&ApplicationGUID); if (AppToDelete != NULL) - { - AppToDelete->InUse = false; - } + AppToDelete->InUse = false; else PacketHeader->Type.NAK = true; @@ -399,7 +402,7 @@ static void SideShow_DeleteApplication(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* const PacketHeader) { Endpoint_ClearOUT(); @@ -411,7 +414,7 @@ static void SideShow_DeleteAllApplications(SideShow_PacketHeader_t* PacketHeader Endpoint_ClearIN(); } -static void SideShow_AddContent(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_AddContent(SideShow_PacketHeader_t* const PacketHeader) { GUID_t ApplicationID; GUID_t EndpointID; @@ -441,7 +444,7 @@ static void SideShow_AddContent(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_DeleteContent(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_DeleteContent(SideShow_PacketHeader_t* const PacketHeader) { GUID_t ApplicationID; GUID_t EndpointID; @@ -466,7 +469,7 @@ static void SideShow_DeleteContent(SideShow_PacketHeader_t* PacketHeader) Endpoint_ClearIN(); } -static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* PacketHeader) +static void SideShow_DeleteAllContent(SideShow_PacketHeader_t* const PacketHeader) { GUID_t ApplicationID; GUID_t EndpointID;