Clean up excessive whitespace at the end of each line using the wspurify tool made by Laszlo Monda
This commit is contained in:
parent
a8871c7fba
commit
5a4def7478
760 changed files with 12883 additions and 12164 deletions
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Main source file for the CDC class bootloader. This file contains the complete bootloader logic.
|
* Main source file for the CDC class bootloader. This file contains the complete bootloader logic.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define INCLUDE_FROM_BOOTLOADERCDC_C
|
#define INCLUDE_FROM_BOOTLOADERCDC_C
|
||||||
#include "BootloaderCDC.h"
|
#include "BootloaderCDC.h"
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@ uint32_t CurrAddress;
|
||||||
bool RunBootloader = true;
|
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, or hard-reset via the watchdog to start
|
* runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start
|
||||||
* the loaded application code.
|
* the loaded application code.
|
||||||
*/
|
*/
|
||||||
|
|
@ -74,7 +74,7 @@ int main(void)
|
||||||
CDC_Task();
|
CDC_Task();
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Disconnect from the host - USB interface will be reset later along with the AVR */
|
/* Disconnect from the host - USB interface will be reset later along with the AVR */
|
||||||
USB_Detach();
|
USB_Detach();
|
||||||
|
|
||||||
|
|
@ -93,11 +93,11 @@ void SetupHardware(void)
|
||||||
|
|
||||||
/* Disable clock division */
|
/* Disable clock division */
|
||||||
clock_prescale_set(clock_div_1);
|
clock_prescale_set(clock_div_1);
|
||||||
|
|
||||||
/* Relocate the interrupt vector table to the bootloader section */
|
/* Relocate the interrupt vector table to the bootloader section */
|
||||||
MCUCR = (1 << IVCE);
|
MCUCR = (1 << IVCE);
|
||||||
MCUCR = (1 << IVSEL);
|
MCUCR = (1 << IVSEL);
|
||||||
|
|
||||||
/* Initialize USB Subsystem */
|
/* Initialize USB Subsystem */
|
||||||
USB_Init();
|
USB_Init();
|
||||||
}
|
}
|
||||||
|
|
@ -132,14 +132,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
{
|
{
|
||||||
case REQ_GetLineEncoding:
|
case REQ_GetLineEncoding:
|
||||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||||
{
|
{
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
/* Write the line coding data to the control endpoint */
|
/* Write the line coding data to the control endpoint */
|
||||||
Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
|
Endpoint_Write_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case REQ_SetLineEncoding:
|
case REQ_SetLineEncoding:
|
||||||
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
if (USB_ControlRequest.bmRequestType == (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||||
|
|
@ -150,7 +150,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
|
Endpoint_Read_Control_Stream_LE(&LineEncoding, sizeof(CDC_Line_Coding_t));
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -164,20 +164,20 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||||
{
|
{
|
||||||
uint16_t BlockSize;
|
uint16_t BlockSize;
|
||||||
char MemoryType;
|
char MemoryType;
|
||||||
|
|
||||||
bool HighByte = false;
|
bool HighByte = false;
|
||||||
uint8_t LowByte = 0;
|
uint8_t LowByte = 0;
|
||||||
|
|
||||||
BlockSize = (FetchNextCommandByte() << 8);
|
BlockSize = (FetchNextCommandByte() << 8);
|
||||||
BlockSize |= FetchNextCommandByte();
|
BlockSize |= FetchNextCommandByte();
|
||||||
|
|
||||||
MemoryType = FetchNextCommandByte();
|
MemoryType = FetchNextCommandByte();
|
||||||
|
|
||||||
if ((MemoryType != 'E') && (MemoryType != 'F'))
|
if ((MemoryType != 'E') && (MemoryType != 'F'))
|
||||||
{
|
{
|
||||||
/* Send error byte back to the host */
|
/* Send error byte back to the host */
|
||||||
WriteNextResponseByte('?');
|
WriteNextResponseByte('?');
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -195,13 +195,13 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||||
#if (FLASHEND > 0xFFFF)
|
#if (FLASHEND > 0xFFFF)
|
||||||
WriteNextResponseByte(pgm_read_byte_far(CurrAddress | HighByte));
|
WriteNextResponseByte(pgm_read_byte_far(CurrAddress | HighByte));
|
||||||
#else
|
#else
|
||||||
WriteNextResponseByte(pgm_read_byte(CurrAddress | HighByte));
|
WriteNextResponseByte(pgm_read_byte(CurrAddress | HighByte));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* If both bytes in current word have been read, increment the address counter */
|
/* If both bytes in current word have been read, increment the address counter */
|
||||||
if (HighByte)
|
if (HighByte)
|
||||||
CurrAddress += 2;
|
CurrAddress += 2;
|
||||||
|
|
||||||
HighByte = !HighByte;
|
HighByte = !HighByte;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -211,7 +211,7 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||||
|
|
||||||
/* Increment the address counter after use */
|
/* Increment the address counter after use */
|
||||||
CurrAddress += 2;
|
CurrAddress += 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -223,11 +223,11 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||||
boot_page_erase(PageStartAddress);
|
boot_page_erase(PageStartAddress);
|
||||||
boot_spm_busy_wait();
|
boot_spm_busy_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
while (BlockSize--)
|
while (BlockSize--)
|
||||||
{
|
{
|
||||||
if (MemoryType == 'F')
|
if (MemoryType == 'F')
|
||||||
{
|
{
|
||||||
/* If both bytes in current word have been written, increment the address counter */
|
/* If both bytes in current word have been written, increment the address counter */
|
||||||
if (HighByte)
|
if (HighByte)
|
||||||
{
|
{
|
||||||
|
|
@ -242,14 +242,14 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
LowByte = FetchNextCommandByte();
|
LowByte = FetchNextCommandByte();
|
||||||
|
|
||||||
HighByte = true;
|
HighByte = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* Write the next EEPROM byte from the endpoint */
|
/* Write the next EEPROM byte from the endpoint */
|
||||||
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
||||||
|
|
||||||
/* Increment the address counter after use */
|
/* Increment the address counter after use */
|
||||||
CurrAddress += 2;
|
CurrAddress += 2;
|
||||||
|
|
@ -261,13 +261,13 @@ static void ReadWriteMemoryBlock(const uint8_t Command)
|
||||||
{
|
{
|
||||||
/* Commit the flash page to memory */
|
/* Commit the flash page to memory */
|
||||||
boot_page_write(PageStartAddress);
|
boot_page_write(PageStartAddress);
|
||||||
|
|
||||||
/* Wait until write operation has completed */
|
/* Wait until write operation has completed */
|
||||||
boot_spm_busy_wait();
|
boot_spm_busy_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send response byte back to the host */
|
/* Send response byte back to the host */
|
||||||
WriteNextResponseByte('\r');
|
WriteNextResponseByte('\r');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,7 +280,7 @@ static uint8_t FetchNextCommandByte(void)
|
||||||
{
|
{
|
||||||
/* Select the OUT endpoint so that the next data byte can be read */
|
/* Select the OUT endpoint so that the next data byte can be read */
|
||||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||||
|
|
||||||
/* If OUT endpoint empty, clear it and wait for the next packet from the host */
|
/* If OUT endpoint empty, clear it and wait for the next packet from the host */
|
||||||
while (!(Endpoint_IsReadWriteAllowed()))
|
while (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
|
|
@ -292,7 +292,7 @@ static uint8_t FetchNextCommandByte(void)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Fetch the next byte from the OUT endpoint */
|
/* Fetch the next byte from the OUT endpoint */
|
||||||
return Endpoint_Read_Byte();
|
return Endpoint_Read_Byte();
|
||||||
}
|
}
|
||||||
|
|
@ -306,19 +306,19 @@ static void WriteNextResponseByte(const uint8_t Response)
|
||||||
{
|
{
|
||||||
/* Select the IN endpoint so that the next data byte can be written */
|
/* Select the IN endpoint so that the next data byte can be written */
|
||||||
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
Endpoint_SelectEndpoint(CDC_TX_EPNUM);
|
||||||
|
|
||||||
/* If IN endpoint full, clear it and wait until ready for the next packet to the host */
|
/* If IN endpoint full, clear it and wait until ready for the next packet to the host */
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
{
|
{
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
while (!(Endpoint_IsINReady()))
|
while (!(Endpoint_IsINReady()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write the next byte to the OUT endpoint */
|
/* Write the next byte to the OUT endpoint */
|
||||||
Endpoint_Write_Byte(Response);
|
Endpoint_Write_Byte(Response);
|
||||||
}
|
}
|
||||||
|
|
@ -330,7 +330,7 @@ void CDC_Task(void)
|
||||||
{
|
{
|
||||||
/* Select the OUT endpoint */
|
/* Select the OUT endpoint */
|
||||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||||
|
|
||||||
/* Check if endpoint has a command in it sent from the host */
|
/* Check if endpoint has a command in it sent from the host */
|
||||||
if (Endpoint_IsOUTReceived())
|
if (Endpoint_IsOUTReceived())
|
||||||
{
|
{
|
||||||
|
|
@ -345,7 +345,7 @@ void CDC_Task(void)
|
||||||
FetchNextCommandByte();
|
FetchNextCommandByte();
|
||||||
|
|
||||||
/* Send confirmation byte back to the host */
|
/* Send confirmation byte back to the host */
|
||||||
WriteNextResponseByte('\r');
|
WriteNextResponseByte('\r');
|
||||||
}
|
}
|
||||||
else if (Command == 't')
|
else if (Command == 't')
|
||||||
{
|
{
|
||||||
|
|
@ -370,13 +370,13 @@ void CDC_Task(void)
|
||||||
else if (Command == 'p')
|
else if (Command == 'p')
|
||||||
{
|
{
|
||||||
/* Indicate serial programmer back to the host */
|
/* Indicate serial programmer back to the host */
|
||||||
WriteNextResponseByte('S');
|
WriteNextResponseByte('S');
|
||||||
}
|
}
|
||||||
else if (Command == 'S')
|
else if (Command == 'S')
|
||||||
{
|
{
|
||||||
/* Write the 7-byte software identifier to the endpoint */
|
/* Write the 7-byte software identifier to the endpoint */
|
||||||
for (uint8_t CurrByte = 0; CurrByte < 7; CurrByte++)
|
for (uint8_t CurrByte = 0; CurrByte < 7; CurrByte++)
|
||||||
WriteNextResponseByte(SOFTWARE_IDENTIFIER[CurrByte]);
|
WriteNextResponseByte(SOFTWARE_IDENTIFIER[CurrByte]);
|
||||||
}
|
}
|
||||||
else if (Command == 'V')
|
else if (Command == 'V')
|
||||||
{
|
{
|
||||||
|
|
@ -385,17 +385,17 @@ void CDC_Task(void)
|
||||||
}
|
}
|
||||||
else if (Command == 's')
|
else if (Command == 's')
|
||||||
{
|
{
|
||||||
WriteNextResponseByte(AVR_SIGNATURE_3);
|
WriteNextResponseByte(AVR_SIGNATURE_3);
|
||||||
WriteNextResponseByte(AVR_SIGNATURE_2);
|
WriteNextResponseByte(AVR_SIGNATURE_2);
|
||||||
WriteNextResponseByte(AVR_SIGNATURE_1);
|
WriteNextResponseByte(AVR_SIGNATURE_1);
|
||||||
}
|
}
|
||||||
else if (Command == 'b')
|
else if (Command == 'b')
|
||||||
{
|
{
|
||||||
WriteNextResponseByte('Y');
|
WriteNextResponseByte('Y');
|
||||||
|
|
||||||
/* Send block size to the host */
|
/* Send block size to the host */
|
||||||
WriteNextResponseByte(SPM_PAGESIZE >> 8);
|
WriteNextResponseByte(SPM_PAGESIZE >> 8);
|
||||||
WriteNextResponseByte(SPM_PAGESIZE & 0xFF);
|
WriteNextResponseByte(SPM_PAGESIZE & 0xFF);
|
||||||
}
|
}
|
||||||
else if (Command == 'e')
|
else if (Command == 'e')
|
||||||
{
|
{
|
||||||
|
|
@ -409,9 +409,9 @@ void CDC_Task(void)
|
||||||
|
|
||||||
CurrFlashAddress += SPM_PAGESIZE;
|
CurrFlashAddress += SPM_PAGESIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Send confirmation byte back to the host */
|
/* Send confirmation byte back to the host */
|
||||||
WriteNextResponseByte('\r');
|
WriteNextResponseByte('\r');
|
||||||
}
|
}
|
||||||
else if (Command == 'l')
|
else if (Command == 'l')
|
||||||
{
|
{
|
||||||
|
|
@ -423,7 +423,7 @@ void CDC_Task(void)
|
||||||
}
|
}
|
||||||
else if (Command == 'r')
|
else if (Command == 'r')
|
||||||
{
|
{
|
||||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOCK_BITS));
|
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_LOCK_BITS));
|
||||||
}
|
}
|
||||||
else if (Command == 'F')
|
else if (Command == 'F')
|
||||||
{
|
{
|
||||||
|
|
@ -431,41 +431,41 @@ void CDC_Task(void)
|
||||||
}
|
}
|
||||||
else if (Command == 'N')
|
else if (Command == 'N')
|
||||||
{
|
{
|
||||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS));
|
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_HIGH_FUSE_BITS));
|
||||||
}
|
}
|
||||||
else if (Command == 'Q')
|
else if (Command == 'Q')
|
||||||
{
|
{
|
||||||
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS));
|
WriteNextResponseByte(boot_lock_fuse_bits_get(GET_EXTENDED_FUSE_BITS));
|
||||||
}
|
}
|
||||||
else if (Command == 'C')
|
else if (Command == 'C')
|
||||||
{
|
{
|
||||||
/* Write the high byte to the current flash page */
|
/* Write the high byte to the current flash page */
|
||||||
boot_page_fill(CurrAddress, FetchNextCommandByte());
|
boot_page_fill(CurrAddress, FetchNextCommandByte());
|
||||||
|
|
||||||
/* Send confirmation byte back to the host */
|
/* Send confirmation byte back to the host */
|
||||||
WriteNextResponseByte('\r');
|
WriteNextResponseByte('\r');
|
||||||
}
|
}
|
||||||
else if (Command == 'c')
|
else if (Command == 'c')
|
||||||
{
|
{
|
||||||
/* Write the low byte to the current flash page */
|
/* Write the low byte to the current flash page */
|
||||||
boot_page_fill(CurrAddress | 1, FetchNextCommandByte());
|
boot_page_fill(CurrAddress | 1, FetchNextCommandByte());
|
||||||
|
|
||||||
/* Increment the address */
|
/* Increment the address */
|
||||||
CurrAddress += 2;
|
CurrAddress += 2;
|
||||||
|
|
||||||
/* Send confirmation byte back to the host */
|
/* Send confirmation byte back to the host */
|
||||||
WriteNextResponseByte('\r');
|
WriteNextResponseByte('\r');
|
||||||
}
|
}
|
||||||
else if (Command == 'm')
|
else if (Command == 'm')
|
||||||
{
|
{
|
||||||
/* Commit the flash page to memory */
|
/* Commit the flash page to memory */
|
||||||
boot_page_write(CurrAddress);
|
boot_page_write(CurrAddress);
|
||||||
|
|
||||||
/* Wait until write operation has completed */
|
/* Wait until write operation has completed */
|
||||||
boot_spm_busy_wait();
|
boot_spm_busy_wait();
|
||||||
|
|
||||||
/* Send confirmation byte back to the host */
|
/* Send confirmation byte back to the host */
|
||||||
WriteNextResponseByte('\r');
|
WriteNextResponseByte('\r');
|
||||||
}
|
}
|
||||||
else if ((Command == 'B') || (Command == 'g'))
|
else if ((Command == 'B') || (Command == 'g'))
|
||||||
{
|
{
|
||||||
|
|
@ -477,9 +477,9 @@ void CDC_Task(void)
|
||||||
#if (FLASHEND > 0xFFFF)
|
#if (FLASHEND > 0xFFFF)
|
||||||
uint16_t ProgramWord = pgm_read_word_far(CurrAddress);
|
uint16_t ProgramWord = pgm_read_word_far(CurrAddress);
|
||||||
#else
|
#else
|
||||||
uint16_t ProgramWord = pgm_read_word(CurrAddress);
|
uint16_t ProgramWord = pgm_read_word(CurrAddress);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
WriteNextResponseByte(ProgramWord >> 8);
|
WriteNextResponseByte(ProgramWord >> 8);
|
||||||
WriteNextResponseByte(ProgramWord & 0xFF);
|
WriteNextResponseByte(ProgramWord & 0xFF);
|
||||||
}
|
}
|
||||||
|
|
@ -487,12 +487,12 @@ void CDC_Task(void)
|
||||||
{
|
{
|
||||||
/* Read the byte from the endpoint and write it to the EEPROM */
|
/* Read the byte from the endpoint and write it to the EEPROM */
|
||||||
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
eeprom_write_byte((uint8_t*)((intptr_t)(CurrAddress >> 1)), FetchNextCommandByte());
|
||||||
|
|
||||||
/* Increment the address after use */
|
/* Increment the address after use */
|
||||||
CurrAddress += 2;
|
CurrAddress += 2;
|
||||||
|
|
||||||
/* Send confirmation byte back to the host */
|
/* Send confirmation byte back to the host */
|
||||||
WriteNextResponseByte('\r');
|
WriteNextResponseByte('\r');
|
||||||
}
|
}
|
||||||
else if (Command == 'd')
|
else if (Command == 'd')
|
||||||
{
|
{
|
||||||
|
|
@ -520,12 +520,12 @@ void CDC_Task(void)
|
||||||
|
|
||||||
/* Send the endpoint data to the host */
|
/* Send the endpoint data to the host */
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
/* If a full endpoint's worth of data was sent, we need to send an empty packet afterwards to signal end of transfer */
|
/* If a full endpoint's worth of data was sent, we need to send an empty packet afterwards to signal end of transfer */
|
||||||
if (IsEndpointFull)
|
if (IsEndpointFull)
|
||||||
{
|
{
|
||||||
while (!(Endpoint_IsINReady()))
|
while (!(Endpoint_IsINReady()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -535,11 +535,11 @@ void CDC_Task(void)
|
||||||
|
|
||||||
/* Wait until the data has been sent to the host */
|
/* Wait until the data has been sent to the host */
|
||||||
while (!(Endpoint_IsINReady()))
|
while (!(Endpoint_IsINReady()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Select the OUT endpoint */
|
/* Select the OUT endpoint */
|
||||||
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
Endpoint_SelectEndpoint(CDC_RX_EPNUM);
|
||||||
|
|
||||||
|
|
@ -547,3 +547,4 @@ void CDC_Task(void)
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for BootloaderCDC.c.
|
* Header file for BootloaderCDC.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _CDC_H_
|
#ifndef _CDC_H_
|
||||||
#define _CDC_H_
|
#define _CDC_H_
|
||||||
|
|
||||||
|
|
@ -55,7 +55,7 @@
|
||||||
|
|
||||||
/** Version minor of the CDC bootloader. */
|
/** Version minor of the CDC bootloader. */
|
||||||
#define BOOTLOADER_VERSION_MINOR 0x00
|
#define BOOTLOADER_VERSION_MINOR 0x00
|
||||||
|
|
||||||
/** Hardware version major of the CDC bootloader. */
|
/** Hardware version major of the CDC bootloader. */
|
||||||
#define BOOTLOADER_HWVERSION_MAJOR 0x01
|
#define BOOTLOADER_HWVERSION_MAJOR 0x01
|
||||||
|
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
|
|
||||||
/** Eight character bootloader firmware identifier reported to the host when requested */
|
/** Eight character bootloader firmware identifier reported to the host when requested */
|
||||||
#define SOFTWARE_IDENTIFIER "LUFACDC"
|
#define SOFTWARE_IDENTIFIER "LUFACDC"
|
||||||
|
|
||||||
/** CDC Class specific request to get the current virtual serial port configuration settings. */
|
/** CDC Class specific request to get the current virtual serial port configuration settings. */
|
||||||
#define REQ_GetLineEncoding 0x21
|
#define REQ_GetLineEncoding 0x21
|
||||||
|
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
|
|
||||||
/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
|
/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
|
||||||
typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
|
typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
|
||||||
|
|
||||||
/* Enums: */
|
/* Enums: */
|
||||||
/** Enum for the possible line encoding formats of a virtual serial port. */
|
/** Enum for the possible line encoding formats of a virtual serial port. */
|
||||||
enum CDCDevice_CDC_LineCodingFormats_t
|
enum CDCDevice_CDC_LineCodingFormats_t
|
||||||
|
|
@ -98,7 +98,7 @@
|
||||||
OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
|
OneAndAHalfStopBits = 1, /**< Each frame contains one and a half stop bits */
|
||||||
TwoStopBits = 2, /**< Each frame contains two stop bits */
|
TwoStopBits = 2, /**< Each frame contains two stop bits */
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Enum for the possible line encoding parity settings of a virtual serial port. */
|
/** Enum for the possible line encoding parity settings of a virtual serial port. */
|
||||||
enum CDCDevice_LineCodingParity_t
|
enum CDCDevice_LineCodingParity_t
|
||||||
{
|
{
|
||||||
|
|
@ -122,3 +122,4 @@
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage CDC Class USB AVR Bootloader
|
/** \mainpage CDC Class USB AVR Bootloader
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Communications Device Class (CDC)</td>
|
* <td>Communications Device Class (CDC)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Abstract Control Model (ACM)</td>
|
* <td>Abstract Control Model (ACM)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -42,15 +42,15 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109
|
* This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109
|
||||||
* protocol compatible programming software to load firmware onto the AVR.
|
* protocol compatible programming software to load firmware onto the AVR.
|
||||||
*
|
*
|
||||||
* Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If
|
* Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If
|
||||||
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
|
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
|
||||||
* values in the accompanying makefile.
|
* values in the accompanying makefile.
|
||||||
*
|
*
|
||||||
* This bootloader is compatible with the open source application AVRDUDE, or Atmel's AVRPROG.
|
* This bootloader is compatible with the open source application AVRDUDE, or Atmel's AVRPROG.
|
||||||
*
|
*
|
||||||
* After running this bootloader for the first time on a new computer, you will need to supply the .INF
|
* After running this bootloader for the first time on a new computer, you will need to supply the .INF
|
||||||
|
|
@ -70,3 +70,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -45,22 +45,22 @@
|
||||||
USB_Descriptor_Device_t DeviceDescriptor =
|
USB_Descriptor_Device_t DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x02,
|
.Class = 0x02,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x204A,
|
.ProductID = 0x204A,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
||||||
.ProductStrIndex = 0x01,
|
.ProductStrIndex = 0x01,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -71,102 +71,102 @@ USB_Descriptor_Device_t DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 2,
|
.TotalInterfaces = 2,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_CCI_Interface =
|
.CDC_CCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x02,
|
.Class = 0x02,
|
||||||
.SubClass = 0x02,
|
.SubClass = 0x02,
|
||||||
.Protocol = 0x01,
|
.Protocol = 0x01,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_Functional_Header =
|
.CDC_Functional_Header =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = 0x00,
|
.Subtype = 0x00,
|
||||||
|
|
||||||
.CDCSpecification = VERSION_BCD(01.10),
|
.CDCSpecification = VERSION_BCD(01.10),
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_Functional_ACM =
|
.CDC_Functional_ACM =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = 0x02,
|
.Subtype = 0x02,
|
||||||
|
|
||||||
.Capabilities = 0x04,
|
.Capabilities = 0x04,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_Functional_Union =
|
.CDC_Functional_Union =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Descriptor_CDC_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = 0x06,
|
.Subtype = 0x06,
|
||||||
|
|
||||||
.MasterInterfaceNumber = 0,
|
.MasterInterfaceNumber = 0,
|
||||||
.SlaveInterfaceNumber = 1,
|
.SlaveInterfaceNumber = 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_NotificationEndpoint =
|
.CDC_NotificationEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||||
.PollingIntervalMS = 0x02
|
.PollingIntervalMS = 0x02
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_DCI_Interface =
|
.CDC_DCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 2,
|
.TotalEndpoints = 2,
|
||||||
|
|
||||||
.Class = 0x0A,
|
.Class = 0x0A,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_DataOutEndpoint =
|
.CDC_DataOutEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_DataInEndpoint =
|
.CDC_DataInEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
|
|
@ -181,7 +181,7 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t LanguageString =
|
USB_Descriptor_String_t LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -192,7 +192,7 @@ USB_Descriptor_String_t LanguageString =
|
||||||
USB_Descriptor_String_t ProductString =
|
USB_Descriptor_String_t ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"AVR CDC Bootloader"
|
.UnicodeString = L"AVR CDC Bootloader"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -233,10 +233,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = ProductString.Header.Size;
|
Size = ProductString.Header.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -96,7 +96,7 @@
|
||||||
#define CDC_NOTIFICATION_EPNUM 2
|
#define CDC_NOTIFICATION_EPNUM 2
|
||||||
|
|
||||||
/** Endpoint number for the CDC data interface TX (data IN) endpoint. */
|
/** Endpoint number for the CDC data interface TX (data IN) endpoint. */
|
||||||
#define CDC_TX_EPNUM 3
|
#define CDC_TX_EPNUM 3
|
||||||
|
|
||||||
/** Endpoint number for the CDC data interface RX (data OUT) endpoint. */
|
/** Endpoint number for the CDC data interface RX (data OUT) endpoint. */
|
||||||
#define CDC_RX_EPNUM 4
|
#define CDC_RX_EPNUM 4
|
||||||
|
|
@ -130,7 +130,7 @@
|
||||||
uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
|
uint8_t Subtype; /**< Sub type value used to distinguish between CDC class-specific descriptors. */
|
||||||
uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
|
uint8_t Capabilities; /**< Capabilities of the ACM interface, given as a bit mask. */
|
||||||
} USB_Descriptor_CDC_FunctionalACM_t;
|
} USB_Descriptor_CDC_FunctionalACM_t;
|
||||||
|
|
||||||
/** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
|
/** Type define for a CDC class-specific functional Union descriptor. This indicates to the host that specific
|
||||||
* CDC control and data interfaces are related. See the CDC class specification for more details.
|
* CDC control and data interfaces are related. See the CDC class specification for more details.
|
||||||
*/
|
*/
|
||||||
|
|
@ -166,3 +166,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -52,14 +52,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -72,7 +72,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -136,7 +136,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -149,7 +149,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -266,7 +266,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -279,7 +279,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -291,7 +291,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -327,7 +327,7 @@ EXTMEMOPTS =
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
|
LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -361,7 +361,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -395,7 +395,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -424,7 +424,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -443,10 +443,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -511,19 +511,19 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -621,14 +621,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -650,7 +650,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -693,3 +693,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program debug gdb-config
|
clean_list clean_doxygen program debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -93,7 +93,7 @@ uint16_t StartAddr = 0x0000;
|
||||||
uint16_t EndAddr = 0x0000;
|
uint16_t EndAddr = 0x0000;
|
||||||
|
|
||||||
|
|
||||||
/** 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, or hard-reset via the watchdog to start
|
* runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start
|
||||||
* the loaded application code.
|
* the loaded application code.
|
||||||
*/
|
*/
|
||||||
|
|
@ -101,17 +101,17 @@ int main(void)
|
||||||
{
|
{
|
||||||
/* Configure hardware required by the bootloader */
|
/* Configure hardware required by the bootloader */
|
||||||
SetupHardware();
|
SetupHardware();
|
||||||
|
|
||||||
/* Enable global interrupts so that the USB stack can function */
|
/* Enable global interrupts so that the USB stack can function */
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
/* Run the USB management task while the bootloader is supposed to be running */
|
/* Run the USB management task while the bootloader is supposed to be running */
|
||||||
while (RunBootloader || WaitForExit)
|
while (RunBootloader || WaitForExit)
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
|
|
||||||
/* Reset configured hardware back to their original states for the user application */
|
/* Reset configured hardware back to their original states for the user application */
|
||||||
ResetHardware();
|
ResetHardware();
|
||||||
|
|
||||||
/* Start the user application */
|
/* Start the user application */
|
||||||
AppStartPtr();
|
AppStartPtr();
|
||||||
}
|
}
|
||||||
|
|
@ -125,7 +125,7 @@ void SetupHardware(void)
|
||||||
|
|
||||||
/* Disable clock division */
|
/* Disable clock division */
|
||||||
clock_prescale_set(clock_div_1);
|
clock_prescale_set(clock_div_1);
|
||||||
|
|
||||||
/* Relocate the interrupt vector table to the bootloader section */
|
/* Relocate the interrupt vector table to the bootloader section */
|
||||||
MCUCR = (1 << IVCE);
|
MCUCR = (1 << IVCE);
|
||||||
MCUCR = (1 << IVSEL);
|
MCUCR = (1 << IVSEL);
|
||||||
|
|
@ -139,7 +139,7 @@ void ResetHardware(void)
|
||||||
{
|
{
|
||||||
/* Shut down the USB subsystem */
|
/* Shut down the USB subsystem */
|
||||||
USB_ShutDown();
|
USB_ShutDown();
|
||||||
|
|
||||||
/* Relocate the interrupt vector table back to the application section */
|
/* Relocate the interrupt vector table back to the application section */
|
||||||
MCUCR = (1 << IVCE);
|
MCUCR = (1 << IVCE);
|
||||||
MCUCR = 0;
|
MCUCR = 0;
|
||||||
|
|
@ -158,32 +158,32 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
{
|
{
|
||||||
case REQ_DFU_DNLOAD:
|
case REQ_DFU_DNLOAD:
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
/* Check if bootloader is waiting to terminate */
|
/* Check if bootloader is waiting to terminate */
|
||||||
if (WaitForExit)
|
if (WaitForExit)
|
||||||
{
|
{
|
||||||
/* Bootloader is terminating - process last received command */
|
/* Bootloader is terminating - process last received command */
|
||||||
ProcessBootloaderCommand();
|
ProcessBootloaderCommand();
|
||||||
|
|
||||||
/* Indicate that the last command has now been processed - free to exit bootloader */
|
/* Indicate that the last command has now been processed - free to exit bootloader */
|
||||||
WaitForExit = false;
|
WaitForExit = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the request has a data stage, load it into the command struct */
|
/* If the request has a data stage, load it into the command struct */
|
||||||
if (SentCommand.DataSize)
|
if (SentCommand.DataSize)
|
||||||
{
|
{
|
||||||
while (!(Endpoint_IsOUTReceived()))
|
while (!(Endpoint_IsOUTReceived()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* First byte of the data stage is the DNLOAD request's command */
|
/* First byte of the data stage is the DNLOAD request's command */
|
||||||
SentCommand.Command = Endpoint_Read_Byte();
|
SentCommand.Command = Endpoint_Read_Byte();
|
||||||
|
|
||||||
/* One byte of the data stage is the command, so subtract it from the total data bytes */
|
/* One byte of the data stage is the command, so subtract it from the total data bytes */
|
||||||
SentCommand.DataSize--;
|
SentCommand.DataSize--;
|
||||||
|
|
||||||
/* Load in the rest of the data stage as command parameters */
|
/* Load in the rest of the data stage as command parameters */
|
||||||
for (uint8_t DataByte = 0; (DataByte < sizeof(SentCommand.Data)) &&
|
for (uint8_t DataByte = 0; (DataByte < sizeof(SentCommand.Data)) &&
|
||||||
Endpoint_BytesInEndpoint(); DataByte++)
|
Endpoint_BytesInEndpoint(); DataByte++)
|
||||||
|
|
@ -191,14 +191,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
SentCommand.Data[DataByte] = Endpoint_Read_Byte();
|
SentCommand.Data[DataByte] = Endpoint_Read_Byte();
|
||||||
SentCommand.DataSize--;
|
SentCommand.DataSize--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Process the command */
|
/* Process the command */
|
||||||
ProcessBootloaderCommand();
|
ProcessBootloaderCommand();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if currently downloading firmware */
|
/* Check if currently downloading firmware */
|
||||||
if (DFU_State == dfuDNLOAD_IDLE)
|
if (DFU_State == dfuDNLOAD_IDLE)
|
||||||
{
|
{
|
||||||
if (!(SentCommand.DataSize))
|
if (!(SentCommand.DataSize))
|
||||||
{
|
{
|
||||||
DFU_State = dfuIDLE;
|
DFU_State = dfuIDLE;
|
||||||
|
|
@ -210,21 +210,21 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
|
|
||||||
/* Throw away the packet alignment filler bytes before the start of the firmware */
|
/* Throw away the packet alignment filler bytes before the start of the firmware */
|
||||||
DiscardFillerBytes(StartAddr % FIXED_CONTROL_ENDPOINT_SIZE);
|
DiscardFillerBytes(StartAddr % FIXED_CONTROL_ENDPOINT_SIZE);
|
||||||
|
|
||||||
/* Calculate the number of bytes remaining to be written */
|
/* Calculate the number of bytes remaining to be written */
|
||||||
uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1);
|
uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1);
|
||||||
|
|
||||||
if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Write flash
|
if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Write flash
|
||||||
{
|
{
|
||||||
/* Calculate the number of words to be written from the number of bytes to be written */
|
/* Calculate the number of words to be written from the number of bytes to be written */
|
||||||
uint16_t WordsRemaining = (BytesRemaining >> 1);
|
uint16_t WordsRemaining = (BytesRemaining >> 1);
|
||||||
|
|
||||||
union
|
union
|
||||||
{
|
{
|
||||||
uint16_t Words[2];
|
uint16_t Words[2];
|
||||||
uint32_t Long;
|
uint32_t Long;
|
||||||
} CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}};
|
} CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}};
|
||||||
|
|
||||||
uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long;
|
uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long;
|
||||||
uint8_t WordsInFlashPage = 0;
|
uint8_t WordsInFlashPage = 0;
|
||||||
|
|
||||||
|
|
@ -236,7 +236,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
|
|
||||||
while (!(Endpoint_IsOUTReceived()))
|
while (!(Endpoint_IsOUTReceived()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -255,7 +255,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
/* Commit the flash page to memory */
|
/* Commit the flash page to memory */
|
||||||
boot_page_write(CurrFlashPageStartAddress);
|
boot_page_write(CurrFlashPageStartAddress);
|
||||||
boot_spm_busy_wait();
|
boot_spm_busy_wait();
|
||||||
|
|
||||||
/* Check if programming incomplete */
|
/* Check if programming incomplete */
|
||||||
if (WordsRemaining)
|
if (WordsRemaining)
|
||||||
{
|
{
|
||||||
|
|
@ -268,10 +268,10 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Once programming complete, start address equals the end address */
|
/* Once programming complete, start address equals the end address */
|
||||||
StartAddr = EndAddr;
|
StartAddr = EndAddr;
|
||||||
|
|
||||||
/* Re-enable the RWW section of flash */
|
/* Re-enable the RWW section of flash */
|
||||||
boot_rww_enable();
|
boot_rww_enable();
|
||||||
}
|
}
|
||||||
|
|
@ -285,7 +285,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
|
|
||||||
while (!(Endpoint_IsOUTReceived()))
|
while (!(Endpoint_IsOUTReceived()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -293,12 +293,12 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
|
|
||||||
/* Read the byte from the USB interface and write to to the EEPROM */
|
/* Read the byte from the USB interface and write to to the EEPROM */
|
||||||
eeprom_write_byte((uint8_t*)StartAddr, Endpoint_Read_Byte());
|
eeprom_write_byte((uint8_t*)StartAddr, Endpoint_Read_Byte());
|
||||||
|
|
||||||
/* Adjust counters */
|
/* Adjust counters */
|
||||||
StartAddr++;
|
StartAddr++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Throw away the currently unused DFU file suffix */
|
/* Throw away the currently unused DFU file suffix */
|
||||||
DiscardFillerBytes(DFU_FILE_SUFFIX_SIZE);
|
DiscardFillerBytes(DFU_FILE_SUFFIX_SIZE);
|
||||||
}
|
}
|
||||||
|
|
@ -313,11 +313,11 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
while (!(Endpoint_IsINReady()))
|
while (!(Endpoint_IsINReady()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (DFU_State != dfuUPLOAD_IDLE)
|
if (DFU_State != dfuUPLOAD_IDLE)
|
||||||
{
|
{
|
||||||
if ((DFU_State == dfuERROR) && IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank Check
|
if ((DFU_State == dfuERROR) && IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank Check
|
||||||
|
|
@ -356,7 +356,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
while (!(Endpoint_IsINReady()))
|
while (!(Endpoint_IsINReady()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -366,13 +366,13 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
#if (FLASHEND > 0xFFFF)
|
#if (FLASHEND > 0xFFFF)
|
||||||
Endpoint_Write_Word_LE(pgm_read_word_far(CurrFlashAddress.Long));
|
Endpoint_Write_Word_LE(pgm_read_word_far(CurrFlashAddress.Long));
|
||||||
#else
|
#else
|
||||||
Endpoint_Write_Word_LE(pgm_read_word(CurrFlashAddress.Long));
|
Endpoint_Write_Word_LE(pgm_read_word(CurrFlashAddress.Long));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Adjust counters */
|
/* Adjust counters */
|
||||||
CurrFlashAddress.Long += 2;
|
CurrFlashAddress.Long += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Once reading is complete, start address equals the end address */
|
/* Once reading is complete, start address equals the end address */
|
||||||
StartAddr = EndAddr;
|
StartAddr = EndAddr;
|
||||||
}
|
}
|
||||||
|
|
@ -384,9 +384,9 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
|
if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE)
|
||||||
{
|
{
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
while (!(Endpoint_IsINReady()))
|
while (!(Endpoint_IsINReady()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -410,14 +410,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
break;
|
break;
|
||||||
case REQ_DFU_GETSTATUS:
|
case REQ_DFU_GETSTATUS:
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
/* Write 8-bit status value */
|
/* Write 8-bit status value */
|
||||||
Endpoint_Write_Byte(DFU_Status);
|
Endpoint_Write_Byte(DFU_Status);
|
||||||
|
|
||||||
/* Write 24-bit poll timeout value */
|
/* Write 24-bit poll timeout value */
|
||||||
Endpoint_Write_Byte(0);
|
Endpoint_Write_Byte(0);
|
||||||
Endpoint_Write_Word_LE(0);
|
Endpoint_Write_Word_LE(0);
|
||||||
|
|
||||||
/* Write 8-bit state value */
|
/* Write 8-bit state value */
|
||||||
Endpoint_Write_Byte(DFU_State);
|
Endpoint_Write_Byte(DFU_State);
|
||||||
|
|
||||||
|
|
@ -425,12 +425,12 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
Endpoint_Write_Byte(0);
|
Endpoint_Write_Byte(0);
|
||||||
|
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
Endpoint_ClearStatusStage();
|
Endpoint_ClearStatusStage();
|
||||||
break;
|
break;
|
||||||
case REQ_DFU_CLRSTATUS:
|
case REQ_DFU_CLRSTATUS:
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
/* Reset the status value variable to the default OK status */
|
/* Reset the status value variable to the default OK status */
|
||||||
DFU_Status = OK;
|
DFU_Status = OK;
|
||||||
|
|
||||||
|
|
@ -438,17 +438,17 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
break;
|
break;
|
||||||
case REQ_DFU_GETSTATE:
|
case REQ_DFU_GETSTATE:
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
/* Write the current device state to the endpoint */
|
/* Write the current device state to the endpoint */
|
||||||
Endpoint_Write_Byte(DFU_State);
|
Endpoint_Write_Byte(DFU_State);
|
||||||
|
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
Endpoint_ClearStatusStage();
|
Endpoint_ClearStatusStage();
|
||||||
break;
|
break;
|
||||||
case REQ_DFU_ABORT:
|
case REQ_DFU_ABORT:
|
||||||
Endpoint_ClearSETUP();
|
Endpoint_ClearSETUP();
|
||||||
|
|
||||||
/* Reset the current state variable to the default idle state */
|
/* Reset the current state variable to the default idle state */
|
||||||
DFU_State = dfuIDLE;
|
DFU_State = dfuIDLE;
|
||||||
|
|
||||||
|
|
@ -472,7 +472,7 @@ static void DiscardFillerBytes(uint8_t NumberOfBytes)
|
||||||
|
|
||||||
/* Wait until next data packet received */
|
/* Wait until next data packet received */
|
||||||
while (!(Endpoint_IsOUTReceived()))
|
while (!(Endpoint_IsOUTReceived()))
|
||||||
{
|
{
|
||||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -501,10 +501,10 @@ static void ProcessBootloaderCommand(void)
|
||||||
/* Set the state and status variables to indicate the error */
|
/* Set the state and status variables to indicate the error */
|
||||||
DFU_State = dfuERROR;
|
DFU_State = dfuERROR;
|
||||||
DFU_Status = errWRITE;
|
DFU_Status = errWRITE;
|
||||||
|
|
||||||
/* Stall command */
|
/* Stall command */
|
||||||
Endpoint_StallTransaction();
|
Endpoint_StallTransaction();
|
||||||
|
|
||||||
/* Don't process the command */
|
/* Don't process the command */
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -544,7 +544,7 @@ static void LoadStartEndAddresses(void)
|
||||||
uint16_t Word;
|
uint16_t Word;
|
||||||
} Address[2] = {{.Bytes = {SentCommand.Data[2], SentCommand.Data[1]}},
|
} Address[2] = {{.Bytes = {SentCommand.Data[2], SentCommand.Data[1]}},
|
||||||
{.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}};
|
{.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}};
|
||||||
|
|
||||||
/* Load in the start and ending read addresses from the sent data packet */
|
/* Load in the start and ending read addresses from the sent data packet */
|
||||||
StartAddr = Address[0].Word;
|
StartAddr = Address[0].Word;
|
||||||
EndAddr = Address[1].Word;
|
EndAddr = Address[1].Word;
|
||||||
|
|
@ -560,7 +560,7 @@ static void ProcessMemProgCommand(void)
|
||||||
{
|
{
|
||||||
/* Load in the start and ending read addresses */
|
/* Load in the start and ending read addresses */
|
||||||
LoadStartEndAddresses();
|
LoadStartEndAddresses();
|
||||||
|
|
||||||
/* If FLASH is being written to, we need to pre-erase the first page to write to */
|
/* If FLASH is being written to, we need to pre-erase the first page to write to */
|
||||||
if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00))
|
if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00))
|
||||||
{
|
{
|
||||||
|
|
@ -569,12 +569,12 @@ static void ProcessMemProgCommand(void)
|
||||||
uint16_t Words[2];
|
uint16_t Words[2];
|
||||||
uint32_t Long;
|
uint32_t Long;
|
||||||
} CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}};
|
} CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}};
|
||||||
|
|
||||||
/* Erase the current page's temp buffer */
|
/* Erase the current page's temp buffer */
|
||||||
boot_page_erase(CurrFlashAddress.Long);
|
boot_page_erase(CurrFlashAddress.Long);
|
||||||
boot_spm_busy_wait();
|
boot_spm_busy_wait();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Set the state so that the next DNLOAD requests reads in the firmware */
|
/* Set the state so that the next DNLOAD requests reads in the firmware */
|
||||||
DFU_State = dfuDNLOAD_IDLE;
|
DFU_State = dfuDNLOAD_IDLE;
|
||||||
}
|
}
|
||||||
|
|
@ -611,7 +611,7 @@ static void ProcessMemReadCommand(void)
|
||||||
/* Save the location of the first non-blank byte for response back to the host */
|
/* Save the location of the first non-blank byte for response back to the host */
|
||||||
Flash64KBPage = (CurrFlashAddress >> 16);
|
Flash64KBPage = (CurrFlashAddress >> 16);
|
||||||
StartAddr = CurrFlashAddress;
|
StartAddr = CurrFlashAddress;
|
||||||
|
|
||||||
/* Set state and status variables to the appropriate error values */
|
/* Set state and status variables to the appropriate error values */
|
||||||
DFU_State = dfuERROR;
|
DFU_State = dfuERROR;
|
||||||
DFU_Status = errCHECK_ERASED;
|
DFU_Status = errCHECK_ERASED;
|
||||||
|
|
@ -680,7 +680,7 @@ static void ProcessWriteCommand(void)
|
||||||
|
|
||||||
/* Re-enable the RWW section of flash as writing to the flash locks it out */
|
/* Re-enable the RWW section of flash as writing to the flash locks it out */
|
||||||
boot_rww_enable();
|
boot_rww_enable();
|
||||||
|
|
||||||
/* Memory has been erased, reset the security bit so that programming/reading is allowed */
|
/* Memory has been erased, reset the security bit so that programming/reading is allowed */
|
||||||
IsSecure = false;
|
IsSecure = false;
|
||||||
}
|
}
|
||||||
|
|
@ -701,3 +701,4 @@ static void ProcessReadCommand(void)
|
||||||
else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte
|
else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte
|
||||||
ResponseByte = SignatureInfo[DataIndexToRead - 0x30];
|
ResponseByte = SignatureInfo[DataIndexToRead - 0x30];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -45,11 +45,11 @@
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
|
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Configuration define. Define this token to true to case the bootloader to reject all memory commands
|
/** Configuration define. Define this token to true to case the bootloader to reject all memory commands
|
||||||
* until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this
|
* until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
/** Minor bootloader version number. */
|
/** Minor bootloader version number. */
|
||||||
#define BOOTLOADER_VERSION_REV 0
|
#define BOOTLOADER_VERSION_REV 0
|
||||||
|
|
||||||
/** Complete bootloader version number expressed as a packed byte, constructed from the
|
/** Complete bootloader version number expressed as a packed byte, constructed from the
|
||||||
* two individual bootloader version macros.
|
* two individual bootloader version macros.
|
||||||
*/
|
*/
|
||||||
#define BOOTLOADER_VERSION ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV)
|
#define BOOTLOADER_VERSION ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV)
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
/** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */
|
/** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */
|
||||||
#define BOOTLOADER_ID_BYTE2 0xFB
|
#define BOOTLOADER_ID_BYTE2 0xFB
|
||||||
|
|
||||||
/** Convenience macro, used to determine if the issued command is the given one-byte long command.
|
/** Convenience macro, used to determine if the issued command is the given one-byte long command.
|
||||||
*
|
*
|
||||||
* \param[in] dataarr Command byte array to check against
|
* \param[in] dataarr Command byte array to check against
|
||||||
|
|
@ -89,7 +89,7 @@
|
||||||
* \param[in] cb2 Second command byte to check
|
* \param[in] cb2 Second command byte to check
|
||||||
*/
|
*/
|
||||||
#define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2)))
|
#define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2)))
|
||||||
|
|
||||||
/** Length of the DFU file suffix block, appended to the end of each complete memory write command.
|
/** Length of the DFU file suffix block, appended to the end of each complete memory write command.
|
||||||
* The DFU file suffix is currently unused (but is designed to give extra file information, such as
|
* The DFU file suffix is currently unused (but is designed to give extra file information, such as
|
||||||
* a CRC of the complete firmware for error checking) and so is discarded.
|
* a CRC of the complete firmware for error checking) and so is discarded.
|
||||||
|
|
@ -100,7 +100,7 @@
|
||||||
* Filler bytes are added to the start of each complete memory write command, and must be discarded.
|
* Filler bytes are added to the start of each complete memory write command, and must be discarded.
|
||||||
*/
|
*/
|
||||||
#define DFU_FILLER_BYTES_SIZE 26
|
#define DFU_FILLER_BYTES_SIZE 26
|
||||||
|
|
||||||
/** DFU class command request to detach from the host. */
|
/** DFU class command request to detach from the host. */
|
||||||
#define REQ_DFU_DETATCH 0x00
|
#define REQ_DFU_DETATCH 0x00
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for a non-returning function pointer to the loaded application. */
|
/** Type define for a non-returning function pointer to the loaded application. */
|
||||||
typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
|
typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
|
||||||
|
|
||||||
/** Type define for a structure containing a complete DFU command issued by the host. */
|
/** Type define for a structure containing a complete DFU command issued by the host. */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
@ -187,7 +187,7 @@
|
||||||
errUNKNOWN = 14,
|
errUNKNOWN = 14,
|
||||||
errSTALLEDPKT = 15
|
errSTALLEDPKT = 15
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
void ResetHardware(void);
|
void ResetHardware(void);
|
||||||
|
|
@ -203,5 +203,6 @@
|
||||||
static void ProcessWriteCommand(void);
|
static void ProcessWriteCommand(void);
|
||||||
static void ProcessReadCommand(void);
|
static void ProcessReadCommand(void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage DFU Class USB AVR Bootloader
|
/** \mainpage DFU Class USB AVR Bootloader
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Device Firmware Update Class (DFU)</td>
|
* <td>Device Firmware Update Class (DFU)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>None</td>
|
* <td>None</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -42,29 +42,29 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming
|
* This bootloader enumerates to the host as a DFU Class device, allowing for DFU-compatible programming
|
||||||
* software to load firmware onto the AVR.
|
* software to load firmware onto the AVR.
|
||||||
*
|
*
|
||||||
* This bootloader is compatible with Atmel's FLIP application. However, it requires the use of Atmel's
|
* This bootloader is compatible with Atmel's FLIP application. However, it requires the use of Atmel's
|
||||||
* DFU drivers. You will need to install Atmel's DFU drivers prior to using this bootloader. If you are
|
* DFU drivers. You will need to install Atmel's DFU drivers prior to using this bootloader. If you are
|
||||||
* using a 64 bit Windows OS, you will need to either disable the driver signing requirement (see online
|
* using a 64 bit Windows OS, you will need to either disable the driver signing requirement (see online
|
||||||
* tutorials for details) or use a digitally signed version of the official Atmel driver provided by a
|
* tutorials for details) or use a digitally signed version of the official Atmel driver provided by a
|
||||||
* third party AVR user at
|
* third party AVR user at
|
||||||
* <a>http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=2196&item_type=project</a>.
|
* <a>http://www.avrfreaks.net/index.php?module=Freaks%20Academy&func=viewItem&item_id=2196&item_type=project</a>.
|
||||||
*
|
*
|
||||||
* As an open-source option, this bootloader is also compatible with the Linux Atmel USB DFU Programmer
|
* As an open-source option, this bootloader is also compatible with the Linux Atmel USB DFU Programmer
|
||||||
* software, available for download at <a>http://sourceforge.net/projects/dfu-programmer/</a>.
|
* software, available for download at <a>http://sourceforge.net/projects/dfu-programmer/</a>.
|
||||||
*
|
*
|
||||||
* If SECURE_MODE is defined as true, upon start-up the bootloader will be locked, with only the chip erase
|
* If SECURE_MODE is defined as true, upon start-up the bootloader will be locked, with only the chip erase
|
||||||
* function available (similar to Atmel's DFU bootloader). If SECURE_MODE is defined as false, all functions
|
* function available (similar to Atmel's DFU bootloader). If SECURE_MODE is defined as false, all functions
|
||||||
* are usable on start-up without the prerequisite firmware erase.
|
* are usable on start-up without the prerequisite firmware erase.
|
||||||
*
|
*
|
||||||
* Out of the box this bootloader builds for the USB1287, and should fit into 4KB of bootloader space. If
|
* Out of the box this bootloader builds for the USB1287, and should fit into 4KB of bootloader space. If
|
||||||
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
|
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
|
||||||
* values in the accompanying makefile.
|
* values in the accompanying makefile.
|
||||||
*
|
*
|
||||||
* <b>NOTE:</b> This device spoofs Atmel's DFU Bootloader USB VID and PID so that the Atmel DFU bootloader
|
* <b>NOTE:</b> This device spoofs Atmel's DFU Bootloader USB VID and PID so that the Atmel DFU bootloader
|
||||||
* drivers included with FLIP will work. If you do not wish to use Atmel's ID codes, please
|
* drivers included with FLIP will work. If you do not wish to use Atmel's ID codes, please
|
||||||
* manually change them in Descriptors.c and alter your driver's INF file accordingly.
|
* manually change them in Descriptors.c and alter your driver's INF file accordingly.
|
||||||
|
|
@ -88,3 +88,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -45,22 +45,22 @@
|
||||||
USB_Descriptor_Device_t DeviceDescriptor =
|
USB_Descriptor_Device_t DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = PRODUCT_ID_CODE,
|
.ProductID = PRODUCT_ID_CODE,
|
||||||
.ReleaseNumber = VERSION_BCD(00.00),
|
.ReleaseNumber = VERSION_BCD(00.00),
|
||||||
|
|
||||||
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
.ManufacturerStrIndex = NO_DESCRIPTOR,
|
||||||
.ProductStrIndex = 0x01,
|
.ProductStrIndex = 0x01,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ USB_Descriptor_Device_t DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
|
|
@ -80,37 +80,37 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.DFU_Interface =
|
.DFU_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 0,
|
.TotalEndpoints = 0,
|
||||||
|
|
||||||
.Class = 0xFE,
|
.Class = 0xFE,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = 0x02,
|
.Protocol = 0x02,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.DFU_Functional =
|
.DFU_Functional =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_DFU_Functional_t), .Type = DTYPE_DFUFunctional},
|
.Header = {.Size = sizeof(USB_Descriptor_DFU_Functional_t), .Type = DTYPE_DFUFunctional},
|
||||||
|
|
||||||
.Attributes = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD),
|
.Attributes = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD),
|
||||||
|
|
||||||
.DetachTimeout = 0x0000,
|
.DetachTimeout = 0x0000,
|
||||||
.TransferSize = 0x0c00,
|
.TransferSize = 0x0c00,
|
||||||
|
|
||||||
.DFUSpecification = VERSION_BCD(01.01)
|
.DFUSpecification = VERSION_BCD(01.01)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
@ -118,11 +118,11 @@ USB_Descriptor_Configuration_t ConfigurationDescriptor =
|
||||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
* via the language ID table available at USB.org what languages the device supports for its string descriptors.
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_String_t LanguageString =
|
USB_Descriptor_String_t LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ USB_Descriptor_String_t LanguageString =
|
||||||
USB_Descriptor_String_t ProductString =
|
USB_Descriptor_String_t ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"AVR DFU Bootloader"
|
.UnicodeString = L"AVR DFU Bootloader"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -159,11 +159,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
if (!(DescriptorNumber))
|
if (!(DescriptorNumber))
|
||||||
{
|
{
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
|
|
@ -174,10 +174,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = ProductString.Header.Size;
|
Size = ProductString.Header.Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Descriptor type value for a DFU class functional descriptor. */
|
/** Descriptor type value for a DFU class functional descriptor. */
|
||||||
#define DTYPE_DFUFunctional 0x21
|
#define DTYPE_DFUFunctional 0x21
|
||||||
|
|
||||||
/** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH
|
/** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH
|
||||||
* command is issued, rather than the host issuing a USB Reset.
|
* command is issued, rather than the host issuing a USB Reset.
|
||||||
*/
|
*/
|
||||||
|
|
@ -52,15 +52,15 @@
|
||||||
* (memory programming phase).
|
* (memory programming phase).
|
||||||
*/
|
*/
|
||||||
#define ATTR_MANEFESTATION_TOLLERANT (1 << 2)
|
#define ATTR_MANEFESTATION_TOLLERANT (1 << 2)
|
||||||
|
|
||||||
/** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from
|
/** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from
|
||||||
* the device to the host.
|
* the device to the host.
|
||||||
*/
|
*/
|
||||||
#define ATTR_CAN_UPLOAD (1 << 1)
|
#define ATTR_CAN_UPLOAD (1 << 1)
|
||||||
|
|
||||||
/** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from
|
/** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from
|
||||||
* the host to the device.
|
* the host to the device.
|
||||||
*/
|
*/
|
||||||
#define ATTR_CAN_DOWNLOAD (1 << 0)
|
#define ATTR_CAN_DOWNLOAD (1 << 0)
|
||||||
|
|
||||||
#if defined(__AVR_AT90USB1287__)
|
#if defined(__AVR_AT90USB1287__)
|
||||||
|
|
@ -126,11 +126,11 @@
|
||||||
#else
|
#else
|
||||||
#error The selected AVR part is not currently supported by this bootloader.
|
#error The selected AVR part is not currently supported by this bootloader.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if !defined(PRODUCT_ID_CODE)
|
#if !defined(PRODUCT_ID_CODE)
|
||||||
#error Current AVR model is not supported by this bootloader.
|
#error Current AVR model is not supported by this bootloader.
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for a DFU class function descriptor. This descriptor gives DFU class information
|
/** Type define for a DFU class function descriptor. This descriptor gives DFU class information
|
||||||
* to the host when read, indicating the DFU device's capabilities.
|
* to the host when read, indicating the DFU device's capabilities.
|
||||||
|
|
@ -138,22 +138,22 @@
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
USB_Descriptor_Header_t Header; /**< Standard descriptor header structure */
|
USB_Descriptor_Header_t Header; /**< Standard descriptor header structure */
|
||||||
|
|
||||||
uint8_t Attributes; /**< DFU device attributes, a mask comprising of the
|
uint8_t Attributes; /**< DFU device attributes, a mask comprising of the
|
||||||
* ATTR_* macros listed in this source file
|
* ATTR_* macros listed in this source file
|
||||||
*/
|
*/
|
||||||
uint16_t DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH
|
uint16_t DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH
|
||||||
* command being issued and the device detaching
|
* command being issued and the device detaching
|
||||||
* from the USB bus
|
* from the USB bus
|
||||||
*/
|
*/
|
||||||
uint16_t TransferSize; /**< Maximum number of bytes the DFU device can accept
|
uint16_t TransferSize; /**< Maximum number of bytes the DFU device can accept
|
||||||
* from the host in a transaction
|
* from the host in a transaction
|
||||||
*/
|
*/
|
||||||
uint16_t DFUSpecification; /**< BCD packed DFU specification number this DFU
|
uint16_t DFUSpecification; /**< BCD packed DFU specification number this DFU
|
||||||
* device complies with
|
* device complies with
|
||||||
*/
|
*/
|
||||||
} USB_Descriptor_DFU_Functional_t;
|
} USB_Descriptor_DFU_Functional_t;
|
||||||
|
|
||||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||||
* vary between devices, and which describe the device's usage to the host.
|
* vary between devices, and which describe the device's usage to the host.
|
||||||
|
|
@ -164,7 +164,7 @@
|
||||||
USB_Descriptor_Interface_t DFU_Interface;
|
USB_Descriptor_Interface_t DFU_Interface;
|
||||||
USB_Descriptor_DFU_Functional_t DFU_Functional;
|
USB_Descriptor_DFU_Functional_t DFU_Functional;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
const uint8_t wIndex,
|
const uint8_t wIndex,
|
||||||
|
|
@ -172,3 +172,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -52,14 +52,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -72,7 +72,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -137,7 +137,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -150,7 +150,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -267,7 +267,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -280,7 +280,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -292,7 +292,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -304,7 +304,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -328,7 +328,7 @@ EXTMEMOPTS =
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
|
LDFLAGS += -Wl,--section-start=.text=$(BOOT_START)
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -362,7 +362,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -396,7 +396,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -425,7 +425,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -444,10 +444,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -512,19 +512,19 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -622,14 +622,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -651,7 +651,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -694,3 +694,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
.PHONY : all begin finish end sizebefore sizeafter gccversion \
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program debug gdb-config
|
clean_list clean_doxygen program debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
#
|
#
|
||||||
# LUFA Library
|
# LUFA Library
|
||||||
# Copyright (C) Dean Camera, 2010.
|
# Copyright (C) Dean Camera, 2010.
|
||||||
#
|
#
|
||||||
# dean [at] fourwalledcubicle [dot] com
|
# dean [at] fourwalledcubicle [dot] com
|
||||||
# www.fourwalledcubicle.com
|
# www.fourwalledcubicle.com
|
||||||
#
|
#
|
||||||
|
|
@ -23,3 +23,4 @@ all:
|
||||||
%:
|
%:
|
||||||
$(MAKE) -C DFU $@
|
$(MAKE) -C DFU $@
|
||||||
$(MAKE) -C CDC $@
|
$(MAKE) -C CDC $@
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -60,7 +60,7 @@ int main(void)
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
ProcessNextSample();
|
ProcessNextSample();
|
||||||
|
|
@ -79,13 +79,13 @@ void SetupHardware(void)
|
||||||
|
|
||||||
/* Disable clock division */
|
/* Disable clock division */
|
||||||
clock_prescale_set(clock_div_1);
|
clock_prescale_set(clock_div_1);
|
||||||
|
|
||||||
/* Hardware Initialization */
|
/* Hardware Initialization */
|
||||||
LEDs_Init();
|
LEDs_Init();
|
||||||
USB_Init();
|
USB_Init();
|
||||||
ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32);
|
ADC_Init(ADC_FREE_RUNNING | ADC_PRESCALE_32);
|
||||||
ADC_SetupChannel(MIC_IN_ADC_CHANNEL);
|
ADC_SetupChannel(MIC_IN_ADC_CHANNEL);
|
||||||
|
|
||||||
/* Start the ADC conversion in free running mode */
|
/* Start the ADC conversion in free running mode */
|
||||||
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_MUX_MASK);
|
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | MIC_IN_ADC_MUX_MASK);
|
||||||
}
|
}
|
||||||
|
|
@ -103,7 +103,7 @@ void ProcessNextSample(void)
|
||||||
|
|
||||||
/* Audio sample is ADC value scaled to fit the entire range */
|
/* Audio sample is ADC value scaled to fit the entire range */
|
||||||
int16_t AudioSample = ((SAMPLE_MAX_RANGE / ADC_MAX_RANGE) * ADC_GetResult());
|
int16_t AudioSample = ((SAMPLE_MAX_RANGE / ADC_MAX_RANGE) * ADC_GetResult());
|
||||||
|
|
||||||
#if defined(MICROPHONE_BIASED_TO_HALF_RAIL)
|
#if defined(MICROPHONE_BIASED_TO_HALF_RAIL)
|
||||||
/* Microphone is biased to half rail voltage, subtract the bias from the sample value */
|
/* Microphone is biased to half rail voltage, subtract the bias from the sample value */
|
||||||
AudioSample -= (SAMPLE_MAX_RANGE / 2);
|
AudioSample -= (SAMPLE_MAX_RANGE / 2);
|
||||||
|
|
@ -148,3 +148,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
{
|
{
|
||||||
Audio_Device_ProcessControlRequest(&Microphone_Audio_Interface);
|
Audio_Device_ProcessControlRequest(&Microphone_Audio_Interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for AudioInput.c.
|
* Header file for AudioInput.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _AUDIO_INPUT_H_
|
#ifndef _AUDIO_INPUT_H_
|
||||||
#define _AUDIO_INPUT_H_
|
#define _AUDIO_INPUT_H_
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** ADC channel number for the microphone input. */
|
/** ADC channel number for the microphone input. */
|
||||||
#define MIC_IN_ADC_CHANNEL 2
|
#define MIC_IN_ADC_CHANNEL 2
|
||||||
|
|
||||||
/** ADC channel MUX mask for the microphone input. */
|
/** ADC channel MUX mask for the microphone input. */
|
||||||
#define MIC_IN_ADC_MUX_MASK ADC_CHANNEL2
|
#define MIC_IN_ADC_MUX_MASK ADC_CHANNEL2
|
||||||
|
|
||||||
|
|
@ -85,3 +85,4 @@
|
||||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Audio Input Device Demo
|
/** \mainpage Audio Input Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Audio Class</td>
|
* <td>Audio Class</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Standard Audio Device</td>
|
* <td>Standard Audio Device</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -43,19 +43,19 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Audio demonstration application. This gives a simple reference
|
* Audio demonstration application. This gives a simple reference
|
||||||
* application for implementing a USB Audio Input device using the
|
* application for implementing a USB Audio Input device using the
|
||||||
* basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers
|
* basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers
|
||||||
* required).
|
* required).
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function
|
* On start-up the system will automatically enumerate and function
|
||||||
* as a USB microphone. Incoming audio from the ADC channel 1 will
|
* as a USB microphone. Incoming audio from the ADC channel 1 will
|
||||||
* be sampled and sent to the host computer.
|
* be sampled and sent to the host computer.
|
||||||
*
|
*
|
||||||
* To use, connect a microphone to the ADC channel 1.
|
* To use, connect a microphone to the ADC channel 1.
|
||||||
*
|
*
|
||||||
* Under Windows, if a driver request dialogue pops up, select the option
|
* Under Windows, if a driver request dialogue pops up, select the option
|
||||||
* to automatically install the appropriate drivers.
|
* to automatically install the appropriate drivers.
|
||||||
*
|
*
|
||||||
|
|
@ -81,3 +81,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,11 +30,11 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||||
|
|
@ -71,7 +71,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
|
|
@ -86,13 +86,13 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_ControlInterface =
|
.Audio_ControlInterface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 0,
|
.TotalEndpoints = 0,
|
||||||
|
|
||||||
.Class = 0x01,
|
.Class = 0x01,
|
||||||
|
|
@ -102,7 +102,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_ControlInterface_SPC =
|
.Audio_ControlInterface_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
|
||||||
|
|
@ -111,12 +111,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.TotalLength = (sizeof(USB_Audio_Descriptor_Interface_AC_t) +
|
.TotalLength = (sizeof(USB_Audio_Descriptor_Interface_AC_t) +
|
||||||
sizeof(USB_Audio_Descriptor_InputTerminal_t) +
|
sizeof(USB_Audio_Descriptor_InputTerminal_t) +
|
||||||
sizeof(USB_Audio_Descriptor_OutputTerminal_t)),
|
sizeof(USB_Audio_Descriptor_OutputTerminal_t)),
|
||||||
|
|
||||||
.InCollection = 1,
|
.InCollection = 1,
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_InputTerminal =
|
.Audio_InputTerminal =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
||||||
|
|
@ -132,7 +132,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.TerminalStrIndex = NO_DESCRIPTOR
|
.TerminalStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_OutputTerminal =
|
.Audio_OutputTerminal =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
||||||
|
|
@ -146,7 +146,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.TerminalStrIndex = NO_DESCRIPTOR
|
.TerminalStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface_Alt0 =
|
.Audio_StreamInterface_Alt0 =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
|
|
@ -162,7 +162,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface_Alt1 =
|
.Audio_StreamInterface_Alt1 =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface_SPC =
|
.Audio_StreamInterface_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_General,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_General,
|
||||||
|
|
@ -189,24 +189,24 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.AudioFormat = 0x0001
|
.AudioFormat = 0x0001
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_AudioFormat =
|
.Audio_AudioFormat =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_Format_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_Format_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_FormatType,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_FormatType,
|
||||||
|
|
||||||
.FormatType = 0x01,
|
.FormatType = 0x01,
|
||||||
.Channels = 0x01,
|
.Channels = 0x01,
|
||||||
|
|
||||||
.SubFrameSize = 0x02,
|
.SubFrameSize = 0x02,
|
||||||
.BitResolution = 16,
|
.BitResolution = 16,
|
||||||
.SampleFrequencyType = AUDIO_TOTAL_SAMPLE_RATES,
|
.SampleFrequencyType = AUDIO_TOTAL_SAMPLE_RATES,
|
||||||
|
|
||||||
.SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
|
.SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamEndpoint =
|
.Audio_StreamEndpoint =
|
||||||
{
|
{
|
||||||
.Endpoint =
|
.Endpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -215,18 +215,18 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.EndpointSize = AUDIO_STREAM_EPSIZE,
|
.EndpointSize = AUDIO_STREAM_EPSIZE,
|
||||||
.PollingIntervalMS = 1
|
.PollingIntervalMS = 1
|
||||||
},
|
},
|
||||||
|
|
||||||
.Refresh = 0,
|
.Refresh = 0,
|
||||||
.SyncEndpointNumber = 0
|
.SyncEndpointNumber = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamEndpoint_SPC =
|
.Audio_StreamEndpoint_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
||||||
|
|
||||||
.Attributes = AUDIO_EP_ACCEPTS_SMALL_PACKETS,
|
.Attributes = AUDIO_EP_ACCEPTS_SMALL_PACKETS,
|
||||||
|
|
||||||
.LockDelayUnits = 0x00,
|
.LockDelayUnits = 0x00,
|
||||||
.LockDelay = 0x0000
|
.LockDelay = 0x0000
|
||||||
}
|
}
|
||||||
|
|
@ -287,30 +287,31 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint number of the Audio isochronous streaming data endpoint. */
|
/** Endpoint number of the Audio isochronous streaming data endpoint. */
|
||||||
#define AUDIO_STREAM_EPNUM 1
|
#define AUDIO_STREAM_EPNUM 1
|
||||||
|
|
||||||
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
|
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
|
||||||
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller
|
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller
|
||||||
* USB AVR models will result in unavoidable distorted output.
|
* USB AVR models will result in unavoidable distorted output.
|
||||||
|
|
@ -82,3 +82,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -137,7 +137,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -150,7 +150,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -264,7 +264,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -277,7 +277,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -289,7 +289,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -301,7 +301,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -324,7 +324,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -358,7 +358,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -392,7 +392,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -421,7 +421,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -440,10 +440,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -508,11 +508,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -539,9 +539,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -639,14 +639,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -668,7 +668,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -712,3 +712,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -60,7 +60,7 @@ int main(void)
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
ProcessNextSample();
|
ProcessNextSample();
|
||||||
|
|
@ -135,7 +135,7 @@ void ProcessNextSample(void)
|
||||||
void EVENT_USB_Device_Connect(void)
|
void EVENT_USB_Device_Connect(void)
|
||||||
{
|
{
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||||
|
|
||||||
/* Sample reload timer initialization */
|
/* Sample reload timer initialization */
|
||||||
OCR0A = (F_CPU / 8 / AUDIO_SAMPLE_FREQUENCY) - 1;
|
OCR0A = (F_CPU / 8 / AUDIO_SAMPLE_FREQUENCY) - 1;
|
||||||
TCCR0A = (1 << WGM01); // CTC mode
|
TCCR0A = (1 << WGM01); // CTC mode
|
||||||
|
|
@ -200,3 +200,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
{
|
{
|
||||||
Audio_Device_ProcessControlRequest(&Speaker_Audio_Interface);
|
Audio_Device_ProcessControlRequest(&Speaker_Audio_Interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -44,13 +44,13 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
#include <LUFA/Version.h>
|
#include <LUFA/Version.h>
|
||||||
#include <LUFA/Drivers/Board/LEDs.h>
|
#include <LUFA/Drivers/Board/LEDs.h>
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
#include <LUFA/Drivers/USB/Class/Audio.h>
|
#include <LUFA/Drivers/USB/Class/Audio.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||||
|
|
||||||
|
|
@ -62,14 +62,15 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
void ProcessNextSample(void);
|
void ProcessNextSample(void);
|
||||||
|
|
||||||
void EVENT_USB_Device_Connect(void);
|
void EVENT_USB_Device_Connect(void);
|
||||||
void EVENT_USB_Device_Disconnect(void);
|
void EVENT_USB_Device_Disconnect(void);
|
||||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Audio Output Device Demo
|
/** \mainpage Audio Output Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Audio Class</td>
|
* <td>Audio Class</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Standard Audio Device</td>
|
* <td>Standard Audio Device</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -43,13 +43,13 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Audio demonstration application. This gives a simple reference
|
* Audio demonstration application. This gives a simple reference
|
||||||
* application for implementing a USB Audio Output device using the
|
* application for implementing a USB Audio Output device using the
|
||||||
* basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers
|
* basic USB Audio 1.0 drivers in all modern OSes (i.e. no special drivers
|
||||||
* required).
|
* required).
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function
|
* On start-up the system will automatically enumerate and function
|
||||||
* as a USB speaker. Outgoing audio will output in 8-bit PWM onto
|
* as a USB speaker. Outgoing audio will output in 8-bit PWM onto
|
||||||
* the timer 3 output compare channel A for AUDIO_OUT_MONO mode, on
|
* the timer 3 output compare channel A for AUDIO_OUT_MONO mode, on
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
* mono sample for AUDIO_OUT_PORTC. Audio output will also be indicated on
|
* mono sample for AUDIO_OUT_PORTC. Audio output will also be indicated on
|
||||||
* the board LEDs in all modes. Decouple audio outputs with a capacitor and
|
* the board LEDs in all modes. Decouple audio outputs with a capacitor and
|
||||||
* attach to a speaker to hear the audio.
|
* attach to a speaker to hear the audio.
|
||||||
*
|
*
|
||||||
* Under Windows, if a driver request dialogue pops up, select the option
|
* Under Windows, if a driver request dialogue pops up, select the option
|
||||||
* to automatically install the appropriate drivers.
|
* to automatically install the appropriate drivers.
|
||||||
*
|
*
|
||||||
|
|
@ -94,3 +94,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,11 +30,11 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||||
|
|
@ -71,7 +71,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
|
|
@ -80,133 +80,133 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_ControlInterface =
|
.Audio_ControlInterface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 0,
|
.TotalEndpoints = 0,
|
||||||
|
|
||||||
.Class = 0x01,
|
.Class = 0x01,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_ControlInterface_SPC =
|
.Audio_ControlInterface_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
|
||||||
|
|
||||||
.ACSpecification = VERSION_BCD(01.00),
|
.ACSpecification = VERSION_BCD(01.00),
|
||||||
.TotalLength = (sizeof(USB_Audio_Descriptor_Interface_AC_t) +
|
.TotalLength = (sizeof(USB_Audio_Descriptor_Interface_AC_t) +
|
||||||
sizeof(USB_Audio_Descriptor_InputTerminal_t) +
|
sizeof(USB_Audio_Descriptor_InputTerminal_t) +
|
||||||
sizeof(USB_Audio_Descriptor_OutputTerminal_t)),
|
sizeof(USB_Audio_Descriptor_OutputTerminal_t)),
|
||||||
|
|
||||||
.InCollection = 1,
|
.InCollection = 1,
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_InputTerminal =
|
.Audio_InputTerminal =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_InputTerminal_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
||||||
|
|
||||||
.TerminalID = 0x01,
|
.TerminalID = 0x01,
|
||||||
.TerminalType = AUDIO_TERMINAL_STREAMING,
|
.TerminalType = AUDIO_TERMINAL_STREAMING,
|
||||||
.AssociatedOutputTerminal = 0x00,
|
.AssociatedOutputTerminal = 0x00,
|
||||||
|
|
||||||
.TotalChannels = 2,
|
.TotalChannels = 2,
|
||||||
.ChannelConfig = (AUDIO_CHANNEL_LEFT_FRONT | AUDIO_CHANNEL_RIGHT_FRONT),
|
.ChannelConfig = (AUDIO_CHANNEL_LEFT_FRONT | AUDIO_CHANNEL_RIGHT_FRONT),
|
||||||
|
|
||||||
.ChannelStrIndex = NO_DESCRIPTOR,
|
.ChannelStrIndex = NO_DESCRIPTOR,
|
||||||
.TerminalStrIndex = NO_DESCRIPTOR
|
.TerminalStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_OutputTerminal =
|
.Audio_OutputTerminal =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_OutputTerminal_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
||||||
|
|
||||||
.TerminalID = 0x02,
|
.TerminalID = 0x02,
|
||||||
.TerminalType = AUDIO_TERMINAL_OUT_SPEAKER,
|
.TerminalType = AUDIO_TERMINAL_OUT_SPEAKER,
|
||||||
.AssociatedInputTerminal = 0x00,
|
.AssociatedInputTerminal = 0x00,
|
||||||
|
|
||||||
.SourceID = 0x01,
|
.SourceID = 0x01,
|
||||||
|
|
||||||
.TerminalStrIndex = NO_DESCRIPTOR
|
.TerminalStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface_Alt0 =
|
.Audio_StreamInterface_Alt0 =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 0,
|
.TotalEndpoints = 0,
|
||||||
|
|
||||||
.Class = 0x01,
|
.Class = 0x01,
|
||||||
.SubClass = 0x02,
|
.SubClass = 0x02,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface_Alt1 =
|
.Audio_StreamInterface_Alt1 =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
.AlternateSetting = 1,
|
.AlternateSetting = 1,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x01,
|
.Class = 0x01,
|
||||||
.SubClass = 0x02,
|
.SubClass = 0x02,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface_SPC =
|
.Audio_StreamInterface_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AS_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_General,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_General,
|
||||||
|
|
||||||
.TerminalLink = 0x01,
|
.TerminalLink = 0x01,
|
||||||
|
|
||||||
.FrameDelay = 1,
|
.FrameDelay = 1,
|
||||||
.AudioFormat = 0x0001
|
.AudioFormat = 0x0001
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_AudioFormat =
|
.Audio_AudioFormat =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_Format_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_Format_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_FormatType,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_FormatType,
|
||||||
|
|
||||||
.FormatType = 0x01,
|
.FormatType = 0x01,
|
||||||
.Channels = 0x02,
|
.Channels = 0x02,
|
||||||
|
|
||||||
.SubFrameSize = 0x02,
|
.SubFrameSize = 0x02,
|
||||||
.BitResolution = 16,
|
.BitResolution = 16,
|
||||||
|
|
||||||
.SampleFrequencyType = AUDIO_TOTAL_SAMPLE_RATES,
|
.SampleFrequencyType = AUDIO_TOTAL_SAMPLE_RATES,
|
||||||
.SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
|
.SampleFrequencies = {AUDIO_SAMPLE_FREQ(AUDIO_SAMPLE_FREQUENCY)}
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamEndpoint =
|
.Audio_StreamEndpoint =
|
||||||
{
|
{
|
||||||
.Endpoint =
|
.Endpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -215,18 +215,18 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.EndpointSize = AUDIO_STREAM_EPSIZE,
|
.EndpointSize = AUDIO_STREAM_EPSIZE,
|
||||||
.PollingIntervalMS = 1
|
.PollingIntervalMS = 1
|
||||||
},
|
},
|
||||||
|
|
||||||
.Refresh = 0,
|
.Refresh = 0,
|
||||||
.SyncEndpointNumber = 0
|
.SyncEndpointNumber = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamEndpoint_SPC =
|
.Audio_StreamEndpoint_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Spc_t), .Type = DTYPE_CSEndpoint},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
||||||
|
|
||||||
.Attributes = AUDIO_EP_ACCEPTS_SMALL_PACKETS,
|
.Attributes = AUDIO_EP_ACCEPTS_SMALL_PACKETS,
|
||||||
|
|
||||||
.LockDelayUnits = 0x00,
|
.LockDelayUnits = 0x00,
|
||||||
.LockDelay = 0x0000
|
.LockDelay = 0x0000
|
||||||
}
|
}
|
||||||
|
|
@ -291,26 +291,27 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -45,16 +45,16 @@
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint number of the Audio isochronous streaming data endpoint. */
|
/** Endpoint number of the Audio isochronous streaming data endpoint. */
|
||||||
#define AUDIO_STREAM_EPNUM 1
|
#define AUDIO_STREAM_EPNUM 1
|
||||||
|
|
||||||
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
|
/** Endpoint size in bytes of the Audio isochronous streaming data endpoint. The Windows audio stack requires
|
||||||
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller
|
* at least 192 bytes for correct output, thus the smaller 128 byte maximum endpoint size on some of the smaller
|
||||||
* USB AVR models will result in unavoidable distorted output.
|
* USB AVR models will result in unavoidable distorted output.
|
||||||
*/
|
*/
|
||||||
#define AUDIO_STREAM_EPSIZE ENDPOINT_MAX_SIZE(AUDIO_STREAM_EPNUM)
|
#define AUDIO_STREAM_EPSIZE ENDPOINT_MAX_SIZE(AUDIO_STREAM_EPNUM)
|
||||||
|
|
||||||
/** Sample frequency of the data being transmitted through the streaming endpoint. */
|
/** Sample frequency of the data being transmitted through the streaming endpoint. */
|
||||||
#define AUDIO_SAMPLE_FREQUENCY 48000
|
#define AUDIO_SAMPLE_FREQUENCY 48000
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint;
|
USB_Audio_Descriptor_StreamEndpoint_Std_t Audio_StreamEndpoint;
|
||||||
USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC;
|
USB_Audio_Descriptor_StreamEndpoint_Spc_t Audio_StreamEndpoint_SPC;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
const uint8_t wIndex,
|
const uint8_t wIndex,
|
||||||
|
|
@ -82,3 +82,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -139,7 +139,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -152,7 +152,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -266,7 +266,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -279,7 +279,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -291,7 +291,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -303,7 +303,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -326,7 +326,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -360,7 +360,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -394,7 +394,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -423,7 +423,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -442,10 +442,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -510,11 +510,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -541,9 +541,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -641,14 +641,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -670,7 +670,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -714,3 +714,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -57,22 +57,22 @@
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0xEF,
|
.Class = 0xEF,
|
||||||
.SubClass = 0x02,
|
.SubClass = 0x02,
|
||||||
.Protocol = 0x01,
|
.Protocol = 0x01,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x204E,
|
.ProductID = 0x204E,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -83,22 +83,22 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 4,
|
.TotalInterfaces = 4,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_IAD =
|
.CDC1_IAD =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
|
||||||
|
|
||||||
|
|
@ -112,94 +112,94 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.IADStrIndex = NO_DESCRIPTOR
|
.IADStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_CCI_Interface =
|
.CDC1_CCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x02,
|
.Class = 0x02,
|
||||||
.SubClass = 0x02,
|
.SubClass = 0x02,
|
||||||
.Protocol = 0x01,
|
.Protocol = 0x01,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_Functional_Header =
|
.CDC1_Functional_Header =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
||||||
|
|
||||||
.CDCSpecification = VERSION_BCD(01.10),
|
.CDCSpecification = VERSION_BCD(01.10),
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_Functional_ACM =
|
.CDC1_Functional_ACM =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
||||||
|
|
||||||
.Capabilities = 0x06,
|
.Capabilities = 0x06,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_Functional_Union =
|
.CDC1_Functional_Union =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
||||||
|
|
||||||
.MasterInterfaceNumber = 0,
|
.MasterInterfaceNumber = 0,
|
||||||
.SlaveInterfaceNumber = 1,
|
.SlaveInterfaceNumber = 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_ManagementEndpoint =
|
.CDC1_ManagementEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC1_NOTIFICATION_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC1_NOTIFICATION_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||||
.PollingIntervalMS = 0xFF
|
.PollingIntervalMS = 0xFF
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_DCI_Interface =
|
.CDC1_DCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 2,
|
.TotalEndpoints = 2,
|
||||||
|
|
||||||
.Class = 0x0A,
|
.Class = 0x0A,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_DataOutEndpoint =
|
.CDC1_DataOutEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC1_RX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC1_RX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC1_DataInEndpoint =
|
.CDC1_DataInEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC1_TX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC1_TX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_IAD =
|
.CDC2_IAD =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_Association_t), .Type = DTYPE_InterfaceAssociation},
|
||||||
|
|
||||||
|
|
@ -213,87 +213,87 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.IADStrIndex = NO_DESCRIPTOR
|
.IADStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_CCI_Interface =
|
.CDC2_CCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 2,
|
.InterfaceNumber = 2,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x02,
|
.Class = 0x02,
|
||||||
.SubClass = 0x02,
|
.SubClass = 0x02,
|
||||||
.Protocol = 0x01,
|
.Protocol = 0x01,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_Functional_Header =
|
.CDC2_Functional_Header =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
||||||
|
|
||||||
.CDCSpecification = VERSION_BCD(01.10),
|
.CDCSpecification = VERSION_BCD(01.10),
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_Functional_ACM =
|
.CDC2_Functional_ACM =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
||||||
|
|
||||||
.Capabilities = 0x06,
|
.Capabilities = 0x06,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_Functional_Union =
|
.CDC2_Functional_Union =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
||||||
|
|
||||||
.MasterInterfaceNumber = 2,
|
.MasterInterfaceNumber = 2,
|
||||||
.SlaveInterfaceNumber = 3,
|
.SlaveInterfaceNumber = 3,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_ManagementEndpoint =
|
.CDC2_ManagementEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC2_NOTIFICATION_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC2_NOTIFICATION_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||||
.PollingIntervalMS = 0xFF
|
.PollingIntervalMS = 0xFF
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_DCI_Interface =
|
.CDC2_DCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 3,
|
.InterfaceNumber = 3,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 2,
|
.TotalEndpoints = 2,
|
||||||
|
|
||||||
.Class = 0x0A,
|
.Class = 0x0A,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_DataOutEndpoint =
|
.CDC2_DataOutEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC2_RX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC2_RX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC2_DataInEndpoint =
|
.CDC2_DataInEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC2_TX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC2_TX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
|
|
@ -356,30 +356,31 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -102,3 +102,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -92,7 +92,7 @@ USB_ClassInfo_CDC_Device_t VirtualSerial2_CDC_Interface =
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
SetupHardware();
|
SetupHardware();
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
|
|
@ -107,7 +107,7 @@ int main(void)
|
||||||
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface);
|
int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial2_CDC_Interface);
|
||||||
if (!(ReceivedByte < 0))
|
if (!(ReceivedByte < 0))
|
||||||
CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)ReceivedByte);
|
CDC_Device_SendByte(&VirtualSerial2_CDC_Interface, (uint8_t)ReceivedByte);
|
||||||
|
|
||||||
CDC_Device_USBTask(&VirtualSerial1_CDC_Interface);
|
CDC_Device_USBTask(&VirtualSerial1_CDC_Interface);
|
||||||
CDC_Device_USBTask(&VirtualSerial2_CDC_Interface);
|
CDC_Device_USBTask(&VirtualSerial2_CDC_Interface);
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
|
|
@ -151,12 +151,12 @@ void CheckJoystickMovement(void)
|
||||||
ReportString = "Joystick Pressed\r\n";
|
ReportString = "Joystick Pressed\r\n";
|
||||||
else
|
else
|
||||||
ActionSent = false;
|
ActionSent = false;
|
||||||
|
|
||||||
if ((ReportString != NULL) && (ActionSent == false))
|
if ((ReportString != NULL) && (ActionSent == false))
|
||||||
{
|
{
|
||||||
ActionSent = true;
|
ActionSent = true;
|
||||||
|
|
||||||
CDC_Device_SendString(&VirtualSerial1_CDC_Interface, ReportString, strlen(ReportString));
|
CDC_Device_SendString(&VirtualSerial1_CDC_Interface, ReportString, strlen(ReportString));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -189,3 +189,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
CDC_Device_ProcessControlRequest(&VirtualSerial1_CDC_Interface);
|
CDC_Device_ProcessControlRequest(&VirtualSerial1_CDC_Interface);
|
||||||
CDC_Device_ProcessControlRequest(&VirtualSerial2_CDC_Interface);
|
CDC_Device_ProcessControlRequest(&VirtualSerial2_CDC_Interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
void CheckJoystickMovement(void);
|
void CheckJoystickMovement(void);
|
||||||
|
|
@ -74,3 +74,4 @@
|
||||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Dual Communications Device Class (Dual Virtual Serial Port) Device
|
/** \mainpage Dual Communications Device Class (Dual Virtual Serial Port) Device
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -27,7 +27,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Communications Device Class (CDC)</td>
|
* <td>Communications Device Class (CDC)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Abstract Control Model (ACM)</td>
|
* <td>Abstract Control Model (ACM)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Dual Communications Device Class demonstration application.
|
* Dual Communications Device Class demonstration application.
|
||||||
* This gives a simple reference application for implementing
|
* This gives a simple reference application for implementing
|
||||||
|
|
@ -56,13 +56,13 @@
|
||||||
* descriptors for each virtual serial port, which may not be
|
* descriptors for each virtual serial port, which may not be
|
||||||
* supported in all OSes - Windows Vista is supported, as is
|
* supported in all OSes - Windows Vista is supported, as is
|
||||||
* XP (although the latter may need a hotfix to function).
|
* XP (although the latter may need a hotfix to function).
|
||||||
*
|
*
|
||||||
* Joystick actions are transmitted to the host as strings
|
* Joystick actions are transmitted to the host as strings
|
||||||
* through the first serial port. The device does not respond to
|
* through the first serial port. The device does not respond to
|
||||||
* serial data sent from the host in the first serial port.
|
* serial data sent from the host in the first serial port.
|
||||||
*
|
*
|
||||||
* The second serial port echoes back data sent from the host.
|
* The second serial port echoes back data sent from the host.
|
||||||
*
|
*
|
||||||
* After running this demo for the first time on a new computer,
|
* After running this demo for the first time on a new computer,
|
||||||
* you will need to supply the .INF file located in this demo
|
* you will need to supply the .INF file located in this demo
|
||||||
* project's directory as the device's driver when running under
|
* project's directory as the device's driver when running under
|
||||||
|
|
@ -83,3 +83,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -71,22 +71,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x204F,
|
.ProductID = 0x204F,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -97,41 +97,41 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 1,
|
.TotalInterfaces = 1,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_Interface =
|
.HID_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0x00,
|
.InterfaceNumber = 0x00,
|
||||||
.AlternateSetting = 0x00,
|
.AlternateSetting = 0x00,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x03,
|
.Class = 0x03,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = HID_BOOTP_NonBootProtocol,
|
.Protocol = HID_BOOTP_NonBootProtocol,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_GenericHID =
|
.HID_GenericHID =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(01.11),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
|
|
@ -139,10 +139,10 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.HIDReportLength = sizeof(GenericReport)
|
.HIDReportLength = sizeof(GenericReport)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_ReportINEndpoint =
|
.HID_ReportINEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | GENERIC_IN_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | GENERIC_IN_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = GENERIC_EPSIZE,
|
.EndpointSize = GENERIC_EPSIZE,
|
||||||
|
|
@ -157,7 +157,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -179,7 +179,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(21), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA Generic HID Demo"
|
.UnicodeString = L"LUFA Generic HID Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -205,38 +205,39 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_HID:
|
case HID_DTYPE_HID:
|
||||||
Address = &ConfigurationDescriptor.HID_GenericHID;
|
Address = &ConfigurationDescriptor.HID_GenericHID;
|
||||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_Report:
|
case HID_DTYPE_Report:
|
||||||
Address = &GenericReport;
|
Address = &GenericReport;
|
||||||
Size = sizeof(GenericReport);
|
Size = sizeof(GenericReport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -61,14 +61,15 @@
|
||||||
|
|
||||||
/** Size in bytes of the Generic HID reporting endpoint. */
|
/** Size in bytes of the Generic HID reporting endpoint. */
|
||||||
#define GENERIC_EPSIZE 8
|
#define GENERIC_EPSIZE 8
|
||||||
|
|
||||||
/** Size in bytes of the Generic HID reports (including report ID byte). */
|
/** Size in bytes of the Generic HID reports (including report ID byte). */
|
||||||
#define GENERIC_REPORT_SIZE 8
|
#define GENERIC_REPORT_SIZE 8
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
const uint8_t wIndex,
|
const uint8_t wIndex,
|
||||||
const void** const DescriptorAddress)
|
const void** const DescriptorAddress)
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -60,7 +60,7 @@ USB_ClassInfo_HID_Device_t Generic_HID_Interface =
|
||||||
.ReportINEndpointNumber = GENERIC_IN_EPNUM,
|
.ReportINEndpointNumber = GENERIC_IN_EPNUM,
|
||||||
.ReportINEndpointSize = GENERIC_EPSIZE,
|
.ReportINEndpointSize = GENERIC_EPSIZE,
|
||||||
.ReportINEndpointDoubleBank = false,
|
.ReportINEndpointDoubleBank = false,
|
||||||
|
|
||||||
.PrevReportINBuffer = PrevHIDReportBuffer,
|
.PrevReportINBuffer = PrevHIDReportBuffer,
|
||||||
.PrevReportINBufferSize = sizeof(PrevHIDReportBuffer),
|
.PrevReportINBufferSize = sizeof(PrevHIDReportBuffer),
|
||||||
},
|
},
|
||||||
|
|
@ -72,10 +72,10 @@ USB_ClassInfo_HID_Device_t Generic_HID_Interface =
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
SetupHardware();
|
SetupHardware();
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
HID_Device_USBTask(&Generic_HID_Interface);
|
HID_Device_USBTask(&Generic_HID_Interface);
|
||||||
|
|
@ -101,7 +101,7 @@ void SetupHardware(void)
|
||||||
/** Event handler for the library USB Connection event. */
|
/** Event handler for the library USB Connection event. */
|
||||||
void EVENT_USB_Device_Connect(void)
|
void EVENT_USB_Device_Connect(void)
|
||||||
{
|
{
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Event handler for the library USB Disconnection event. */
|
/** Event handler for the library USB Disconnection event. */
|
||||||
|
|
@ -154,7 +154,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
*ReportID = HIDReportEcho.ReportID;
|
*ReportID = HIDReportEcho.ReportID;
|
||||||
|
|
||||||
memcpy(ReportData, HIDReportEcho.ReportData, HIDReportEcho.ReportSize);
|
memcpy(ReportData, HIDReportEcho.ReportData, HIDReportEcho.ReportSize);
|
||||||
|
|
||||||
*ReportSize = HIDReportEcho.ReportSize;
|
*ReportSize = HIDReportEcho.ReportSize;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -177,3 +177,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
||||||
HIDReportEcho.ReportSize = ReportSize;
|
HIDReportEcho.ReportSize = ReportSize;
|
||||||
memcpy(HIDReportEcho.ReportData, ReportData, ReportSize);
|
memcpy(HIDReportEcho.ReportData, ReportData, ReportSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for GenericHID.c.
|
* Header file for GenericHID.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _GENERICHID_H_
|
#ifndef _GENERICHID_H_
|
||||||
#define _GENERICHID_H_
|
#define _GENERICHID_H_
|
||||||
|
|
||||||
|
|
@ -42,7 +42,7 @@
|
||||||
#include <avr/power.h>
|
#include <avr/power.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
#include <LUFA/Version.h>
|
#include <LUFA/Version.h>
|
||||||
|
|
@ -78,9 +78,10 @@
|
||||||
void* ReportData,
|
void* ReportData,
|
||||||
uint16_t* const ReportSize);
|
uint16_t* const ReportSize);
|
||||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||||
const uint8_t ReportID,
|
const uint8_t ReportID,
|
||||||
const uint8_t ReportType,
|
const uint8_t ReportType,
|
||||||
const void* ReportData,
|
const void* ReportData,
|
||||||
const uint16_t ReportSize);
|
const uint16_t ReportSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Generic HID Device
|
/** \mainpage Generic HID Device
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Human Interface Device (HID)</td>
|
* <td>Human Interface Device (HID)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>N/A</td>
|
* <td>N/A</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -44,19 +44,19 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Generic HID device demonstration application. This gives a simple reference application
|
* Generic HID device demonstration application. This gives a simple reference application
|
||||||
* for implementing a generic HID device, using the basic USB HID drivers in all modern
|
* for implementing a generic HID device, using the basic USB HID drivers in all modern
|
||||||
* OSes (i.e. no special drivers required). By default it accepts and sends up to 8 byte reports
|
* OSes (i.e. no special drivers required). By default it accepts and sends up to 8 byte reports
|
||||||
* to and from a USB Host, and transmits the last sent report back to the host.
|
* to and from a USB Host, and transmits the last sent report back to the host.
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function as a vendor HID device.
|
* On start-up the system will automatically enumerate and function as a vendor HID device.
|
||||||
* When controlled by a custom HID class application, reports can be sent and received by
|
* When controlled by a custom HID class application, reports can be sent and received by
|
||||||
* both the standard data endpoint and control request methods defined in the HID specification.
|
* both the standard data endpoint and control request methods defined in the HID specification.
|
||||||
*
|
*
|
||||||
* \section SSec_Options Project Options
|
* \section SSec_Options Project Options
|
||||||
*
|
*
|
||||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||||
*
|
*
|
||||||
* <table>
|
* <table>
|
||||||
|
|
@ -73,3 +73,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -81,22 +81,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM JoystickReport[] =
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x2043,
|
.ProductID = 0x2043,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -107,41 +107,41 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 1,
|
.TotalInterfaces = 1,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_Interface =
|
.HID_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0x00,
|
.InterfaceNumber = 0x00,
|
||||||
.AlternateSetting = 0x00,
|
.AlternateSetting = 0x00,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x03,
|
.Class = 0x03,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = HID_BOOTP_NonBootProtocol,
|
.Protocol = HID_BOOTP_NonBootProtocol,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_JoystickHID =
|
.HID_JoystickHID =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(01.11),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
|
|
@ -149,15 +149,15 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.HIDReportLength = sizeof(JoystickReport)
|
.HIDReportLength = sizeof(JoystickReport)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_ReportINEndpoint =
|
.HID_ReportINEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | JOYSTICK_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | JOYSTICK_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = JOYSTICK_EPSIZE,
|
.EndpointSize = JOYSTICK_EPSIZE,
|
||||||
.PollingIntervalMS = 0x0A
|
.PollingIntervalMS = 0x0A
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||||
|
|
@ -167,7 +167,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -189,7 +189,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA Joystick Demo"
|
.UnicodeString = L"LUFA Joystick Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -215,38 +215,39 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_HID:
|
case HID_DTYPE_HID:
|
||||||
Address = &ConfigurationDescriptor.HID_JoystickHID;
|
Address = &ConfigurationDescriptor.HID_JoystickHID;
|
||||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_Report:
|
case HID_DTYPE_Report:
|
||||||
Address = &JoystickReport;
|
Address = &JoystickReport;
|
||||||
Size = sizeof(JoystickReport);
|
Size = sizeof(JoystickReport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -69,3 +69,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -64,10 +64,10 @@ USB_ClassInfo_HID_Device_t Joystick_HID_Interface =
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
SetupHardware();
|
SetupHardware();
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
HID_Device_USBTask(&Joystick_HID_Interface);
|
HID_Device_USBTask(&Joystick_HID_Interface);
|
||||||
|
|
@ -145,7 +145,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
uint16_t* const ReportSize)
|
uint16_t* const ReportSize)
|
||||||
{
|
{
|
||||||
USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;
|
USB_JoystickReport_Data_t* JoystickReport = (USB_JoystickReport_Data_t*)ReportData;
|
||||||
|
|
||||||
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
||||||
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
||||||
|
|
||||||
|
|
@ -161,10 +161,10 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_PRESS)
|
if (JoyStatus_LCL & JOY_PRESS)
|
||||||
JoystickReport->Button = (1 << 1);
|
JoystickReport->Button = (1 << 1);
|
||||||
|
|
||||||
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
||||||
JoystickReport->Button |= (1 << 0);
|
JoystickReport->Button |= (1 << 0);
|
||||||
|
|
||||||
*ReportSize = sizeof(USB_JoystickReport_Data_t);
|
*ReportSize = sizeof(USB_JoystickReport_Data_t);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -185,3 +185,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
||||||
{
|
{
|
||||||
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Joystick.c.
|
* Header file for Joystick.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _JOYSTICK_H_
|
#ifndef _JOYSTICK_H_
|
||||||
#define _JOYSTICK_H_
|
#define _JOYSTICK_H_
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
int8_t Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */
|
int8_t Y; /**< Current absolute joystick Y position, as a signed 8-bit integer */
|
||||||
uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */
|
uint8_t Button; /**< Bit mask of the currently pressed joystick buttons */
|
||||||
} USB_JoystickReport_Data_t;
|
} USB_JoystickReport_Data_t;
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||||
|
|
@ -91,9 +91,10 @@
|
||||||
void* ReportData,
|
void* ReportData,
|
||||||
uint16_t* const ReportSize);
|
uint16_t* const ReportSize);
|
||||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||||
const uint8_t ReportID,
|
const uint8_t ReportID,
|
||||||
const uint8_t ReportType,
|
const uint8_t ReportType,
|
||||||
const void* ReportData,
|
const void* ReportData,
|
||||||
const uint16_t ReportSize);
|
const uint16_t ReportSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Joystick Device Demo
|
/** \mainpage Joystick Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Human Interface Device (HID)</td>
|
* <td>Human Interface Device (HID)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>N/A</td>
|
* <td>N/A</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -44,19 +44,19 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Joystick demonstration application. This gives a simple reference
|
* Joystick demonstration application. This gives a simple reference
|
||||||
* application for implementing a USB Keyboard device, for USB Joysticks
|
* application for implementing a USB Keyboard device, for USB Joysticks
|
||||||
* using the standard Keyboard HID profile.
|
* using the standard Keyboard HID profile.
|
||||||
*
|
*
|
||||||
* This device will show up as a generic joystick device, with two buttons.
|
* This device will show up as a generic joystick device, with two buttons.
|
||||||
* Pressing the joystick inwards is the first button, and the HWB button
|
* Pressing the joystick inwards is the first button, and the HWB button
|
||||||
* is the second.
|
* is the second.
|
||||||
*
|
*
|
||||||
* Moving the joystick on the selected board moves the joystick location on
|
* Moving the joystick on the selected board moves the joystick location on
|
||||||
* the host computer.
|
* the host computer.
|
||||||
*
|
*
|
||||||
* Currently only single interface joysticks are supported.
|
* Currently only single interface joysticks are supported.
|
||||||
*
|
*
|
||||||
* \section SSec_Options Project Options
|
* \section SSec_Options Project Options
|
||||||
|
|
@ -71,3 +71,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -87,22 +87,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x2042,
|
.ProductID = 0x2042,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -113,49 +113,49 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 1,
|
.TotalInterfaces = 1,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_Interface =
|
.HID_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0x00,
|
.InterfaceNumber = 0x00,
|
||||||
.AlternateSetting = 0x00,
|
.AlternateSetting = 0x00,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x03,
|
.Class = 0x03,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = HID_BOOTP_KeyboardBootProtocol,
|
.Protocol = HID_BOOTP_KeyboardBootProtocol,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_KeyboardHID =
|
.HID_KeyboardHID =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(01.11),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
.HIDReportLength = sizeof(KeyboardReport)
|
.HIDReportLength = sizeof(KeyboardReport)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_ReportINEndpoint =
|
.HID_ReportINEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -173,7 +173,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -184,7 +184,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -195,7 +195,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(18), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA Keyboard Demo"
|
.UnicodeString = L"LUFA Keyboard Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -217,42 +217,43 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
|
|
||||||
switch (DescriptorType)
|
switch (DescriptorType)
|
||||||
{
|
{
|
||||||
case DTYPE_Device:
|
case DTYPE_Device:
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_HID:
|
case HID_DTYPE_HID:
|
||||||
Address = &ConfigurationDescriptor.HID_KeyboardHID;
|
Address = &ConfigurationDescriptor.HID_KeyboardHID;
|
||||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_Report:
|
case HID_DTYPE_Report:
|
||||||
Address = &KeyboardReport;
|
Address = &KeyboardReport;
|
||||||
Size = sizeof(KeyboardReport);
|
Size = sizeof(KeyboardReport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -54,12 +54,12 @@
|
||||||
USB_HID_Descriptor_HID_t HID_KeyboardHID;
|
USB_HID_Descriptor_HID_t HID_KeyboardHID;
|
||||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint number of the Keyboard HID reporting IN endpoint. */
|
/** Endpoint number of the Keyboard HID reporting IN endpoint. */
|
||||||
#define KEYBOARD_EPNUM 1
|
#define KEYBOARD_EPNUM 1
|
||||||
|
|
||||||
/** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */
|
/** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */
|
||||||
#define KEYBOARD_EPSIZE 8
|
#define KEYBOARD_EPSIZE 8
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
|
|
@ -69,3 +69,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -67,7 +67,7 @@ int main(void)
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
HID_Device_USBTask(&Keyboard_HID_Interface);
|
HID_Device_USBTask(&Keyboard_HID_Interface);
|
||||||
|
|
@ -142,12 +142,12 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
const uint8_t ReportType, void* ReportData, uint16_t* const ReportSize)
|
const uint8_t ReportType, void* ReportData, uint16_t* const ReportSize)
|
||||||
{
|
{
|
||||||
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
||||||
|
|
||||||
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
||||||
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
||||||
|
|
||||||
uint8_t UsedKeyCodes = 0;
|
uint8_t UsedKeyCodes = 0;
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_UP)
|
if (JoyStatus_LCL & JOY_UP)
|
||||||
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x04; // A
|
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x04; // A
|
||||||
else if (JoyStatus_LCL & JOY_DOWN)
|
else if (JoyStatus_LCL & JOY_DOWN)
|
||||||
|
|
@ -160,7 +160,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_PRESS)
|
if (JoyStatus_LCL & JOY_PRESS)
|
||||||
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x08; // E
|
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x08; // E
|
||||||
|
|
||||||
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
||||||
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x09; // F
|
KeyboardReport->KeyCode[UsedKeyCodes++] = 0x09; // F
|
||||||
|
|
||||||
|
|
@ -190,12 +190,13 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK)
|
||||||
LEDMask |= LEDS_LED1;
|
LEDMask |= LEDS_LED1;
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
|
||||||
LEDMask |= LEDS_LED3;
|
LEDMask |= LEDS_LED3;
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
|
||||||
LEDMask |= LEDS_LED4;
|
LEDMask |= LEDS_LED4;
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMask);
|
LEDs_SetAllLEDs(LEDMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -52,7 +52,7 @@
|
||||||
#include <LUFA/Drivers/Board/Buttons.h>
|
#include <LUFA/Drivers/Board/Buttons.h>
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||||
|
|
@ -65,7 +65,7 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
|
|
||||||
|
|
@ -81,9 +81,10 @@
|
||||||
void* ReportData,
|
void* ReportData,
|
||||||
uint16_t* const ReportSize);
|
uint16_t* const ReportSize);
|
||||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||||
const uint8_t ReportID,
|
const uint8_t ReportID,
|
||||||
const uint8_t ReportType,
|
const uint8_t ReportType,
|
||||||
const void* ReportData,
|
const void* ReportData,
|
||||||
const uint16_t ReportSize);
|
const uint16_t ReportSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Keyboard Device Demo
|
/** \mainpage Keyboard Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Human Interface Device (HID)</td>
|
* <td>Human Interface Device (HID)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Keyboard Subclass</td>
|
* <td>Keyboard Subclass</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -50,8 +50,8 @@
|
||||||
* for implementing a USB Keyboard using the basic USB HID drivers in all modern
|
* for implementing a USB Keyboard using the basic USB HID drivers in all modern
|
||||||
* OSes (i.e. no special drivers required). It is boot protocol compatible, and thus
|
* OSes (i.e. no special drivers required). It is boot protocol compatible, and thus
|
||||||
* works under compatible BIOS as if it was a native keyboard (e.g. PS/2).
|
* works under compatible BIOS as if it was a native keyboard (e.g. PS/2).
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function as a keyboard
|
* On start-up the system will automatically enumerate and function as a keyboard
|
||||||
* when the USB connection to a host is present. To use the keyboard example,
|
* when the USB connection to a host is present. To use the keyboard example,
|
||||||
* manipulate the joystick to send the letters a, b, c, d and e. See the USB HID
|
* manipulate the joystick to send the letters a, b, c, d and e. See the USB HID
|
||||||
* documentation for more information on sending keyboard event and key presses. Unlike
|
* documentation for more information on sending keyboard event and key presses. Unlike
|
||||||
|
|
@ -59,7 +59,7 @@
|
||||||
* inside the same report to the host.
|
* inside the same report to the host.
|
||||||
*
|
*
|
||||||
* \section SSec_Options Project Options
|
* \section SSec_Options Project Options
|
||||||
*
|
*
|
||||||
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
|
||||||
*
|
*
|
||||||
* <table>
|
* <table>
|
||||||
|
|
@ -70,3 +70,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -120,22 +120,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x204D,
|
.ProductID = 0x204D,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -146,49 +146,49 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 2,
|
.TotalInterfaces = 2,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID1_KeyboardInterface =
|
.HID1_KeyboardInterface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0x00,
|
.InterfaceNumber = 0x00,
|
||||||
.AlternateSetting = 0x00,
|
.AlternateSetting = 0x00,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x03,
|
.Class = 0x03,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = HID_BOOTP_KeyboardBootProtocol,
|
.Protocol = HID_BOOTP_KeyboardBootProtocol,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID1_KeyboardHID =
|
.HID1_KeyboardHID =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(01.11),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
.HIDReportLength = sizeof(KeyboardReport)
|
.HIDReportLength = sizeof(KeyboardReport)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID1_ReportINEndpoint =
|
.HID1_ReportINEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -198,34 +198,34 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.PollingIntervalMS = 0x0A
|
.PollingIntervalMS = 0x0A
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID2_MouseInterface =
|
.HID2_MouseInterface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0x01,
|
.InterfaceNumber = 0x01,
|
||||||
.AlternateSetting = 0x00,
|
.AlternateSetting = 0x00,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x03,
|
.Class = 0x03,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = HID_BOOTP_MouseBootProtocol,
|
.Protocol = HID_BOOTP_MouseBootProtocol,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID2_MouseHID =
|
.HID2_MouseHID =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(01.11),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
.HIDReportLength = sizeof(MouseReport)
|
.HIDReportLength = sizeof(MouseReport)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID2_ReportINEndpoint =
|
.HID2_ReportINEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -243,7 +243,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -254,7 +254,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -265,7 +265,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(28), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(28), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA Mouse and Keyboard Demo"
|
.UnicodeString = L"LUFA Mouse and Keyboard Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -287,33 +287,33 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
|
|
||||||
switch (DescriptorType)
|
switch (DescriptorType)
|
||||||
{
|
{
|
||||||
case DTYPE_Device:
|
case DTYPE_Device:
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_HID:
|
case HID_DTYPE_HID:
|
||||||
if (!(wIndex))
|
if (!(wIndex))
|
||||||
{
|
{
|
||||||
Address = &ConfigurationDescriptor.HID1_KeyboardHID;
|
Address = &ConfigurationDescriptor.HID1_KeyboardHID;
|
||||||
|
|
@ -322,24 +322,25 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Address = &ConfigurationDescriptor.HID2_MouseHID;
|
Address = &ConfigurationDescriptor.HID2_MouseHID;
|
||||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_Report:
|
case HID_DTYPE_Report:
|
||||||
if (!(wIndex))
|
if (!(wIndex))
|
||||||
{
|
{
|
||||||
Address = &KeyboardReport;
|
Address = &KeyboardReport;
|
||||||
Size = sizeof(KeyboardReport);
|
Size = sizeof(KeyboardReport);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Address = &MouseReport;
|
Address = &MouseReport;
|
||||||
Size = sizeof(MouseReport);
|
Size = sizeof(MouseReport);
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -57,7 +57,7 @@
|
||||||
USB_HID_Descriptor_HID_t HID2_MouseHID;
|
USB_HID_Descriptor_HID_t HID2_MouseHID;
|
||||||
USB_Descriptor_Endpoint_t HID2_ReportINEndpoint;
|
USB_Descriptor_Endpoint_t HID2_ReportINEndpoint;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint number of the Keyboard HID reporting IN endpoint. */
|
/** Endpoint number of the Keyboard HID reporting IN endpoint. */
|
||||||
#define KEYBOARD_IN_EPNUM 1
|
#define KEYBOARD_IN_EPNUM 1
|
||||||
|
|
@ -75,3 +75,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -61,7 +61,7 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
|
||||||
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
|
.PrevReportINBufferSize = sizeof(PrevKeyboardHIDReportBuffer),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/** LUFA HID Class driver interface configuration and state information. This structure is
|
/** LUFA HID Class driver interface configuration and state information. This structure is
|
||||||
* passed to all HID Class driver functions, so that multiple instances of the same class
|
* passed to all HID Class driver functions, so that multiple instances of the same class
|
||||||
* within a device can be differentiated from one another. This is for the mouse HID
|
* within a device can be differentiated from one another. This is for the mouse HID
|
||||||
|
|
@ -78,7 +78,7 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
|
||||||
|
|
||||||
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
|
.PrevReportINBuffer = PrevMouseHIDReportBuffer,
|
||||||
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
|
.PrevReportINBufferSize = sizeof(PrevMouseHIDReportBuffer),
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Main program entry point. This routine contains the overall program flow, including initial
|
/** Main program entry point. This routine contains the overall program flow, including initial
|
||||||
|
|
@ -177,11 +177,11 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
if (HIDInterfaceInfo == &Keyboard_HID_Interface)
|
if (HIDInterfaceInfo == &Keyboard_HID_Interface)
|
||||||
{
|
{
|
||||||
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
||||||
|
|
||||||
/* If first board button not being held down, no keyboard report */
|
/* If first board button not being held down, no keyboard report */
|
||||||
if (!(ButtonStatus_LCL & BUTTONS_BUTTON1))
|
if (!(ButtonStatus_LCL & BUTTONS_BUTTON1))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;
|
KeyboardReport->Modifier = HID_KEYBOARD_MODIFER_LEFTSHIFT;
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_UP)
|
if (JoyStatus_LCL & JOY_UP)
|
||||||
|
|
@ -196,7 +196,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_PRESS)
|
if (JoyStatus_LCL & JOY_PRESS)
|
||||||
KeyboardReport->KeyCode[0] = 0x08; // E
|
KeyboardReport->KeyCode[0] = 0x08; // E
|
||||||
|
|
||||||
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
|
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -207,7 +207,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
/* If first board button being held down, no mouse report */
|
/* If first board button being held down, no mouse report */
|
||||||
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_UP)
|
if (JoyStatus_LCL & JOY_UP)
|
||||||
MouseReport->Y = -1;
|
MouseReport->Y = -1;
|
||||||
else if (JoyStatus_LCL & JOY_DOWN)
|
else if (JoyStatus_LCL & JOY_DOWN)
|
||||||
|
|
@ -220,9 +220,9 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_PRESS)
|
if (JoyStatus_LCL & JOY_PRESS)
|
||||||
MouseReport->Button |= (1 << 0);
|
MouseReport->Button |= (1 << 0);
|
||||||
|
|
||||||
*ReportSize = sizeof(USB_MouseReport_Data_t);
|
*ReportSize = sizeof(USB_MouseReport_Data_t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -247,13 +247,13 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK)
|
||||||
LEDMask |= LEDS_LED1;
|
LEDMask |= LEDS_LED1;
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
|
||||||
LEDMask |= LEDS_LED3;
|
LEDMask |= LEDS_LED3;
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
|
||||||
LEDMask |= LEDS_LED4;
|
LEDMask |= LEDS_LED4;
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMask);
|
LEDs_SetAllLEDs(LEDMask);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,21 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -60,7 +60,7 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
|
|
||||||
|
|
@ -76,9 +76,10 @@
|
||||||
void* ReportData,
|
void* ReportData,
|
||||||
uint16_t* const ReportSize);
|
uint16_t* const ReportSize);
|
||||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||||
const uint8_t ReportID,
|
const uint8_t ReportID,
|
||||||
const uint8_t ReportType,
|
const uint8_t ReportType,
|
||||||
const void* ReportData,
|
const void* ReportData,
|
||||||
const uint16_t ReportSize);
|
const uint16_t ReportSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Dual HID Keyboard and Mouse Device Demo
|
/** \mainpage Dual HID Keyboard and Mouse Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Human Interface Device (HID)</td>
|
* <td>Human Interface Device (HID)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>N/A</td>
|
* <td>N/A</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Keyboard/Mouse demonstration application. This gives a simple reference
|
* Keyboard/Mouse demonstration application. This gives a simple reference
|
||||||
* application for implementing a composite device containing both USB Keyboard
|
* application for implementing a composite device containing both USB Keyboard
|
||||||
|
|
@ -52,13 +52,13 @@
|
||||||
* (i.e. no special drivers required). This example uses two separate HID
|
* (i.e. no special drivers required). This example uses two separate HID
|
||||||
* interfaces for each function. It is boot protocol compatible, and thus works under
|
* interfaces for each function. It is boot protocol compatible, and thus works under
|
||||||
* compatible BIOS as if it was a native keyboard and mouse (e.g. PS/2).
|
* compatible BIOS as if it was a native keyboard and mouse (e.g. PS/2).
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function
|
* On start-up the system will automatically enumerate and function
|
||||||
* as a keyboard when the USB connection to a host is present and the HWB is not
|
* as a keyboard when the USB connection to a host is present and the HWB is not
|
||||||
* pressed. When enabled, manipulate the joystick to send the letters
|
* pressed. When enabled, manipulate the joystick to send the letters
|
||||||
* a, b, c, d and e. See the USB HID documentation for more information
|
* a, b, c, d and e. See the USB HID documentation for more information
|
||||||
* on sending keyboard event and key presses.
|
* on sending keyboard event and key presses.
|
||||||
*
|
*
|
||||||
* When the HWB is pressed, the mouse mode is enabled. When enabled, move the
|
* When the HWB is pressed, the mouse mode is enabled. When enabled, move the
|
||||||
* joystick to move the pointer, and push the joystick inwards to simulate a
|
* joystick to move the pointer, and push the joystick inwards to simulate a
|
||||||
* left-button click.
|
* left-button click.
|
||||||
|
|
@ -75,3 +75,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,11 +30,11 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||||
|
|
@ -45,22 +45,22 @@
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x2048,
|
.ProductID = 0x2048,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
|
|
@ -80,122 +80,122 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_ControlInterface =
|
.Audio_ControlInterface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 0,
|
.TotalEndpoints = 0,
|
||||||
|
|
||||||
.Class = 0x01,
|
.Class = 0x01,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_ControlInterface_SPC =
|
.Audio_ControlInterface_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_Interface_AC_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_Header,
|
||||||
|
|
||||||
.ACSpecification = VERSION_BCD(01.00),
|
.ACSpecification = VERSION_BCD(01.00),
|
||||||
.TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t),
|
.TotalLength = sizeof(USB_Audio_Descriptor_Interface_AC_t),
|
||||||
|
|
||||||
.InCollection = 1,
|
.InCollection = 1,
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface =
|
.Audio_StreamInterface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 2,
|
.TotalEndpoints = 2,
|
||||||
|
|
||||||
.Class = 0x01,
|
.Class = 0x01,
|
||||||
.SubClass = 0x03,
|
.SubClass = 0x03,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.Audio_StreamInterface_SPC =
|
.Audio_StreamInterface_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_MIDI_Descriptor_AudioInterface_AS_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_General,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_General,
|
||||||
|
|
||||||
.AudioSpecification = VERSION_BCD(01.00),
|
.AudioSpecification = VERSION_BCD(01.00),
|
||||||
|
|
||||||
.TotalLength = (sizeof(USB_Descriptor_Configuration_t) -
|
.TotalLength = (sizeof(USB_Descriptor_Configuration_t) -
|
||||||
offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC))
|
offsetof(USB_Descriptor_Configuration_t, Audio_StreamInterface_SPC))
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_In_Jack_Emb =
|
.MIDI_In_Jack_Emb =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
||||||
|
|
||||||
.JackType = MIDI_JACKTYPE_Embedded,
|
.JackType = MIDI_JACKTYPE_Embedded,
|
||||||
.JackID = 0x01,
|
.JackID = 0x01,
|
||||||
|
|
||||||
.JackStrIndex = NO_DESCRIPTOR
|
.JackStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_In_Jack_Ext =
|
.MIDI_In_Jack_Ext =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_MIDI_Descriptor_InputJack_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_InputTerminal,
|
||||||
|
|
||||||
.JackType = MIDI_JACKTYPE_External,
|
.JackType = MIDI_JACKTYPE_External,
|
||||||
.JackID = 0x02,
|
.JackID = 0x02,
|
||||||
|
|
||||||
.JackStrIndex = NO_DESCRIPTOR
|
.JackStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_Out_Jack_Emb =
|
.MIDI_Out_Jack_Emb =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
||||||
|
|
||||||
.JackType = MIDI_JACKTYPE_Embedded,
|
.JackType = MIDI_JACKTYPE_Embedded,
|
||||||
.JackID = 0x03,
|
.JackID = 0x03,
|
||||||
|
|
||||||
.NumberOfPins = 1,
|
.NumberOfPins = 1,
|
||||||
.SourceJackID = {0x02},
|
.SourceJackID = {0x02},
|
||||||
.SourcePinID = {0x01},
|
.SourcePinID = {0x01},
|
||||||
|
|
||||||
.JackStrIndex = NO_DESCRIPTOR
|
.JackStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_Out_Jack_Ext =
|
.MIDI_Out_Jack_Ext =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_MIDI_Descriptor_OutputJack_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
.Subtype = AUDIO_DSUBTYPE_CSInterface_OutputTerminal,
|
||||||
|
|
||||||
.JackType = MIDI_JACKTYPE_External,
|
.JackType = MIDI_JACKTYPE_External,
|
||||||
.JackID = 0x04,
|
.JackID = 0x04,
|
||||||
|
|
||||||
.NumberOfPins = 1,
|
.NumberOfPins = 1,
|
||||||
.SourceJackID = {0x01},
|
.SourceJackID = {0x01},
|
||||||
.SourcePinID = {0x01},
|
.SourcePinID = {0x01},
|
||||||
|
|
||||||
.JackStrIndex = NO_DESCRIPTOR
|
.JackStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_In_Jack_Endpoint =
|
.MIDI_In_Jack_Endpoint =
|
||||||
{
|
{
|
||||||
.Endpoint =
|
.Endpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -204,12 +204,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.EndpointSize = MIDI_STREAM_EPSIZE,
|
.EndpointSize = MIDI_STREAM_EPSIZE,
|
||||||
.PollingIntervalMS = 0
|
.PollingIntervalMS = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
.Refresh = 0,
|
.Refresh = 0,
|
||||||
.SyncEndpointNumber = 0
|
.SyncEndpointNumber = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_In_Jack_Endpoint_SPC =
|
.MIDI_In_Jack_Endpoint_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
|
.Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
||||||
|
|
@ -218,9 +218,9 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.AssociatedJackID = {0x01}
|
.AssociatedJackID = {0x01}
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_Out_Jack_Endpoint =
|
.MIDI_Out_Jack_Endpoint =
|
||||||
{
|
{
|
||||||
.Endpoint =
|
.Endpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Audio_Descriptor_StreamEndpoint_Std_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -229,12 +229,12 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.EndpointSize = MIDI_STREAM_EPSIZE,
|
.EndpointSize = MIDI_STREAM_EPSIZE,
|
||||||
.PollingIntervalMS = 0
|
.PollingIntervalMS = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
.Refresh = 0,
|
.Refresh = 0,
|
||||||
.SyncEndpointNumber = 0
|
.SyncEndpointNumber = 0
|
||||||
},
|
},
|
||||||
|
|
||||||
.MIDI_Out_Jack_Endpoint_SPC =
|
.MIDI_Out_Jack_Endpoint_SPC =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
|
.Header = {.Size = sizeof(USB_MIDI_Descriptor_Jack_Endpoint_t), .Type = DTYPE_CSEndpoint},
|
||||||
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
.Subtype = AUDIO_DSUBTYPE_CSEndpoint_General,
|
||||||
|
|
@ -251,7 +251,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -262,7 +262,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -273,7 +273,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(14), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(14), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA MIDI Demo"
|
.UnicodeString = L"LUFA MIDI Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -295,34 +295,35 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
|
|
||||||
switch (DescriptorType)
|
switch (DescriptorType)
|
||||||
{
|
{
|
||||||
case DTYPE_Device:
|
case DTYPE_Device:
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
/** Endpoint size in bytes of the Audio isochronous streaming data IN and OUT endpoints. */
|
/** Endpoint size in bytes of the Audio isochronous streaming data IN and OUT endpoints. */
|
||||||
#define MIDI_STREAM_EPSIZE 64
|
#define MIDI_STREAM_EPSIZE 64
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||||
|
|
@ -73,7 +73,7 @@
|
||||||
USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint;
|
USB_Audio_Descriptor_StreamEndpoint_Std_t MIDI_Out_Jack_Endpoint;
|
||||||
USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC;
|
USB_MIDI_Descriptor_Jack_Endpoint_t MIDI_Out_Jack_Endpoint_SPC;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
const uint8_t wIndex,
|
const uint8_t wIndex,
|
||||||
|
|
@ -81,3 +81,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -65,11 +65,11 @@ int main(void)
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
CheckJoystickMovement();
|
CheckJoystickMovement();
|
||||||
|
|
||||||
MIDI_EventPacket_t ReceivedMIDIEvent;
|
MIDI_EventPacket_t ReceivedMIDIEvent;
|
||||||
if (MIDI_Device_ReceiveEventPacket(&Keyboard_MIDI_Interface, &ReceivedMIDIEvent))
|
if (MIDI_Device_ReceiveEventPacket(&Keyboard_MIDI_Interface, &ReceivedMIDIEvent))
|
||||||
{
|
{
|
||||||
|
|
@ -78,7 +78,7 @@ int main(void)
|
||||||
else
|
else
|
||||||
LEDs_SetAllLEDs(LEDS_NO_LEDS);
|
LEDs_SetAllLEDs(LEDS_NO_LEDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
MIDI_Device_USBTask(&Keyboard_MIDI_Interface);
|
MIDI_Device_USBTask(&Keyboard_MIDI_Interface);
|
||||||
USB_USBTask();
|
USB_USBTask();
|
||||||
}
|
}
|
||||||
|
|
@ -93,7 +93,7 @@ void SetupHardware(void)
|
||||||
|
|
||||||
/* Disable clock division */
|
/* Disable clock division */
|
||||||
clock_prescale_set(clock_div_1);
|
clock_prescale_set(clock_div_1);
|
||||||
|
|
||||||
/* Hardware Initialization */
|
/* Hardware Initialization */
|
||||||
Joystick_Init();
|
Joystick_Init();
|
||||||
LEDs_Init();
|
LEDs_Init();
|
||||||
|
|
@ -108,11 +108,11 @@ void CheckJoystickMovement(void)
|
||||||
|
|
||||||
uint8_t MIDICommand = 0;
|
uint8_t MIDICommand = 0;
|
||||||
uint8_t MIDIPitch;
|
uint8_t MIDIPitch;
|
||||||
|
|
||||||
/* Get current joystick mask, XOR with previous to detect joystick changes */
|
/* Get current joystick mask, XOR with previous to detect joystick changes */
|
||||||
uint8_t JoystickStatus = Joystick_GetStatus();
|
uint8_t JoystickStatus = Joystick_GetStatus();
|
||||||
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
|
uint8_t JoystickChanges = (JoystickStatus ^ PrevJoystickStatus);
|
||||||
|
|
||||||
/* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
|
/* Get board button status - if pressed use channel 10 (percussion), otherwise use channel 1 */
|
||||||
uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
uint8_t Channel = ((Buttons_GetStatus() & BUTTONS_BUTTON1) ? MIDI_CHANNEL(10) : MIDI_CHANNEL(1));
|
||||||
|
|
||||||
|
|
@ -133,7 +133,7 @@ void CheckJoystickMovement(void)
|
||||||
MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
MIDICommand = ((JoystickStatus & JOY_RIGHT)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||||
MIDIPitch = 0x3E;
|
MIDIPitch = 0x3E;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (JoystickChanges & JOY_DOWN)
|
if (JoystickChanges & JOY_DOWN)
|
||||||
{
|
{
|
||||||
MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
MIDICommand = ((JoystickStatus & JOY_DOWN)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||||
|
|
@ -145,19 +145,19 @@ void CheckJoystickMovement(void)
|
||||||
MIDICommand = ((JoystickStatus & JOY_PRESS)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
MIDICommand = ((JoystickStatus & JOY_PRESS)? MIDI_COMMAND_NOTE_ON : MIDI_COMMAND_NOTE_OFF);
|
||||||
MIDIPitch = 0x3B;
|
MIDIPitch = 0x3B;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (MIDICommand)
|
if (MIDICommand)
|
||||||
{
|
{
|
||||||
MIDI_EventPacket_t MIDIEvent = (MIDI_EventPacket_t)
|
MIDI_EventPacket_t MIDIEvent = (MIDI_EventPacket_t)
|
||||||
{
|
{
|
||||||
.CableNumber = 0,
|
.CableNumber = 0,
|
||||||
.Command = (MIDICommand >> 4),
|
.Command = (MIDICommand >> 4),
|
||||||
|
|
||||||
.Data1 = MIDICommand | Channel,
|
.Data1 = MIDICommand | Channel,
|
||||||
.Data2 = MIDIPitch,
|
.Data2 = MIDIPitch,
|
||||||
.Data3 = MIDI_STANDARD_VELOCITY,
|
.Data3 = MIDI_STANDARD_VELOCITY,
|
||||||
};
|
};
|
||||||
|
|
||||||
MIDI_Device_SendEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent);
|
MIDI_Device_SendEventPacket(&Keyboard_MIDI_Interface, &MIDIEvent);
|
||||||
MIDI_Device_Flush(&Keyboard_MIDI_Interface);
|
MIDI_Device_Flush(&Keyboard_MIDI_Interface);
|
||||||
}
|
}
|
||||||
|
|
@ -192,3 +192,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
{
|
{
|
||||||
MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface);
|
MIDI_Device_ProcessControlRequest(&Keyboard_MIDI_Interface);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for AudioOutput.c.
|
* Header file for AudioOutput.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _AUDIO_OUTPUT_H_
|
#ifndef _AUDIO_OUTPUT_H_
|
||||||
#define _AUDIO_OUTPUT_H_
|
#define _AUDIO_OUTPUT_H_
|
||||||
|
|
||||||
|
|
@ -45,7 +45,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
#include <LUFA/Version.h>
|
#include <LUFA/Version.h>
|
||||||
#include <LUFA/Drivers/Board/LEDs.h>
|
#include <LUFA/Drivers/Board/LEDs.h>
|
||||||
#include <LUFA/Drivers/Board/Joystick.h>
|
#include <LUFA/Drivers/Board/Joystick.h>
|
||||||
|
|
@ -65,14 +65,15 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
void CheckJoystickMovement(void);
|
void CheckJoystickMovement(void);
|
||||||
|
|
||||||
void EVENT_USB_Device_Connect(void);
|
void EVENT_USB_Device_Connect(void);
|
||||||
void EVENT_USB_Device_Disconnect(void);
|
void EVENT_USB_Device_Disconnect(void);
|
||||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage MIDI Input Device Demo
|
/** \mainpage MIDI Input Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Audio Class</td>
|
* <td>Audio Class</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Standard Audio Device</td>
|
* <td>Standard Audio Device</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -44,19 +44,19 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* MIDI demonstration application. This gives a simple reference
|
* MIDI demonstration application. This gives a simple reference
|
||||||
* application for implementing the USB-MIDI class in USB devices.
|
* application for implementing the USB-MIDI class in USB devices.
|
||||||
* It is built upon the USB Audio class.
|
* It is built upon the USB Audio class.
|
||||||
*
|
*
|
||||||
* Joystick movements are translated into note on/off messages and
|
* Joystick movements are translated into note on/off messages and
|
||||||
* are sent to the host PC as MIDI streams which can be read by any
|
* are sent to the host PC as MIDI streams which can be read by any
|
||||||
* MIDI program supporting MIDI IN devices.
|
* MIDI program supporting MIDI IN devices.
|
||||||
*
|
*
|
||||||
* If the HWB is not pressed, channel 1 (default piano) is used. If
|
* If the HWB is not pressed, channel 1 (default piano) is used. If
|
||||||
* the HWB is set, then channel 10 (default percussion) is selected.
|
* the HWB is set, then channel 10 (default percussion) is selected.
|
||||||
*
|
*
|
||||||
* This device implements MIDI-THRU mode, with the IN MIDI data being
|
* This device implements MIDI-THRU mode, with the IN MIDI data being
|
||||||
* generated by the device itself. OUT MIDI data is discarded.
|
* generated by the device itself. OUT MIDI data is discarded.
|
||||||
*
|
*
|
||||||
|
|
@ -72,3 +72,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -57,22 +57,22 @@
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x2045,
|
.ProductID = 0x2045,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -83,38 +83,38 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 1,
|
.TotalInterfaces = 1,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.MS_Interface =
|
.MS_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 2,
|
.TotalEndpoints = 2,
|
||||||
|
|
||||||
.Class = 0x08,
|
.Class = 0x08,
|
||||||
.SubClass = 0x06,
|
.SubClass = 0x06,
|
||||||
.Protocol = 0x50,
|
.Protocol = 0x50,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.MS_DataInEndpoint =
|
.MS_DataInEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -124,7 +124,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.MS_DataOutEndpoint =
|
.MS_DataOutEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -153,7 +153,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -164,7 +164,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA Mass Storage Demo"
|
.UnicodeString = L"LUFA Mass Storage Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -186,34 +186,35 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
|
|
||||||
switch (DescriptorType)
|
switch (DescriptorType)
|
||||||
{
|
{
|
||||||
case DTYPE_Device:
|
case DTYPE_Device:
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -44,15 +44,15 @@
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
||||||
#define MASS_STORAGE_IN_EPNUM 3
|
#define MASS_STORAGE_IN_EPNUM 3
|
||||||
|
|
||||||
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
||||||
#define MASS_STORAGE_OUT_EPNUM 4
|
#define MASS_STORAGE_OUT_EPNUM 4
|
||||||
|
|
||||||
/** Size in bytes of the Mass Storage data endpoints. */
|
/** Size in bytes of the Mass Storage data endpoints. */
|
||||||
#define MASS_STORAGE_IO_EPSIZE 64
|
#define MASS_STORAGE_IO_EPSIZE 64
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||||
* vary between devices, and which describe the device's usage to the host.
|
* vary between devices, and which describe the device's usage to the host.
|
||||||
|
|
@ -64,7 +64,7 @@
|
||||||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||||
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
const uint8_t wIndex,
|
const uint8_t wIndex,
|
||||||
|
|
@ -72,3 +72,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -77,7 +77,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -86,7 +86,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
{
|
{
|
||||||
/* Clear the current endpoint bank */
|
/* Clear the current endpoint bank */
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
|
|
||||||
/* Wait until the host has sent another packet */
|
/* Wait until the host has sent another packet */
|
||||||
if (Endpoint_WaitUntilReady())
|
if (Endpoint_WaitUntilReady())
|
||||||
return;
|
return;
|
||||||
|
|
@ -125,7 +125,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
|
|
||||||
/* Send the Dataflash buffer write command */
|
/* Send the Dataflash buffer write command */
|
||||||
Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
|
Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
|
||||||
Dataflash_SendAddressBytes(0, 0);
|
Dataflash_SendAddressBytes(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write one 16-byte chunk of data to the Dataflash */
|
/* Write one 16-byte chunk of data to the Dataflash */
|
||||||
|
|
@ -145,7 +145,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
|
|
@ -154,9 +154,9 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
|
|
||||||
/* Check if the current command is being aborted by the host */
|
/* Check if the current command is being aborted by the host */
|
||||||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
@ -201,15 +201,15 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
|
|
||||||
/* Wait until endpoint is ready before continuing */
|
/* Wait until endpoint is ready before continuing */
|
||||||
if (Endpoint_WaitUntilReady())
|
if (Endpoint_WaitUntilReady())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -218,12 +218,12 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
{
|
{
|
||||||
/* Clear the endpoint bank to send its contents to the host */
|
/* Clear the endpoint bank to send its contents to the host */
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
/* Wait until the endpoint is ready for more data */
|
/* Wait until the endpoint is ready for more data */
|
||||||
if (Endpoint_WaitUntilReady())
|
if (Endpoint_WaitUntilReady())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if end of Dataflash page reached */
|
/* Check if end of Dataflash page reached */
|
||||||
if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
|
if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +233,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
|
|
||||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||||
|
|
||||||
/* Send the Dataflash main memory page read command */
|
/* Send the Dataflash main memory page read command */
|
||||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||||
|
|
@ -241,7 +241,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read one 16-byte chunk of data from the Dataflash */
|
/* Read one 16-byte chunk of data from the Dataflash */
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
|
|
@ -260,10 +260,10 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
/* Increment the block 16 byte block counter */
|
/* Increment the block 16 byte block counter */
|
||||||
BytesInBlockDiv16++;
|
BytesInBlockDiv16++;
|
||||||
|
|
||||||
|
|
@ -271,11 +271,11 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter */
|
/* Decrement the blocks remaining counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the endpoint is full, send its contents to the host */
|
/* If the endpoint is full, send its contents to the host */
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
@ -315,11 +315,11 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
||||||
/* Send the Dataflash buffer write command */
|
/* Send the Dataflash buffer write command */
|
||||||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||||
Dataflash_SendAddressBytes(0, CurrDFPageByte);
|
Dataflash_SendAddressBytes(0, CurrDFPageByte);
|
||||||
|
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -359,18 +359,18 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
||||||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||||
Dataflash_SendAddressBytes(0, 0);
|
Dataflash_SendAddressBytes(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write one 16-byte chunk of data to the Dataflash */
|
/* Write one 16-byte chunk of data to the Dataflash */
|
||||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||||
Dataflash_SendByte(*(BufferPtr++));
|
Dataflash_SendByte(*(BufferPtr++));
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
/* Increment the block 16 byte block counter */
|
/* Increment the block 16 byte block counter */
|
||||||
BytesInBlockDiv16++;
|
BytesInBlockDiv16++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
@ -416,7 +416,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -429,7 +429,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
||||||
|
|
||||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||||
|
|
||||||
/* Send the Dataflash main memory page read command */
|
/* Send the Dataflash main memory page read command */
|
||||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||||
|
|
@ -437,19 +437,19 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read one 16-byte chunk of data from the Dataflash */
|
/* Read one 16-byte chunk of data from the Dataflash */
|
||||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||||
*(BufferPtr++) = Dataflash_ReceiveByte();
|
*(BufferPtr++) = Dataflash_ReceiveByte();
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
/* Increment the block 16 byte block counter */
|
/* Increment the block 16 byte block counter */
|
||||||
BytesInBlockDiv16++;
|
BytesInBlockDiv16++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter */
|
/* Decrement the blocks remaining counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
@ -464,7 +464,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||||
/* Select first Dataflash chip, send the read status register command */
|
/* Select first Dataflash chip, send the read status register command */
|
||||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||||
|
|
||||||
/* Check if sector protection is enabled */
|
/* Check if sector protection is enabled */
|
||||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||||
{
|
{
|
||||||
|
|
@ -476,12 +476,12 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
|
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
|
||||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Select second Dataflash chip (if present on selected board), send read status register command */
|
/* Select second Dataflash chip (if present on selected board), send read status register command */
|
||||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||||
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
||||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||||
|
|
||||||
/* Check if sector protection is enabled */
|
/* Check if sector protection is enabled */
|
||||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||||
{
|
{
|
||||||
|
|
@ -494,7 +494,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Deselect current Dataflash chip */
|
/* Deselect current Dataflash chip */
|
||||||
Dataflash_DeselectChip();
|
Dataflash_DeselectChip();
|
||||||
}
|
}
|
||||||
|
|
@ -528,6 +528,7 @@ bool DataflashManager_CheckDataflashOperation(void)
|
||||||
if (ReturnByte != DF_MANUFACTURER_ATMEL)
|
if (ReturnByte != DF_MANUFACTURER_ATMEL)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,13 +32,13 @@
|
||||||
*
|
*
|
||||||
* Header file for DataflashManager.c.
|
* Header file for DataflashManager.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DATAFLASH_MANAGER_H_
|
#ifndef _DATAFLASH_MANAGER_H_
|
||||||
#define _DATAFLASH_MANAGER_H_
|
#define _DATAFLASH_MANAGER_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#include "MassStorage.h"
|
#include "MassStorage.h"
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
|
|
@ -60,12 +60,12 @@
|
||||||
* storage media (Dataflash) using a different native block size. Do not change this value.
|
* storage media (Dataflash) using a different native block size. Do not change this value.
|
||||||
*/
|
*/
|
||||||
#define VIRTUAL_MEMORY_BLOCK_SIZE 512
|
#define VIRTUAL_MEMORY_BLOCK_SIZE 512
|
||||||
|
|
||||||
/** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not
|
/** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not
|
||||||
* change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.
|
* change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.
|
||||||
*/
|
*/
|
||||||
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
|
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||||
const uint32_t BlockAddress,
|
const uint32_t BlockAddress,
|
||||||
|
|
@ -81,5 +81,6 @@
|
||||||
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
|
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
|
||||||
void DataflashManager_ResetDataflashProtections(void);
|
void DataflashManager_ResetDataflashProtections(void);
|
||||||
bool DataflashManager_CheckDataflashOperation(void);
|
bool DataflashManager_CheckDataflashOperation(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -34,29 +34,29 @@
|
||||||
* devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information,
|
* devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information,
|
||||||
* which wrap around standard SCSI device commands for controlling the actual storage medium.
|
* which wrap around standard SCSI device commands for controlling the actual storage medium.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define INCLUDE_FROM_SCSI_C
|
#define INCLUDE_FROM_SCSI_C
|
||||||
#include "SCSI.h"
|
#include "SCSI.h"
|
||||||
|
|
||||||
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
||||||
* features and capabilities.
|
* features and capabilities.
|
||||||
*/
|
*/
|
||||||
SCSI_Inquiry_Response_t InquiryData =
|
SCSI_Inquiry_Response_t InquiryData =
|
||||||
{
|
{
|
||||||
.DeviceType = DEVICE_TYPE_BLOCK,
|
.DeviceType = DEVICE_TYPE_BLOCK,
|
||||||
.PeripheralQualifier = 0,
|
.PeripheralQualifier = 0,
|
||||||
|
|
||||||
.Removable = true,
|
.Removable = true,
|
||||||
|
|
||||||
.Version = 0,
|
.Version = 0,
|
||||||
|
|
||||||
.ResponseDataFormat = 2,
|
.ResponseDataFormat = 2,
|
||||||
.NormACA = false,
|
.NormACA = false,
|
||||||
.TrmTsk = false,
|
.TrmTsk = false,
|
||||||
.AERC = false,
|
.AERC = false,
|
||||||
|
|
||||||
.AdditionalLength = 0x1F,
|
.AdditionalLength = 0x1F,
|
||||||
|
|
||||||
.SoftReset = false,
|
.SoftReset = false,
|
||||||
.CmdQue = false,
|
.CmdQue = false,
|
||||||
.Linked = false,
|
.Linked = false,
|
||||||
|
|
@ -64,7 +64,7 @@ SCSI_Inquiry_Response_t InquiryData =
|
||||||
.WideBus16Bit = false,
|
.WideBus16Bit = false,
|
||||||
.WideBus32Bit = false,
|
.WideBus32Bit = false,
|
||||||
.RelAddr = false,
|
.RelAddr = false,
|
||||||
|
|
||||||
.VendorID = "LUFA",
|
.VendorID = "LUFA",
|
||||||
.ProductID = "Dataflash Disk",
|
.ProductID = "Dataflash Disk",
|
||||||
.RevisionID = {'0','.','0','0'},
|
.RevisionID = {'0','.','0','0'},
|
||||||
|
|
@ -96,13 +96,13 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||||
switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
|
switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
|
||||||
{
|
{
|
||||||
case SCSI_CMD_INQUIRY:
|
case SCSI_CMD_INQUIRY:
|
||||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||||
break;
|
break;
|
||||||
case SCSI_CMD_REQUEST_SENSE:
|
case SCSI_CMD_REQUEST_SENSE:
|
||||||
CommandSuccess = SCSI_Command_Request_Sense(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Request_Sense(MSInterfaceInfo);
|
||||||
break;
|
break;
|
||||||
case SCSI_CMD_READ_CAPACITY_10:
|
case SCSI_CMD_READ_CAPACITY_10:
|
||||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||||
break;
|
break;
|
||||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||||
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
||||||
|
|
@ -134,7 +134,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_GOOD,
|
SCSI_SET_SENSE(SCSI_SENSE_KEY_GOOD,
|
||||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,11 +165,11 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||||
|
|
||||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||||
|
|
||||||
/* Pad out remaining bytes with 0x00 */
|
/* Pad out remaining bytes with 0x00 */
|
||||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
|
|
||||||
/* Succeed the command and update the bytes transferred counter */
|
/* Succeed the command and update the bytes transferred counter */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +193,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||||
{
|
{
|
||||||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||||
|
|
||||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||||
|
|
||||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||||
|
|
@ -221,10 +221,10 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
/* Succeed the command and update the bytes transferred counter */
|
/* Succeed the command and update the bytes transferred counter */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,21 +248,21 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check to see if all attached Dataflash ICs are functional */
|
/* Check to see if all attached Dataflash ICs are functional */
|
||||||
if (!(DataflashManager_CheckDataflashOperation()))
|
if (!(DataflashManager_CheckDataflashOperation()))
|
||||||
{
|
{
|
||||||
/* Update SENSE key with a hardware error condition and return command fail */
|
/* Update SENSE key with a hardware error condition and return command fail */
|
||||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
||||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Succeed the command and update the bytes transferred counter */
|
/* Succeed the command and update the bytes transferred counter */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,13 +280,13 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||||
{
|
{
|
||||||
uint32_t BlockAddress;
|
uint32_t BlockAddress;
|
||||||
uint16_t TotalBlocks;
|
uint16_t TotalBlocks;
|
||||||
|
|
||||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||||
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
||||||
|
|
||||||
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */
|
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */
|
||||||
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
||||||
|
|
||||||
/* Check if the block address is outside the maximum allowable value for the LUN */
|
/* Check if the block address is outside the maximum allowable value for the LUN */
|
||||||
if (BlockAddress >= LUN_MEDIA_BLOCKS)
|
if (BlockAddress >= LUN_MEDIA_BLOCKS)
|
||||||
{
|
{
|
||||||
|
|
@ -302,7 +302,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 */
|
/* 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);
|
BlockAddress += ((uint32_t)MSInterfaceInfo->State.CommandBlock.LUN * LUN_MEDIA_BLOCKS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||||
if (IsDataRead == DATA_READ)
|
if (IsDataRead == DATA_READ)
|
||||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||||
|
|
@ -311,6 +311,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||||
|
|
||||||
/* Update the bytes transferred counter and succeed the command */
|
/* Update the bytes transferred counter and succeed the command */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for SCSI.c.
|
* Header file for SCSI.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SCSI_H_
|
#ifndef _SCSI_H_
|
||||||
#define _SCSI_H_
|
#define _SCSI_H_
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
#include "MassStorage.h"
|
#include "MassStorage.h"
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
#include "DataflashManager.h"
|
#include "DataflashManager.h"
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
||||||
* is for convenience, as it allows for all three sense values (returned upon request to the host to give information about
|
* is for convenience, as it allows for all three sense values (returned upon request to the host to give information about
|
||||||
|
|
@ -68,13 +68,13 @@
|
||||||
|
|
||||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
||||||
#define DEVICE_TYPE_BLOCK 0x00
|
#define DEVICE_TYPE_BLOCK 0x00
|
||||||
|
|
||||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
||||||
#define DEVICE_TYPE_CDROM 0x05
|
#define DEVICE_TYPE_CDROM 0x05
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||||
|
|
||||||
#if defined(INCLUDE_FROM_SCSI_C)
|
#if defined(INCLUDE_FROM_SCSI_C)
|
||||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||||
|
|
@ -83,5 +83,6 @@
|
||||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||||
const bool IsDataRead);
|
const bool IsDataRead);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -130,10 +130,11 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||||
{
|
{
|
||||||
bool CommandSuccess;
|
bool CommandSuccess;
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||||
|
|
||||||
return CommandSuccess;
|
return CommandSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -68,13 +68,13 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||||
|
|
||||||
/** Total number of logical drives within the device - must be non-zero. */
|
/** Total number of logical drives within the device - must be non-zero. */
|
||||||
#define TOTAL_LUNS 1
|
#define TOTAL_LUNS 1
|
||||||
|
|
||||||
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */
|
/** 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)
|
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
|
|
||||||
|
|
@ -86,3 +86,4 @@
|
||||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Mass Storage Device Demo
|
/** \mainpage Mass Storage Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Mass Storage Device</td>
|
* <td>Mass Storage Device</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Bulk-Only Transport</td>
|
* <td>Bulk-Only Transport</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -45,23 +45,23 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Dual LUN Mass Storage demonstration application. This gives a simple
|
* Dual LUN Mass Storage demonstration application. This gives a simple
|
||||||
* reference application for implementing a multiple LUN USB Mass Storage
|
* reference application for implementing a multiple LUN USB Mass Storage
|
||||||
* device using the basic USB UFI drivers in all modern OSes (i.e. no
|
* device using the basic USB UFI drivers in all modern OSes (i.e. no
|
||||||
* special drivers required).
|
* special drivers required).
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function as an
|
* On start-up the system will automatically enumerate and function as an
|
||||||
* external mass storage device with two LUNs (separate disks) which may
|
* external mass storage device with two LUNs (separate disks) which may
|
||||||
* be formatted and used in the same manner as commercial USB Mass Storage
|
* be formatted and used in the same manner as commercial USB Mass Storage
|
||||||
* devices.
|
* devices.
|
||||||
*
|
*
|
||||||
* You will need to format the mass storage drives upon first run of this
|
* You will need to format the mass storage drives upon first run of this
|
||||||
* demonstration - as the device acts only as a data block transport between
|
* demonstration - as the device acts only as a data block transport between
|
||||||
* the host and the storage media, it does not matter what file system is used,
|
* the host and the storage media, it does not matter what file system is used,
|
||||||
* as the data interpretation is performed by the host and not the USB device.
|
* as the data interpretation is performed by the host and not the USB device.
|
||||||
*
|
*
|
||||||
* This demo is not restricted to only two LUNs; by changing the TOTAL_LUNS
|
* This demo is not restricted to only two LUNs; by changing the TOTAL_LUNS
|
||||||
* value in MassStorageDualLUN.h, any number of LUNs can be used (from 1 to
|
* value in MassStorageDualLUN.h, any number of LUNs can be used (from 1 to
|
||||||
* 255), with each LUN being allocated an equal portion of the available
|
* 255), with each LUN being allocated an equal portion of the available
|
||||||
|
|
@ -90,3 +90,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -138,7 +138,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -151,7 +151,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -265,7 +265,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -290,7 +290,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -302,7 +302,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -359,7 +359,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -393,7 +393,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -422,7 +422,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -441,10 +441,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -509,11 +509,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -540,9 +540,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -640,14 +640,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -669,7 +669,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -713,3 +713,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
||||||
|
|
||||||
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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -31,9 +31,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -100,22 +100,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x2061,
|
.ProductID = 0x2061,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -126,38 +126,38 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 2,
|
.TotalInterfaces = 2,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.MS_Interface =
|
.MS_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 2,
|
.TotalEndpoints = 2,
|
||||||
|
|
||||||
.Class = 0x08,
|
.Class = 0x08,
|
||||||
.SubClass = 0x06,
|
.SubClass = 0x06,
|
||||||
.Protocol = 0x50,
|
.Protocol = 0x50,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.MS_DataInEndpoint =
|
.MS_DataInEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.MS_DataOutEndpoint =
|
.MS_DataOutEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -177,34 +177,34 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_KeyboardInterface =
|
.HID_KeyboardInterface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x03,
|
.Class = 0x03,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = HID_BOOTP_KeyboardBootProtocol,
|
.Protocol = HID_BOOTP_KeyboardBootProtocol,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_KeyboardHID =
|
.HID_KeyboardHID =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
.HIDSpec = VERSION_BCD(01.11),
|
.HIDSpec = VERSION_BCD(01.11),
|
||||||
.CountryCode = 0x00,
|
.CountryCode = 0x00,
|
||||||
.TotalReportDescriptors = 1,
|
.TotalReportDescriptors = 1,
|
||||||
.HIDReportType = HID_DTYPE_Report,
|
.HIDReportType = HID_DTYPE_Report,
|
||||||
.HIDReportLength = sizeof(KeyboardReport)
|
.HIDReportLength = sizeof(KeyboardReport)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_ReportINEndpoint =
|
.HID_ReportINEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -222,7 +222,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -233,7 +233,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -244,7 +244,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(35), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(35), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA Mass Storage and Keyboard Demo"
|
.UnicodeString = L"LUFA Mass Storage and Keyboard Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -266,31 +266,31 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
|
|
||||||
switch (DescriptorType)
|
switch (DescriptorType)
|
||||||
{
|
{
|
||||||
case DTYPE_Device:
|
case DTYPE_Device:
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_String:
|
case DTYPE_String:
|
||||||
switch (DescriptorNumber)
|
switch (DescriptorNumber)
|
||||||
{
|
{
|
||||||
case 0x00:
|
case 0x00:
|
||||||
Address = &LanguageString;
|
Address = &LanguageString;
|
||||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x01:
|
case 0x01:
|
||||||
Address = &ManufacturerString;
|
Address = &ManufacturerString;
|
||||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||||
break;
|
break;
|
||||||
case 0x02:
|
case 0x02:
|
||||||
Address = &ProductString;
|
Address = &ProductString;
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_HID:
|
case HID_DTYPE_HID:
|
||||||
Address = &ConfigurationDescriptor.HID_KeyboardHID;
|
Address = &ConfigurationDescriptor.HID_KeyboardHID;
|
||||||
|
|
@ -301,7 +301,8 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Size = sizeof(KeyboardReport);
|
Size = sizeof(KeyboardReport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
||||||
|
|
||||||
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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -47,20 +47,20 @@
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint number of the Keyboard HID reporting IN endpoint. */
|
/** Endpoint number of the Keyboard HID reporting IN endpoint. */
|
||||||
#define KEYBOARD_EPNUM 1
|
#define KEYBOARD_EPNUM 1
|
||||||
|
|
||||||
/** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */
|
/** Size in bytes of the Keyboard HID reporting IN and OUT endpoints. */
|
||||||
#define KEYBOARD_EPSIZE 8
|
#define KEYBOARD_EPSIZE 8
|
||||||
|
|
||||||
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
||||||
#define MASS_STORAGE_IN_EPNUM 3
|
#define MASS_STORAGE_IN_EPNUM 3
|
||||||
|
|
||||||
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
||||||
#define MASS_STORAGE_OUT_EPNUM 4
|
#define MASS_STORAGE_OUT_EPNUM 4
|
||||||
|
|
||||||
/** Size in bytes of the Mass Storage data endpoints. */
|
/** Size in bytes of the Mass Storage data endpoints. */
|
||||||
#define MASS_STORAGE_IO_EPSIZE 64
|
#define MASS_STORAGE_IO_EPSIZE 64
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||||
* vary between devices, and which describe the device's usage to the host.
|
* vary between devices, and which describe the device's usage to the host.
|
||||||
|
|
@ -75,7 +75,7 @@
|
||||||
USB_HID_Descriptor_HID_t HID_KeyboardHID;
|
USB_HID_Descriptor_HID_t HID_KeyboardHID;
|
||||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
const uint8_t wIndex,
|
const uint8_t wIndex,
|
||||||
|
|
@ -83,3 +83,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -77,7 +77,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -86,7 +86,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
{
|
{
|
||||||
/* Clear the current endpoint bank */
|
/* Clear the current endpoint bank */
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
|
|
||||||
/* Wait until the host has sent another packet */
|
/* Wait until the host has sent another packet */
|
||||||
if (Endpoint_WaitUntilReady())
|
if (Endpoint_WaitUntilReady())
|
||||||
return;
|
return;
|
||||||
|
|
@ -125,7 +125,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
|
|
||||||
/* Send the Dataflash buffer write command */
|
/* Send the Dataflash buffer write command */
|
||||||
Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
|
Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
|
||||||
Dataflash_SendAddressBytes(0, 0);
|
Dataflash_SendAddressBytes(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write one 16-byte chunk of data to the Dataflash */
|
/* Write one 16-byte chunk of data to the Dataflash */
|
||||||
|
|
@ -145,7 +145,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
|
|
@ -154,9 +154,9 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
||||||
|
|
||||||
/* Check if the current command is being aborted by the host */
|
/* Check if the current command is being aborted by the host */
|
||||||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
@ -201,15 +201,15 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
|
|
||||||
/* Wait until endpoint is ready before continuing */
|
/* Wait until endpoint is ready before continuing */
|
||||||
if (Endpoint_WaitUntilReady())
|
if (Endpoint_WaitUntilReady())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -218,12 +218,12 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
{
|
{
|
||||||
/* Clear the endpoint bank to send its contents to the host */
|
/* Clear the endpoint bank to send its contents to the host */
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
/* Wait until the endpoint is ready for more data */
|
/* Wait until the endpoint is ready for more data */
|
||||||
if (Endpoint_WaitUntilReady())
|
if (Endpoint_WaitUntilReady())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if end of Dataflash page reached */
|
/* Check if end of Dataflash page reached */
|
||||||
if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
|
if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -233,7 +233,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
|
|
||||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||||
|
|
||||||
/* Send the Dataflash main memory page read command */
|
/* Send the Dataflash main memory page read command */
|
||||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||||
|
|
@ -241,7 +241,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read one 16-byte chunk of data from the Dataflash */
|
/* Read one 16-byte chunk of data from the Dataflash */
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
|
|
@ -260,10 +260,10 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
/* Increment the block 16 byte block counter */
|
/* Increment the block 16 byte block counter */
|
||||||
BytesInBlockDiv16++;
|
BytesInBlockDiv16++;
|
||||||
|
|
||||||
|
|
@ -271,11 +271,11 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter */
|
/* Decrement the blocks remaining counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* If the endpoint is full, send its contents to the host */
|
/* If the endpoint is full, send its contents to the host */
|
||||||
if (!(Endpoint_IsReadWriteAllowed()))
|
if (!(Endpoint_IsReadWriteAllowed()))
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
@ -315,11 +315,11 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
||||||
/* Send the Dataflash buffer write command */
|
/* Send the Dataflash buffer write command */
|
||||||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||||
Dataflash_SendAddressBytes(0, CurrDFPageByte);
|
Dataflash_SendAddressBytes(0, CurrDFPageByte);
|
||||||
|
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -359,18 +359,18 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
||||||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||||
Dataflash_SendAddressBytes(0, 0);
|
Dataflash_SendAddressBytes(0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Write one 16-byte chunk of data to the Dataflash */
|
/* Write one 16-byte chunk of data to the Dataflash */
|
||||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||||
Dataflash_SendByte(*(BufferPtr++));
|
Dataflash_SendByte(*(BufferPtr++));
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
/* Increment the block 16 byte block counter */
|
/* Increment the block 16 byte block counter */
|
||||||
BytesInBlockDiv16++;
|
BytesInBlockDiv16++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
@ -416,7 +416,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
||||||
while (TotalBlocks)
|
while (TotalBlocks)
|
||||||
{
|
{
|
||||||
uint8_t BytesInBlockDiv16 = 0;
|
uint8_t BytesInBlockDiv16 = 0;
|
||||||
|
|
||||||
/* Write an endpoint packet sized data block to the Dataflash */
|
/* Write an endpoint packet sized data block to the Dataflash */
|
||||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||||
{
|
{
|
||||||
|
|
@ -429,7 +429,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
||||||
|
|
||||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||||
|
|
||||||
/* Send the Dataflash main memory page read command */
|
/* Send the Dataflash main memory page read command */
|
||||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||||
|
|
@ -437,19 +437,19 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
Dataflash_SendByte(0x00);
|
Dataflash_SendByte(0x00);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Read one 16-byte chunk of data from the Dataflash */
|
/* Read one 16-byte chunk of data from the Dataflash */
|
||||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||||
*(BufferPtr++) = Dataflash_ReceiveByte();
|
*(BufferPtr++) = Dataflash_ReceiveByte();
|
||||||
|
|
||||||
/* Increment the Dataflash page 16 byte block counter */
|
/* Increment the Dataflash page 16 byte block counter */
|
||||||
CurrDFPageByteDiv16++;
|
CurrDFPageByteDiv16++;
|
||||||
|
|
||||||
/* Increment the block 16 byte block counter */
|
/* Increment the block 16 byte block counter */
|
||||||
BytesInBlockDiv16++;
|
BytesInBlockDiv16++;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Decrement the blocks remaining counter */
|
/* Decrement the blocks remaining counter */
|
||||||
TotalBlocks--;
|
TotalBlocks--;
|
||||||
}
|
}
|
||||||
|
|
@ -464,7 +464,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||||
/* Select first Dataflash chip, send the read status register command */
|
/* Select first Dataflash chip, send the read status register command */
|
||||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||||
|
|
||||||
/* Check if sector protection is enabled */
|
/* Check if sector protection is enabled */
|
||||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||||
{
|
{
|
||||||
|
|
@ -476,12 +476,12 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
|
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
|
||||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Select second Dataflash chip (if present on selected board), send read status register command */
|
/* Select second Dataflash chip (if present on selected board), send read status register command */
|
||||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||||
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
||||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||||
|
|
||||||
/* Check if sector protection is enabled */
|
/* Check if sector protection is enabled */
|
||||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||||
{
|
{
|
||||||
|
|
@ -494,7 +494,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
||||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Deselect current Dataflash chip */
|
/* Deselect current Dataflash chip */
|
||||||
Dataflash_DeselectChip();
|
Dataflash_DeselectChip();
|
||||||
}
|
}
|
||||||
|
|
@ -528,6 +528,7 @@ bool DataflashManager_CheckDataflashOperation(void)
|
||||||
if (ReturnByte != DF_MANUFACTURER_ATMEL)
|
if (ReturnByte != DF_MANUFACTURER_ATMEL)
|
||||||
return false;
|
return false;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,13 +32,13 @@
|
||||||
*
|
*
|
||||||
* Header file for DataflashManager.c.
|
* Header file for DataflashManager.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DATAFLASH_MANAGER_H_
|
#ifndef _DATAFLASH_MANAGER_H_
|
||||||
#define _DATAFLASH_MANAGER_H_
|
#define _DATAFLASH_MANAGER_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#include "MassStorageKeyboard.h"
|
#include "MassStorageKeyboard.h"
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
|
|
@ -59,16 +59,16 @@
|
||||||
* storage media (Dataflash) using a different native block size.
|
* storage media (Dataflash) using a different native block size.
|
||||||
*/
|
*/
|
||||||
#define VIRTUAL_MEMORY_BLOCK_SIZE 512
|
#define VIRTUAL_MEMORY_BLOCK_SIZE 512
|
||||||
|
|
||||||
/** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. */
|
/** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. */
|
||||||
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
|
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
|
||||||
|
|
||||||
/** Total number of logical drives within the device - must be non-zero. */
|
/** Total number of logical drives within the device - must be non-zero. */
|
||||||
#define TOTAL_LUNS 1
|
#define TOTAL_LUNS 1
|
||||||
|
|
||||||
/** Blocks in each LUN, calculated from the total capacity divided by the total number of Logical Units in the device. */
|
/** 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)
|
#define LUN_MEDIA_BLOCKS (VIRTUAL_MEMORY_BLOCKS / TOTAL_LUNS)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||||
const uint32_t BlockAddress,
|
const uint32_t BlockAddress,
|
||||||
|
|
@ -84,5 +84,6 @@
|
||||||
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
|
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
|
||||||
void DataflashManager_ResetDataflashProtections(void);
|
void DataflashManager_ResetDataflashProtections(void);
|
||||||
bool DataflashManager_CheckDataflashOperation(void);
|
bool DataflashManager_CheckDataflashOperation(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -34,29 +34,29 @@
|
||||||
* devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information,
|
* devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information,
|
||||||
* which wrap around standard SCSI device commands for controlling the actual storage medium.
|
* which wrap around standard SCSI device commands for controlling the actual storage medium.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define INCLUDE_FROM_SCSI_C
|
#define INCLUDE_FROM_SCSI_C
|
||||||
#include "SCSI.h"
|
#include "SCSI.h"
|
||||||
|
|
||||||
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
||||||
* features and capabilities.
|
* features and capabilities.
|
||||||
*/
|
*/
|
||||||
SCSI_Inquiry_Response_t InquiryData =
|
SCSI_Inquiry_Response_t InquiryData =
|
||||||
{
|
{
|
||||||
.DeviceType = DEVICE_TYPE_BLOCK,
|
.DeviceType = DEVICE_TYPE_BLOCK,
|
||||||
.PeripheralQualifier = 0,
|
.PeripheralQualifier = 0,
|
||||||
|
|
||||||
.Removable = true,
|
.Removable = true,
|
||||||
|
|
||||||
.Version = 0,
|
.Version = 0,
|
||||||
|
|
||||||
.ResponseDataFormat = 2,
|
.ResponseDataFormat = 2,
|
||||||
.NormACA = false,
|
.NormACA = false,
|
||||||
.TrmTsk = false,
|
.TrmTsk = false,
|
||||||
.AERC = false,
|
.AERC = false,
|
||||||
|
|
||||||
.AdditionalLength = 0x1F,
|
.AdditionalLength = 0x1F,
|
||||||
|
|
||||||
.SoftReset = false,
|
.SoftReset = false,
|
||||||
.CmdQue = false,
|
.CmdQue = false,
|
||||||
.Linked = false,
|
.Linked = false,
|
||||||
|
|
@ -64,7 +64,7 @@ SCSI_Inquiry_Response_t InquiryData =
|
||||||
.WideBus16Bit = false,
|
.WideBus16Bit = false,
|
||||||
.WideBus32Bit = false,
|
.WideBus32Bit = false,
|
||||||
.RelAddr = false,
|
.RelAddr = false,
|
||||||
|
|
||||||
.VendorID = "LUFA",
|
.VendorID = "LUFA",
|
||||||
.ProductID = "Dataflash Disk",
|
.ProductID = "Dataflash Disk",
|
||||||
.RevisionID = {'0','.','0','0'},
|
.RevisionID = {'0','.','0','0'},
|
||||||
|
|
@ -96,13 +96,13 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||||
switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
|
switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
|
||||||
{
|
{
|
||||||
case SCSI_CMD_INQUIRY:
|
case SCSI_CMD_INQUIRY:
|
||||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||||
break;
|
break;
|
||||||
case SCSI_CMD_REQUEST_SENSE:
|
case SCSI_CMD_REQUEST_SENSE:
|
||||||
CommandSuccess = SCSI_Command_Request_Sense(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Request_Sense(MSInterfaceInfo);
|
||||||
break;
|
break;
|
||||||
case SCSI_CMD_READ_CAPACITY_10:
|
case SCSI_CMD_READ_CAPACITY_10:
|
||||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||||
break;
|
break;
|
||||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||||
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
||||||
|
|
@ -134,7 +134,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_GOOD,
|
SCSI_SET_SENSE(SCSI_SENSE_KEY_GOOD,
|
||||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -165,11 +165,11 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||||
|
|
||||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||||
|
|
||||||
/* Pad out remaining bytes with 0x00 */
|
/* Pad out remaining bytes with 0x00 */
|
||||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
||||||
|
|
||||||
/* Succeed the command and update the bytes transferred counter */
|
/* Succeed the command and update the bytes transferred counter */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -193,7 +193,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
||||||
{
|
{
|
||||||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||||
|
|
||||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||||
|
|
||||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||||
|
|
@ -221,10 +221,10 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
||||||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
|
|
||||||
/* Succeed the command and update the bytes transferred counter */
|
/* Succeed the command and update the bytes transferred counter */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -248,21 +248,21 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check to see if all attached Dataflash ICs are functional */
|
/* Check to see if all attached Dataflash ICs are functional */
|
||||||
if (!(DataflashManager_CheckDataflashOperation()))
|
if (!(DataflashManager_CheckDataflashOperation()))
|
||||||
{
|
{
|
||||||
/* Update SENSE key with a hardware error condition and return command fail */
|
/* Update SENSE key with a hardware error condition and return command fail */
|
||||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
||||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Succeed the command and update the bytes transferred counter */
|
/* Succeed the command and update the bytes transferred counter */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -280,13 +280,13 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||||
{
|
{
|
||||||
uint32_t BlockAddress;
|
uint32_t BlockAddress;
|
||||||
uint16_t TotalBlocks;
|
uint16_t TotalBlocks;
|
||||||
|
|
||||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||||
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
||||||
|
|
||||||
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */
|
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */
|
||||||
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
||||||
|
|
||||||
/* Check if the block address is outside the maximum allowable value for the LUN */
|
/* Check if the block address is outside the maximum allowable value for the LUN */
|
||||||
if (BlockAddress >= LUN_MEDIA_BLOCKS)
|
if (BlockAddress >= LUN_MEDIA_BLOCKS)
|
||||||
{
|
{
|
||||||
|
|
@ -302,7 +302,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 */
|
/* 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);
|
BlockAddress += ((uint32_t)MSInterfaceInfo->State.CommandBlock.LUN * LUN_MEDIA_BLOCKS);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||||
if (IsDataRead == DATA_READ)
|
if (IsDataRead == DATA_READ)
|
||||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||||
|
|
@ -311,6 +311,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
||||||
|
|
||||||
/* Update the bytes transferred counter and succeed the command */
|
/* Update the bytes transferred counter and succeed the command */
|
||||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for SCSI.c.
|
* Header file for SCSI.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _SCSI_H_
|
#ifndef _SCSI_H_
|
||||||
#define _SCSI_H_
|
#define _SCSI_H_
|
||||||
|
|
||||||
|
|
@ -46,7 +46,7 @@
|
||||||
#include "MassStorageKeyboard.h"
|
#include "MassStorageKeyboard.h"
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
#include "DataflashManager.h"
|
#include "DataflashManager.h"
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
||||||
* is for convenience, as it allows for all three sense values (returned upon request to the host to give information about
|
* is for convenience, as it allows for all three sense values (returned upon request to the host to give information about
|
||||||
|
|
@ -68,13 +68,13 @@
|
||||||
|
|
||||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
||||||
#define DEVICE_TYPE_BLOCK 0x00
|
#define DEVICE_TYPE_BLOCK 0x00
|
||||||
|
|
||||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
||||||
#define DEVICE_TYPE_CDROM 0x05
|
#define DEVICE_TYPE_CDROM 0x05
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||||
|
|
||||||
#if defined(INCLUDE_FROM_SCSI_C)
|
#if defined(INCLUDE_FROM_SCSI_C)
|
||||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||||
|
|
@ -83,5 +83,6 @@
|
||||||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||||
const bool IsDataRead);
|
const bool IsDataRead);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
||||||
|
|
||||||
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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -36,7 +36,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "MassStorageKeyboard.h"
|
#include "MassStorageKeyboard.h"
|
||||||
|
|
||||||
/** LUFA Mass Storage Class driver interface configuration and state information. This structure is
|
/** 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
|
* 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.
|
* within a device can be differentiated from one another.
|
||||||
|
|
@ -160,11 +160,11 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||||
{
|
{
|
||||||
bool CommandSuccess;
|
bool CommandSuccess;
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||||
|
|
||||||
return CommandSuccess;
|
return CommandSuccess;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -191,7 +191,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
uint16_t* const ReportSize)
|
uint16_t* const ReportSize)
|
||||||
{
|
{
|
||||||
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
USB_KeyboardReport_Data_t* KeyboardReport = (USB_KeyboardReport_Data_t*)ReportData;
|
||||||
|
|
||||||
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
||||||
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
||||||
|
|
||||||
|
|
@ -209,10 +209,10 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_PRESS)
|
if (JoyStatus_LCL & JOY_PRESS)
|
||||||
KeyboardReport->KeyCode[0] = 0x08; // E
|
KeyboardReport->KeyCode[0] = 0x08; // E
|
||||||
|
|
||||||
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
||||||
KeyboardReport->KeyCode[0] = 0x09; // F
|
KeyboardReport->KeyCode[0] = 0x09; // F
|
||||||
|
|
||||||
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
|
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
@ -236,13 +236,13 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_NUMLOCK)
|
||||||
LEDMask |= LEDS_LED1;
|
LEDMask |= LEDS_LED1;
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_CAPSLOCK)
|
||||||
LEDMask |= LEDS_LED3;
|
LEDMask |= LEDS_LED3;
|
||||||
|
|
||||||
if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
|
if (*LEDReport & HID_KEYBOARD_LED_SCROLLLOCK)
|
||||||
LEDMask |= LEDS_LED4;
|
LEDMask |= LEDS_LED4;
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMask);
|
LEDs_SetAllLEDs(LEDMask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -10,13 +10,13 @@
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||||
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
Copyright 2010 Matthias Hullin (lufa [at] matthias [dot] hullin [dot] net)
|
||||||
|
|
||||||
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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -58,7 +58,7 @@
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
#include <LUFA/Drivers/USB/Class/MassStorage.h>
|
#include <LUFA/Drivers/USB/Class/MassStorage.h>
|
||||||
#include <LUFA/Drivers/USB/Class/Device/HID.h>
|
#include <LUFA/Drivers/USB/Class/Device/HID.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||||
|
|
@ -74,7 +74,7 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
|
|
||||||
|
|
@ -92,9 +92,10 @@
|
||||||
void* ReportData,
|
void* ReportData,
|
||||||
uint16_t* const ReportSize);
|
uint16_t* const ReportSize);
|
||||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||||
const uint8_t ReportID,
|
const uint8_t ReportID,
|
||||||
const uint8_t ReportType,
|
const uint8_t ReportType,
|
||||||
const void* ReportData,
|
const void* ReportData,
|
||||||
const uint16_t ReportSize);
|
const uint16_t ReportSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Combined Mass Storage and Keyboard Device Demo
|
/** \mainpage Combined Mass Storage and Keyboard Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -29,7 +29,7 @@
|
||||||
* <td>Mass Storage Device \n
|
* <td>Mass Storage Device \n
|
||||||
* Human Interface Device</td>
|
* Human Interface Device</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclasses:</b></td>
|
* <td><b>USB Subclasses:</b></td>
|
||||||
* <td>Bulk-Only Transport \n
|
* <td>Bulk-Only Transport \n
|
||||||
* Keyboard Subclass</td>
|
* Keyboard Subclass</td>
|
||||||
|
|
@ -49,24 +49,24 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Combined Mass Storage and Keyboard demonstration application. This gives a
|
* Combined Mass Storage and Keyboard demonstration application. This gives a
|
||||||
* simple reference application for implementing a dual class USB Mass Storage
|
* simple reference application for implementing a dual class USB Mass Storage
|
||||||
* and USB HID Keyboard device using the basic USB UFI and HID drivers in all
|
* and USB HID Keyboard device using the basic USB UFI and HID drivers in all
|
||||||
* modern OSes (i.e. no special drivers required).
|
* modern OSes (i.e. no special drivers required).
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function as an
|
* On start-up the system will automatically enumerate and function as an
|
||||||
* external mass storage device (which may be formatted and used in the same
|
* external mass storage device (which may be formatted and used in the same
|
||||||
* manner as commercial USB Mass Storage devices) and a USB keyboard.
|
* manner as commercial USB Mass Storage devices) and a USB keyboard.
|
||||||
*
|
*
|
||||||
* You will need to format the mass storage drive upon first run of this
|
* You will need to format the mass storage drive upon first run of this
|
||||||
* demonstration - as the device acts only as a data block transport between
|
* demonstration - as the device acts only as a data block transport between
|
||||||
* the host and the storage media, it does not matter what file system is used,
|
* the host and the storage media, it does not matter what file system is used,
|
||||||
* as the data interpretation is performed by the host and not the USB device.
|
* as the data interpretation is performed by the host and not the USB device.
|
||||||
*
|
*
|
||||||
* Keys on the USB keyboard can be pressed by moving the board's Joystick.
|
* Keys on the USB keyboard can be pressed by moving the board's Joystick.
|
||||||
*
|
*
|
||||||
* The USB control endpoint is managed entirely by the library using endpoint
|
* The USB control endpoint is managed entirely by the library using endpoint
|
||||||
* interrupts, as the INTERRUPT_CONTROL_ENDPOINT option is enabled. This allows for
|
* interrupts, as the INTERRUPT_CONTROL_ENDPOINT option is enabled. This allows for
|
||||||
* the host to reset the Mass Storage device state during long transfers without
|
* the host to reset the Mass Storage device state during long transfers without
|
||||||
|
|
@ -90,3 +90,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -138,7 +138,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -151,7 +151,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -265,7 +265,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -278,7 +278,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -290,7 +290,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -302,7 +302,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -325,7 +325,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -359,7 +359,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -393,7 +393,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -422,7 +422,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -441,10 +441,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -509,11 +509,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -540,9 +540,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -640,14 +640,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -669,7 +669,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -713,3 +713,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,9 +30,9 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
@ -81,22 +81,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM MouseReport[] =
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x00,
|
.Class = 0x00,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x2041,
|
.ProductID = 0x2041,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -107,38 +107,38 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 1,
|
.TotalInterfaces = 1,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_Interface =
|
.HID_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0x00,
|
.InterfaceNumber = 0x00,
|
||||||
.AlternateSetting = 0x00,
|
.AlternateSetting = 0x00,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x03,
|
.Class = 0x03,
|
||||||
.SubClass = 0x01,
|
.SubClass = 0x01,
|
||||||
.Protocol = HID_BOOTP_MouseBootProtocol,
|
.Protocol = HID_BOOTP_MouseBootProtocol,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_MouseHID =
|
.HID_MouseHID =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||||
|
|
||||||
|
|
@ -149,7 +149,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.HIDReportLength = sizeof(MouseReport)
|
.HIDReportLength = sizeof(MouseReport)
|
||||||
},
|
},
|
||||||
|
|
||||||
.HID_ReportINEndpoint =
|
.HID_ReportINEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
|
|
@ -167,7 +167,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -178,7 +178,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -189,7 +189,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(15), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(15), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA Mouse Demo"
|
.UnicodeString = L"LUFA Mouse Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -235,19 +235,19 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_HID:
|
case HID_DTYPE_HID:
|
||||||
Address = &ConfigurationDescriptor.HID_MouseHID;
|
Address = &ConfigurationDescriptor.HID_MouseHID;
|
||||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||||
break;
|
break;
|
||||||
case HID_DTYPE_Report:
|
case HID_DTYPE_Report:
|
||||||
Address = &MouseReport;
|
Address = &MouseReport;
|
||||||
Size = sizeof(MouseReport);
|
Size = sizeof(MouseReport);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,7 +32,7 @@
|
||||||
*
|
*
|
||||||
* Header file for Descriptors.c.
|
* Header file for Descriptors.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DESCRIPTORS_H_
|
#ifndef _DESCRIPTORS_H_
|
||||||
#define _DESCRIPTORS_H_
|
#define _DESCRIPTORS_H_
|
||||||
|
|
||||||
|
|
@ -54,11 +54,11 @@
|
||||||
USB_HID_Descriptor_HID_t HID_MouseHID;
|
USB_HID_Descriptor_HID_t HID_MouseHID;
|
||||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
||||||
} USB_Descriptor_Configuration_t;
|
} USB_Descriptor_Configuration_t;
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Endpoint number of the Mouse HID reporting IN endpoint. */
|
/** Endpoint number of the Mouse HID reporting IN endpoint. */
|
||||||
#define MOUSE_EPNUM 1
|
#define MOUSE_EPNUM 1
|
||||||
|
|
||||||
/** Size in bytes of the Mouse HID reporting IN endpoint. */
|
/** Size in bytes of the Mouse HID reporting IN endpoint. */
|
||||||
#define MOUSE_EPSIZE 8
|
#define MOUSE_EPSIZE 8
|
||||||
|
|
||||||
|
|
@ -69,3 +69,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -62,9 +62,9 @@ USB_ClassInfo_HID_Device_t Mouse_HID_Interface =
|
||||||
* setup of all components and the main program loop.
|
* setup of all components and the main program loop.
|
||||||
*/
|
*/
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
SetupHardware();
|
SetupHardware();
|
||||||
|
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||||
sei();
|
sei();
|
||||||
|
|
||||||
|
|
@ -145,7 +145,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
uint16_t* const ReportSize)
|
uint16_t* const ReportSize)
|
||||||
{
|
{
|
||||||
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;
|
USB_MouseReport_Data_t* MouseReport = (USB_MouseReport_Data_t*)ReportData;
|
||||||
|
|
||||||
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
uint8_t JoyStatus_LCL = Joystick_GetStatus();
|
||||||
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
uint8_t ButtonStatus_LCL = Buttons_GetStatus();
|
||||||
|
|
||||||
|
|
@ -161,10 +161,10 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
||||||
|
|
||||||
if (JoyStatus_LCL & JOY_PRESS)
|
if (JoyStatus_LCL & JOY_PRESS)
|
||||||
MouseReport->Button |= (1 << 0);
|
MouseReport->Button |= (1 << 0);
|
||||||
|
|
||||||
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
if (ButtonStatus_LCL & BUTTONS_BUTTON1)
|
||||||
MouseReport->Button |= (1 << 1);
|
MouseReport->Button |= (1 << 1);
|
||||||
|
|
||||||
*ReportSize = sizeof(USB_MouseReport_Data_t);
|
*ReportSize = sizeof(USB_MouseReport_Data_t);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -185,3 +185,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
||||||
{
|
{
|
||||||
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -44,7 +44,7 @@
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "Descriptors.h"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
#include <LUFA/Version.h>
|
#include <LUFA/Version.h>
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
#include <LUFA/Drivers/Board/Buttons.h>
|
#include <LUFA/Drivers/Board/Buttons.h>
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
/** LED mask for the library LED driver, to indicate that the USB interface is not ready. */
|
||||||
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
#define LEDMASK_USB_NOTREADY LEDS_LED1
|
||||||
|
|
@ -66,7 +66,7 @@
|
||||||
|
|
||||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
/** 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)
|
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void SetupHardware(void);
|
void SetupHardware(void);
|
||||||
|
|
||||||
|
|
@ -82,9 +82,10 @@
|
||||||
void* ReportData,
|
void* ReportData,
|
||||||
uint16_t* const ReportSize);
|
uint16_t* const ReportSize);
|
||||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||||
const uint8_t ReportID,
|
const uint8_t ReportID,
|
||||||
const uint8_t ReportType,
|
const uint8_t ReportType,
|
||||||
const void* ReportData,
|
const void* ReportData,
|
||||||
const uint16_t ReportSize);
|
const uint16_t ReportSize);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
* This file contains special DoxyGen information for the generation of the main page and other special
|
* This file contains special DoxyGen information for the generation of the main page and other special
|
||||||
* documentation pages. It is not a project source file.
|
* documentation pages. It is not a project source file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/** \mainpage Mouse Device Demo
|
/** \mainpage Mouse Device Demo
|
||||||
*
|
*
|
||||||
* \section SSec_Compat Demo Compatibility:
|
* \section SSec_Compat Demo Compatibility:
|
||||||
|
|
@ -28,7 +28,7 @@
|
||||||
* <td><b>USB Class:</b></td>
|
* <td><b>USB Class:</b></td>
|
||||||
* <td>Human Interface Device (HID)</td>
|
* <td>Human Interface Device (HID)</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td><b>USB Subclass:</b></td>
|
* <td><b>USB Subclass:</b></td>
|
||||||
* <td>Mouse Subclass</td>
|
* <td>Mouse Subclass</td>
|
||||||
* </tr>
|
* </tr>
|
||||||
|
|
@ -44,14 +44,14 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*
|
*
|
||||||
* \section SSec_Description Project Description:
|
* \section SSec_Description Project Description:
|
||||||
*
|
*
|
||||||
* Mouse demonstration application. This gives a simple reference
|
* Mouse demonstration application. This gives a simple reference
|
||||||
* application for implementing a USB Mouse using the basic USB HID
|
* application for implementing a USB Mouse using the basic USB HID
|
||||||
* drivers in all modern OSes (i.e. no special drivers required). It is
|
* drivers in all modern OSes (i.e. no special drivers required). It is
|
||||||
* boot protocol compatible, and thus works under compatible BIOS as if
|
* boot protocol compatible, and thus works under compatible BIOS as if
|
||||||
* it was a native mouse (e.g. PS/2).
|
* it was a native mouse (e.g. PS/2).
|
||||||
*
|
*
|
||||||
* On start-up the system will automatically enumerate and function
|
* On start-up the system will automatically enumerate and function
|
||||||
* as a mouse when the USB connection to a host is present. To use
|
* as a mouse when the USB connection to a host is present. To use
|
||||||
* the mouse, move the joystick to move the pointer, and push the
|
* the mouse, move the joystick to move the pointer, and push the
|
||||||
|
|
@ -70,3 +70,4 @@
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -47,7 +47,7 @@
|
||||||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||||
# DoxyGen installed)
|
# DoxyGen installed)
|
||||||
#
|
#
|
||||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||||
# with avr-gdb or avr-insight as the front end 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.s = Just compile filename.c into the assembler code only.
|
||||||
|
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
||||||
|
|
||||||
|
|
||||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
# 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
|
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||||
# "Board" inside the application directory.
|
# "Board" inside the application directory.
|
||||||
BOARD = USBKEY
|
BOARD = USBKEY
|
||||||
|
|
||||||
|
|
||||||
# Processor frequency.
|
# Processor frequency.
|
||||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
# 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
|
# 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
|
# 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.
|
# automatically to create a 32-bit value in your source code.
|
||||||
#
|
#
|
||||||
|
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
||||||
|
|
||||||
|
|
||||||
# Input clock frequency.
|
# Input clock frequency.
|
||||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
# 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
|
# 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
|
# 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
|
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||||
|
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
||||||
|
|
||||||
|
|
||||||
# List C++ source files here. (C dependencies are automatically generated.)
|
# List C++ source files here. (C dependencies are automatically generated.)
|
||||||
CPPSRC =
|
CPPSRC =
|
||||||
|
|
||||||
|
|
||||||
# List Assembler source files here.
|
# List Assembler source files here.
|
||||||
|
|
@ -148,7 +148,7 @@ CPPSRC =
|
||||||
ASRC =
|
ASRC =
|
||||||
|
|
||||||
|
|
||||||
# Optimization level, can be [0, 1, 2, 3, s].
|
# Optimization level, can be [0, 1, 2, 3, s].
|
||||||
# 0 = turn off optimization. s = optimize for size.
|
# 0 = turn off optimization. s = optimize for size.
|
||||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||||
OPT = s
|
OPT = s
|
||||||
|
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
||||||
# for use in COFF files, additional information about filenames
|
# for use in COFF files, additional information about filenames
|
||||||
# and function names needs to be present in the assembler source
|
# and function names needs to be present in the assembler source
|
||||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
# -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.
|
# 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
|
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||||
|
|
||||||
|
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
||||||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard printf version.
|
# If this is left blank, then it will use the Standard printf version.
|
||||||
PRINTF_LIB =
|
PRINTF_LIB =
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
||||||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||||
|
|
||||||
# If this is left blank, then it will use the Standard scanf version.
|
# If this is left blank, then it will use the Standard scanf version.
|
||||||
SCANF_LIB =
|
SCANF_LIB =
|
||||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||||
|
|
||||||
|
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
||||||
# Each directory must be seperated by a space.
|
# Each directory must be seperated by a space.
|
||||||
# Use forward slashes for directory separators.
|
# Use forward slashes for directory separators.
|
||||||
# For a directory that has spaces, enclose it in quotes.
|
# For a directory that has spaces, enclose it in quotes.
|
||||||
EXTRALIBDIRS =
|
EXTRALIBDIRS =
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
||||||
# -Map: create map file
|
# -Map: create map file
|
||||||
# --cref: add cross reference to map file
|
# --cref: add cross reference to map file
|
||||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||||
LDFLAGS += -Wl,--relax
|
LDFLAGS += -Wl,--relax
|
||||||
LDFLAGS += -Wl,--gc-sections
|
LDFLAGS += -Wl,--gc-sections
|
||||||
LDFLAGS += $(EXTMEMOPTS)
|
LDFLAGS += $(EXTMEMOPTS)
|
||||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||||
|
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
||||||
#AVRDUDE_NO_VERIFY = -V
|
#AVRDUDE_NO_VERIFY = -V
|
||||||
|
|
||||||
# Increase verbosity level. Please use this when submitting bug
|
# Increase verbosity level. Please use this when submitting bug
|
||||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||||
# to submit bug reports.
|
# to submit bug reports.
|
||||||
#AVRDUDE_VERBOSE = -v -v
|
#AVRDUDE_VERBOSE = -v -v
|
||||||
|
|
||||||
|
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
||||||
DEBUG_PORT = 4242
|
DEBUG_PORT = 4242
|
||||||
|
|
||||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||||
# just set to localhost unless doing some sort of crazy debugging when
|
# just set to localhost unless doing some sort of crazy debugging when
|
||||||
# avarice is running on a different computer.
|
# avarice is running on a different computer.
|
||||||
DEBUG_HOST = localhost
|
DEBUG_HOST = localhost
|
||||||
|
|
||||||
|
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
||||||
MSG_ERRORS_NONE = Errors: none
|
MSG_ERRORS_NONE = Errors: none
|
||||||
MSG_BEGIN = -------- begin --------
|
MSG_BEGIN = -------- begin --------
|
||||||
MSG_END = -------- end --------
|
MSG_END = -------- end --------
|
||||||
MSG_SIZE_BEFORE = Size before:
|
MSG_SIZE_BEFORE = Size before:
|
||||||
MSG_SIZE_AFTER = Size after:
|
MSG_SIZE_AFTER = Size after:
|
||||||
MSG_COFF = Converting to AVR COFF:
|
MSG_COFF = Converting to AVR COFF:
|
||||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||||
|
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
||||||
|
|
||||||
|
|
||||||
# Define all object files.
|
# Define all object files.
|
||||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||||
|
|
||||||
# Define all listing files.
|
# Define all listing files.
|
||||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||||
|
|
||||||
|
|
||||||
# Compiler flags to generate dependency files.
|
# Compiler flags to generate dependency files.
|
||||||
|
|
@ -506,11 +506,11 @@ sizeafter:
|
||||||
|
|
||||||
|
|
||||||
# Display compiler version information.
|
# Display compiler version information.
|
||||||
gccversion :
|
gccversion :
|
||||||
@$(CC) --version
|
@$(CC) --version
|
||||||
|
|
||||||
|
|
||||||
# Program the device.
|
# Program the device.
|
||||||
program: $(TARGET).hex $(TARGET).eep
|
program: $(TARGET).hex $(TARGET).eep
|
||||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||||
|
|
||||||
|
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
||||||
|
|
||||||
|
|
||||||
# Generate avr-gdb config/init file which does the following:
|
# Generate avr-gdb config/init file which does the following:
|
||||||
# define the reset signal, load the target file, connect to target, and set
|
# define the reset signal, load the target file, connect to target, and set
|
||||||
# a breakpoint at main().
|
# a breakpoint at main().
|
||||||
gdb-config:
|
gdb-config:
|
||||||
@$(REMOVE) $(GDBINIT_FILE)
|
@$(REMOVE) $(GDBINIT_FILE)
|
||||||
@echo define reset >> $(GDBINIT_FILE)
|
@echo define reset >> $(GDBINIT_FILE)
|
||||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||||
|
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
||||||
$(OBJDIR)/%.o : %.c
|
$(OBJDIR)/%.o : %.c
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING) $<
|
@echo $(MSG_COMPILING) $<
|
||||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create object files from C++ source files.
|
# Compile: create object files from C++ source files.
|
||||||
$(OBJDIR)/%.o : %.cpp
|
$(OBJDIR)/%.o : %.cpp
|
||||||
@echo
|
@echo
|
||||||
@echo $(MSG_COMPILING_CPP) $<
|
@echo $(MSG_COMPILING_CPP) $<
|
||||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Compile: create assembler files from C source files.
|
# Compile: create assembler files from C source files.
|
||||||
|
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
||||||
|
|
||||||
# Create preprocessed source for use in sending a bug report.
|
# Create preprocessed source for use in sending a bug report.
|
||||||
%.i : %.c
|
%.i : %.c
|
||||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||||
|
|
||||||
|
|
||||||
# Target: clean project.
|
# Target: clean project.
|
||||||
|
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
||||||
build elf hex eep lss sym coff extcoff doxygen clean \
|
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||||
debug gdb-config
|
debug gdb-config
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -30,11 +30,11 @@
|
||||||
|
|
||||||
/** \file
|
/** \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
|
* 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"
|
#include "Descriptors.h"
|
||||||
|
|
||||||
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
/** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall
|
||||||
|
|
@ -45,22 +45,22 @@
|
||||||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||||
|
|
||||||
.USBSpecification = VERSION_BCD(01.10),
|
.USBSpecification = VERSION_BCD(01.10),
|
||||||
.Class = 0x02,
|
.Class = 0x02,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||||
|
|
||||||
.VendorID = 0x03EB,
|
.VendorID = 0x03EB,
|
||||||
.ProductID = 0x204C,
|
.ProductID = 0x204C,
|
||||||
.ReleaseNumber = VERSION_BCD(00.01),
|
.ReleaseNumber = VERSION_BCD(00.01),
|
||||||
|
|
||||||
.ManufacturerStrIndex = 0x01,
|
.ManufacturerStrIndex = 0x01,
|
||||||
.ProductStrIndex = 0x02,
|
.ProductStrIndex = 0x02,
|
||||||
.SerialNumStrIndex = NO_DESCRIPTOR,
|
.SerialNumStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -71,102 +71,102 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
{
|
{
|
||||||
.Config =
|
.Config =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||||
|
|
||||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||||
.TotalInterfaces = 2,
|
.TotalInterfaces = 2,
|
||||||
|
|
||||||
.ConfigurationNumber = 1,
|
.ConfigurationNumber = 1,
|
||||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||||
|
|
||||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||||
|
|
||||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_CCI_Interface =
|
.CDC_CCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 0,
|
.InterfaceNumber = 0,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 1,
|
.TotalEndpoints = 1,
|
||||||
|
|
||||||
.Class = 0x02,
|
.Class = 0x02,
|
||||||
.SubClass = 0x02,
|
.SubClass = 0x02,
|
||||||
.Protocol = 0xFF,
|
.Protocol = 0xFF,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_Functional_Header =
|
.CDC_Functional_Header =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
||||||
|
|
||||||
.CDCSpecification = VERSION_BCD(01.10),
|
.CDCSpecification = VERSION_BCD(01.10),
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_Functional_ACM =
|
.CDC_Functional_ACM =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
||||||
|
|
||||||
.Capabilities = 0x00,
|
.Capabilities = 0x00,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_Functional_Union =
|
.CDC_Functional_Union =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
||||||
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
||||||
|
|
||||||
.MasterInterfaceNumber = 0,
|
.MasterInterfaceNumber = 0,
|
||||||
.SlaveInterfaceNumber = 1,
|
.SlaveInterfaceNumber = 1,
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_NotificationEndpoint =
|
.CDC_NotificationEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
||||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||||
.PollingIntervalMS = 0x02
|
.PollingIntervalMS = 0x02
|
||||||
},
|
},
|
||||||
|
|
||||||
.CDC_DCI_Interface =
|
.CDC_DCI_Interface =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||||
|
|
||||||
.InterfaceNumber = 1,
|
.InterfaceNumber = 1,
|
||||||
.AlternateSetting = 0,
|
.AlternateSetting = 0,
|
||||||
|
|
||||||
.TotalEndpoints = 2,
|
.TotalEndpoints = 2,
|
||||||
|
|
||||||
.Class = 0x0A,
|
.Class = 0x0A,
|
||||||
.SubClass = 0x00,
|
.SubClass = 0x00,
|
||||||
.Protocol = 0x00,
|
.Protocol = 0x00,
|
||||||
|
|
||||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||||
},
|
},
|
||||||
|
|
||||||
.RNDIS_DataOutEndpoint =
|
.RNDIS_DataOutEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
.PollingIntervalMS = 0x00
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.RNDIS_DataInEndpoint =
|
.RNDIS_DataInEndpoint =
|
||||||
{
|
{
|
||||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||||
|
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||||
|
|
@ -181,7 +181,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -192,7 +192,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"Dean Camera"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -203,7 +203,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"LUFA RNDIS CDC Demo"
|
.UnicodeString = L"LUFA RNDIS CDC Demo"
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -229,7 +229,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Address = &DeviceDescriptor;
|
Address = &DeviceDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Device_t);
|
Size = sizeof(USB_Descriptor_Device_t);
|
||||||
break;
|
break;
|
||||||
case DTYPE_Configuration:
|
case DTYPE_Configuration:
|
||||||
Address = &ConfigurationDescriptor;
|
Address = &ConfigurationDescriptor;
|
||||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||||
break;
|
break;
|
||||||
|
|
@ -249,10 +249,11 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
*DescriptorAddress = Address;
|
*DescriptorAddress = Address;
|
||||||
return Size;
|
return Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -39,7 +39,7 @@
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
||||||
|
|
||||||
#include <avr/pgmspace.h>
|
#include <avr/pgmspace.h>
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
|
|
@ -47,10 +47,10 @@
|
||||||
#define CDC_NOTIFICATION_EPNUM 3
|
#define CDC_NOTIFICATION_EPNUM 3
|
||||||
|
|
||||||
/** Endpoint number of the CDC device-to-host data IN endpoint. */
|
/** Endpoint number of the CDC device-to-host data IN endpoint. */
|
||||||
#define CDC_TX_EPNUM 1
|
#define CDC_TX_EPNUM 1
|
||||||
|
|
||||||
/** Endpoint number of the CDC host-to-device data OUT endpoint. */
|
/** Endpoint number of the CDC host-to-device data OUT endpoint. */
|
||||||
#define CDC_RX_EPNUM 2
|
#define CDC_RX_EPNUM 2
|
||||||
|
|
||||||
/** Size in bytes of the CDC device-to-host notification IN endpoint. */
|
/** Size in bytes of the CDC device-to-host notification IN endpoint. */
|
||||||
#define CDC_NOTIFICATION_EPSIZE 8
|
#define CDC_NOTIFICATION_EPSIZE 8
|
||||||
|
|
@ -83,3 +83,4 @@
|
||||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
* conversion of physical MAC addresses to protocol IP addresses between the host and the
|
* conversion of physical MAC addresses to protocol IP addresses between the host and the
|
||||||
* device.
|
* device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ARP.h"
|
#include "ARP.h"
|
||||||
|
|
||||||
/** Processes an ARP packet inside an Ethernet frame, and writes the appropriate response
|
/** Processes an ARP packet inside an Ethernet frame, and writes the appropriate response
|
||||||
|
|
@ -59,7 +59,7 @@ int16_t ARP_ProcessARPPacket(void* InDataStart,
|
||||||
(SwapEndian_16(ARPHeaderIN->Operation) == ARP_OPERATION_REQUEST))
|
(SwapEndian_16(ARPHeaderIN->Operation) == ARP_OPERATION_REQUEST))
|
||||||
{
|
{
|
||||||
/* If the ARP packet is requesting the MAC or IP of the virtual webserver, return the response */
|
/* If the ARP packet is requesting the MAC or IP of the virtual webserver, return the response */
|
||||||
if (IP_COMPARE(&ARPHeaderIN->TPA, &ServerIPAddress) ||
|
if (IP_COMPARE(&ARPHeaderIN->TPA, &ServerIPAddress) ||
|
||||||
MAC_COMPARE(&ARPHeaderIN->THA, &ServerMACAddress))
|
MAC_COMPARE(&ARPHeaderIN->THA, &ServerMACAddress))
|
||||||
{
|
{
|
||||||
/* Fill out the ARP response header */
|
/* Fill out the ARP response header */
|
||||||
|
|
@ -81,6 +81,7 @@ int16_t ARP_ProcessARPPacket(void* InDataStart,
|
||||||
return sizeof(ARP_Header_t);
|
return sizeof(ARP_Header_t);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_RESPONSE;
|
return NO_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,18 +32,18 @@
|
||||||
*
|
*
|
||||||
* Header file for ARP.c.
|
* Header file for ARP.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ARP_H_
|
#ifndef _ARP_H_
|
||||||
#define _ARP_H_
|
#define _ARP_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "EthernetProtocols.h"
|
#include "EthernetProtocols.h"
|
||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
#include "ProtocolDecoders.h"
|
#include "ProtocolDecoders.h"
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** ARP header operation constant, indicating a request from a host for an address translation. */
|
/** ARP header operation constant, indicating a request from a host for an address translation. */
|
||||||
#define ARP_OPERATION_REQUEST 1
|
#define ARP_OPERATION_REQUEST 1
|
||||||
|
|
@ -57,19 +57,20 @@
|
||||||
{
|
{
|
||||||
uint16_t HardwareType; /**< Hardware type constant, indicating the hardware used */
|
uint16_t HardwareType; /**< Hardware type constant, indicating the hardware used */
|
||||||
uint16_t ProtocolType; /**< Protocol being resolved, usually ETHERTYPE_IPV4 */
|
uint16_t ProtocolType; /**< Protocol being resolved, usually ETHERTYPE_IPV4 */
|
||||||
|
|
||||||
uint8_t HLEN; /**< Length in bytes of the source/destination hardware addresses */
|
uint8_t HLEN; /**< Length in bytes of the source/destination hardware addresses */
|
||||||
uint8_t PLEN; /**< Length in bytes of the source/destination protocol addresses */
|
uint8_t PLEN; /**< Length in bytes of the source/destination protocol addresses */
|
||||||
uint16_t Operation; /**< Type of operation, either ARP_OPERATION_REQUEST or ARP_OPERATION_REPLY */
|
uint16_t Operation; /**< Type of operation, either ARP_OPERATION_REQUEST or ARP_OPERATION_REPLY */
|
||||||
|
|
||||||
MAC_Address_t SHA; /**< Sender's hardware address */
|
MAC_Address_t SHA; /**< Sender's hardware address */
|
||||||
IP_Address_t SPA; /**< Sender's protocol address */
|
IP_Address_t SPA; /**< Sender's protocol address */
|
||||||
MAC_Address_t THA; /**< Target's hardware address */
|
MAC_Address_t THA; /**< Target's hardware address */
|
||||||
IP_Address_t TPA; /**< Target's protocol address */
|
IP_Address_t TPA; /**< Target's protocol address */
|
||||||
} ARP_Header_t;
|
} ARP_Header_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
int16_t ARP_ProcessARPPacket(void* InDataStart,
|
int16_t ARP_ProcessARPPacket(void* InDataStart,
|
||||||
void* OutDataStart);
|
void* OutDataStart);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
* handles the automatic IP negotiation to the host, so that the host will use the provided
|
* handles the automatic IP negotiation to the host, so that the host will use the provided
|
||||||
* IP address given to it by the device.
|
* IP address given to it by the device.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "DHCP.h"
|
#include "DHCP.h"
|
||||||
|
|
||||||
/** Processes a DHCP packet inside an Ethernet frame, and writes the appropriate response
|
/** Processes a DHCP packet inside an Ethernet frame, and writes the appropriate response
|
||||||
|
|
@ -53,7 +53,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart,
|
||||||
IP_Header_t* IPHeaderIN = (IP_Header_t*)IPHeaderInStart;
|
IP_Header_t* IPHeaderIN = (IP_Header_t*)IPHeaderInStart;
|
||||||
DHCP_Header_t* DHCPHeaderIN = (DHCP_Header_t*)DHCPHeaderInStart;
|
DHCP_Header_t* DHCPHeaderIN = (DHCP_Header_t*)DHCPHeaderInStart;
|
||||||
DHCP_Header_t* DHCPHeaderOUT = (DHCP_Header_t*)DHCPHeaderOutStart;
|
DHCP_Header_t* DHCPHeaderOUT = (DHCP_Header_t*)DHCPHeaderOutStart;
|
||||||
|
|
||||||
uint8_t* DHCPOptionsINStart = (uint8_t*)(DHCPHeaderInStart + sizeof(DHCP_Header_t));
|
uint8_t* DHCPOptionsINStart = (uint8_t*)(DHCPHeaderInStart + sizeof(DHCP_Header_t));
|
||||||
uint8_t* DHCPOptionsOUTStart = (uint8_t*)(DHCPHeaderOutStart + sizeof(DHCP_Header_t));
|
uint8_t* DHCPOptionsOUTStart = (uint8_t*)(DHCPHeaderOutStart + sizeof(DHCP_Header_t));
|
||||||
|
|
||||||
|
|
@ -73,7 +73,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart,
|
||||||
DHCPHeaderOUT->YourIP = ClientIPAddress;
|
DHCPHeaderOUT->YourIP = ClientIPAddress;
|
||||||
memmove(&DHCPHeaderOUT->ClientHardwareAddress, &DHCPHeaderIN->ClientHardwareAddress, sizeof(MAC_Address_t));
|
memmove(&DHCPHeaderOUT->ClientHardwareAddress, &DHCPHeaderIN->ClientHardwareAddress, sizeof(MAC_Address_t));
|
||||||
DHCPHeaderOUT->Cookie = SwapEndian_32(DHCP_MAGIC_COOKIE);
|
DHCPHeaderOUT->Cookie = SwapEndian_32(DHCP_MAGIC_COOKIE);
|
||||||
|
|
||||||
/* Alter the incoming IP packet header so that the corrected IP source and destinations are used - this means that
|
/* Alter the incoming IP packet header so that the corrected IP source and destinations are used - this means that
|
||||||
when the response IP header is generated, it will use the corrected addresses and not the null/broatcast addresses */
|
when the response IP header is generated, it will use the corrected addresses and not the null/broatcast addresses */
|
||||||
IPHeaderIN->SourceAddress = ClientIPAddress;
|
IPHeaderIN->SourceAddress = ClientIPAddress;
|
||||||
|
|
@ -81,7 +81,7 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart,
|
||||||
|
|
||||||
/* Process the incoming DHCP packet options */
|
/* Process the incoming DHCP packet options */
|
||||||
while (DHCPOptionsINStart[0] != DHCP_OPTION_END)
|
while (DHCPOptionsINStart[0] != DHCP_OPTION_END)
|
||||||
{
|
{
|
||||||
/* Find the Message Type DHCP option, to determine the type of DHCP packet */
|
/* Find the Message Type DHCP option, to determine the type of DHCP packet */
|
||||||
if (DHCPOptionsINStart[0] == DHCP_OPTION_MESSAGETYPE)
|
if (DHCPOptionsINStart[0] == DHCP_OPTION_MESSAGETYPE)
|
||||||
{
|
{
|
||||||
|
|
@ -107,14 +107,15 @@ int16_t DHCP_ProcessDHCPPacket(void* IPHeaderInStart,
|
||||||
DHCPOptionsOUTStart += sizeof(IP_Address_t);
|
DHCPOptionsOUTStart += sizeof(IP_Address_t);
|
||||||
|
|
||||||
*(DHCPOptionsOUTStart++) = DHCP_OPTION_END;
|
*(DHCPOptionsOUTStart++) = DHCP_OPTION_END;
|
||||||
|
|
||||||
return (sizeof(DHCP_Header_t) + 12 + sizeof(IP_Address_t));
|
return (sizeof(DHCP_Header_t) + 12 + sizeof(IP_Address_t));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Go to the next DHCP option - skip one byte if option is a padding byte, else skip the complete option's size */
|
/* Go to the next DHCP option - skip one byte if option is a padding byte, else skip the complete option's size */
|
||||||
DHCPOptionsINStart += ((DHCPOptionsINStart[0] == DHCP_OPTION_PAD) ? 1 : (DHCPOptionsINStart[1] + 2));
|
DHCPOptionsINStart += ((DHCPOptionsINStart[0] == DHCP_OPTION_PAD) ? 1 : (DHCPOptionsINStart[1] + 2));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_RESPONSE;
|
return NO_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,14 +32,14 @@
|
||||||
*
|
*
|
||||||
* Header file for DHCP.c.
|
* Header file for DHCP.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _DHCP_H_
|
#ifndef _DHCP_H_
|
||||||
#define _DHCP_H_
|
#define _DHCP_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "EthernetProtocols.h"
|
#include "EthernetProtocols.h"
|
||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
#include "ProtocolDecoders.h"
|
#include "ProtocolDecoders.h"
|
||||||
|
|
@ -50,13 +50,13 @@
|
||||||
|
|
||||||
/** DHCP operation constant, indicating a reply from a DHCP server to a host. */
|
/** DHCP operation constant, indicating a reply from a DHCP server to a host. */
|
||||||
#define DHCP_OP_BOOTREPLY 0x02
|
#define DHCP_OP_BOOTREPLY 0x02
|
||||||
|
|
||||||
/** Hardware type constant, indicating Ethernet as a carrier. */
|
/** Hardware type constant, indicating Ethernet as a carrier. */
|
||||||
#define DHCP_HTYPE_ETHERNET 0x01
|
#define DHCP_HTYPE_ETHERNET 0x01
|
||||||
|
|
||||||
/** Magic boot protocol "cookie", inserted into all BOOTP packets (BOOTP is the carrier of DHCP). */
|
/** Magic boot protocol "cookie", inserted into all BOOTP packets (BOOTP is the carrier of DHCP). */
|
||||||
#define DHCP_MAGIC_COOKIE 0x63825363
|
#define DHCP_MAGIC_COOKIE 0x63825363
|
||||||
|
|
||||||
/** DHCP option list entry header, indicating that a subnet mask will follow. */
|
/** DHCP option list entry header, indicating that a subnet mask will follow. */
|
||||||
#define DHCP_OPTION_SUBNETMASK 1
|
#define DHCP_OPTION_SUBNETMASK 1
|
||||||
|
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
|
|
||||||
/** DHCP option list entry header, indicating the end of option data. */
|
/** DHCP option list entry header, indicating the end of option data. */
|
||||||
#define DHCP_OPTION_END 255
|
#define DHCP_OPTION_END 255
|
||||||
|
|
||||||
/** Message type constant, used in the DHCP option data field, requesting that a DHCP server offer an IP address. */
|
/** Message type constant, used in the DHCP option data field, requesting that a DHCP server offer an IP address. */
|
||||||
#define DHCP_MESSAGETYPE_DISCOVER 1
|
#define DHCP_MESSAGETYPE_DISCOVER 1
|
||||||
|
|
||||||
|
|
@ -106,16 +106,16 @@
|
||||||
|
|
||||||
uint16_t ElapsedSeconds; /**< Elapsed seconds since the request was made */
|
uint16_t ElapsedSeconds; /**< Elapsed seconds since the request was made */
|
||||||
uint16_t Flags; /**< BOOTP packet flags */
|
uint16_t Flags; /**< BOOTP packet flags */
|
||||||
|
|
||||||
IP_Address_t ClientIP; /**< Client IP address, if already leased an IP */
|
IP_Address_t ClientIP; /**< Client IP address, if already leased an IP */
|
||||||
IP_Address_t YourIP; /**< Client IP address */
|
IP_Address_t YourIP; /**< Client IP address */
|
||||||
IP_Address_t NextServerIP; /**< Legacy BOOTP protocol field, unused for DHCP */
|
IP_Address_t NextServerIP; /**< Legacy BOOTP protocol field, unused for DHCP */
|
||||||
IP_Address_t RelayAgentIP; /**< Legacy BOOTP protocol field, unused for DHCP */
|
IP_Address_t RelayAgentIP; /**< Legacy BOOTP protocol field, unused for DHCP */
|
||||||
|
|
||||||
uint8_t ClientHardwareAddress[16]; /**< Hardware (MAC) address of the client making a request to the DHCP server */
|
uint8_t ClientHardwareAddress[16]; /**< Hardware (MAC) address of the client making a request to the DHCP server */
|
||||||
uint8_t ServerHostnameString[64]; /**< Legacy BOOTP protocol field, unused for DHCP */
|
uint8_t ServerHostnameString[64]; /**< Legacy BOOTP protocol field, unused for DHCP */
|
||||||
uint8_t BootFileName[128]; /**< Legacy BOOTP protocol field, unused for DHCP */
|
uint8_t BootFileName[128]; /**< Legacy BOOTP protocol field, unused for DHCP */
|
||||||
|
|
||||||
uint32_t Cookie; /**< Magic BOOTP protocol cookie to indicate a valid packet */
|
uint32_t Cookie; /**< Magic BOOTP protocol cookie to indicate a valid packet */
|
||||||
} DHCP_Header_t;
|
} DHCP_Header_t;
|
||||||
|
|
||||||
|
|
@ -125,3 +125,4 @@
|
||||||
void* DHCPHeaderOutStart);
|
void* DHCPHeaderOutStart);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
* frames sent and received, deferring the processing of sub-packet protocols to the appropriate
|
* frames sent and received, deferring the processing of sub-packet protocols to the appropriate
|
||||||
* protocol handlers, such as DHCP or ARP.
|
* protocol handlers, such as DHCP or ARP.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
|
|
||||||
/** Constant for convenience when checking against or setting a MAC address to the virtual server MAC address. */
|
/** Constant for convenience when checking against or setting a MAC address to the virtual server MAC address. */
|
||||||
|
|
@ -64,9 +64,9 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
/* Cast the incoming Ethernet frame to the Ethernet header type */
|
/* Cast the incoming Ethernet frame to the Ethernet header type */
|
||||||
Ethernet_Frame_Header_t* FrameINHeader = (Ethernet_Frame_Header_t*)&FrameIN->FrameData;
|
Ethernet_Frame_Header_t* FrameINHeader = (Ethernet_Frame_Header_t*)&FrameIN->FrameData;
|
||||||
Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&FrameOUT->FrameData;
|
Ethernet_Frame_Header_t* FrameOUTHeader = (Ethernet_Frame_Header_t*)&FrameOUT->FrameData;
|
||||||
|
|
||||||
int16_t RetSize = NO_RESPONSE;
|
int16_t RetSize = NO_RESPONSE;
|
||||||
|
|
||||||
/* Ensure frame is addressed to either all (broadcast) or the virtual webserver, and is a type II frame */
|
/* Ensure frame is addressed to either all (broadcast) or the virtual webserver, and is a type II frame */
|
||||||
if ((MAC_COMPARE(&FrameINHeader->Destination, &ServerMACAddress) ||
|
if ((MAC_COMPARE(&FrameINHeader->Destination, &ServerMACAddress) ||
|
||||||
MAC_COMPARE(&FrameINHeader->Destination, &BroadcastMACAddress)) &&
|
MAC_COMPARE(&FrameINHeader->Destination, &BroadcastMACAddress)) &&
|
||||||
|
|
@ -78,14 +78,14 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
case ETHERTYPE_ARP:
|
case ETHERTYPE_ARP:
|
||||||
RetSize = ARP_ProcessARPPacket(&FrameIN->FrameData[sizeof(Ethernet_Frame_Header_t)],
|
RetSize = ARP_ProcessARPPacket(&FrameIN->FrameData[sizeof(Ethernet_Frame_Header_t)],
|
||||||
&FrameOUT->FrameData[sizeof(Ethernet_Frame_Header_t)]);
|
&FrameOUT->FrameData[sizeof(Ethernet_Frame_Header_t)]);
|
||||||
break;
|
break;
|
||||||
case ETHERTYPE_IPV4:
|
case ETHERTYPE_IPV4:
|
||||||
RetSize = IP_ProcessIPPacket(FrameIN,
|
RetSize = IP_ProcessIPPacket(FrameIN,
|
||||||
&FrameIN->FrameData[sizeof(Ethernet_Frame_Header_t)],
|
&FrameIN->FrameData[sizeof(Ethernet_Frame_Header_t)],
|
||||||
&FrameOUT->FrameData[sizeof(Ethernet_Frame_Header_t)]);
|
&FrameOUT->FrameData[sizeof(Ethernet_Frame_Header_t)]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Protocol processing routine has filled a response, complete the ethernet frame header */
|
/* Protocol processing routine has filled a response, complete the ethernet frame header */
|
||||||
if (RetSize > 0)
|
if (RetSize > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -93,7 +93,7 @@ void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
FrameOUTHeader->Source = ServerMACAddress;
|
FrameOUTHeader->Source = ServerMACAddress;
|
||||||
FrameOUTHeader->Destination = FrameINHeader->Source;
|
FrameOUTHeader->Destination = FrameINHeader->Source;
|
||||||
FrameOUTHeader->EtherType = FrameINHeader->EtherType;
|
FrameOUTHeader->EtherType = FrameINHeader->EtherType;
|
||||||
|
|
||||||
/* Set the response length in the buffer and indicate that a response is ready to be sent */
|
/* Set the response length in the buffer and indicate that a response is ready to be sent */
|
||||||
FrameOUT->FrameLength = (sizeof(Ethernet_Frame_Header_t) + RetSize);
|
FrameOUT->FrameLength = (sizeof(Ethernet_Frame_Header_t) + RetSize);
|
||||||
FrameOUT->FrameInBuffer = true;
|
FrameOUT->FrameInBuffer = true;
|
||||||
|
|
@ -124,9 +124,10 @@ uint16_t Ethernet_Checksum16(void* Data,
|
||||||
|
|
||||||
for (uint16_t CurrWord = 0; CurrWord < (Bytes >> 1); CurrWord++)
|
for (uint16_t CurrWord = 0; CurrWord < (Bytes >> 1); CurrWord++)
|
||||||
Checksum += Words[CurrWord];
|
Checksum += Words[CurrWord];
|
||||||
|
|
||||||
while (Checksum & 0xFFFF0000)
|
while (Checksum & 0xFFFF0000)
|
||||||
Checksum = ((Checksum & 0xFFFF) + (Checksum >> 16));
|
Checksum = ((Checksum & 0xFFFF) + (Checksum >> 16));
|
||||||
|
|
||||||
return ~Checksum;
|
return ~Checksum;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,14 +32,14 @@
|
||||||
*
|
*
|
||||||
* Header file for Ethernet.c.
|
* Header file for Ethernet.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _ETHERNET_H_
|
#ifndef _ETHERNET_H_
|
||||||
#define _ETHERNET_H_
|
#define _ETHERNET_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
#include <LUFA/Drivers/USB/Class/RNDIS.h>
|
||||||
|
|
||||||
#include "EthernetProtocols.h"
|
#include "EthernetProtocols.h"
|
||||||
|
|
@ -50,31 +50,31 @@
|
||||||
#include "DHCP.h"
|
#include "DHCP.h"
|
||||||
#include "ARP.h"
|
#include "ARP.h"
|
||||||
#include "IP.h"
|
#include "IP.h"
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Physical MAC address of the USB RNDIS network adapter. */
|
/** Physical MAC address of the USB RNDIS network adapter. */
|
||||||
#define ADAPTER_MAC_ADDRESS {0x02, 0x00, 0x02, 0x00, 0x02, 0x00}
|
#define ADAPTER_MAC_ADDRESS {0x02, 0x00, 0x02, 0x00, 0x02, 0x00}
|
||||||
|
|
||||||
/** Physical MAC address of the virtual server on the network. */
|
/** Physical MAC address of the virtual server on the network. */
|
||||||
#define SERVER_MAC_ADDRESS {0x00, 0x01, 0x00, 0x01, 0x00, 0x01}
|
#define SERVER_MAC_ADDRESS {0x00, 0x01, 0x00, 0x01, 0x00, 0x01}
|
||||||
|
|
||||||
/** Physical MAC address of the network broadcast address. */
|
/** Physical MAC address of the network broadcast address. */
|
||||||
#define BROADCAST_MAC_ADDRESS {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
|
#define BROADCAST_MAC_ADDRESS {0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF}
|
||||||
|
|
||||||
/** Performs a comparison between two MAC addresses, indicating if they are identical.
|
/** Performs a comparison between two MAC addresses, indicating if they are identical.
|
||||||
*
|
*
|
||||||
* \param[in] MAC1 First MAC address
|
* \param[in] MAC1 First MAC address
|
||||||
* \param[in] MAC2 Second MAC address
|
* \param[in] MAC2 Second MAC address
|
||||||
*
|
*
|
||||||
* \return True if the addresses match, false otherwise
|
* \return True if the addresses match, false otherwise
|
||||||
*/
|
*/
|
||||||
#define MAC_COMPARE(MAC1, MAC2) (memcmp(MAC1, MAC2, sizeof(MAC_Address_t)) == 0)
|
#define MAC_COMPARE(MAC1, MAC2) (memcmp(MAC1, MAC2, sizeof(MAC_Address_t)) == 0)
|
||||||
|
|
||||||
/** Minimum size of an Ethernet packet in bytes, to conform to the Ethernet V2 packet standard. */
|
/** Minimum size of an Ethernet packet in bytes, to conform to the Ethernet V2 packet standard. */
|
||||||
#define ETHERNET_VER2_MINSIZE 0x0600
|
#define ETHERNET_VER2_MINSIZE 0x0600
|
||||||
|
|
||||||
/** Return value for all sub protocol handling routines, indicating that no response packet has been generated. */
|
/** Return value for all sub protocol handling routines, indicating that no response packet has been generated. */
|
||||||
#define NO_RESPONSE 0
|
#define NO_RESPONSE 0
|
||||||
|
|
||||||
/** Return value for all sub protocol handling routines, indicating that the packet has not yet been handled. */
|
/** Return value for all sub protocol handling routines, indicating that the packet has not yet been handled. */
|
||||||
#define NO_PROCESS -1
|
#define NO_PROCESS -1
|
||||||
|
|
@ -87,18 +87,19 @@
|
||||||
MAC_Address_t Source; /**< Physics MAC address of the packet source */
|
MAC_Address_t Source; /**< Physics MAC address of the packet source */
|
||||||
uint16_t EtherType; /**< Ethernet packet sub-protocol type, for Ethernet V2 packets */
|
uint16_t EtherType; /**< Ethernet packet sub-protocol type, for Ethernet V2 packets */
|
||||||
} Ethernet_Frame_Header_t;
|
} Ethernet_Frame_Header_t;
|
||||||
|
|
||||||
/* External Variables: */
|
/* External Variables: */
|
||||||
extern const MAC_Address_t ServerMACAddress;
|
extern const MAC_Address_t ServerMACAddress;
|
||||||
extern const IP_Address_t ServerIPAddress;
|
extern const IP_Address_t ServerIPAddress;
|
||||||
extern const MAC_Address_t BroadcastMACAddress;
|
extern const MAC_Address_t BroadcastMACAddress;
|
||||||
extern const IP_Address_t BroadcastIPAddress;
|
extern const IP_Address_t BroadcastIPAddress;
|
||||||
extern const IP_Address_t ClientIPAddress;
|
extern const IP_Address_t ClientIPAddress;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
|
void Ethernet_ProcessPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
Ethernet_Frame_Info_t* const FrameOUT);
|
Ethernet_Frame_Info_t* const FrameOUT);
|
||||||
uint16_t Ethernet_Checksum16(void* Data,
|
uint16_t Ethernet_Checksum16(void* Data,
|
||||||
uint16_t Bytes);
|
uint16_t Bytes);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -63,7 +63,7 @@
|
||||||
#define ETHERTYPE_FIBRECHANNEL 0x8906
|
#define ETHERTYPE_FIBRECHANNEL 0x8906
|
||||||
#define ETHERTYPE_QINQ 0x9100
|
#define ETHERTYPE_QINQ 0x9100
|
||||||
#define ETHERTYPE_VLLT 0xCAFE
|
#define ETHERTYPE_VLLT 0xCAFE
|
||||||
|
|
||||||
#define PROTOCOL_ICMP 1
|
#define PROTOCOL_ICMP 1
|
||||||
#define PROTOCOL_IGMP 2
|
#define PROTOCOL_IGMP 2
|
||||||
#define PROTOCOL_TCP 6
|
#define PROTOCOL_TCP 6
|
||||||
|
|
@ -71,7 +71,7 @@
|
||||||
#define PROTOCOL_OSPF 89
|
#define PROTOCOL_OSPF 89
|
||||||
#define PROTOCOL_SCTP 132
|
#define PROTOCOL_SCTP 132
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for a protocol IP address of a device on a network. */
|
/** Type define for a protocol IP address of a device on a network. */
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
|
|
@ -79,3 +79,4 @@
|
||||||
} IP_Address_t;
|
} IP_Address_t;
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -34,7 +34,7 @@
|
||||||
* Echo requests from the host, to indicate a successful network connection between the host
|
* Echo requests from the host, to indicate a successful network connection between the host
|
||||||
* and the virtual server.
|
* and the virtual server.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ICMP.h"
|
#include "ICMP.h"
|
||||||
|
|
||||||
/** Processes an ICMP packet inside an Ethernet frame, and writes the appropriate response
|
/** Processes an ICMP packet inside an Ethernet frame, and writes the appropriate response
|
||||||
|
|
@ -64,9 +64,9 @@ int16_t ICMP_ProcessICMPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
ICMPHeaderOUT->Checksum = 0;
|
ICMPHeaderOUT->Checksum = 0;
|
||||||
ICMPHeaderOUT->Id = ICMPHeaderIN->Id;
|
ICMPHeaderOUT->Id = ICMPHeaderIN->Id;
|
||||||
ICMPHeaderOUT->Sequence = ICMPHeaderIN->Sequence;
|
ICMPHeaderOUT->Sequence = ICMPHeaderIN->Sequence;
|
||||||
|
|
||||||
intptr_t DataSize = FrameIN->FrameLength - ((((intptr_t)InDataStart + sizeof(ICMP_Header_t)) - (intptr_t)FrameIN->FrameData));
|
intptr_t DataSize = FrameIN->FrameLength - ((((intptr_t)InDataStart + sizeof(ICMP_Header_t)) - (intptr_t)FrameIN->FrameData));
|
||||||
|
|
||||||
/* Copy the remaining payload to the response - echo requests should echo back any sent data */
|
/* Copy the remaining payload to the response - echo requests should echo back any sent data */
|
||||||
memmove(&((uint8_t*)OutDataStart)[sizeof(ICMP_Header_t)],
|
memmove(&((uint8_t*)OutDataStart)[sizeof(ICMP_Header_t)],
|
||||||
&((uint8_t*)InDataStart)[sizeof(ICMP_Header_t)],
|
&((uint8_t*)InDataStart)[sizeof(ICMP_Header_t)],
|
||||||
|
|
@ -77,6 +77,7 @@ int16_t ICMP_ProcessICMPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
/* Return the size of the response so far */
|
/* Return the size of the response so far */
|
||||||
return (DataSize + sizeof(ICMP_Header_t));
|
return (DataSize + sizeof(ICMP_Header_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
return NO_RESPONSE;
|
return NO_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -39,18 +39,18 @@
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "EthernetProtocols.h"
|
#include "EthernetProtocols.h"
|
||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
#include "ProtocolDecoders.h"
|
#include "ProtocolDecoders.h"
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** ICMP message type constant, indicating an ICMP ECHO Reply message. */
|
/** ICMP message type constant, indicating an ICMP ECHO Reply message. */
|
||||||
#define ICMP_TYPE_ECHOREPLY 0
|
#define ICMP_TYPE_ECHOREPLY 0
|
||||||
|
|
||||||
/** ICMP message type constant, indicating a packet destination is unreachable. */
|
/** ICMP message type constant, indicating a packet destination is unreachable. */
|
||||||
#define ICMP_TYPE_DESTINATIONUNREACHABLE 3
|
#define ICMP_TYPE_DESTINATIONUNREACHABLE 3
|
||||||
|
|
||||||
/** ICMP message type constant, indicating an ICMP Source Quench message. */
|
/** ICMP message type constant, indicating an ICMP Source Quench message. */
|
||||||
#define ICMP_TYPE_SOURCEQUENCH 4
|
#define ICMP_TYPE_SOURCEQUENCH 4
|
||||||
|
|
||||||
|
|
@ -62,7 +62,7 @@
|
||||||
|
|
||||||
/** ICMP message type constant, indicating an ICMP Time Exceeded message. */
|
/** ICMP message type constant, indicating an ICMP Time Exceeded message. */
|
||||||
#define ICMP_TYPE_TIMEEXCEEDED 11
|
#define ICMP_TYPE_TIMEEXCEEDED 11
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define for an ICMP message header. */
|
/** Type define for an ICMP message header. */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
@ -73,10 +73,11 @@
|
||||||
uint16_t Id; /**< Id of the ICMP message */
|
uint16_t Id; /**< Id of the ICMP message */
|
||||||
uint16_t Sequence; /**< Sequence number of the ICMP message, to link together message responses */
|
uint16_t Sequence; /**< Sequence number of the ICMP message, to link together message responses */
|
||||||
} ICMP_Header_t;
|
} ICMP_Header_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
int16_t ICMP_ProcessICMPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
int16_t ICMP_ProcessICMPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
void* InDataStart,
|
void* InDataStart,
|
||||||
void* OutDataStart);
|
void* OutDataStart);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
* Internet Protocol (IP) packet handling routines. This protocol handles IP packets from the
|
* Internet Protocol (IP) packet handling routines. This protocol handles IP packets from the
|
||||||
* host which typically encapsulate other protocols such as ICMP, UDP and TCP.
|
* host which typically encapsulate other protocols such as ICMP, UDP and TCP.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "IP.h"
|
#include "IP.h"
|
||||||
|
|
||||||
/** Processes an IP packet inside an Ethernet frame, and writes the appropriate response
|
/** Processes an IP packet inside an Ethernet frame, and writes the appropriate response
|
||||||
|
|
@ -67,7 +67,7 @@ int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
{
|
{
|
||||||
return NO_RESPONSE;
|
return NO_RESPONSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Pass off the IP payload to the appropriate protocol processing routine */
|
/* Pass off the IP payload to the appropriate protocol processing routine */
|
||||||
switch (IPHeaderIN->Protocol)
|
switch (IPHeaderIN->Protocol)
|
||||||
{
|
{
|
||||||
|
|
@ -79,15 +79,15 @@ int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
case PROTOCOL_TCP:
|
case PROTOCOL_TCP:
|
||||||
RetSize = TCP_ProcessTCPPacket(InDataStart,
|
RetSize = TCP_ProcessTCPPacket(InDataStart,
|
||||||
&((uint8_t*)InDataStart)[HeaderLengthBytes],
|
&((uint8_t*)InDataStart)[HeaderLengthBytes],
|
||||||
&((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]);
|
&((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]);
|
||||||
break;
|
break;
|
||||||
case PROTOCOL_UDP:
|
case PROTOCOL_UDP:
|
||||||
RetSize = UDP_ProcessUDPPacket(InDataStart,
|
RetSize = UDP_ProcessUDPPacket(InDataStart,
|
||||||
&((uint8_t*)InDataStart)[HeaderLengthBytes],
|
&((uint8_t*)InDataStart)[HeaderLengthBytes],
|
||||||
&((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]);
|
&((uint8_t*)OutDataStart)[sizeof(IP_Header_t)]);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check to see if the protocol processing routine has filled out a response */
|
/* Check to see if the protocol processing routine has filled out a response */
|
||||||
if (RetSize > 0)
|
if (RetSize > 0)
|
||||||
{
|
{
|
||||||
|
|
@ -104,12 +104,13 @@ int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
IPHeaderOUT->TTL = DEFAULT_TTL;
|
IPHeaderOUT->TTL = DEFAULT_TTL;
|
||||||
IPHeaderOUT->SourceAddress = IPHeaderIN->DestinationAddress;
|
IPHeaderOUT->SourceAddress = IPHeaderIN->DestinationAddress;
|
||||||
IPHeaderOUT->DestinationAddress = IPHeaderIN->SourceAddress;
|
IPHeaderOUT->DestinationAddress = IPHeaderIN->SourceAddress;
|
||||||
|
|
||||||
IPHeaderOUT->HeaderChecksum = Ethernet_Checksum16(IPHeaderOUT, sizeof(IP_Header_t));
|
IPHeaderOUT->HeaderChecksum = Ethernet_Checksum16(IPHeaderOUT, sizeof(IP_Header_t));
|
||||||
|
|
||||||
/* Return the size of the response so far */
|
/* Return the size of the response so far */
|
||||||
return (sizeof(IP_Header_t) + RetSize);
|
return (sizeof(IP_Header_t) + RetSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
return RetSize;
|
return RetSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
/*
|
/*
|
||||||
LUFA Library
|
LUFA Library
|
||||||
Copyright (C) Dean Camera, 2010.
|
Copyright (C) Dean Camera, 2010.
|
||||||
|
|
||||||
dean [at] fourwalledcubicle [dot] com
|
dean [at] fourwalledcubicle [dot] com
|
||||||
www.fourwalledcubicle.com
|
www.fourwalledcubicle.com
|
||||||
*/
|
*/
|
||||||
|
|
@ -9,13 +9,13 @@
|
||||||
/*
|
/*
|
||||||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
Copyright 2010 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
|
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
|
all copies and that both that the copyright notice and this
|
||||||
permission notice and warranty disclaimer appear in supporting
|
permission notice and warranty disclaimer appear in supporting
|
||||||
documentation, and that the name of the author not be used in
|
documentation, and that the name of the author not be used in
|
||||||
advertising or publicity pertaining to distribution of the
|
advertising or publicity pertaining to distribution of the
|
||||||
software without specific, written prior permission.
|
software without specific, written prior permission.
|
||||||
|
|
||||||
The author disclaim all warranties with regard to this
|
The author disclaim all warranties with regard to this
|
||||||
|
|
@ -32,18 +32,18 @@
|
||||||
*
|
*
|
||||||
* Header file for IP.c.
|
* Header file for IP.c.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifndef _IP_H_
|
#ifndef _IP_H_
|
||||||
#define _IP_H_
|
#define _IP_H_
|
||||||
|
|
||||||
/* Includes: */
|
/* Includes: */
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "EthernetProtocols.h"
|
#include "EthernetProtocols.h"
|
||||||
#include "Ethernet.h"
|
#include "Ethernet.h"
|
||||||
#include "ProtocolDecoders.h"
|
#include "ProtocolDecoders.h"
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
/** Protocol IP address of the host (client) machine, once assigned by DHCP. */
|
/** Protocol IP address of the host (client) machine, once assigned by DHCP. */
|
||||||
#define CLIENT_IP_ADDRESS { 10, 0, 0, 1}
|
#define CLIENT_IP_ADDRESS { 10, 0, 0, 1}
|
||||||
|
|
@ -58,16 +58,16 @@
|
||||||
* is reached.
|
* is reached.
|
||||||
*/
|
*/
|
||||||
#define DEFAULT_TTL 128
|
#define DEFAULT_TTL 128
|
||||||
|
|
||||||
/** Performs a comparison between two IP addresses, indicating if they are identical.
|
/** Performs a comparison between two IP addresses, indicating if they are identical.
|
||||||
*
|
*
|
||||||
* \param[in] IP1 First IP address
|
* \param[in] IP1 First IP address
|
||||||
* \param[in] IP2 Second IP address
|
* \param[in] IP2 Second IP address
|
||||||
*
|
*
|
||||||
* \return True if the addresses match, false otherwise
|
* \return True if the addresses match, false otherwise
|
||||||
*/
|
*/
|
||||||
#define IP_COMPARE(IP1, IP2) (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0)
|
#define IP_COMPARE(IP1, IP2) (memcmp(IP1, IP2, sizeof(IP_Address_t)) == 0)
|
||||||
|
|
||||||
/* Type Defines: */
|
/* Type Defines: */
|
||||||
/** Type define of an IP packet header. */
|
/** Type define of an IP packet header. */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
@ -84,14 +84,15 @@
|
||||||
uint8_t TTL; /**< Maximum allowable number of hops to reach the packet destination */
|
uint8_t TTL; /**< Maximum allowable number of hops to reach the packet destination */
|
||||||
uint8_t Protocol; /**< Encapsulated protocol type */
|
uint8_t Protocol; /**< Encapsulated protocol type */
|
||||||
uint16_t HeaderChecksum; /**< Ethernet checksum of the IP header */
|
uint16_t HeaderChecksum; /**< Ethernet checksum of the IP header */
|
||||||
|
|
||||||
IP_Address_t SourceAddress; /**< Source protocol IP address of the packet */
|
IP_Address_t SourceAddress; /**< Source protocol IP address of the packet */
|
||||||
IP_Address_t DestinationAddress; /**< Destination protocol IP address of the packet */
|
IP_Address_t DestinationAddress; /**< Destination protocol IP address of the packet */
|
||||||
} IP_Header_t;
|
} IP_Header_t;
|
||||||
|
|
||||||
/* Function Prototypes: */
|
/* Function Prototypes: */
|
||||||
int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
int16_t IP_ProcessIPPacket(Ethernet_Frame_Info_t* const FrameIN,
|
||||||
void* InDataStart,
|
void* InDataStart,
|
||||||
void* OutDataStart);
|
void* OutDataStart);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue