Run wspurify script on /trunk/ and /branches/ C source files, to remove any trailing whitespace at the end of each line.
This commit is contained in:
parent
77f354609f
commit
f201f6697b
278 changed files with 1000 additions and 910 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
|
||||
.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t))
|
||||
},
|
||||
|
||||
|
||||
.Audio_AudioFormatSampleRates =
|
||||
{
|
||||
AUDIO_SAMPLE_FREQ(8000),
|
||||
|
|
|
@ -91,7 +91,7 @@ void SetupHardware(void)
|
|||
ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
||||
{
|
||||
uint8_t PrevEndpoint = Endpoint_GetCurrentEndpoint();
|
||||
|
||||
|
||||
/* Check that the USB bus is ready for the next sample to read */
|
||||
if (Audio_Device_IsSampleReceived(&Speaker_Audio_Interface))
|
||||
{
|
||||
|
@ -128,8 +128,8 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
|||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
Endpoint_SelectEndpoint(PrevEndpoint);
|
||||
|
||||
Endpoint_SelectEndpoint(PrevEndpoint);
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Connection event. */
|
||||
|
@ -248,10 +248,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)
|
||||
|
@ -260,13 +260,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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
|
||||
.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)),
|
||||
},
|
||||
|
||||
|
||||
.Audio_AudioFormatSampleRates =
|
||||
{
|
||||
AUDIO_SAMPLE_FREQ(8000),
|
||||
|
|
|
@ -83,3 +83,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -109,3 +109,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -145,7 +145,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
|||
{
|
||||
uint8_t* Data = (uint8_t*)ReportData;
|
||||
uint8_t CurrLEDMask = LEDs_GetLEDs();
|
||||
|
||||
|
||||
Data[0] = ((CurrLEDMask & LEDS_LED1) ? 1 : 0);
|
||||
Data[1] = ((CurrLEDMask & LEDS_LED2) ? 1 : 0);
|
||||
Data[2] = ((CurrLEDMask & LEDS_LED3) ? 1 : 0);
|
||||
|
@ -171,7 +171,7 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
|||
{
|
||||
uint8_t* Data = (uint8_t*)ReportData;
|
||||
uint8_t NewLEDMask = LEDS_NO_LEDS;
|
||||
|
||||
|
||||
if (Data[0])
|
||||
NewLEDMask |= LEDS_LED1;
|
||||
|
||||
|
@ -183,7 +183,7 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
|||
|
||||
if (Data[3])
|
||||
NewLEDMask |= LEDS_LED1;
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(NewLEDMask);
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@
|
|||
* descriptor is parsed by the host and its contents used to determine what data (and in what encoding)
|
||||
* the device will send, and what it may be sent back from the host. Refer to the HID specification for
|
||||
* more details on HID report descriptors.
|
||||
*/
|
||||
*/
|
||||
const USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
|
||||
{
|
||||
/* Use the HID class driver's standard Joystick report.
|
||||
|
|
|
@ -8,7 +8,7 @@
|
|||
|
||||
/*
|
||||
Copyright 2011 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
|
||||
|
|
|
@ -279,7 +279,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
Address = &ConfigurationDescriptor.HID2_MouseHID;
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case HID_DTYPE_Report:
|
||||
if (!(wIndex))
|
||||
|
|
|
@ -258,3 +258,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
|||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,7 +77,7 @@ const USB_Descriptor_HIDReport_Datatype_t PROGMEM HIDReport[] =
|
|||
HID_RI_INPUT(8, HID_IOF_DATA | HID_IOF_VARIABLE | HID_IOF_RELATIVE),
|
||||
HID_RI_END_COLLECTION(0),
|
||||
HID_RI_END_COLLECTION(0),
|
||||
|
||||
|
||||
/* Keyboard Report */
|
||||
HID_RI_USAGE_PAGE(8, 0x01), /* Generic Desktop */
|
||||
HID_RI_USAGE(8, 0x06), /* Keyboard */
|
||||
|
@ -280,7 +280,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
break;
|
||||
case HID_DTYPE_HID:
|
||||
Address = &ConfigurationDescriptor.HID_HIDData;
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
break;
|
||||
case HID_DTYPE_Report:
|
||||
Address = &HIDReport;
|
||||
|
|
|
@ -62,7 +62,7 @@
|
|||
|
||||
/** Size in bytes of each of the HID reporting IN endpoint. */
|
||||
#define HID_EPSIZE 8
|
||||
|
||||
|
||||
/* Enums: */
|
||||
/** Enum for the HID report IDs used in the device. */
|
||||
enum
|
||||
|
|
|
@ -148,7 +148,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
|||
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
||||
|
||||
if (!(ButtonStatus_LCL & BUTTONS_BUTTON1))
|
||||
{
|
||||
{
|
||||
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
||||
|
||||
KeyboardReport->Modifier = HID_KEYBOARD_MODIFIER_LEFTSHIFT;
|
||||
|
@ -221,3 +221,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
|||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
SCSI_ASENSE_WRITE_PROTECTED,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
|
@ -311,7 +311,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
/* Adjust the given block address to the real media address based on the selected LUN */
|
||||
BlockAddress += ((uint32_t)MSInterfaceInfo->State.CommandBlock.LUN * LUN_MEDIA_BLOCKS);
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||
if (IsDataRead == DATA_READ)
|
||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||
|
@ -345,3 +345,4 @@ static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfac
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,7 @@
|
|||
|
||||
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */
|
||||
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)
|
||||
|
||||
|
||||
/** Indicates if the disk is write protected or not. */
|
||||
#define DISK_READ_ONLY false
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
SCSI_ASENSE_WRITE_PROTECTED,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
|
@ -345,3 +345,4 @@ static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfac
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@
|
|||
|
||||
/** Indicates if the disk is write protected or not. */
|
||||
#define DISK_READ_ONLY false
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
|
|
@ -87,16 +87,16 @@ int main(void)
|
|||
if (RNDIS_Device_IsPacketReceived(&Ethernet_RNDIS_Interface))
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
|
||||
RNDIS_Device_ReadPacket(&Ethernet_RNDIS_Interface, &FrameIN.FrameData, &FrameIN.FrameLength);
|
||||
Ethernet_ProcessPacket(&FrameIN, &FrameOUT);
|
||||
|
||||
|
||||
if (FrameOUT.FrameLength)
|
||||
{
|
||||
RNDIS_Device_SendPacket(&Ethernet_RNDIS_Interface, &FrameOUT.FrameData, FrameOUT.FrameLength);
|
||||
RNDIS_Device_SendPacket(&Ethernet_RNDIS_Interface, &FrameOUT.FrameData, FrameOUT.FrameLength);
|
||||
FrameOUT.FrameLength = 0;
|
||||
}
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
|
||||
|
|
|
@ -287,7 +287,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
SCSI_ASENSE_WRITE_PROTECTED,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
|
@ -311,7 +311,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
/* Adjust the given block address to the real media address based on the selected LUN */
|
||||
BlockAddress += ((uint32_t)MSInterfaceInfo->State.CommandBlock.LUN * LUN_MEDIA_BLOCKS);
|
||||
#endif
|
||||
|
||||
|
||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||
if (IsDataRead == DATA_READ)
|
||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||
|
@ -345,3 +345,4 @@ static bool SCSI_Command_ModeSense_6(USB_ClassInfo_MS_Device_t* const MSInterfac
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -59,7 +59,7 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
|
|||
.NotificationEndpointDoubleBank = false,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
|
||||
* passed to all Mass Storage Class driver functions, so that multiple instances of the same class
|
||||
* within a device can be differentiated from one another.
|
||||
|
@ -211,3 +211,4 @@ bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSI
|
|||
|
||||
return CommandSuccess;
|
||||
}
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
#include "Lib/SCSI.h"
|
||||
#include "Lib/DataflashManager.h"
|
||||
|
||||
|
||||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/Board/Joystick.h>
|
||||
|
@ -74,7 +74,7 @@
|
|||
|
||||
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */
|
||||
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)
|
||||
|
||||
|
||||
/** Indicates if the disk is write protected or not. */
|
||||
#define DISK_READ_ONLY false
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
|
||||
// SideShow Interface
|
||||
USB_Descriptor_Interface_t SSHOW_Interface;
|
||||
USB_Descriptor_Endpoint_t SSHOW_DataInEndpoint;
|
||||
|
|
|
@ -102,3 +102,4 @@
|
|||
void SideShow_Discard_Byte_Stream(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -125,3 +125,4 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2011.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.lufa-lib.org
|
||||
*/
|
||||
|
@ -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
|
||||
|
@ -38,7 +38,7 @@ TMC_Capabilities_t Capabilities =
|
|||
{
|
||||
.Status = TMC_STATUS_SUCCESS,
|
||||
.TMCVersion = VERSION_BCD(1.00),
|
||||
|
||||
|
||||
.Interface =
|
||||
{
|
||||
.ListenOnly = false,
|
||||
|
@ -82,7 +82,7 @@ int main(void)
|
|||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
TMC_Task();
|
||||
|
@ -99,7 +99,7 @@ void SetupHardware(void)
|
|||
|
||||
/* Disable clock division */
|
||||
clock_prescale_set(clock_div_1);
|
||||
|
||||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
@ -167,43 +167,43 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
{
|
||||
/* Indicate that all in-progress/pending data OUT requests should be aborted */
|
||||
IsTMCBulkOUTReset = true;
|
||||
|
||||
|
||||
/* Save the split request for later checking when a new request is received */
|
||||
RequestInProgress = Req_InitiateAbortBulkOut;
|
||||
}
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
|
||||
/* Write the request response byte */
|
||||
Endpoint_Write_8(TMCRequestStatus);
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case Req_CheckAbortBulkOutStatus:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
|
||||
{
|
||||
/* Check that an ABORT BULK OUT transaction has been requested and that the request has completed */
|
||||
if (RequestInProgress != Req_InitiateAbortBulkOut)
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
else if (IsTMCBulkOUTReset)
|
||||
TMCRequestStatus = TMC_STATUS_PENDING;
|
||||
else
|
||||
RequestInProgress = 0;
|
||||
RequestInProgress = 0;
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
|
||||
/* Write the request response bytes */
|
||||
Endpoint_Write_8(TMCRequestStatus);
|
||||
Endpoint_Write_16_LE(0);
|
||||
Endpoint_Write_32_LE(LastTransferLength);
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearStatusStage();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case Req_InitiateAbortBulkIn:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
|
||||
|
@ -211,7 +211,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
/* Check that no split transaction is already in progress and the data transfer tag is valid */
|
||||
if (RequestInProgress != 0)
|
||||
{
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS;
|
||||
}
|
||||
else if (USB_ControlRequest.wValue != CurrentTransferTag)
|
||||
{
|
||||
|
@ -221,13 +221,13 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
{
|
||||
/* Indicate that all in-progress/pending data IN requests should be aborted */
|
||||
IsTMCBulkINReset = true;
|
||||
|
||||
|
||||
/* Save the split request for later checking when a new request is received */
|
||||
RequestInProgress = Req_InitiateAbortBulkIn;
|
||||
}
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
|
||||
/* Write the request response bytes */
|
||||
Endpoint_Write_8(TMCRequestStatus);
|
||||
Endpoint_Write_8(CurrentTransferTag);
|
||||
|
@ -235,7 +235,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
Endpoint_ClearIN();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case Req_CheckAbortBulkInStatus:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
|
||||
|
@ -249,7 +249,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
RequestInProgress = 0;
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
|
||||
/* Write the request response bytes */
|
||||
Endpoint_Write_8(TMCRequestStatus);
|
||||
Endpoint_Write_16_LE(0);
|
||||
|
@ -258,7 +258,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
Endpoint_ClearIN();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case Req_InitiateClear:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
|
@ -266,34 +266,34 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
/* Check that no split transaction is already in progress */
|
||||
if (RequestInProgress != 0)
|
||||
{
|
||||
Endpoint_Write_8(TMC_STATUS_SPLIT_IN_PROGRESS);
|
||||
Endpoint_Write_8(TMC_STATUS_SPLIT_IN_PROGRESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Indicate that all in-progress/pending data IN and OUT requests should be aborted */
|
||||
IsTMCBulkINReset = true;
|
||||
IsTMCBulkOUTReset = true;
|
||||
|
||||
|
||||
/* Save the split request for later checking when a new request is received */
|
||||
RequestInProgress = Req_InitiateClear;
|
||||
}
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
|
||||
/* Write the request response byte */
|
||||
Endpoint_Write_8(TMCRequestStatus);
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case Req_CheckClearStatus:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
/* Check that a CLEAR transaction has been requested and that the request has completed */
|
||||
if (RequestInProgress != Req_InitiateClear)
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
else if (IsTMCBulkINReset || IsTMCBulkOUTReset)
|
||||
TMCRequestStatus = TMC_STATUS_PENDING;
|
||||
else
|
||||
|
@ -304,22 +304,22 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
/* Write the request response bytes */
|
||||
Endpoint_Write_8(TMCRequestStatus);
|
||||
Endpoint_Write_8(0);
|
||||
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearStatusStage();
|
||||
Endpoint_ClearStatusStage();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case Req_GetCapabilities:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
|
||||
/* Write the device capabilities to the control endpoint */
|
||||
Endpoint_Write_Control_Stream_LE(&Capabilities, sizeof(TMC_Capabilities_t));
|
||||
Endpoint_Write_Control_Stream_LE(&Capabilities, sizeof(TMC_Capabilities_t));
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -351,16 +351,16 @@ void TMC_Task(void)
|
|||
/* Device must be connected and configured for the task to run */
|
||||
if (USB_DeviceState != DEVICE_STATE_Configured)
|
||||
return;
|
||||
|
||||
|
||||
TMC_MessageHeader_t MessageHeader;
|
||||
uint8_t MessagePayload[128];
|
||||
|
||||
|
||||
/* Try to read in a TMC message from the interface, process if one is available */
|
||||
if (ReadTMCHeader(&MessageHeader))
|
||||
{
|
||||
/* Indicate busy */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
|
||||
switch (MessageHeader.MessageID)
|
||||
{
|
||||
case TMC_MESSAGEID_DEV_DEP_MSG_OUT:
|
||||
|
@ -371,15 +371,15 @@ void TMC_Task(void)
|
|||
if (IsTMCBulkOUTReset)
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
ProcessSentMessage(MessagePayload, LastTransferLength);
|
||||
ProcessSentMessage(MessagePayload, LastTransferLength);
|
||||
break;
|
||||
case TMC_MESSAGEID_DEV_DEP_MSG_IN:
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
MessageHeader.TransferSize = GetNextMessage(MessagePayload);
|
||||
|
||||
MessageHeader.TransferSize = GetNextMessage(MessagePayload);
|
||||
MessageHeader.MessageIDSpecific.DeviceOUT.LastMessageTransaction = true;
|
||||
WriteTMCHeader(&MessageHeader);
|
||||
|
||||
|
@ -400,7 +400,7 @@ void TMC_Task(void)
|
|||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
|
||||
|
||||
/* All pending data has been processed - reset the data abort flags */
|
||||
IsTMCBulkINReset = false;
|
||||
IsTMCBulkOUTReset = false;
|
||||
|
@ -419,11 +419,11 @@ bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader)
|
|||
|
||||
/* Select the Data Out endpoint */
|
||||
Endpoint_SelectEndpoint(TMC_OUT_EPNUM);
|
||||
|
||||
|
||||
/* Abort if no command has been sent from the host */
|
||||
if (!(Endpoint_IsOUTReceived()))
|
||||
return false;
|
||||
|
||||
|
||||
/* Read in the header of the command from the host */
|
||||
BytesTransferred = 0;
|
||||
while ((ErrorCode = Endpoint_Read_Stream_LE(MessageHeader, sizeof(TMC_MessageHeader_t), &BytesTransferred)) ==
|
||||
|
@ -435,7 +435,7 @@ bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader)
|
|||
|
||||
/* Store the new command tag value for later use */
|
||||
CurrentTransferTag = MessageHeader->Tag;
|
||||
|
||||
|
||||
/* Indicate if the command has been aborted or not */
|
||||
return (!(IsTMCBulkOUTReset) && (ErrorCode == ENDPOINT_RWSTREAM_NoError));
|
||||
}
|
||||
|
@ -464,3 +464,4 @@ bool WriteTMCHeader(TMC_MessageHeader_t* const MessageHeader)
|
|||
/* Indicate if the command has been aborted or not */
|
||||
return (!(IsTMCBulkINReset) && (ErrorCode == ENDPOINT_RWSTREAM_NoError));
|
||||
}
|
||||
|
||||
|
|
|
@ -163,16 +163,16 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
/* Extract out the relevant request information to get the target Endpoint address and control being set */
|
||||
uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex;
|
||||
uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8);
|
||||
|
||||
|
||||
/* Only handle SET CURRENT requests to the audio endpoint's sample frequency property */
|
||||
if ((EndpointAddress == (ENDPOINT_DIR_IN | AUDIO_STREAM_EPNUM)) && (EndpointControl == AUDIO_EPCONTROL_SamplingFreq))
|
||||
{
|
||||
uint8_t SampleRate[3];
|
||||
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Read_Control_Stream_LE(SampleRate, sizeof(SampleRate));
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Set the new sampling frequency to the value given by the host */
|
||||
CurrentAudioSampleFrequency = (((uint32_t)SampleRate[2] << 16) | ((uint32_t)SampleRate[1] << 8) | (uint32_t)SampleRate[0]);
|
||||
|
||||
|
@ -180,7 +180,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case AUDIO_REQ_GetCurrent:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_ENDPOINT))
|
||||
|
@ -188,20 +188,20 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
/* Extract out the relevant request information to get the target Endpoint address and control being retrieved */
|
||||
uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex;
|
||||
uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8);
|
||||
|
||||
|
||||
/* Only handle GET CURRENT requests to the audio endpoint's sample frequency property */
|
||||
if ((EndpointAddress == (ENDPOINT_DIR_IN | AUDIO_STREAM_EPNUM)) && (EndpointControl == AUDIO_EPCONTROL_SamplingFreq))
|
||||
{
|
||||
uint8_t SampleRate[3];
|
||||
|
||||
|
||||
/* Convert the sampling rate value into the 24-bit format the host expects for the property */
|
||||
SampleRate[2] = (CurrentAudioSampleFrequency >> 16);
|
||||
SampleRate[1] = (CurrentAudioSampleFrequency >> 8);
|
||||
SampleRate[0] = (CurrentAudioSampleFrequency & 0xFF);
|
||||
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Write_Control_Stream_LE(SampleRate, sizeof(SampleRate));
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -225,11 +225,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
|
||||
|
@ -239,7 +239,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
|||
#if defined(MICROPHONE_BIASED_TO_HALF_RAIL)
|
||||
/* Microphone is biased to half rail voltage, subtract the bias from the sample value */
|
||||
AudioSample -= (SAMPLE_MAX_RANGE / 2);
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Write the sample to the buffer */
|
||||
|
|
|
@ -204,7 +204,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
|
||||
.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)),
|
||||
},
|
||||
|
||||
|
||||
.Audio_AudioFormatSampleRates =
|
||||
{
|
||||
AUDIO_SAMPLE_FREQ(8000),
|
||||
|
|
|
@ -189,16 +189,16 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
/* Extract out the relevant request information to get the target Endpoint address and control being set */
|
||||
uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex;
|
||||
uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8);
|
||||
|
||||
|
||||
/* Only handle SET CURRENT requests to the audio endpoint's sample frequency property */
|
||||
if ((EndpointAddress == (ENDPOINT_DIR_OUT | AUDIO_STREAM_EPNUM)) && (EndpointControl == AUDIO_EPCONTROL_SamplingFreq))
|
||||
{
|
||||
uint8_t SampleRate[3];
|
||||
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Read_Control_Stream_LE(SampleRate, sizeof(SampleRate));
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
|
||||
/* Set the new sampling frequency to the value given by the host */
|
||||
CurrentAudioSampleFrequency = (((uint32_t)SampleRate[2] << 16) | ((uint32_t)SampleRate[1] << 8) | (uint32_t)SampleRate[0]);
|
||||
|
||||
|
@ -206,7 +206,7 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
OCR0A = ((F_CPU / 8 / CurrentAudioSampleFrequency) - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case AUDIO_REQ_GetCurrent:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_ENDPOINT))
|
||||
|
@ -214,20 +214,20 @@ void EVENT_USB_Device_ControlRequest(void)
|
|||
/* Extract out the relevant request information to get the target Endpoint address and control being retrieved */
|
||||
uint8_t EndpointAddress = (uint8_t)USB_ControlRequest.wIndex;
|
||||
uint8_t EndpointControl = (USB_ControlRequest.wValue >> 8);
|
||||
|
||||
|
||||
/* Only handle GET CURRENT requests to the audio endpoint's sample frequency property */
|
||||
if ((EndpointAddress == (ENDPOINT_DIR_OUT | AUDIO_STREAM_EPNUM)) && (EndpointControl == AUDIO_EPCONTROL_SamplingFreq))
|
||||
{
|
||||
uint8_t SampleRate[3];
|
||||
|
||||
|
||||
/* Convert the sampling rate value into the 24-bit format the host expects for the property */
|
||||
SampleRate[2] = (CurrentAudioSampleFrequency >> 16);
|
||||
SampleRate[1] = (CurrentAudioSampleFrequency >> 8);
|
||||
SampleRate[0] = (CurrentAudioSampleFrequency & 0xFF);
|
||||
|
||||
|
||||
Endpoint_ClearSETUP();
|
||||
Endpoint_Write_Control_Stream_LE(SampleRate, sizeof(SampleRate));
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -286,7 +286,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
|||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
|
||||
Endpoint_SelectEndpoint(PrevEndpoint);
|
||||
}
|
||||
|
||||
|
|
|
@ -204,7 +204,7 @@ const USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
|
||||
.TotalDiscreteSampleRates = (sizeof(ConfigurationDescriptor.Audio_AudioFormatSampleRates) / sizeof(USB_Audio_SampleFreq_t)),
|
||||
},
|
||||
|
||||
|
||||
.Audio_AudioFormatSampleRates =
|
||||
{
|
||||
AUDIO_SAMPLE_FREQ(8000),
|
||||
|
|
|
@ -83,3 +83,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -109,3 +109,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -157,7 +157,7 @@ void ProcessGenericHIDReport(uint8_t* DataArray)
|
|||
holding the report sent from the host.
|
||||
*/
|
||||
|
||||
uint8_t NewLEDMask = LEDS_NO_LEDS;
|
||||
uint8_t NewLEDMask = LEDS_NO_LEDS;
|
||||
|
||||
if (DataArray[0])
|
||||
NewLEDMask |= LEDS_LED1;
|
||||
|
@ -170,7 +170,7 @@ void ProcessGenericHIDReport(uint8_t* DataArray)
|
|||
|
||||
if (DataArray[3])
|
||||
NewLEDMask |= LEDS_LED1;
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(NewLEDMask);
|
||||
}
|
||||
|
||||
|
@ -187,7 +187,7 @@ void CreateGenericHIDReport(uint8_t* DataArray)
|
|||
*/
|
||||
|
||||
uint8_t CurrLEDMask = LEDs_GetLEDs();
|
||||
|
||||
|
||||
DataArray[0] = ((CurrLEDMask & LEDS_LED1) ? 1 : 0);
|
||||
DataArray[1] = ((CurrLEDMask & LEDS_LED2) ? 1 : 0);
|
||||
DataArray[2] = ((CurrLEDMask & LEDS_LED3) ? 1 : 0);
|
||||
|
|
|
@ -59,7 +59,7 @@
|
|||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
|
||||
// Mass Storage Interface
|
||||
USB_Descriptor_Interface_t MS_Interface;
|
||||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||
|
|
|
@ -287,12 +287,12 @@ static bool SCSI_Command_ReadWrite_10(const bool IsDataRead)
|
|||
SCSI_ASENSE_WRITE_PROTECTED,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
BlockAddress = SwapEndian_32(*(uint32_t*)&CommandBlock.SCSICommandData[2]);
|
||||
TotalBlocks = SwapEndian_16(*(uint16_t*)&CommandBlock.SCSICommandData[7]);
|
||||
|
||||
|
||||
/* Check if the block address is outside the maximum allowable value for the LUN */
|
||||
if (BlockAddress >= LUN_MEDIA_BLOCKS)
|
||||
{
|
||||
|
@ -340,3 +340,4 @@ static bool SCSI_Command_ModeSense_6(void)
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -309,7 +309,8 @@ static void ReturnCommandStatus(void)
|
|||
if (IsMassStoreReset)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Finalize the stream transfer to send the last packet */
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@
|
|||
typedef struct
|
||||
{
|
||||
USB_Descriptor_Configuration_Header_t Config;
|
||||
|
||||
|
||||
// Mouse HID Interface
|
||||
USB_Descriptor_Interface_t HID_Interface;
|
||||
USB_HID_Descriptor_HID_t HID_MouseHID;
|
||||
|
|
|
@ -73,9 +73,9 @@ void SetupHardware(void)
|
|||
LEDs_Init();
|
||||
Serial_Init(9600, false);
|
||||
USB_Init();
|
||||
|
||||
|
||||
/* Create a stdio stream for the serial port for stdin and stdout */
|
||||
Serial_CreateStream(NULL);
|
||||
Serial_CreateStream(NULL);
|
||||
}
|
||||
|
||||
/** Event handler for the USB_Connect event. This indicates that the device is enumerating via the status LEDs and
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue