Commit 1f4f912124fce2ce393d7507476ebc9a71ccb40f

Authored by dmohamed
1 parent 57f5d0bc

UPDATE:Inspiration d'un projet LUFA

lufa/Config/LUFAConfig.h
... ... @@ -71,7 +71,7 @@
71 71 // #define USE_EEPROM_DESCRIPTORS
72 72 // #define NO_INTERNAL_SERIAL
73 73 #define FIXED_CONTROL_ENDPOINT_SIZE 8
74   -// #define DEVICE_STATE_AS_GPIOR {Insert Value Here}
  74 + #define DEVICE_STATE_AS_GPIOR 0
75 75 #define FIXED_NUM_CONFIGURATIONS 1
76 76 // #define CONTROL_ONLY_DEVICE
77 77 #define INTERRUPT_CONTROL_ENDPOINT
... ... @@ -79,45 +79,12 @@
79 79 // #define NO_DEVICE_SELF_POWER
80 80  
81 81 /* USB Host Mode Driver Related Tokens: */
82   -// #define HOST_STATE_AS_GPIOR {Insert Value Here}
  82 +// #define HOST_STATE_AS_GPIOR 0
83 83 // #define USB_HOST_TIMEOUT_MS {Insert Value Here}
84 84 // #define HOST_DEVICE_SETTLE_DELAY_MS {Insert Value Here}
85 85 // #define NO_AUTO_VBUS_MANAGEMENT
86 86 // #define INVERTED_VBUS_ENABLE_LINE
87 87  
88   - #elif (ARCH == ARCH_XMEGA)
89   -
90   - /* Non-USB Related Configuration Tokens: */
91   -// #define DISABLE_TERMINAL_CODES
92   -
93   - /* USB Class Driver Related Tokens: */
94   -// #define HID_HOST_BOOT_PROTOCOL_ONLY
95   -// #define HID_STATETABLE_STACK_DEPTH {Insert Value Here}
96   -// #define HID_USAGE_STACK_DEPTH {Insert Value Here}
97   -// #define HID_MAX_COLLECTIONS {Insert Value Here}
98   -// #define HID_MAX_REPORTITEMS {Insert Value Here}
99   -// #define HID_MAX_REPORT_IDS {Insert Value Here}
100   -// #define NO_CLASS_DRIVER_AUTOFLUSH
101   -
102   - /* General USB Driver Related Tokens: */
103   - #define USE_STATIC_OPTIONS (USB_DEVICE_OPT_FULLSPEED | USB_OPT_RC32MCLKSRC | USB_OPT_BUSEVENT_PRIHIGH)
104   -// #define USB_STREAM_TIMEOUT_MS {Insert Value Here}
105   -// #define NO_LIMITED_CONTROLLER_CONNECT
106   -// #define NO_SOF_EVENTS
107   -
108   - /* USB Device Mode Driver Related Tokens: */
109   -// #define USE_RAM_DESCRIPTORS
110   - #define USE_FLASH_DESCRIPTORS
111   -// #define USE_EEPROM_DESCRIPTORS
112   -// #define NO_INTERNAL_SERIAL
113   - #define FIXED_CONTROL_ENDPOINT_SIZE 8
114   -// #define DEVICE_STATE_AS_GPIOR {Insert Value Here}
115   - #define FIXED_NUM_CONFIGURATIONS 1
116   -// #define CONTROL_ONLY_DEVICE
117   - #define MAX_ENDPOINT_INDEX 4
118   -// #define NO_DEVICE_REMOTE_WAKEUP
119   -// #define NO_DEVICE_SELF_POWER
120   -
121 88 #else
122 89  
123 90 #error Unsupported architecture for this LUFA configuration file.
... ...
lufa/Descriptors.c
... ... @@ -55,7 +55,7 @@ const USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
55 55 .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
56 56  
57 57 .VendorID = 0x03EB,
58   - .ProductID = 0x2044,
  58 + .ProductID = 0x204B,
59 59 .ReleaseNumber = VERSION_BCD(0,0,1),
60 60  
61 61 .ManufacturerStrIndex = STRING_ID_Manufacturer,
... ... @@ -191,7 +191,7 @@ const USB_Descriptor_String_t PROGMEM ManufacturerString = USB_STRING_DESCRIPTOR
191 191 * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device
192 192 * Descriptor.
193 193 */
194   -const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA CDC Demo");
  194 +const USB_Descriptor_String_t PROGMEM ProductString = USB_STRING_DESCRIPTOR(L"LUFA USB-RS232 Adapter");
195 195  
196 196 /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
197 197 * documentation) by the application code so that the address and size of a requested descriptor can be given
... ...
lufa/Descriptors.h
... ... @@ -66,7 +66,7 @@
66 66 {
67 67 USB_Descriptor_Configuration_Header_t Config;
68 68  
69   - // CDC Control Interface
  69 + // CDC Command Interface
70 70 USB_Descriptor_Interface_t CDC_CCI_Interface;
71 71 USB_CDC_Descriptor_FunctionalHeader_t CDC_Functional_Header;
72 72 USB_CDC_Descriptor_FunctionalACM_t CDC_Functional_ACM;
... ...
lufa/LUFA USBtoSerial.inf 0 โ†’ 100644
... ... @@ -0,0 +1,66 @@
  1 +;************************************************************
  2 +; Windows USB CDC ACM Setup File
  3 +; Copyright (c) 2000 Microsoft Corporation
  4 +;************************************************************
  5 +
  6 +[DefaultInstall]
  7 +CopyINF="LUFA USBtoSerial.inf"
  8 +
  9 +[Version]
  10 +Signature="$Windows NT$"
  11 +Class=Ports
  12 +ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318}
  13 +Provider=%MFGNAME%
  14 +DriverVer=7/1/2012,10.0.0.0
  15 +
  16 +[Manufacturer]
  17 +%MFGNAME%=DeviceList, NTx86, NTamd64, NTia64
  18 +
  19 +[SourceDisksNames]
  20 +
  21 +[SourceDisksFiles]
  22 +
  23 +[DestinationDirs]
  24 +DefaultDestDir=12
  25 +
  26 +[DriverInstall]
  27 +Include=mdmcpq.inf
  28 +CopyFiles=FakeModemCopyFileSection
  29 +AddReg=DriverInstall.AddReg
  30 +
  31 +[DriverInstall.Services]
  32 +Include=mdmcpq.inf
  33 +AddService=usbser, 0x00000002, LowerFilter_Service_Inst
  34 +
  35 +[DriverInstall.AddReg]
  36 +HKR,,EnumPropPages32,,"msports.dll,SerialPortPropPageProvider"
  37 +
  38 +;------------------------------------------------------------------------------
  39 +; Vendor and Product ID Definitions
  40 +;------------------------------------------------------------------------------
  41 +; When developing your USB device, the VID and PID used in the PC side
  42 +; application program and the firmware on the microcontroller must match.
  43 +; Modify the below line to use your VID and PID. Use the format as shown below.
  44 +; Note: One INF file can be used for multiple devices with different VID and PIDs.
  45 +; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line.
  46 +;------------------------------------------------------------------------------
  47 +[DeviceList]
  48 +%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204B
  49 +
  50 +[DeviceList.NTx86]
  51 +%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204B
  52 +
  53 +[DeviceList.NTamd64]
  54 +%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204B
  55 +
  56 +[DeviceList.NTia64]
  57 +%DESCRIPTION%=DriverInstall, USB\VID_03EB&PID_204B
  58 +
  59 +;------------------------------------------------------------------------------
  60 +; String Definitions
  61 +;------------------------------------------------------------------------------
  62 +;Modify these strings to customize your device
  63 +;------------------------------------------------------------------------------
  64 +[Strings]
  65 +MFGNAME="http://www.lufa-lib.org"
  66 +DESCRIPTION="LUFA USB to Serial"
0 67 \ No newline at end of file
... ...
lufa/USB_gadget.c
1 1 /*
2 2 LUFA Library
3   - Copyright (C) Dean Camera, 2010.
  3 + Copyright (C) Dean Camera, 2017.
4 4  
5 5 dean [at] fourwalledcubicle [dot] com
6   - www.fourwalledcubicle.com
  6 + www.lufa-lib.org
7 7 */
8 8  
9 9 /*
10   - Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
  10 + Copyright 2017 Dean Camera (dean [at] fourwalledcubicle [dot] com)
11 11  
12 12 Permission to use, copy, modify, distribute, and sell this
13 13 software and its documentation for any purpose is hereby granted
... ... @@ -18,7 +18,7 @@
18 18 advertising or publicity pertaining to distribution of the
19 19 software without specific, written prior permission.
20 20  
21   - The author disclaim all warranties with regard to this
  21 + The author disclaims all warranties with regard to this
22 22 software, including all implied warranties of merchantability
23 23 and fitness. In no event shall the author be liable for any
24 24 special, indirect or consequential damages or any damages
... ... @@ -31,16 +31,22 @@
31 31 /** \file
32 32 *
33 33 * Main source file for the USBtoSerial project. This file contains the main tasks of
34   - * the demo and is responsible for the initial application hardware configuration.
  34 + * the project and is responsible for the initial application hardware configuration.
35 35 */
36 36  
37   -#include "USBtoSerial.h"
  37 +#include "USB_gadget.h"
38 38  
39 39 /** Circular buffer to hold data from the host before it is sent to the device via the serial port. */
40   -RingBuff_t USBtoUSART_Buffer;
  40 +static RingBuffer_t USBtoUSART_Buffer;
  41 +
  42 +/** Underlying data buffer for \ref USBtoUSART_Buffer, where the stored bytes are located. */
  43 +static uint8_t USBtoUSART_Buffer_Data[128];
41 44  
42 45 /** Circular buffer to hold data from the serial port before it is sent to the host. */
43   -RingBuff_t USARTtoUSB_Buffer;
  46 +static RingBuffer_t USARTtoUSB_Buffer;
  47 +
  48 +/** Underlying data buffer for \ref USARTtoUSB_Buffer, where the stored bytes are located. */
  49 +static uint8_t USARTtoUSB_Buffer_Data[128];
44 50  
45 51 /** LUFA CDC Class driver interface configuration and state information. This structure is
46 52 * passed to all CDC Class driver functions, so that multiple instances of the same class
... ... @@ -50,22 +56,29 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
50 56 {
51 57 .Config =
52 58 {
53   - .ControlInterfaceNumber = 0,
54   -
55   - .DataINEndpointNumber = CDC_TX_EPNUM,
56   - .DataINEndpointSize = CDC_TXRX_EPSIZE,
57   - .DataINEndpointDoubleBank = false,
58   -
59   - .DataOUTEndpointNumber = CDC_RX_EPNUM,
60   - .DataOUTEndpointSize = CDC_TXRX_EPSIZE,
61   - .DataOUTEndpointDoubleBank = false,
62   -
63   - .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM,
64   - .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE,
65   - .NotificationEndpointDoubleBank = false,
  59 + .ControlInterfaceNumber = INTERFACE_ID_CDC_CCI,
  60 + .DataINEndpoint =
  61 + {
  62 + .Address = CDC_TX_EPADDR,
  63 + .Size = CDC_TXRX_EPSIZE,
  64 + .Banks = 1,
  65 + },
  66 + .DataOUTEndpoint =
  67 + {
  68 + .Address = CDC_RX_EPADDR,
  69 + .Size = CDC_TXRX_EPSIZE,
  70 + .Banks = 1,
  71 + },
  72 + .NotificationEndpoint =
  73 + {
  74 + .Address = CDC_NOTIFICATION_EPADDR,
  75 + .Size = CDC_NOTIFICATION_EPSIZE,
  76 + .Banks = 1,
  77 + },
66 78 },
67 79 };
68 80  
  81 +
69 82 /** Main program entry point. This routine contains the overall program flow, including initial
70 83 * setup of all components and the main program loop.
71 84 */
... ... @@ -73,33 +86,56 @@ int main(void)
73 86 {
74 87 SetupHardware();
75 88  
76   - RingBuffer_InitBuffer(&USBtoUSART_Buffer);
77   - RingBuffer_InitBuffer(&USARTtoUSB_Buffer);
  89 + RingBuffer_InitBuffer(&USBtoUSART_Buffer, USBtoUSART_Buffer_Data, sizeof(USBtoUSART_Buffer_Data));
  90 + RingBuffer_InitBuffer(&USARTtoUSB_Buffer, USARTtoUSB_Buffer_Data, sizeof(USARTtoUSB_Buffer_Data));
78 91  
79 92 LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
80   - sei();
  93 + GlobalInterruptEnable();
81 94  
82 95 for (;;)
83 96 {
84   - /* Read bytes from the USB OUT endpoint into the USART transmit buffer */
85   - int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
86   - if (!(ReceivedByte < 0) && !(RingBuffer_IsFull(&USBtoUSART_Buffer)))
87   - RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte);
88   -
89   - /* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */
90   - RingBuff_Count_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer);
91   - if ((TIFR0 & (1 << TOV0)) || (BufferCount > 200))
  97 + /* Only try to read in bytes from the CDC interface if the transmit buffer is not full */
  98 + if (!(RingBuffer_IsFull(&USBtoUSART_Buffer)))
