From 04774208b6d4131466a2b5e44af314252ab1734e Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 11 Nov 2009 09:09:39 +0000 Subject: [PATCH] Minor code cleanups for clarity. --- Bootloaders/DFU/Descriptors.c | 2 +- Bootloaders/TeensyHID/TeensyHID.c | 5 ++-- Demos/Device/ClassDriver/CDC/CDC.c | 4 +-- Demos/Device/Incomplete/Sideshow/Sideshow.c | 4 +-- LUFA/Drivers/Peripheral/SerialStream.c | 5 ++-- LUFA/Drivers/Peripheral/SerialStream.h | 6 +++-- LUFA/Drivers/USB/LowLevel/DevChapter9.c | 27 +++++++++------------ LUFA/ManPages/ChangeLog.txt | 6 ++--- LUFA/ManPages/DeviceSupport.txt | 2 +- LUFA/ManPages/FutureChanges.txt | 4 +-- LUFA/ManPages/LUFAPoweredProjects.txt | 1 + 11 files changed, 33 insertions(+), 33 deletions(-) diff --git a/Bootloaders/DFU/Descriptors.c b/Bootloaders/DFU/Descriptors.c index 6fcdc4bce6..eb5c580b07 100644 --- a/Bootloaders/DFU/Descriptors.c +++ b/Bootloaders/DFU/Descriptors.c @@ -108,7 +108,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor = .Attributes = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD), - .DetachTimeout = 0x0000, + .DetachTimeout = 0x0000, .TransferSize = 0x0c00, .DFUSpecification = VERSION_BCD(01.01) diff --git a/Bootloaders/TeensyHID/TeensyHID.c b/Bootloaders/TeensyHID/TeensyHID.c index f3d86a66f6..4b9224abc3 100644 --- a/Bootloaders/TeensyHID/TeensyHID.c +++ b/Bootloaders/TeensyHID/TeensyHID.c @@ -41,7 +41,6 @@ */ bool RunBootloader = true; - /** Main program entry point. This routine configures the hardware required by the bootloader, then continuously * runs the bootloader processing routine until instructed to soft-exit. */ @@ -105,7 +104,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) { Endpoint_ClearSETUP(); - /* Wait until the command (report) has been sent by the host */ + /* Wait until the command has been sent by the host */ while (!(Endpoint_IsOUTReceived())); /* Read in the write destination address */ @@ -123,7 +122,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void) boot_spm_busy_wait(); /* Write each of the FLASH page's bytes in sequence */ - for (uint8_t PageByte = 0; PageByte < 128; PageByte += 2) + for (uint8_t PageByte = 0; PageByte < SPM_PAGESIZE; PageByte += 2) { /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ if (!(Endpoint_BytesInEndpoint())) diff --git a/Demos/Device/ClassDriver/CDC/CDC.c b/Demos/Device/ClassDriver/CDC/CDC.c index 5d74cb1a55..8940ae0428 100644 --- a/Demos/Device/ClassDriver/CDC/CDC.c +++ b/Demos/Device/ClassDriver/CDC/CDC.c @@ -130,10 +130,10 @@ void CheckJoystickMovement(void) { ActionSent = true; - // Write the string to the virtual COM port via the created character stream + /* Write the string to the virtual COM port via the created character stream */ fputs(ReportString, &USBSerialStream); - // Alternatively, without the stream: + /* Alternatively, without the stream: */ // CDC_Device_SendString(&VirtualSerial_CDC_Interface, ReportString, strlen(ReportString)); } } diff --git a/Demos/Device/Incomplete/Sideshow/Sideshow.c b/Demos/Device/Incomplete/Sideshow/Sideshow.c index 151d282008..45dfb74bf2 100644 --- a/Demos/Device/Incomplete/Sideshow/Sideshow.c +++ b/Demos/Device/Incomplete/Sideshow/Sideshow.c @@ -32,8 +32,8 @@ 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 Vista machine to also be displayed on an externally connected - interactive display. Upon enumeration on a Vista system, this will + 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. diff --git a/LUFA/Drivers/Peripheral/SerialStream.c b/LUFA/Drivers/Peripheral/SerialStream.c index fec5f7314e..f8839c9b49 100644 --- a/LUFA/Drivers/Peripheral/SerialStream.c +++ b/LUFA/Drivers/Peripheral/SerialStream.c @@ -28,18 +28,19 @@ this software. */ +#define INCLUDE_FROM_SERIALSTREAM_C #include "SerialStream.h" FILE USARTStream = FDEV_SETUP_STREAM(SerialStream_TxByte, SerialStream_RxByte, _FDEV_SETUP_RW); -int SerialStream_TxByte(char DataByte, FILE *Stream) +static int SerialStream_TxByte(char DataByte, FILE *Stream) { Serial_TxByte(DataByte); return 0; } -int SerialStream_RxByte(FILE *Stream) +static int SerialStream_RxByte(FILE *Stream) { return Serial_RxByte(); } diff --git a/LUFA/Drivers/Peripheral/SerialStream.h b/LUFA/Drivers/Peripheral/SerialStream.h index 293fda0768..d93ea529e6 100644 --- a/LUFA/Drivers/Peripheral/SerialStream.h +++ b/LUFA/Drivers/Peripheral/SerialStream.h @@ -70,8 +70,10 @@ extern FILE USARTStream; /* Function Prototypes: */ - int SerialStream_TxByte(char DataByte, FILE *Stream) ATTR_NON_NULL_PTR_ARG(2); - int SerialStream_RxByte(FILE *Stream) ATTR_NON_NULL_PTR_ARG(1); + #if defined(INCLUDE_FROM_SERIALSTREAM_C) + static int SerialStream_TxByte(char DataByte, FILE *Stream) ATTR_NON_NULL_PTR_ARG(2); + static int SerialStream_RxByte(FILE *Stream) ATTR_NON_NULL_PTR_ARG(1); + #endif #endif /* Public Interface - May be used in end-application: */ diff --git a/LUFA/Drivers/USB/LowLevel/DevChapter9.c b/LUFA/Drivers/USB/LowLevel/DevChapter9.c index bb6104fec0..6e7b2c718b 100644 --- a/LUFA/Drivers/USB/LowLevel/DevChapter9.c +++ b/LUFA/Drivers/USB/LowLevel/DevChapter9.c @@ -129,11 +129,11 @@ static void USB_Device_SetAddress(void) return; } - UDADDR = ((1 << ADDEN) | DeviceAddress); - if (DeviceAddress) USB_DeviceState = DEVICE_STATE_Addressed; + UDADDR = ((1 << ADDEN) | DeviceAddress); + return; } @@ -192,10 +192,7 @@ static void USB_Device_SetConfiguration(void) Endpoint_ClearStatusStage(); - if (USB_ConfigurationNumber) - USB_DeviceState = DEVICE_STATE_Configured; - else - USB_DeviceState = DEVICE_STATE_Addressed; + USB_DeviceState = (USB_ConfigurationNumber) ? DEVICE_STATE_Configured : DEVICE_STATE_Addressed; EVENT_USB_Device_ConfigurationChanged(); } @@ -225,10 +222,10 @@ static void USB_Device_GetInternalSerialDescriptor(void) int16_t UnicodeString[20]; } SignatureDescriptor; - SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor); - SignatureDescriptor.Header.Type = DTYPE_String; + SignatureDescriptor.Header.Type = DTYPE_String; + SignatureDescriptor.Header.Size = sizeof(SignatureDescriptor); - uint8_t SigReadAddress = 0x0E; + uint8_t SigReadAddress = 0x0E; for (uint8_t SerialCharNum = 0; SerialCharNum < 20; SerialCharNum++) { @@ -358,16 +355,16 @@ static void USB_Device_ClearSetFeature(void) if (Endpoint_IsEnabled()) { - if (USB_ControlRequest.bRequest == REQ_ClearFeature) + if (USB_ControlRequest.bRequest == REQ_SetFeature) { - Endpoint_ClearStall(); - Endpoint_ResetFIFO(EndpointIndex); - Endpoint_ResetDataToggle(); + Endpoint_StallTransaction(); } else { - Endpoint_StallTransaction(); - } + Endpoint_ClearStall(); + Endpoint_ResetFIFO(EndpointIndex); + Endpoint_ResetDataToggle(); + } } } diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index aaa811f6de..b3a3d927d3 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -17,13 +17,13 @@ * - Added new Joystick Host ClassDriver and LowLevel demos * - Added new Printer Host mode Class driver * - Added new Printer Host mode ClassDriver demo - * - Added optional support for double banked endpoints in the Device mode Class drivers - * - Added new stream creation function to the CDC Class drivers, to easily make standard streams from CDC Class driver instances + * - Added optional support for double banked endpoints and pipes in the Device and Host mode Class drivers + * - Added new stream creation function to the CDC Class drivers, to easily make standard I/O streams from CDC Class driver instances * * Changed: * - Removed mostly useless "TestApp" demo, as it was mainly useful only for checking for sytax errors in the library * - MIDI device demos now receive MIDI events from the host and display note ON messages via the board LEDs - * - Cleanups to the Device mode Mass Storage demo applications' SCSI routines + * - Cleanups to the Device mode Mass Storage demo application SCSI routines * - Changed Audio Class driver sample read/write functions to be inline, to reduce the number of cycles needed to transfer * samples to and from the device (allowing more time for sample processing and output) * - Audio class Device mode demos now work at both 16MHz and 8MHz, rather than just at 8MHz diff --git a/LUFA/ManPages/DeviceSupport.txt b/LUFA/ManPages/DeviceSupport.txt index b9793ff783..832edc9bc2 100644 --- a/LUFA/ManPages/DeviceSupport.txt +++ b/LUFA/ManPages/DeviceSupport.txt @@ -29,7 +29,7 @@ * - ATAVRUSBRF01 * - XPLAIN (AT90USB1287 only) * - * Currently supported third-party boards: + * Currently supported third-party board (via hardware drivers): * - BUMBLEB (using officially recommended peripheral layout) * - Any Other Custom User Boards (with Board Drivers, \see Page_WritingBoardDrivers) */ diff --git a/LUFA/ManPages/FutureChanges.txt b/LUFA/ManPages/FutureChanges.txt index 750fb15d74..93a9a51dd4 100644 --- a/LUFA/ManPages/FutureChanges.txt +++ b/LUFA/ManPages/FutureChanges.txt @@ -12,10 +12,10 @@ * or post your suggestion as an enhancement request to the project bug tracker. * * Targeted for the Next Release (SVN Development Only): - * - Add hub support to match Atmel's stack - * - Add ability to get number of bytes not written with pipe/endpoint write routines after an error * * Targeted for Future Releases: + * - Add hub support to match Atmel's stack + * - Add ability to get number of bytes not written with pipe/endpoint write routines after an error * - Add standardized descriptor names to class driver structures * - Remake AVRStudio project files * - Add detailed overviews of how each demo works diff --git a/LUFA/ManPages/LUFAPoweredProjects.txt b/LUFA/ManPages/LUFAPoweredProjects.txt index 4c5a694475..a548b8fb03 100644 --- a/LUFA/ManPages/LUFAPoweredProjects.txt +++ b/LUFA/ManPages/LUFAPoweredProjects.txt @@ -41,6 +41,7 @@ * - Opendous-JTAG, an open source JTAG device: http://code.google.com/p/opendous-jtag/ * - Openkubus, an open source hardware-based authentication dongle: http://code.google.com/p/openkubus/ * - Orbee, a USB connected RGB Orb for notifications: http://www.franksworkshop.com.au/Electronics/Orbee/Orbee.htm + * - Programmable XBOX controller: http://richard-burke.dyndns.org/wordpress/pan-galactic-gargantuan-gargle-brain-aka-xbox-360-usb-controller/ * - Reprap with LUFA, a LUFA powered 3D printer: http://code.google.com/p/at90usb1287-code-for-arduino-and-eclipse/ * - SEGA Megadrive/Genesis Development Cartridge: http://www.makestuff.eu/wordpress/?page_id=398 * - SEGA Megadrive/Super Nintendo Cartridge Reader: http://www.snega2usb.com