Commit f201f669 authored by Dean Camera's avatar Dean Camera

Run wspurify script on /trunk/ and /branches/ C source files, to remove any...

Run wspurify script on /trunk/ and /branches/ C source files, to remove any trailing whitespace at the end of each line.
parent 77f35460
......@@ -40,9 +40,9 @@
#include <avr/io.h>
#include <avr/boot.h>
#include <stdbool.h>
#include <LUFA/Common/Common.h>
/* Function Prototypes: */
void BootloaderAPI_ErasePage(const uint32_t Address);
void BootloaderAPI_WritePage(const uint32_t Address);
......
......@@ -104,10 +104,10 @@ void SetupHardware(void)
/* Initialize USB Subsystem */
USB_Init();
LEDs_Init();
/* Bootloader active LED toggle timer initialization */
TIMSK1 = (1 << TOIE1);
TCCR1B = ((1 << CS11) | (1 << CS10));
TCCR1B = ((1 << CS11) | (1 << CS10));
}
/** ISR to periodically toggle the LEDs on the board to indicate that the bootloader is active. */
......@@ -266,7 +266,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
{
LowByte = FetchNextCommandByte();
}
HighByte = !HighByte;
}
else
......@@ -365,7 +365,7 @@ void CDC_Task(void)
if (Command == 'E')
{
RunBootloader = false;
/* Send confirmation byte back to the host */
WriteNextResponseByte('\r');
}
......
......@@ -46,7 +46,7 @@
#include <stdbool.h>
#include "Descriptors.h"
#include "BootloaderAPI.h"
#include "BootloaderAPI.h"
#include <LUFA/Drivers/USB/USB.h>
#include <LUFA/Drivers/Board/LEDs.h>
......
......@@ -115,14 +115,14 @@
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// CDC Control Interface
USB_Descriptor_Interface_t CDC_CCI_Interface;
USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
USB_CDC_Descriptor_FunctionalUnion_t CDC_Functional_Union;
USB_Descriptor_Endpoint_t CDC_NotificationEndpoint;
// CDC Data Interface
USB_Descriptor_Interface_t CDC_DCI_Interface;
USB_Descriptor_Endpoint_t CDC_DataOutEndpoint;
......
......@@ -40,9 +40,9 @@
#include <avr/io.h>
#include <avr/boot.h>
#include <stdbool.h>
#include <LUFA/Common/Common.h>
/* Function Prototypes: */
void BootloaderAPI_ErasePage(const uint32_t Address);
void BootloaderAPI_WritePage(const uint32_t Address);
......
......@@ -113,10 +113,10 @@ int main(void)
/* If the TCK pin is not jumpered to ground, start the user application instead */
RunBootloader = (!(PINF & (1 << 4)));
/* Re-enable JTAG debugging */
MCUCR &= ~(1 << JTD);
MCUCR &= ~(1 << JTD);
MCUCR &= ~(1 << JTD);
#endif
/* Turn on first LED on the board to indicate that the bootloader has started */
......@@ -153,7 +153,7 @@ void SetupHardware(void)
/* Initialize the USB subsystem */
USB_Init();
LEDs_Init();
/* Bootloader active LED toggle timer initialization */
TIMSK1 = (1 << TOIE1);
TCCR1B = ((1 << CS11) | (1 << CS10));
......@@ -181,7 +181,7 @@ ISR(TIMER1_OVF_vect, ISR_BLOCK)
* internally.
*/
void EVENT_USB_Device_ControlRequest(void)
{
{
/* Ignore any requests that aren't directed to the DFU interface */
if ((USB_ControlRequest.bmRequestType & (CONTROL_REQTYPE_TYPE | CONTROL_REQTYPE_RECIPIENT)) !=
(REQTYPE_CLASS | REQREC_INTERFACE))
......@@ -742,3 +742,4 @@ static void ProcessReadCommand(void)
else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte
ResponseByte = SignatureInfo[DataIndexToRead - 0x30];
}
......@@ -159,11 +159,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
Address = &DeviceDescriptor;
Size = sizeof(USB_Descriptor_Device_t);
break;
case DTYPE_Configuration:
case DTYPE_Configuration:
Address = &ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
break;
case DTYPE_String:
case DTYPE_String:
if (!(DescriptorNumber))
{
Address = &LanguageString;
......@@ -174,10 +174,10 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
Address = &ProductString;
Size = ProductString.Header.Size;
}
break;
}
*DescriptorAddress = Address;
return Size;
}
......
......@@ -161,7 +161,7 @@
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// DFU Interface
USB_Descriptor_Interface_t DFU_Interface;
USB_Descriptor_DFU_Functional_t DFU_Functional;
......
......@@ -9,13 +9,13 @@
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
......@@ -32,7 +32,7 @@
*
* Main source file for the HID class bootloader. This file contains the complete bootloader logic.
*/
#include "BootloaderHID.h"
/** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run
......@@ -41,20 +41,20 @@
*/
static bool RunBootloader = true;
/** Main program entry point. This routine configures the hardware required by the bootloader, then continuously
/** 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.
*/
int main(void)
{
/* Setup hardware required for the bootloader */
SetupHardware();
/* Enable global interrupts so that the USB stack can function */
sei();
while (RunBootloader)
USB_USBTask();
/* Disconnect from the host - USB interface will be reset later along with the AVR */
USB_Detach();
......@@ -108,17 +108,17 @@ void EVENT_USB_Device_ControlRequest(void)
{
case HID_REQ_SetReport:
Endpoint_ClearSETUP();
/* Wait until the command has been sent by the host */
while (!(Endpoint_IsOUTReceived()));
/* Read in the write destination address */
#if (FLASHEND > 0xFFFF)
uint32_t PageAddress = ((uint32_t)Endpoint_Read_16_LE() << 8);
#else
uint16_t PageAddress = Endpoint_Read_16_LE();
#endif
/* Check if the command is a program page command, or a start application command */
#if (FLASHEND > 0xFFFF)
if ((uint16_t)(PageAddress >> 8) == COMMAND_STARTAPPLICATION)
......@@ -133,9 +133,9 @@ void EVENT_USB_Device_ControlRequest(void)
/* Erase the given FLASH page, ready to be programmed */
boot_page_erase(PageAddress);
boot_spm_busy_wait();
/* Write each of the FLASH page's bytes in sequence */
for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)
for (uint8_t PageWord = 0; PageWord < (SPM_PAGESIZE / 2); PageWord++)
{
/* Check if endpoint is empty - if so clear it and wait until ready for next packet */
if (!(Endpoint_BytesInEndpoint()))
......@@ -162,3 +162,4 @@ void EVENT_USB_Device_ControlRequest(void)
break;
}
}
......@@ -8,14 +8,14 @@
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
......@@ -32,7 +32,7 @@
*
* Header file for TeensyHID.c.
*/
#ifndef _TEENSYHID_H_
#define _TEENSYHID_H_
......@@ -47,15 +47,16 @@
#include "Descriptors.h"
#include <LUFA/Drivers/USB/USB.h>
/* Macros: */
/* Macros: */
/** Bootloader special address to start the user application */
#define COMMAND_STARTAPPLICATION 0xFFFF
/* Function Prototypes: */
void SetupHardware(void);
void EVENT_USB_Device_ConfigurationChanged(void);
void EVENT_USB_Device_UnhandledControlRequest(void);
#endif
......@@ -8,14 +8,14 @@
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
......@@ -30,9 +30,9 @@
/** \file
*
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special
* computer-readable structures which the host requests upon device enumeration, to determine
* the device's capabilities and functions.
* the device's capabilities and functions.
*/
#include "Descriptors.h"
......@@ -52,7 +52,7 @@ const USB_Descriptor_HIDReport_Datatype_t HIDReport[] =
HID_RI_LOGICAL_MINIMUM(8, 0x00),
HID_RI_LOGICAL_MAXIMUM(8, 0xFF),
HID_RI_REPORT_SIZE(8, 0x08),
HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),
HID_RI_REPORT_COUNT(16, (sizeof(uint16_t) + SPM_PAGESIZE)),
HID_RI_OUTPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_ABSOLUTE | HID_IOF_NON_VOLATILE),
HID_RI_END_COLLECTION(0),
};
......@@ -91,49 +91,49 @@ const USB_Descriptor_Device_t DeviceDescriptor =
*/
const USB_Descriptor_Configuration_t ConfigurationDescriptor =
{
.Config =
.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,
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
},
.HID_Interface =
.HID_Interface =
{
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
.InterfaceNumber = 0x00,
.AlternateSetting = 0x00,
.TotalEndpoints = 1,
.Class = HID_CSCP_HIDClass,
.SubClass = HID_CSCP_NonBootSubclass,
.Protocol = HID_CSCP_NonBootProtocol,
.InterfaceStrIndex = NO_DESCRIPTOR
},
.HID_VendorHID =
{
.HID_VendorHID =
{
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
.HIDSpec = VERSION_BCD(01.11),
.CountryCode = 0x00,
.TotalReportDescriptors = 1,
.HIDReportType = HID_DTYPE_Report,
.HIDReportLength = sizeof(HIDReport)
},
.HID_ReportINEndpoint =
.HID_ReportINEndpoint =
{
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
......@@ -158,17 +158,17 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
const void* Address = NULL;
uint16_t Size = NO_DESCRIPTOR;
/* If/Else If chain compiles slightly smaller than a switch case */
if (DescriptorType == DTYPE_Device)
{
Address = &DeviceDescriptor;
Size = sizeof(USB_Descriptor_Device_t);
Size = sizeof(USB_Descriptor_Device_t);
}
else if (DescriptorType == DTYPE_Configuration)
{
Address = &ConfigurationDescriptor;
Size = sizeof(USB_Descriptor_Configuration_t);
Size = sizeof(USB_Descriptor_Configuration_t);
}
else if (DescriptorType == HID_DTYPE_HID)
{
......@@ -184,3 +184,4 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
*DescriptorAddress = Address;
return Size;
}
......@@ -8,14 +8,14 @@
/*
Copyright 2011 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this
Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in
without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the
software without specific, written prior permission.
The author disclaim all warranties with regard to this
......@@ -47,18 +47,18 @@
typedef struct
{
USB_Descriptor_Configuration_Header_t Config;
// Generic HID Interface
USB_Descriptor_Interface_t HID_Interface;
USB_HID_Descriptor_HID_t HID_VendorHID;
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
} USB_Descriptor_Configuration_t;
/* Macros: */
/** Endpoint number of the HID data IN endpoint. */
#define HID_IN_EPNUM 1
/** Size in bytes of the HID reporting IN endpoint. */
/** Size in bytes of the HID reporting IN endpoint. */
#define HID_IN_EPSIZE 64
/* Function Prototypes: */
......@@ -68,3 +68,4 @@
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
#endif
......@@ -710,10 +710,10 @@ int teensy_open(void)
{
teensy_close();
uhid_teensy_fd = open_usb_device(0x16C0, 0x0478);
if (uhid_teensy_fd < 0)
uhid_teensy_fd = open_usb_device(0x03eb, 0x2067);
if (uhid_teensy_fd < 0) return 0;
return 1;
}
......@@ -826,7 +826,7 @@ parse_hex_line(char *line)
int addr, code, num;
int sum, len, cksum, i;
char *ptr;
num = 0;
if (line[0] != ':') return 0;
if (strlen(line) < 11) return 0;
......
......@@ -106,11 +106,11 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
#if defined(USE_TEST_TONE)
static uint8_t SquareWaveSampleCount;
static int16_t CurrentWaveValue;
/* In test tone mode, generate a square wave at 1/256 of the sample rate */
if (SquareWaveSampleCount++ == 0xFF)
CurrentWaveValue ^= 0x8000;
/* Only generate audio if the board button is being pressed */
AudioSample = (Buttons_GetStatus() & BUTTONS_BUTTON1) ? CurrentWaveValue : 0;
#else
......@@ -122,7 +122,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
AudioSample -= (SAMPLE_MAX_RANGE / 2);
#endif
#endif
Audio_Device_WriteSample16(&Microphone_Audio_Interface, AudioSample);
}
......@@ -211,10 +211,10 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
CurrentAudioSampleFrequency = (((uint32_t)Data[2] << 16) | ((uint32_t)Data[1] << 8) | (uint32_t)Data[0]);
/* Adjust sample reload timer to the new frequency */
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
}
return true;
return true;
case AUDIO_REQ_GetCurrent:
/* Check if we are just testing for a valid property, or actually reading it */
if (DataLength != NULL)
......@@ -223,13 +223,14 @@ bool CALLBACK_Audio_Device_GetSetEndpointProperty(USB_ClassInfo_Audio_Device_t*
Data[2] = (CurrentAudioSampleFrequency >> 16);
Data[1] = (CurrentAudioSampleFrequency >> 8);
Data[0] = (CurrentAudioSampleFrequency & 0xFF);
Data[0] = (CurrentAudioSampleFrequency & 0xFF);
}
return true;
}
}
}