92 99 {
93   - TIFR0 |= (1 << TOV0);
  100 + int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface);
94 101  
95   - /* Read bytes from the USART receive buffer into the USB IN endpoint */
96   - while (BufferCount--)
97   - CDC_Device_SendByte(&VirtualSerial_CDC_Interface, RingBuffer_Remove(&USARTtoUSB_Buffer));
  102 + /* Store received byte into the USART transmit buffer */
  103 + if (!(ReceivedByte < 0))
  104 + RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte);
98 105 }
99 106  
100   - /* Load the next byte from the USART transmit buffer into the USART */
101   - if (!(RingBuffer_IsEmpty(&USBtoUSART_Buffer)))
102   - Serial_TxByte(RingBuffer_Remove(&USBtoUSART_Buffer));
  107 + uint16_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer);
  108 + if (BufferCount)
  109 + {
  110 + Endpoint_SelectEndpoint(VirtualSerial_CDC_Interface.Config.DataINEndpoint.Address);
  111 +
  112 + /* Check if a packet is already enqueued to the host - if so, we shouldn't try to send more data
  113 + * until it completes as there is a chance nothing is listening and a lengthy timeout could occur */
  114 + if (Endpoint_IsINReady())
  115 + {
  116 + /* Never send more than one bank size less one byte to the host at a time, so that we don't block
  117 + * while a Zero Length Packet (ZLP) to terminate the transfer is sent if the host isn't listening */
  118 + uint8_t BytesToSend = MIN(BufferCount, (CDC_TXRX_EPSIZE - 1));
  119 +
  120 + /* Read bytes from the USART receive buffer into the USB IN endpoint */
  121 + while (BytesToSend--)
  122 + {
  123 + /* Try to send the next byte of data to the host, abort if there is an error without dequeuing */
  124 + if (CDC_Device_SendByte(&VirtualSerial_CDC_Interface,
  125 + RingBuffer_Peek(&USARTtoUSB_Buffer)) != ENDPOINT_READYWAIT_NoError)
  126 + {
  127 + break;
  128 + }
  129 +
  130 + /* Dequeue the already sent byte from the buffer now we have confirmed that no transmission error occurred */
  131 + RingBuffer_Remove(&USARTtoUSB_Buffer);
  132 + }
  133 + }
  134 + }
  135 +
  136 + /* Load the next byte from the USART transmit buffer into the USART if transmit buffer space is available */
  137 + if (Serial_IsSendReady() && !(RingBuffer_IsEmpty(&USBtoUSART_Buffer)))
  138 + Serial_SendByte(RingBuffer_Remove(&USBtoUSART_Buffer));
103 139  
104 140 CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
105 141 USB_USBTask();
... ... @@ -109,19 +145,18 @@ int main(void)
109 145 /** Configures the board hardware and chip peripherals for the demo's functionality. */
110 146 void SetupHardware(void)
111 147 {
  148 +#if (ARCH == ARCH_AVR8)
112 149 /* Disable watchdog if enabled by bootloader/fuses */
113 150 MCUSR &= ~(1 << WDRF);
114 151 wdt_disable();
115 152  
116 153 /* Disable clock division */
117 154 clock_prescale_set(clock_div_1);
  155 +#endif
118 156  
119 157 /* Hardware Initialization */
120 158 LEDs_Init();
121 159 USB_Init();
122   -
123   - /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */
124   - TCCR0B = (1 << CS02);
125 160 }
126 161  
127 162 /** Event handler for the library USB Connection event. */
... ... @@ -146,8 +181,8 @@ void EVENT_USB_Device_ConfigurationChanged(void)
146 181 LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
147 182 }
148 183  
149   -/** Event handler for the library USB Unhandled Control Request event. */
150   -void EVENT_USB_Device_UnhandledControlRequest(void)
  184 +/** Event handler for the library USB Control Request reception event. */
  185 +void EVENT_USB_Device_ControlRequest(void)
151 186 {
152 187 CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface);
153 188 }
... ... @@ -159,7 +194,7 @@ ISR(USART1_RX_vect, ISR_BLOCK)
159 194 {
160 195 uint8_t ReceivedByte = UDR1;
161 196  
162   - if (USB_DeviceState == DEVICE_STATE_Configured)
  197 + if ((USB_DeviceState == DEVICE_STATE_Configured) && !(RingBuffer_IsFull(&USARTtoUSB_Buffer)))
163 198 RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte);
164 199 }
165 200  
... ... @@ -197,6 +232,9 @@ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCI
197 232 break;
198 233 }
199 234  
  235 + /* Keep the TX line held high (idle) while the USART is reconfigured */
  236 + PORTD |= (1 << 3);
  237 +
200 238 /* Must turn off USART before reconfiguring it, otherwise incorrect operation may occur */
201 239 UCSR1B = 0;
202 240 UCSR1A = 0;
... ... @@ -209,4 +247,8 @@ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCI
209 247 UCSR1C = ConfigMask;
210 248 UCSR1A = (1 << U2X1);
211 249 UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1));
  250 +
  251 + /* Release the TX line after the USART has been reconfigured */
  252 + PORTD &= ~(1 << 3);
212 253 }
  254 +
... ...
lufa/USB_gadget.h
... ... @@ -30,24 +30,23 @@
30 30  
31 31 /** \file
32 32 *
33   - * Header file for VirtualSerial.c.
  33 + * Header file for USBtoSerial.c.
34 34 */
35 35  
36   -#ifndef _VIRTUALSERIAL_H_
37   -#define _VIRTUALSERIAL_H_
  36 +#ifndef _USB_SERIAL_H_
  37 +#define _USB_SERIAL_H_
38 38  
39 39 /* Includes: */
40 40 #include <avr/io.h>
41 41 #include <avr/wdt.h>
42   - #include <avr/power.h>
43 42 #include <avr/interrupt.h>
44   - #include <string.h>
45   - #include <stdio.h>
  43 + #include <avr/power.h>
46 44  
47 45 #include "Descriptors.h"
48 46  
49   - //#include <LUFA/Drivers/Board/LEDs.h>
50   - //#include <LUFA/Drivers/Board/Joystick.h>
  47 + #include <LUFA/Drivers/Board/LEDs.h>
  48 + #include <LUFA/Drivers/Peripheral/Serial.h>
  49 + #include <LUFA/Drivers/Misc/RingBuffer.h>
51 50 #include <LUFA/Drivers/USB/USB.h>
52 51 #include <LUFA/Platform/Platform.h>
53 52  
... ... @@ -66,12 +65,13 @@
66 65  
67 66 /* Function Prototypes: */
68 67 void SetupHardware(void);
69   - void CheckJoystickMovement(void);
70 68  
71 69 void EVENT_USB_Device_Connect(void);
72 70 void EVENT_USB_Device_Disconnect(void);
73 71 void EVENT_USB_Device_ConfigurationChanged(void);
74 72 void EVENT_USB_Device_ControlRequest(void);
75 73  
  74 + void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
  75 +
76 76 #endif
77 77  
... ...
lufa/USBtoSerial.txt 0 โ†’ 100644
... ... @@ -0,0 +1,78 @@
  1 +/** \file
  2 + *
  3 + * This file contains special DoxyGen information for the generation of the main page and other special
  4 + * documentation pages. It is not a project source file.
  5 + */
  6 +
  7 +/** \mainpage USB to Serial Converter Project
  8 + *
  9 + * \section Sec_Compat Project Compatibility:
  10 + *
  11 + * The following list indicates what microcontrollers are compatible with this project.
  12 + *
  13 + * \li Series 7 USB AVRs (AT90USBxxx7)
  14 + * \li Series 6 USB AVRs (AT90USBxxx6)
  15 + * \li Series 4 USB AVRs (ATMEGAxxU4)
  16 + * \li Series 2 USB AVRs (AT90USBxx2, ATMEGAxxU2)
  17 + *
  18 + * \section Sec_Info USB Information:
  19 + *
  20 + * The following table gives a rundown of the USB utilization of this project.
  21 + *
  22 + * <table>
  23 + * <tr>
  24 + * <td><b>USB Mode:</b></td>
  25 + * <td>Device</td>
  26 + * </tr>
  27 + * <tr>
  28 + * <td><b>USB Class:</b></td>
  29 + * <td>Communications Device Class (CDC)</td>
  30 + * </tr>
  31 + * <tr>
  32 + * <td><b>USB Subclass:</b></td>
  33 + * <td>Abstract Control Model (ACM)</td>
  34 + * </tr>
  35 + * <tr>
  36 + * <td><b>Relevant Standards:</b></td>
  37 + * <td>USBIF CDC Class Standard</td>
  38 + * </tr>
  39 + * <tr>
  40 + * <td><b>Supported USB Speeds:</b></td>
  41 + * <td>Full Speed Mode</td>
  42 + * </tr>
  43 + * </table>
  44 + *
  45 + * \section Sec_Description Project Description:
  46 + *
  47 + * USB to Serial bridge project. This project allows a USB AVR to serve
  48 + * as a USB to USART bridge between a USB host and a device lacking a
  49 + * USB port. When programmed into a USB AVR, the AVR will enumerate as a
  50 + * virtual COM port.
  51 + *
  52 + * The AVR's hardware USART's settings will change to mirror as closely as
  53 + * possible the serial settings set on the host. However, due to hardware
  54 + * limitations, some options may not be supported (baud rates with unacceptable
  55 + * error rates at the AVR's clock speed, data lengths other than 6, 7 or 8 bits,
  56 + * 1.5 stop bits, parity other than none, even or odd).
  57 + *
  58 + * After running this project for the first time on a new computer,
  59 + * you will need to supply the .INF file located in this project
  60 + * project's directory as the device's driver when running under
  61 + * Windows. This will enable Windows to use its inbuilt CDC drivers,
  62 + * negating the need for custom drivers for the device. Other
  63 + * Operating Systems should automatically use their own inbuilt
  64 + * CDC-ACM drivers.
  65 + *
  66 + * \section Sec_Options Project Options
  67 + *
  68 + * The following defines can be found in this project, which can control the project behaviour when defined, or changed in value.
  69 + *
  70 + * <table>
  71 + * <tr>
  72 + * <td>
  73 + * None
  74 + * </td>
  75 + * </tr>
  76 + * </table>
  77 + */
  78 +
... ...
lufa/asf.xml
1 1 <asf xmlversion="1.0">
2   - <project caption="Virtual Serial CDC Device Demo (Class Driver APIs)" id="lufa.demos.device.class.cdc.example.avr8">
3   - <require idref="lufa.demos.device.class.cdc"/>
  2 + <project caption="USB to Serial Converter" id="lufa.projects.usb_to_serial.avr8">
  3 + <require idref="lufa.projects.usb_to_serial"/>
4 4 <require idref="lufa.boards.dummy.avr8"/>
5 5 <generator value="as5_8"/>
6 6  
7 7 <device-support value="at90usb1287"/>
8   - <config name="lufa.drivers.board.name" value="none"/>
  8 + <config name="lufa.drivers.board.name" value="usbkey"/>
9 9  
10   - <build type="define" name="F_CPU" value="16000000UL"/>
11   - <build type="define" name="F_USB" value="16000000UL"/>
  10 + <build type="define" name="F_CPU" value="8000000UL"/>
  11 + <build type="define" name="F_USB" value="8000000UL"/>
12 12 </project>
13 13  
14   - <project caption="Virtual Serial CDC Device Demo (Class Driver APIs)" id="lufa.demos.device.class.cdc.example.xmega">
15   - <require idref="lufa.demos.device.class.cdc"/>
16   - <require idref="lufa.boards.dummy.xmega"/>
17   - <generator value="as5_8"/>
18   -
19   - <device-support value="atxmega128a1u"/>
20   - <config name="lufa.drivers.board.name" value="none"/>
21   -
22   - <build type="define" name="F_CPU" value="32000000UL"/>
23   - <build type="define" name="F_USB" value="48000000UL"/>
24   - </project>
25   -
26   - <module type="application" id="lufa.demos.device.class.cdc" caption="Virtual Serial CDC Device Demo (Class Driver APIs)">
  14 + <module type="application" id="lufa.projects.usb_to_serial" caption="USB to Serial Converter">
27 15 <info type="description" value="summary">
28   - Virtual Serial device demo, implementing a virtual serial channel between the host PC and the device. This demo uses the user-friendly USB Class Driver APIs to provide a simple, abstracted interface into the USB stack.
  16 + USB to Serial USART converter project.
29 17 </info>
30 18  
31 19 <info type="gui-flag" value="move-to-root"/>
... ... @@ -41,12 +29,12 @@
41 29 <device-support-alias value="lufa_uc3"/>
42 30  
43 31 <build type="distribute" subtype="user-file" value="doxyfile"/>
44   - <build type="distribute" subtype="user-file" value="VirtualSerial.txt"/>
45   - <build type="distribute" subtype="user-file" value="LUFA VirtualSerial.inf"/>
  32 + <build type="distribute" subtype="user-file" value="USBtoSerial.txt"/>
  33 + <build type="distribute" subtype="user-file" value="LUFA USBtoSerial.inf"/>
46 34  
47   - <build type="c-source" value="VirtualSerial.c"/>
  35 + <build type="c-source" value="USBtoSerial.c"/>
48 36 <build type="c-source" value="Descriptors.c"/>
49   - <build type="header-file" value="VirtualSerial.h"/>
  37 + <build type="header-file" value="USBtoSerial.h"/>
50 38 <build type="header-file" value="Descriptors.h"/>
51 39  
52 40 <build type="module-config" subtype="path" value="Config"/>
... ... @@ -54,9 +42,10 @@
54 42  
55 43 <require idref="lufa.common"/>
56 44 <require idref="lufa.platform"/>
  45 + <require idref="lufa.drivers.peripheral.usart"/>
57 46 <require idref="lufa.drivers.usb"/>
58 47 <require idref="lufa.drivers.board"/>
59 48 <require idref="lufa.drivers.board.leds"/>
60   - <require idref="lufa.drivers.board.joystick"/>
  49 + <require idref="lufa.drivers.misc.ringbuffer"/>
61 50 </module>
62 51 </asf>
... ...
lufa/doxyfile
... ... @@ -32,7 +32,7 @@ DOXYFILE_ENCODING = UTF-8
32 32 # title of most generated pages and in a few other places.
33 33 # The default value is: My Project.
34 34  
35   -PROJECT_NAME = "LUFA Library - Virtual Serial Device Demo"
  35 +PROJECT_NAME = "LUFA Library - USB to Serial Device Project"
36 36  
37 37 # The PROJECT_NUMBER tag can be used to enter a project or revision number. This
38 38 # could be handy for archiving the generated documentation or if some version
... ...
lufa/makefile
... ... @@ -17,9 +17,9 @@ BOARD = USBKEY
17 17 F_CPU = 8000000
18 18 F_USB = $(F_CPU)
19 19 OPTIMIZATION = s
20   -TARGET = VirtualSerial
  20 +TARGET = USB_gadget
21 21 SRC = $(TARGET).c Descriptors.c $(LUFA_SRC_USB) $(LUFA_SRC_USBCLASS)
22   -LUFA_PATH = ../../../../LUFA
  22 +LUFA_PATH = ../../LUFA
23 23 CC_FLAGS = -DUSE_LUFA_CONFIG_HEADER -IConfig/
24 24 LD_FLAGS =
25 25  
... ...