├── Bootloaders ├── readme.txt └── sparkfun-usbdfu-v10 │ ├── Board │ └── LEDs.h │ ├── Descriptors.c │ ├── Descriptors.h │ ├── makefile │ ├── sparkfun-usbdfu.c │ ├── sparkfun-usbdfu.h │ └── sparkfun-usbdfu.hex ├── Projects ├── readme.txt └── sparkfun_USBtoSerial-v10 │ ├── Board │ └── LEDs.h │ ├── Descriptors.c │ ├── Descriptors.h │ ├── Lib │ └── LightweightRingBuff.h │ ├── makefile │ ├── sparkfun_USBtoSerial.c │ ├── sparkfun_USBtoSerial.h │ └── sparkfun_USBtoSerial.hex ├── README.txt ├── sparkfun_USBtoSerial_combined.hex └── sparkfun_USBtoSerial_driver.inf /Bootloaders/readme.txt: -------------------------------------------------------------------------------- 1 | Usage: 2 | 3 | -Download Atmel's Flip 4 | -open a command prompt 5 | -cd into the project (e.g. \sparkfun-usbdfu-v10) directory 6 | -make clean 7 | -make 8 | -grab hex and load via AVR programmer and AVRStudio 9 | -change fuses to (for SparkFun USBtoSerial) HF: 0xD9, LF: 0xFF, EF:0xF4, Lock:0x0F 10 | -unplug then replug board, divers are found in the Flip directories 11 | -if correct driver is used, board should enumerate as a *AT90USB82* 12 | -now the board is ready to bootload code over USB using the Flip software 13 | 14 | *ATTENTION* Be sure to use the AT90USB82 as the device in the FLIP software 15 | -------------------------------------------------------------------------------- /Bootloaders/sparkfun-usbdfu-v10/Board/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /* 32 | Board LEDs driver for the Benito board, from www.dorkbotpdx.org. 33 | */ 34 | 35 | #ifndef __LEDS_ARDUINOUNO_H__ 36 | #define __LEDS_ARDUINOUNO_H__ 37 | 38 | /* Includes: */ 39 | #include 40 | 41 | /* Enable C linkage for C++ Compilers: */ 42 | #if defined(__cplusplus) 43 | extern "C" { 44 | #endif 45 | 46 | /* Preprocessor Checks: */ 47 | #if !defined(INCLUDE_FROM_LEDS_H) 48 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 49 | #endif 50 | 51 | /* Public Interface - May be used in end-application: */ 52 | /* Macros: */ 53 | /** LED mask for the first LED on the board. */ 54 | #define LEDS_LED1 (1 << 5) 55 | 56 | /** LED mask for the second LED on the board. */ 57 | #define LEDS_LED2 (1 << 4) 58 | 59 | /** LED mask for all the LEDs on the board. */ 60 | #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) 61 | 62 | /** LED mask for the none of the board LEDs */ 63 | #define LEDS_NO_LEDS 0 64 | 65 | /* Inline Functions: */ 66 | #if !defined(__DOXYGEN__) 67 | static inline void LEDs_Init(void) 68 | { 69 | DDRD |= LEDS_ALL_LEDS; 70 | PORTD |= LEDS_ALL_LEDS; 71 | } 72 | 73 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 74 | { 75 | PORTD &= ~LEDMask; 76 | } 77 | 78 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 79 | { 80 | PORTD |= LEDMask; 81 | } 82 | 83 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 84 | { 85 | PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); 86 | } 87 | 88 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) 89 | { 90 | PORTD = ((PORTD | ActiveMask) & ~LEDMask); 91 | } 92 | 93 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 94 | { 95 | PORTD ^= LEDMask; 96 | } 97 | 98 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 99 | static inline uint8_t LEDs_GetLEDs(void) 100 | { 101 | return (PORTD & LEDS_ALL_LEDS); 102 | } 103 | #endif 104 | 105 | /* Disable C linkage for C++ Compilers: */ 106 | #if defined(__cplusplus) 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /Bootloaders/sparkfun-usbdfu-v10/Descriptors.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * USB Device Descriptors, for library use when in USB device mode. Descriptors are special 34 | * computer-readable structures which the host requests upon device enumeration, to determine 35 | * the device's capabilities and functions. 36 | */ 37 | 38 | #include "Descriptors.h" 39 | 40 | /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall 41 | * device characteristics, including the supported USB version, control endpoint size and the 42 | * number of device configurations. The descriptor is read out by the USB host when the enumeration 43 | * process begins. 44 | */ 45 | USB_Descriptor_Device_t DeviceDescriptor = 46 | { 47 | .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, 48 | 49 | .USBSpecification = VERSION_BCD(01.10), 50 | .Class = 0x00, 51 | .SubClass = 0x00, 52 | .Protocol = 0x00, 53 | 54 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, 55 | 56 | .VendorID = 0x03EB, // Atmel 57 | .ProductID = PRODUCT_ID_CODE, // MCU-dependent 58 | .ReleaseNumber = 0x0000, 59 | 60 | .ManufacturerStrIndex = NO_DESCRIPTOR, 61 | .ProductStrIndex = 0x01, 62 | .SerialNumStrIndex = NO_DESCRIPTOR, 63 | 64 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS 65 | }; 66 | 67 | /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage 68 | * of the device in one of its supported configurations, including information about any device interfaces 69 | * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting 70 | * a configuration so that the host may correctly communicate with the USB device. 71 | */ 72 | USB_Descriptor_Configuration_t ConfigurationDescriptor = 73 | { 74 | .Config = 75 | { 76 | .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, 77 | 78 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), 79 | .TotalInterfaces = 1, 80 | 81 | .ConfigurationNumber = 1, 82 | .ConfigurationStrIndex = NO_DESCRIPTOR, 83 | 84 | .ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED, 85 | 86 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) 87 | }, 88 | 89 | .DFU_Interface = 90 | { 91 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 92 | 93 | .InterfaceNumber = 0, 94 | .AlternateSetting = 0, 95 | 96 | .TotalEndpoints = 0, 97 | 98 | .Class = 0xFE, 99 | .SubClass = 0x01, 100 | .Protocol = 0x02, 101 | 102 | .InterfaceStrIndex = NO_DESCRIPTOR 103 | }, 104 | 105 | .DFU_Functional = 106 | { 107 | .Header = {.Size = sizeof(USB_DFU_Functional_Descriptor_t), .Type = DTYPE_DFUFunctional}, 108 | 109 | .Attributes = (ATTR_CAN_UPLOAD | ATTR_CAN_DOWNLOAD), 110 | 111 | .DetachTimeout = 0x0000, 112 | .TransferSize = 0x0c00, 113 | 114 | .DFUSpecification = VERSION_BCD(01.01) 115 | } 116 | }; 117 | 118 | /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests 119 | * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate 120 | * via the language ID table available at USB.org what languages the device supports for its string descriptors. 121 | */ 122 | USB_Descriptor_String_t LanguageString = 123 | { 124 | .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, 125 | 126 | .UnicodeString = {LANGUAGE_ID_ENG} 127 | }; 128 | 129 | /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, 130 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device 131 | * Descriptor. 132 | */ 133 | USB_Descriptor_String_t ProductString = 134 | { 135 | .Header = {.Size = USB_STRING_LEN(19), .Type = DTYPE_String}, 136 | 137 | .UnicodeString = L"SparkFun Bootloader" 138 | }; 139 | 140 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" 141 | * documentation) by the application code so that the address and size of a requested descriptor can be given 142 | * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function 143 | * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the 144 | * USB host. 145 | */ 146 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 147 | const uint8_t wIndex, 148 | void** const DescriptorAddress) 149 | { 150 | const uint8_t DescriptorType = (wValue >> 8); 151 | const uint8_t DescriptorNumber = (wValue & 0xFF); 152 | 153 | void* Address = NULL; 154 | uint16_t Size = NO_DESCRIPTOR; 155 | 156 | switch (DescriptorType) 157 | { 158 | case DTYPE_Device: 159 | Address = &DeviceDescriptor; 160 | Size = sizeof(USB_Descriptor_Device_t); 161 | break; 162 | case DTYPE_Configuration: 163 | Address = &ConfigurationDescriptor; 164 | Size = sizeof(USB_Descriptor_Configuration_t); 165 | break; 166 | case DTYPE_String: 167 | if (!(DescriptorNumber)) 168 | { 169 | Address = &LanguageString; 170 | Size = LanguageString.Header.Size; 171 | } 172 | else 173 | { 174 | Address = &ProductString; 175 | Size = ProductString.Header.Size; 176 | } 177 | 178 | break; 179 | } 180 | 181 | *DescriptorAddress = Address; 182 | return Size; 183 | } 184 | -------------------------------------------------------------------------------- /Bootloaders/sparkfun-usbdfu-v10/Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Descriptors.c. 34 | */ 35 | 36 | #ifndef _DESCRIPTORS_H_ 37 | #define _DESCRIPTORS_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | /* Macros: */ 43 | /** Descriptor type value for a DFU class functional descriptor. */ 44 | #define DTYPE_DFUFunctional 0x21 45 | 46 | /** DFU attribute mask, indicating that the DFU device will detach and re-attach when a DFU_DETACH 47 | * command is issued, rather than the host issuing a USB Reset. 48 | */ 49 | #define ATTR_WILL_DETATCH (1 << 3) 50 | 51 | /** DFU attribute mask, indicating that the DFU device can communicate during the manifestation phase 52 | * (memory programming phase). 53 | */ 54 | #define ATTR_MANEFESTATION_TOLLERANT (1 << 2) 55 | 56 | /** DFU attribute mask, indicating that the DFU device can accept DFU_UPLOAD requests to send data from 57 | * the device to the host. 58 | */ 59 | #define ATTR_CAN_UPLOAD (1 << 1) 60 | 61 | /** DFU attribute mask, indicating that the DFU device can accept DFU_DNLOAD requests to send data from 62 | * the host to the device. 63 | */ 64 | #define ATTR_CAN_DOWNLOAD (1 << 0) 65 | 66 | #if defined(__AVR_AT90USB1287__) 67 | #define PRODUCT_ID_CODE 0x2FFB 68 | #define AVR_SIGNATURE_1 0x1E 69 | #define AVR_SIGNATURE_2 0x97 70 | #define AVR_SIGNATURE_3 0x82 71 | #elif defined(__AVR_AT90USB1286__) 72 | #define PRODUCT_ID_CODE 0x2FFB 73 | #define AVR_SIGNATURE_1 0x1E 74 | #define AVR_SIGNATURE_2 0x97 75 | #define AVR_SIGNATURE_3 0x82 76 | #elif defined(__AVR_AT90USB647__) 77 | #define PRODUCT_ID_CODE 0x2FF9 78 | #define AVR_SIGNATURE_1 0x1E 79 | #define AVR_SIGNATURE_2 0x96 80 | #define AVR_SIGNATURE_3 0x82 81 | #elif defined(__AVR_AT90USB646__) 82 | #define PRODUCT_ID_CODE 0x2FF9 83 | #define AVR_SIGNATURE_1 0x1E 84 | #define AVR_SIGNATURE_2 0x96 85 | #define AVR_SIGNATURE_3 0x82 86 | #elif defined(__AVR_ATmega32U6__) 87 | #define PRODUCT_ID_CODE 0x2FFB 88 | #define AVR_SIGNATURE_1 0x1E 89 | #define AVR_SIGNATURE_2 0x95 90 | #define AVR_SIGNATURE_3 0x88 91 | #elif defined(__AVR_ATmega32U4__) 92 | #define PRODUCT_ID_CODE 0x2FF4 93 | #define AVR_SIGNATURE_1 0x1E 94 | #define AVR_SIGNATURE_2 0x95 95 | #define AVR_SIGNATURE_3 0x87 96 | #elif defined(__AVR_ATmega32U2__) 97 | #define PRODUCT_ID_CODE 0x2FF0 98 | #define AVR_SIGNATURE_1 0x1E 99 | #define AVR_SIGNATURE_2 0x95 100 | #define AVR_SIGNATURE_3 0x8A 101 | #elif defined(__AVR_ATmega16U4__) 102 | #define PRODUCT_ID_CODE 0x2FF3 103 | #define AVR_SIGNATURE_1 0x1E 104 | #define AVR_SIGNATURE_2 0x94 105 | #define AVR_SIGNATURE_3 0x88 106 | #elif defined(__AVR_ATmega16U2__) 107 | #define PRODUCT_ID_CODE 0x2FEF 108 | #define AVR_SIGNATURE_1 0x1E 109 | #define AVR_SIGNATURE_2 0x94 110 | #define AVR_SIGNATURE_3 0x89 111 | #elif defined(__AVR_AT90USB162__) 112 | #define PRODUCT_ID_CODE 0x2FFA 113 | #define AVR_SIGNATURE_1 0x1E 114 | #define AVR_SIGNATURE_2 0x94 115 | #define AVR_SIGNATURE_3 0x82 116 | #elif defined(__AVR_AT90USB82__) 117 | #define PRODUCT_ID_CODE 0x2FEE 118 | #define AVR_SIGNATURE_1 0x1E 119 | #define AVR_SIGNATURE_2 0x93 120 | #define AVR_SIGNATURE_3 0x89 121 | #elif defined(__AVR_ATmega8U2__) 122 | #define PRODUCT_ID_CODE 0x2FF7 123 | #define AVR_SIGNATURE_1 0x1E 124 | #define AVR_SIGNATURE_2 0x93 125 | #define AVR_SIGNATURE_3 0x82 126 | #else 127 | #error The selected AVR part is not currently supported by this bootloader. 128 | #endif 129 | 130 | #if !defined(PRODUCT_ID_CODE) 131 | #error Current AVR model is not supported by this bootloader. 132 | #endif 133 | 134 | /* Type Defines: */ 135 | /** Type define for a DFU class function descriptor. This descriptor gives DFU class information 136 | * to the host when read, indicating the DFU device's capabilities. 137 | */ 138 | typedef struct 139 | { 140 | USB_Descriptor_Header_t Header; /**< Standard descriptor header structure */ 141 | 142 | uint8_t Attributes; /**< DFU device attributes, a mask comprising of the 143 | * ATTR_* macros listed in this source file 144 | */ 145 | uint16_t DetachTimeout; /**< Timeout in milliseconds between a USB_DETACH 146 | * command being issued and the device detaching 147 | * from the USB bus 148 | */ 149 | uint16_t TransferSize; /**< Maximum number of bytes the DFU device can accept 150 | * from the host in a transaction 151 | */ 152 | uint16_t DFUSpecification; /**< BCD packed DFU specification number this DFU 153 | * device complies with 154 | */ 155 | } USB_DFU_Functional_Descriptor_t; 156 | 157 | /** Type define for the device configuration descriptor structure. This must be defined in the 158 | * application code, as the configuration descriptor contains several sub-descriptors which 159 | * vary between devices, and which describe the device's usage to the host. 160 | */ 161 | typedef struct 162 | { 163 | USB_Descriptor_Configuration_Header_t Config; 164 | USB_Descriptor_Interface_t DFU_Interface; 165 | USB_DFU_Functional_Descriptor_t DFU_Functional; 166 | } USB_Descriptor_Configuration_t; 167 | 168 | /* Function Prototypes: */ 169 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 170 | const uint8_t wIndex, 171 | void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); 172 | 173 | #endif 174 | -------------------------------------------------------------------------------- /Bootloaders/sparkfun-usbdfu-v10/makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitsmashed/SparkFun-USBtoSerial/9af40178a83abf6712ae7fd74b576ac0fef3585c/Bootloaders/sparkfun-usbdfu-v10/makefile -------------------------------------------------------------------------------- /Bootloaders/sparkfun-usbdfu-v10/sparkfun-usbdfu.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Main source file for the DFU class bootloader. This file contains the complete bootloader logic. 34 | */ 35 | 36 | #define INCLUDE_FROM_BOOTLOADER_C 37 | #include "sparkfun-usbdfu.h" 38 | 39 | /** Flag to indicate if the bootloader should be running, or should exit and allow the application code to run 40 | * via a soft reset. When cleared, the bootloader will abort, the USB interface will shut down and the application 41 | * jumped to via an indirect jump to location 0x0000 (or other location specified by the host). 42 | */ 43 | bool RunBootloader = true; 44 | 45 | /** Flag to indicate if the bootloader is waiting to exit. When the host requests the bootloader to exit and 46 | * jump to the application address it specifies, it sends two sequential commands which must be properly 47 | * acknowledged. Upon reception of the first the RunBootloader flag is cleared and the WaitForExit flag is set, 48 | * causing the bootloader to wait for the final exit command before shutting down. 49 | */ 50 | bool WaitForExit = false; 51 | 52 | /** Current DFU state machine state, one of the values in the DFU_State_t enum. */ 53 | uint8_t DFU_State = dfuIDLE; 54 | 55 | /** Status code of the last executed DFU command. This is set to one of the values in the DFU_Status_t enum after 56 | * each operation, and returned to the host when a Get Status DFU request is issued. 57 | */ 58 | uint8_t DFU_Status = OK; 59 | 60 | /** Data containing the DFU command sent from the host. */ 61 | DFU_Command_t SentCommand; 62 | 63 | /** Response to the last issued Read Data DFU command. Unlike other DFU commands, the read command 64 | * requires a single byte response from the bootloader containing the read data when the next DFU_UPLOAD command 65 | * is issued by the host. 66 | */ 67 | uint8_t ResponseByte; 68 | 69 | /** Pointer to the start of the user application. By default this is 0x0000 (the reset vector), however the host 70 | * may specify an alternate address when issuing the application soft-start command. 71 | */ 72 | AppPtr_t AppStartPtr = (AppPtr_t)0x0000; 73 | 74 | /** 64-bit flash page number. This is concatenated with the current 16-bit address on USB AVRs containing more than 75 | * 64KB of flash memory. 76 | */ 77 | uint8_t Flash64KBPage = 0; 78 | 79 | /** Memory start address, indicating the current address in the memory being addressed (either FLASH or EEPROM 80 | * depending on the issued command from the host). 81 | */ 82 | uint16_t StartAddr = 0x0000; 83 | 84 | /** Memory end address, indicating the end address to read to/write from in the memory being addressed (either FLASH 85 | * of EEPROM depending on the issued command from the host). 86 | */ 87 | uint16_t EndAddr = 0x0000; 88 | 89 | 90 | /** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ 91 | volatile struct 92 | { 93 | uint8_t TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ 94 | uint8_t RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ 95 | uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */ 96 | } PulseMSRemaining; 97 | 98 | /** Main program entry point. This routine configures the hardware required by the bootloader, then continuously 99 | * runs the bootloader processing routine until instructed to soft-exit, or hard-reset via the watchdog to start 100 | * the loaded application code. 101 | */ 102 | int main(void) 103 | { 104 | /* Configure hardware required by the bootloader */ 105 | SetupHardware(); 106 | 107 | /* Enable global interrupts so that the USB stack can function */ 108 | sei(); 109 | 110 | /* Run the USB management task while the bootloader is supposed to be running */ 111 | while (RunBootloader || WaitForExit) 112 | USB_USBTask(); 113 | 114 | /* Reset configured hardware back to their original states for the user application */ 115 | ResetHardware(); 116 | 117 | /* Start the user application */ 118 | AppStartPtr(); 119 | } 120 | 121 | /** Configures all hardware required for the bootloader. */ 122 | void SetupHardware(void) 123 | { 124 | /* Disable watchdog if enabled by bootloader/fuses */ 125 | MCUSR &= ~(1 << WDRF); 126 | wdt_disable(); 127 | 128 | /* Disable clock division */ 129 | // clock_prescale_set(clock_div_1); 130 | 131 | /* Relocate the interrupt vector table to the bootloader section */ 132 | MCUCR = (1 << IVCE); 133 | MCUCR = (1 << IVSEL); 134 | 135 | LEDs_Init(); 136 | 137 | /* Initialize the USB subsystem */ 138 | USB_Init(); 139 | } 140 | 141 | /** Resets all configured hardware required for the bootloader back to their original states. */ 142 | void ResetHardware(void) 143 | { 144 | /* Shut down the USB subsystem */ 145 | USB_ShutDown(); 146 | 147 | /* Relocate the interrupt vector table back to the application section */ 148 | MCUCR = (1 << IVCE); 149 | MCUCR = 0; 150 | } 151 | 152 | /** Event handler for the USB_UnhandledControlRequest event. This is used to catch standard and class specific 153 | * control requests that are not handled internally by the USB library (including the DFU commands, which are 154 | * all issued via the control endpoint), so that they can be handled appropriately for the application. 155 | */ 156 | void EVENT_USB_Device_UnhandledControlRequest(void) 157 | { 158 | /* Get the size of the command and data from the wLength value */ 159 | SentCommand.DataSize = USB_ControlRequest.wLength; 160 | 161 | /* Turn off TX LED(s) once the TX pulse period has elapsed */ 162 | if (PulseMSRemaining.TxLEDPulse && !(--PulseMSRemaining.TxLEDPulse)) 163 | LEDs_TurnOffLEDs(LEDMASK_TX); 164 | 165 | /* Turn off RX LED(s) once the RX pulse period has elapsed */ 166 | if (PulseMSRemaining.RxLEDPulse && !(--PulseMSRemaining.RxLEDPulse)) 167 | LEDs_TurnOffLEDs(LEDMASK_RX); 168 | 169 | switch (USB_ControlRequest.bRequest) 170 | { 171 | case DFU_DNLOAD: 172 | LEDs_TurnOnLEDs(LEDMASK_RX); 173 | PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS; 174 | 175 | Endpoint_ClearSETUP(); 176 | 177 | /* Check if bootloader is waiting to terminate */ 178 | if (WaitForExit) 179 | { 180 | /* Bootloader is terminating - process last received command */ 181 | ProcessBootloaderCommand(); 182 | 183 | /* Turn off TX/RX status LEDs so that they're not left on when application starts */ 184 | LEDs_TurnOffLEDs(LEDMASK_TX); 185 | LEDs_TurnOffLEDs(LEDMASK_RX); 186 | 187 | /* Indicate that the last command has now been processed - free to exit bootloader */ 188 | WaitForExit = false; 189 | } 190 | 191 | /* If the request has a data stage, load it into the command struct */ 192 | if (SentCommand.DataSize) 193 | { 194 | while (!(Endpoint_IsOUTReceived())) 195 | { 196 | if (USB_DeviceState == DEVICE_STATE_Unattached) 197 | return; 198 | } 199 | 200 | /* First byte of the data stage is the DNLOAD request's command */ 201 | SentCommand.Command = Endpoint_Read_Byte(); 202 | 203 | /* One byte of the data stage is the command, so subtract it from the total data bytes */ 204 | SentCommand.DataSize--; 205 | 206 | /* Load in the rest of the data stage as command parameters */ 207 | for (uint8_t DataByte = 0; (DataByte < sizeof(SentCommand.Data)) && 208 | Endpoint_BytesInEndpoint(); DataByte++) 209 | { 210 | SentCommand.Data[DataByte] = Endpoint_Read_Byte(); 211 | SentCommand.DataSize--; 212 | } 213 | 214 | /* Process the command */ 215 | ProcessBootloaderCommand(); 216 | } 217 | 218 | /* Check if currently downloading firmware */ 219 | if (DFU_State == dfuDNLOAD_IDLE) 220 | { 221 | if (!(SentCommand.DataSize)) 222 | { 223 | DFU_State = dfuIDLE; 224 | } 225 | else 226 | { 227 | /* Throw away the filler bytes before the start of the firmware */ 228 | DiscardFillerBytes(DFU_FILLER_BYTES_SIZE); 229 | 230 | /* Throw away the packet alignment filler bytes before the start of the firmware */ 231 | DiscardFillerBytes(StartAddr % FIXED_CONTROL_ENDPOINT_SIZE); 232 | 233 | /* Calculate the number of bytes remaining to be written */ 234 | uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); 235 | 236 | if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Write flash 237 | { 238 | /* Calculate the number of words to be written from the number of bytes to be written */ 239 | uint16_t WordsRemaining = (BytesRemaining >> 1); 240 | 241 | union 242 | { 243 | uint16_t Words[2]; 244 | uint32_t Long; 245 | } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; 246 | 247 | uint32_t CurrFlashPageStartAddress = CurrFlashAddress.Long; 248 | uint8_t WordsInFlashPage = 0; 249 | 250 | while (WordsRemaining--) 251 | { 252 | /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ 253 | if (!(Endpoint_BytesInEndpoint())) 254 | { 255 | Endpoint_ClearOUT(); 256 | 257 | while (!(Endpoint_IsOUTReceived())) 258 | { 259 | if (USB_DeviceState == DEVICE_STATE_Unattached) 260 | return; 261 | } 262 | } 263 | 264 | /* Write the next word into the current flash page */ 265 | boot_page_fill(CurrFlashAddress.Long, Endpoint_Read_Word_LE()); 266 | 267 | /* Adjust counters */ 268 | WordsInFlashPage += 1; 269 | CurrFlashAddress.Long += 2; 270 | 271 | /* See if an entire page has been written to the flash page buffer */ 272 | if ((WordsInFlashPage == (SPM_PAGESIZE >> 1)) || !(WordsRemaining)) 273 | { 274 | /* Commit the flash page to memory */ 275 | boot_page_write(CurrFlashPageStartAddress); 276 | boot_spm_busy_wait(); 277 | 278 | /* Check if programming incomplete */ 279 | if (WordsRemaining) 280 | { 281 | CurrFlashPageStartAddress = CurrFlashAddress.Long; 282 | WordsInFlashPage = 0; 283 | 284 | /* Erase next page's temp buffer */ 285 | boot_page_erase(CurrFlashAddress.Long); 286 | boot_spm_busy_wait(); 287 | } 288 | } 289 | } 290 | 291 | /* Once programming complete, start address equals the end address */ 292 | StartAddr = EndAddr; 293 | 294 | /* Re-enable the RWW section of flash */ 295 | boot_rww_enable(); 296 | } 297 | else // Write EEPROM 298 | { 299 | while (BytesRemaining--) 300 | { 301 | /* Check if endpoint is empty - if so clear it and wait until ready for next packet */ 302 | if (!(Endpoint_BytesInEndpoint())) 303 | { 304 | Endpoint_ClearOUT(); 305 | 306 | while (!(Endpoint_IsOUTReceived())) 307 | { 308 | if (USB_DeviceState == DEVICE_STATE_Unattached) 309 | return; 310 | } 311 | } 312 | 313 | /* Read the byte from the USB interface and write to to the EEPROM */ 314 | eeprom_write_byte((uint8_t*)StartAddr, Endpoint_Read_Byte()); 315 | 316 | /* Adjust counters */ 317 | StartAddr++; 318 | } 319 | } 320 | 321 | /* Throw away the currently unused DFU file suffix */ 322 | DiscardFillerBytes(DFU_FILE_SUFFIX_SIZE); 323 | } 324 | } 325 | 326 | Endpoint_ClearOUT(); 327 | 328 | Endpoint_ClearStatusStage(); 329 | 330 | break; 331 | case DFU_UPLOAD: 332 | Endpoint_ClearSETUP(); 333 | 334 | LEDs_TurnOnLEDs(LEDMASK_TX); 335 | PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS; 336 | 337 | while (!(Endpoint_IsINReady())) 338 | { 339 | if (USB_DeviceState == DEVICE_STATE_Unattached) 340 | return; 341 | } 342 | 343 | if (DFU_State != dfuUPLOAD_IDLE) 344 | { 345 | if ((DFU_State == dfuERROR) && IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank Check 346 | { 347 | /* Blank checking is performed in the DFU_DNLOAD request - if we get here we've told the host 348 | that the memory isn't blank, and the host is requesting the first non-blank address */ 349 | Endpoint_Write_Word_LE(StartAddr); 350 | } 351 | else 352 | { 353 | /* Idle state upload - send response to last issued command */ 354 | Endpoint_Write_Byte(ResponseByte); 355 | } 356 | } 357 | else 358 | { 359 | /* Determine the number of bytes remaining in the current block */ 360 | uint16_t BytesRemaining = ((EndAddr - StartAddr) + 1); 361 | 362 | if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read FLASH 363 | { 364 | /* Calculate the number of words to be written from the number of bytes to be written */ 365 | uint16_t WordsRemaining = (BytesRemaining >> 1); 366 | 367 | union 368 | { 369 | uint16_t Words[2]; 370 | uint32_t Long; 371 | } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; 372 | 373 | while (WordsRemaining--) 374 | { 375 | /* Check if endpoint is full - if so clear it and wait until ready for next packet */ 376 | if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) 377 | { 378 | Endpoint_ClearIN(); 379 | 380 | while (!(Endpoint_IsINReady())) 381 | { 382 | if (USB_DeviceState == DEVICE_STATE_Unattached) 383 | return; 384 | } 385 | } 386 | 387 | /* Read the flash word and send it via USB to the host */ 388 | #if (FLASHEND > 0xFFFF) 389 | Endpoint_Write_Word_LE(pgm_read_word_far(CurrFlashAddress.Long)); 390 | #else 391 | Endpoint_Write_Word_LE(pgm_read_word(CurrFlashAddress.Long)); 392 | #endif 393 | 394 | /* Adjust counters */ 395 | CurrFlashAddress.Long += 2; 396 | } 397 | 398 | /* Once reading is complete, start address equals the end address */ 399 | StartAddr = EndAddr; 400 | } 401 | else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM 402 | { 403 | while (BytesRemaining--) 404 | { 405 | /* Check if endpoint is full - if so clear it and wait until ready for next packet */ 406 | if (Endpoint_BytesInEndpoint() == FIXED_CONTROL_ENDPOINT_SIZE) 407 | { 408 | Endpoint_ClearIN(); 409 | 410 | while (!(Endpoint_IsINReady())) 411 | { 412 | if (USB_DeviceState == DEVICE_STATE_Unattached) 413 | return; 414 | } 415 | } 416 | 417 | /* Read the EEPROM byte and send it via USB to the host */ 418 | Endpoint_Write_Byte(eeprom_read_byte((uint8_t*)StartAddr)); 419 | 420 | /* Adjust counters */ 421 | StartAddr++; 422 | } 423 | } 424 | 425 | /* Return to idle state */ 426 | DFU_State = dfuIDLE; 427 | } 428 | 429 | Endpoint_ClearIN(); 430 | 431 | Endpoint_ClearStatusStage(); 432 | break; 433 | case DFU_GETSTATUS: 434 | Endpoint_ClearSETUP(); 435 | 436 | /* Write 8-bit status value */ 437 | Endpoint_Write_Byte(DFU_Status); 438 | 439 | /* Write 24-bit poll timeout value */ 440 | Endpoint_Write_Byte(0); 441 | Endpoint_Write_Word_LE(0); 442 | 443 | /* Write 8-bit state value */ 444 | Endpoint_Write_Byte(DFU_State); 445 | 446 | /* Write 8-bit state string ID number */ 447 | Endpoint_Write_Byte(0); 448 | 449 | Endpoint_ClearIN(); 450 | 451 | Endpoint_ClearStatusStage(); 452 | break; 453 | case DFU_CLRSTATUS: 454 | Endpoint_ClearSETUP(); 455 | 456 | /* Reset the status value variable to the default OK status */ 457 | DFU_Status = OK; 458 | 459 | Endpoint_ClearStatusStage(); 460 | break; 461 | case DFU_GETSTATE: 462 | Endpoint_ClearSETUP(); 463 | 464 | /* Write the current device state to the endpoint */ 465 | Endpoint_Write_Byte(DFU_State); 466 | 467 | Endpoint_ClearIN(); 468 | 469 | Endpoint_ClearStatusStage(); 470 | break; 471 | case DFU_ABORT: 472 | Endpoint_ClearSETUP(); 473 | 474 | /* Turn off TX/RX status LEDs so that they're not left on when application starts */ 475 | LEDs_TurnOffLEDs(LEDMASK_TX); 476 | LEDs_TurnOffLEDs(LEDMASK_RX); 477 | 478 | /* Reset the current state variable to the default idle state */ 479 | DFU_State = dfuIDLE; 480 | 481 | Endpoint_ClearStatusStage(); 482 | break; 483 | } 484 | } 485 | 486 | /** Routine to discard the specified number of bytes from the control endpoint stream. This is used to 487 | * discard unused bytes in the stream from the host, including the memory program block suffix. 488 | * 489 | * \param[in] NumberOfBytes Number of bytes to discard from the host from the control endpoint 490 | */ 491 | static void DiscardFillerBytes(uint8_t NumberOfBytes) 492 | { 493 | while (NumberOfBytes--) 494 | { 495 | if (!(Endpoint_BytesInEndpoint())) 496 | { 497 | Endpoint_ClearOUT(); 498 | 499 | /* Wait until next data packet received */ 500 | while (!(Endpoint_IsOUTReceived())) 501 | { 502 | if (USB_DeviceState == DEVICE_STATE_Unattached) 503 | return; 504 | } 505 | } 506 | else 507 | { 508 | Endpoint_Discard_Byte(); 509 | } 510 | } 511 | } 512 | 513 | /** Routine to process an issued command from the host, via a DFU_DNLOAD request wrapper. This routine ensures 514 | * that the command is allowed based on the current secure mode flag value, and passes the command off to the 515 | * appropriate handler function. 516 | */ 517 | static void ProcessBootloaderCommand(void) 518 | { 519 | /* Check if device is in secure mode */ 520 | // if (IsSecure) 521 | // { 522 | // /* Don't process command unless it is a READ or chip erase command */ 523 | // if (!(((SentCommand.Command == COMMAND_WRITE) && 524 | // IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) || 525 | // (SentCommand.Command == COMMAND_READ))) 526 | // { 527 | // /* Set the state and status variables to indicate the error */ 528 | // DFU_State = dfuERROR; 529 | // DFU_Status = errWRITE; 530 | // 531 | // /* Stall command */ 532 | // Endpoint_StallTransaction(); 533 | // 534 | // /* Don't process the command */ 535 | // return; 536 | // } 537 | // } 538 | 539 | /* Dispatch the required command processing routine based on the command type */ 540 | switch (SentCommand.Command) 541 | { 542 | case COMMAND_PROG_START: 543 | ProcessMemProgCommand(); 544 | break; 545 | case COMMAND_DISP_DATA: 546 | ProcessMemReadCommand(); 547 | break; 548 | case COMMAND_WRITE: 549 | ProcessWriteCommand(); 550 | break; 551 | case COMMAND_READ: 552 | ProcessReadCommand(); 553 | break; 554 | case COMMAND_CHANGE_BASE_ADDR: 555 | if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x03, 0x00)) // Set 64KB flash page command 556 | Flash64KBPage = SentCommand.Data[2]; 557 | break; 558 | } 559 | } 560 | 561 | /** Routine to concatenate the given pair of 16-bit memory start and end addresses from the host, and store them 562 | * in the StartAddr and EndAddr global variables. 563 | */ 564 | static void LoadStartEndAddresses(void) 565 | { 566 | union 567 | { 568 | uint8_t Bytes[2]; 569 | uint16_t Word; 570 | } Address[2] = {{.Bytes = {SentCommand.Data[2], SentCommand.Data[1]}}, 571 | {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}}; 572 | 573 | /* Load in the start and ending read addresses from the sent data packet */ 574 | StartAddr = Address[0].Word; 575 | EndAddr = Address[1].Word; 576 | } 577 | 578 | /** Handler for a Memory Program command issued by the host. This routine handles the preparations needed 579 | * to write subsequent data from the host into the specified memory. 580 | */ 581 | static void ProcessMemProgCommand(void) 582 | { 583 | if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Write FLASH command 584 | IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Write EEPROM command 585 | { 586 | /* Load in the start and ending read addresses */ 587 | LoadStartEndAddresses(); 588 | 589 | /* If FLASH is being written to, we need to pre-erase the first page to write to */ 590 | if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) 591 | { 592 | union 593 | { 594 | uint16_t Words[2]; 595 | uint32_t Long; 596 | } CurrFlashAddress = {.Words = {StartAddr, Flash64KBPage}}; 597 | 598 | /* Erase the current page's temp buffer */ 599 | boot_page_erase(CurrFlashAddress.Long); 600 | boot_spm_busy_wait(); 601 | } 602 | 603 | /* Set the state so that the next DNLOAD requests reads in the firmware */ 604 | DFU_State = dfuDNLOAD_IDLE; 605 | } 606 | } 607 | 608 | /** Handler for a Memory Read command issued by the host. This routine handles the preparations needed 609 | * to read subsequent data from the specified memory out to the host, as well as implementing the memory 610 | * blank check command. 611 | */ 612 | static void ProcessMemReadCommand(void) 613 | { 614 | if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00) || // Read FLASH command 615 | IS_ONEBYTE_COMMAND(SentCommand.Data, 0x02)) // Read EEPROM command 616 | { 617 | /* Load in the start and ending read addresses */ 618 | LoadStartEndAddresses(); 619 | 620 | /* Set the state so that the next UPLOAD requests read out the firmware */ 621 | DFU_State = dfuUPLOAD_IDLE; 622 | } 623 | else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Blank check FLASH command 624 | { 625 | uint32_t CurrFlashAddress = 0; 626 | 627 | while (CurrFlashAddress < BOOT_START_ADDR) 628 | { 629 | /* Check if the current byte is not blank */ 630 | #if (FLASHEND > 0xFFFF) 631 | if (pgm_read_byte_far(CurrFlashAddress) != 0xFF) 632 | #else 633 | if (pgm_read_byte(CurrFlashAddress) != 0xFF) 634 | #endif 635 | { 636 | /* Save the location of the first non-blank byte for response back to the host */ 637 | Flash64KBPage = (CurrFlashAddress >> 16); 638 | StartAddr = CurrFlashAddress; 639 | 640 | /* Set state and status variables to the appropriate error values */ 641 | DFU_State = dfuERROR; 642 | DFU_Status = errCHECK_ERASED; 643 | 644 | break; 645 | } 646 | 647 | CurrFlashAddress++; 648 | } 649 | } 650 | } 651 | 652 | /** Handler for a Data Write command issued by the host. This routine handles non-programming commands such as 653 | * bootloader exit (both via software jumps and hardware watchdog resets) and flash memory erasure. 654 | */ 655 | static void ProcessWriteCommand(void) 656 | { 657 | if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x03)) // Start application 658 | { 659 | /* Indicate that the bootloader is terminating */ 660 | WaitForExit = true; 661 | 662 | /* Check if data supplied for the Start Program command - no data executes the program */ 663 | if (SentCommand.DataSize) 664 | { 665 | if (SentCommand.Data[1] == 0x01) // Start via jump 666 | { 667 | union 668 | { 669 | uint8_t Bytes[2]; 670 | AppPtr_t FuncPtr; 671 | } Address = {.Bytes = {SentCommand.Data[4], SentCommand.Data[3]}}; 672 | 673 | /* Load in the jump address into the application start address pointer */ 674 | AppStartPtr = Address.FuncPtr; 675 | } 676 | } 677 | else 678 | { 679 | if (SentCommand.Data[1] == 0x00) // Start via watchdog 680 | { 681 | /* Start the watchdog to reset the AVR once the communications are finalized */ 682 | wdt_enable(WDTO_250MS); 683 | } 684 | else // Start via jump 685 | { 686 | /* Set the flag to terminate the bootloader at next opportunity */ 687 | RunBootloader = false; 688 | } 689 | } 690 | } 691 | else if (IS_TWOBYTE_COMMAND(SentCommand.Data, 0x00, 0xFF)) // Erase flash 692 | { 693 | uint32_t CurrFlashAddress = 0; 694 | 695 | /* Clear the application section of flash */ 696 | while (CurrFlashAddress < BOOT_START_ADDR) 697 | { 698 | boot_page_erase(CurrFlashAddress); 699 | boot_spm_busy_wait(); 700 | boot_page_write(CurrFlashAddress); 701 | boot_spm_busy_wait(); 702 | 703 | CurrFlashAddress += SPM_PAGESIZE; 704 | } 705 | 706 | /* Re-enable the RWW section of flash as writing to the flash locks it out */ 707 | boot_rww_enable(); 708 | 709 | /* Memory has been erased, reset the security bit so that programming/reading is allowed */ 710 | // IsSecure = false; 711 | } 712 | } 713 | 714 | /** Handler for a Data Read command issued by the host. This routine handles bootloader information retrieval 715 | * commands such as device signature and bootloader version retrieval. 716 | */ 717 | static void ProcessReadCommand(void) 718 | { 719 | const uint8_t BootloaderInfo[3] = {BOOTLOADER_VERSION, BOOTLOADER_ID_BYTE1, BOOTLOADER_ID_BYTE2}; 720 | const uint8_t SignatureInfo[3] = {AVR_SIGNATURE_1, AVR_SIGNATURE_2, AVR_SIGNATURE_3}; 721 | 722 | uint8_t DataIndexToRead = SentCommand.Data[1]; 723 | 724 | if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x00)) // Read bootloader info 725 | ResponseByte = BootloaderInfo[DataIndexToRead]; 726 | else if (IS_ONEBYTE_COMMAND(SentCommand.Data, 0x01)) // Read signature byte 727 | ResponseByte = SignatureInfo[DataIndexToRead - 0x30]; 728 | } 729 | -------------------------------------------------------------------------------- /Bootloaders/sparkfun-usbdfu-v10/sparkfun-usbdfu.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for sparkfun-usbdfu.c. 34 | */ 35 | 36 | #ifndef _SPARKFUN_USB_DFU_BOOTLOADER_H_ 37 | #define _SPARKFUN_USB_DFU_BOOTLOADER_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | #include 46 | #include 47 | #include 48 | 49 | #include "Descriptors.h" 50 | 51 | #include 52 | #include 53 | 54 | /* Macros: */ 55 | /** LED mask for the library LED driver, to indicate TX activity. */ 56 | #define LEDMASK_TX LEDS_LED1 57 | 58 | /** LED mask for the library LED driver, to indicate RX activity. */ 59 | #define LEDMASK_RX LEDS_LED2 60 | 61 | /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ 62 | #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) 63 | 64 | /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ 65 | #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) 66 | 67 | /** Configuration define. Define this token to true to case the bootloader to reject all memory commands 68 | * until a memory erase has been performed. When used in conjunction with the lockbits of the AVR, this 69 | * can protect the AVR's firmware from being dumped from a secured AVR. When false, memory operations are 70 | * allowed at any time. 71 | */ 72 | // #define SECURE_MODE false 73 | 74 | /** Major bootloader version number. */ 75 | #define BOOTLOADER_VERSION_MINOR 2 76 | 77 | /** Minor bootloader version number. */ 78 | #define BOOTLOADER_VERSION_REV 0 79 | 80 | /** Complete bootloader version number expressed as a packed byte, constructed from the 81 | * two individual bootloader version macros. 82 | */ 83 | #define BOOTLOADER_VERSION ((BOOTLOADER_VERSION_MINOR << 4) | BOOTLOADER_VERSION_REV) 84 | 85 | /** First byte of the bootloader identification bytes, used to identify a device's bootloader. */ 86 | #define BOOTLOADER_ID_BYTE1 0xDC 87 | 88 | /** Second byte of the bootloader identification bytes, used to identify a device's bootloader. */ 89 | #define BOOTLOADER_ID_BYTE2 0xFB 90 | 91 | /** Convenience macro, used to determine if the issued command is the given one-byte long command. 92 | * 93 | * \param[in] dataarr Command byte array to check against 94 | * \param[in] cb1 First command byte to check 95 | */ 96 | #define IS_ONEBYTE_COMMAND(dataarr, cb1) (dataarr[0] == (cb1)) 97 | 98 | /** Convenience macro, used to determine if the issued command is the given two-byte long command. 99 | * 100 | * \param[in] dataarr Command byte array to check against 101 | * \param[in] cb1 First command byte to check 102 | * \param[in] cb2 Second command byte to check 103 | */ 104 | #define IS_TWOBYTE_COMMAND(dataarr, cb1, cb2) ((dataarr[0] == (cb1)) && (dataarr[1] == (cb2))) 105 | 106 | /** Length of the DFU file suffix block, appended to the end of each complete memory write command. 107 | * The DFU file suffix is currently unused (but is designed to give extra file information, such as 108 | * a CRC of the complete firmware for error checking) and so is discarded. 109 | */ 110 | #define DFU_FILE_SUFFIX_SIZE 16 111 | 112 | /** Length of the DFU file filler block, appended to the start of each complete memory write command. 113 | * Filler bytes are added to the start of each complete memory write command, and must be discarded. 114 | */ 115 | #define DFU_FILLER_BYTES_SIZE 26 116 | 117 | /** DFU class command request to detach from the host. */ 118 | #define DFU_DETATCH 0x00 119 | 120 | /** DFU class command request to send data from the host to the bootloader. */ 121 | #define DFU_DNLOAD 0x01 122 | 123 | /** DFU class command request to send data from the bootloader to the host. */ 124 | #define DFU_UPLOAD 0x02 125 | 126 | /** DFU class command request to get the current DFU status and state from the bootloader. */ 127 | #define DFU_GETSTATUS 0x03 128 | 129 | /** DFU class command request to reset the current DFU status and state variables to their defaults. */ 130 | #define DFU_CLRSTATUS 0x04 131 | 132 | /** DFU class command request to get the current DFU state of the bootloader. */ 133 | #define DFU_GETSTATE 0x05 134 | 135 | /** DFU class command request to abort the current multi-request transfer and return to the dfuIDLE state. */ 136 | #define DFU_ABORT 0x06 137 | 138 | /** DFU command to begin programming the device's memory. */ 139 | #define COMMAND_PROG_START 0x01 140 | 141 | /** DFU command to begin reading the device's memory. */ 142 | #define COMMAND_DISP_DATA 0x03 143 | 144 | /** DFU command to issue a write command. */ 145 | #define COMMAND_WRITE 0x04 146 | 147 | /** DFU command to issue a read command. */ 148 | #define COMMAND_READ 0x05 149 | 150 | /** DFU command to issue a memory base address change command, to set the current 64KB flash page 151 | * that subsequent flash operations should use. */ 152 | #define COMMAND_CHANGE_BASE_ADDR 0x06 153 | 154 | /* Type Defines: */ 155 | /** Type define for a non-returning function pointer to the loaded application. */ 156 | typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; 157 | 158 | /** Type define for a structure containing a complete DFU command issued by the host. */ 159 | typedef struct 160 | { 161 | uint8_t Command; /**< Single byte command to perform, one of the COMMAND_* macro values */ 162 | uint8_t Data[5]; /**< Command parameters */ 163 | uint16_t DataSize; /**< Size of the command parameters */ 164 | } DFU_Command_t; 165 | 166 | /* Enums: */ 167 | /** DFU bootloader states. Refer to the DFU class specification for information on each state. */ 168 | enum DFU_State_t 169 | { 170 | appIDLE = 0, 171 | appDETACH = 1, 172 | dfuIDLE = 2, 173 | dfuDNLOAD_SYNC = 3, 174 | dfuDNBUSY = 4, 175 | dfuDNLOAD_IDLE = 5, 176 | dfuMANIFEST_SYNC = 6, 177 | dfuMANIFEST = 7, 178 | dfuMANIFEST_WAIT_RESET = 8, 179 | dfuUPLOAD_IDLE = 9, 180 | dfuERROR = 10 181 | }; 182 | 183 | /** DFU command status error codes. Refer to the DFU class specification for information on each error code. */ 184 | enum DFU_Status_t 185 | { 186 | OK = 0, 187 | errTARGET = 1, 188 | errFILE = 2, 189 | errWRITE = 3, 190 | errERASE = 4, 191 | errCHECK_ERASED = 5, 192 | errPROG = 6, 193 | errVERIFY = 7, 194 | errADDRESS = 8, 195 | errNOTDONE = 9, 196 | errFIRMWARE = 10, 197 | errVENDOR = 11, 198 | errUSBR = 12, 199 | errPOR = 13, 200 | errUNKNOWN = 14, 201 | errSTALLEDPKT = 15 202 | }; 203 | 204 | /* Function Prototypes: */ 205 | void SetupHardware(void); 206 | void ResetHardware(void); 207 | 208 | void EVENT_USB_Device_UnhandledControlRequest(void); 209 | 210 | #if defined(INCLUDE_FROM_BOOTLOADER_C) 211 | static void DiscardFillerBytes(uint8_t NumberOfBytes); 212 | static void ProcessBootloaderCommand(void); 213 | static void LoadStartEndAddresses(void); 214 | static void ProcessMemProgCommand(void); 215 | static void ProcessMemReadCommand(void); 216 | static void ProcessWriteCommand(void); 217 | static void ProcessReadCommand(void); 218 | #endif 219 | 220 | #endif /* _SPARKFUN_USB_DFU_BOOTLOADER_H_ */ 221 | -------------------------------------------------------------------------------- /Bootloaders/sparkfun-usbdfu-v10/sparkfun-usbdfu.hex: -------------------------------------------------------------------------------- 1 | :101000004BC0000064C0000062C0000060C000006F 2 | :101010005EC000005CC000005AC0000058C0000064 3 | :1010200056C0000054C0000052C00000CBC40000F5 4 | :101030004EC000004CC000004AC0000048C0000084 5 | :1010400046C0000044C0000042C0000040C0000094 6 | :101050003EC000003CC000003AC0000038C00000A4 7 | :1010600036C0000034C0000032C0000030C00000B4 8 | :101070002EC000002CC000002AC0000028C00000C4 9 | :1010800026C0000024C0000022C0000020C00000D4 10 | :101090001EC000001CC0000011241FBECFEFD2E014 11 | :1010A000DEBFCDBF11E0A0E0B1E0E4EBFCE102C0A7 12 | :1010B00005900D92A436B107D9F711E0A4E6B1E08E 13 | :1010C00001C01D92A338B107E1F74FD3F1C598CF06 14 | :1010D000982F15C08091F200882371F48091E80068 15 | :1010E0008B7F8093E80003C08EB3882351F08091FA 16 | :1010F000E80082FFF9CF02C08091F100915099235E 17 | :1011000049F7089520917201309171018091700129 18 | :1011100090916F018093690190936A01C901809356 19 | :101120006B0190936C01089580916D01843009F4F6 20 | :101130005AC0853030F4813059F0833009F0C3C093 21 | :101140001FC0853009F4A0C0863009F0BCC0AFC014 22 | :1011500080916E01823008F0B6C0D4DF80916E01BC 23 | :10116000882361F48091690190916A0123E0FC0178 24 | :1011700020935700E89507B600FCFDCF85E008C036 25 | :1011800080916E01882311F0823029F4BBDF89E061 26 | :10119000809301010895813009F095C020E030E08E 27 | :1011A00040E050E0F90184918F3F81F0CA01AA2705 28 | :1011B000BB278093680130936A01209369018AE01C 29 | :1011C0008093010185E08093650108952F5F3F4F73 30 | :1011D0004F4F5F4F2030F0E13F07F0E04F07F0E066 31 | :1011E0005F0701F7089580916E01833051F581E02A 32 | :1011F000809364018091730190917401892B71F047 33 | :1012000080916F01813009F05EC0809172019091F0 34 | :1012100071019093670180936601089580916F0139 35 | :10122000882361F42CE088E190E00FB6F894A8954B 36 | :10123000809360000FBE209360000895109200011B 37 | :101240000895882309F03FC080916F018F3F09F016 38 | :101250003AC0E0E0F0E093E085E090935700E89535 39 | :1012600007B600FCFDCF80935700E89507B600FC59 40 | :10127000FDCFE058FF4F20E1E030F20771F781E148 41 | :1012800080935700E8950895E0916F0180916E0179 42 | :10129000882321F4F0E0EB5FFE4F05C0813099F424 43 | :1012A000F0E0EE52FF4F80818093780108958091A5 44 | :1012B0006E01833041F480916F01882321F4809185 45 | :1012C00070018093680108952F923F924F925F9230 46 | :1012D0006F927F929F92AF92BF92CF92DF92EF92E6 47 | :1012E000FF920F931F93CF93DF9380918101909191 48 | :1012F000820190937401809373018091750188231A 49 | :1013000051F0809175018150809375018091750134 50 | :10131000882309F45D9A80917601882351F08091A9 51 | :10132000760181508093760180917601882309F4BB 52 | :101330005C9A80917C01833009F4B2C1843030F42E 53 | :10134000813071F0823009F0E3C111C1853009F4B8 54 | :10135000C5C1853008F4BAC1863009F0D9C1CDC104 55 | :101360005C9883E0809376018091E800877F80938A 56 | :10137000E80080916401882329F0D6DE5D9A5C9AAA 57 | :10138000109264012091730130917401211531058F 58 | :1013900029F42AC08EB3882309F4BAC18091E800E9 59 | :1013A00082FFF8CF8091F10080936D012150304091 60 | :1013B0003093740120937301EEE6F1E00CC080914C 61 | :1013C000F10081932150304081E0E337F80719F4B0 62 | :1013D0003183208308C08091F200882381F7309305 63 | :1013E000740120937301A0DE80910101853009F022 64 | :1013F000BAC08091730190917401892B21F482E02D 65 | :1014000080930101B0C08AE163DE809169018F7130 66 | :101410005FDEC0916B01D0916C0120916901309128 67 | :101420006A0121968E01021B130B219780916E0198 68 | :10143000882309F093C0180136942794C901A0911C 69 | :101440006801B0E09C01AD0162E0E62EF12C012DB7 70 | :10145000112DE20EF31E041F151F59016A0190E0C1 71 | :1014600099249394B5E0A3E048C08091F2008823CA 72 | :1014700071F48091E8008B7F8093E80004C08EB304 73 | :10148000882309F445C18091E80082FFF8CF0894D1 74 | :10149000210831088091F100682F8091F100782FA8 75 | :1014A000F5010B0190925700E89511249F5F90344D 76 | :1014B00019F021143104A1F4F901B0935700E89513 77 | :1014C00007B600FCFDCF2114310451F0F701A093C1 78 | :1014D0005700E89507B600FCFDCFA801970190E002 79 | :1014E00042E0442E512C612C712CE40CF51C061D9D 80 | :1014F000171DA40CB51CC61CD71C2114310409F0FF 81 | :10150000B4CFD0936A01C093690181E18093570001 82 | :10151000E89527C08091F200882371F48091E8005B 83 | :101520008B7F8093E80004C08EB3882309F4F0C059 84 | :101530008091E80082FFF8CF6091F100809169010D 85 | :1015400090916A01A7D38091690190916A010196F7 86 | :1015500090936A01809369010150104001151105B3 87 | :10156000C9F680E1B5DD8091E8008B7FC3C0809132 88 | :10157000E800877F8093E8005D9883E080937501A1 89 | :1015800004C08EB3882309F4C3C08091E80080FFB3 90 | :10159000F8CF80910101893091F08A3069F480910F 91 | :1015A0006E01813049F48091690190916A018093C4 92 | :1015B000F1009093F1009BC08091780196C06091FA 93 | :1015C0006B0170916C012091690130916A016F5F2C 94 | :1015D0007F4F7B01E21AF30A6150704080916E01E7 95 | :1015E000882389F5870116950795C901A09168019F 96 | :1015F000B0E09C01AD011FC08091F200803271F417 97 | :101600008091E8008E7F8093E80004C08EB3882329 98 | :1016100009F47EC08091E80080FFF8CFF901859140 99 | :1016200094918093F1009093F100015010402E5F4F 100 | :101630003F4F4F4F5F4F01151105F1F670936A014F 101 | :101640006093690129C0823039F523C08091F2008E 102 | :10165000803271F48091E8008E7F8093E80004C0AE 103 | :101660008EB3882309F454C08091E80080FFF8CF3E 104 | :101670000091690110916A01C80104D38093F100BF 105 | :101680000F5F1F4F10936A01009369010894E108EE 106 | :10169000F108E114F104D1F682E08093010127C042 107 | :1016A0008091E800877F8093E800809165018093B6 108 | :1016B000F1001092F1001092F1001092F10080916F 109 | :1016C00001018093F1001092F10011C08091E800B7 110 | :1016D000877F8093E8001092650119C08091E8002F 111 | :1016E000877F8093E800809101018093F1008091D1 112 | :1016F000E8008E7F8093E8000AC08091E800877F31 113 | :101700008093E8005D9A5C9A82E08093010187D023 114 | :10171000DF91CF911F910F91FF90EF90DF90CF90CD 115 | :10172000BF90AF909F907F906F905F904F903F9051 116 | :101730002F9008952BD181E085BF15BE089584B701 117 | :10174000877F84BF88E10FB6F89480936000109281 118 | :1017500060000FBE81E085BF82E085BF8AB18063F3 119 | :101760008AB98BB180638BB90CC1E9DF789401C071 120 | :1017700080D2809100018823D9F780916401882369 121 | :10178000B9F7D8DFE0916601F09167010995FA0198 122 | :10179000923071F0933089F0913029F488E091E033 123 | :1017A00022E130E019C080E090E020E030E014C099 124 | :1017B0008AE191E02BE130E00FC0882339F4809179 125 | :1017C0003501282F30E085E391E006C08091390192 126 | :1017D000282F30E089E391E091838083C901089547 127 | :1017E0008091EB0081608093EB001092ED0060939C 128 | :1017F000EC004093ED008091EE00881F8827881F41 129 | :1018000008951092F4001092F0001092E8001092E7 130 | :10181000ED00EBEEF0E080818E7F80830895809173 131 | :101820007B0188238CF403C08EB38823B1F08091B0 132 | :10183000E80082FFF9CF8091E8008B7F8093E80079 133 | :1018400008958EB3882349F08091E80080FFF9CF96 134 | :101850008091E8008E7F8093E80008959C0140917C 135 | :101860008101509182014617570718F4F90120E0D1 136 | :1018700038C06115710511F0AB01F8CF8091E80017 137 | :101880008E7F8093E80040E050E0F0CF8091E80048 138 | :1018900083FF02C081E008958091E80082FD2DC0A1 139 | :1018A0008EB3882381F18EB3853079F18091E80081 140 | :1018B00080FF17C09091F20006C081918093F100E3 141 | :1018C000415050409F5F4115510511F09032A8F3EF 142 | :1018D00020E0903209F421E08091E8008E7F80932F 143 | :1018E000E8004115510591F6222381F606C08EB31A 144 | :1018F000882349F08EB3853041F08091E80082FF63 145 | :10190000F6CF80E0089582E0089583E0089554D0F2 146 | :1019100056D01EBA1092790184E089BD89B58260E3 147 | :1019200089BD09B400FEFDCF8091D800982F9F7724 148 | :101930009093D80080688093D800809163008E7F58 149 | :10194000809363008091D8008F7D8093D800809130 150 | :10195000E0008E7F8093E0008091E1008E7F809395 151 | :10196000E1008091E20081608093E2008091E100DB 152 | :10197000877F8093E1008091E20088608093E2009D 153 | :101980000895C5DF81E080937A010895C0DFE0EE1D 154 | :10199000F0E0808181608083E8EDF0E080818F77E6 155 | :1019A00080830AD00CD019BCE3E6F0E0808181602E 156 | :1019B000808310927A0108951092E20008951092A7 157 | :1019C000E10008951F920F920FB60F9211242F93EA 158 | :1019D0003F934F935F936F937F938F939F93AF93B7 159 | :1019E000BF93EF93FF938091E10080FF1BC0809134 160 | :1019F000E20080FF17C08091E1008E7F8093E100BC 161 | :101A00008091E2008E7F8093E2008091E20080610D 162 | :101A10008093E2008091D80080628093D80019BC46 163 | :101A20001EBA26D18091E10084FF29C08091E20096 164 | :101A300084FF25C084E089BD89B5826089BD09B471 165 | :101A400000FEFDCF8091D8008F7D8093D8008091DB 166 | :101A5000E1008F7E8093E1008091E2008F7E809391 167 | :101A6000E2008091E20081608093E2008091790140 168 | :101A7000882311F481E001C084E08EBBF9D080910D 169 | :101A8000E10083FF22C08091E20083FF1EC08091AD 170 | :101A9000E100877F8093E10082E08EBB10927901A4 171 | :101AA0008091E1008E7F8093E1008091E2008E7F43 172 | :101AB0008093E2008091E20080618093E200A1DEE9 173 | :101AC00080E060E042E28CDED3D08091E10082FFD2 174 | :101AD0000AC08091E20082FF06C08091E1008B7F06 175 | :101AE0008093E100C5D0FF91EF91BF91AF919F919D 176 | :101AF0008F917F916F915F914F913F912F910F90B7 177 | :101B00000FBE0F901F9018951F93DF93CF9300D0B7 178 | :101B1000CDB7DEB7EBE7F1E08091F100819381E092 179 | :101B2000E338F807C9F790917B0180917C018530FB 180 | :101B300011F1863040F48130B9F0813070F083309B 181 | :101B400009F081C011C0883009F453C0893009F40C 182 | :101B500062C0863009F077C02DC0903809F474C097 183 | :101B6000923809F070C070C0992309F46DC09230AA 184 | :101B700009F069C069C0992309F065C010917D0121 185 | :101B80008091E800877F8093E80049DE04C08EB32F 186 | :101B9000882309F459C08091E80080FFF8CF812F95 187 | :101BA0008F7711F492E001C093E09EBB8068809330 188 | :101BB000E3004AC09058923008F045C080917D0102 189 | :101BC00090917E0160917F01AE014F5F5F4FDFDD3D 190 | :101BD000BC010097C9F18091E800877F8093E800FD 191 | :101BE00089819A813BDE8091E8008B7F8093E800B9 192 | :101BF0002BC0903841F58091E800877F8093E80002 193 | :101C0000809179018093F1008091E8008E7F80932C 194 | :101C1000E80005DE19C09923B1F490917D0192305E 195 | :101C200098F48091E800877F8093E8009093790191 196 | :101C3000F6DD80917901882311F483E001C084E00E 197 | :101C40008EBB16D001C040DB8091E80083FF0AC044 198 | :101C50008091EB0080628093EB008091E800877FA9 199 | :101C60008093E8000F900F90CF91DF911F9108951E 200 | :101C700008958EB3882329F08091E80083FF01C086 201 | :101C800043CF0895F999FECF92BD81BDF89A992767 202 | :101C900080B50895262FF999FECF1FBA92BD81BD58 203 | :101CA00020BD0FB6F894FA9AF99A0FBE01960895DE 204 | :041CB000F894FFCFD6 205 | :101CB40001021E938220DCFB1201100100000020AF 206 | :101CC400EB03F72F00000001000109021B000101D2 207 | :101CD4000080320904000000FE0102000921030013 208 | :101CE40000000C0001040309042803530070006180 209 | :101CF4000072006B00460075006E00200042006F09 210 | :101D0400006F0074006C006F006100640065007275 211 | :041D140000000000CB 212 | :0400000300001000E9 213 | :00000001FF 214 | -------------------------------------------------------------------------------- /Projects/readme.txt: -------------------------------------------------------------------------------- 1 | When the ATmega8U2 Breakout board plugs into USB it will enumerate as a COM port. To enter bootload mode, pull PD7 low, reset board, release reset, then release PD7. If asked for a driver, point to the Flip directory. Device should now enumerate as a AT90USB82 (NOT a ATmega8U2). Next: 2 | 3 | -download Atmel's Flip 4 | -open a command prompt 5 | -cd to the project (e.g. sparkfun_USBtoSerial-v10) dicrectory 6 | -make clean 7 | -make 8 | -make flip OR open FLIP and load hex file 9 | 10 | *ATTENTION* Be sure to use the AT90USB82 as the device in the FLIP software 11 | 12 | Unplug, replug board, it now should come up as SparkFun COM Port. 13 | -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/Board/LEDs.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /* 32 | Board LEDs driver for the Benito board, from www.dorkbotpdx.org. 33 | */ 34 | 35 | #ifndef __LEDS_ARDUINOUNO_H__ 36 | #define __LEDS_ARDUINOUNO_H__ 37 | 38 | /* Includes: */ 39 | #include 40 | 41 | /* Enable C linkage for C++ Compilers: */ 42 | #if defined(__cplusplus) 43 | extern "C" { 44 | #endif 45 | 46 | /* Preprocessor Checks: */ 47 | #if !defined(INCLUDE_FROM_LEDS_H) 48 | #error Do not include this file directly. Include LUFA/Drivers/Board/LEDS.h instead. 49 | #endif 50 | 51 | /* Public Interface - May be used in end-application: */ 52 | /* Macros: */ 53 | /** LED mask for the first LED on the board. */ 54 | #define LEDS_LED1 (1 << 5) 55 | 56 | /** LED mask for the second LED on the board. */ 57 | #define LEDS_LED2 (1 << 4) 58 | 59 | /** LED mask for all the LEDs on the board. */ 60 | #define LEDS_ALL_LEDS (LEDS_LED1 | LEDS_LED2) 61 | 62 | /** LED mask for the none of the board LEDs */ 63 | #define LEDS_NO_LEDS 0 64 | 65 | /* Inline Functions: */ 66 | #if !defined(__DOXYGEN__) 67 | static inline void LEDs_Init(void) 68 | { 69 | DDRD |= LEDS_ALL_LEDS; 70 | PORTD |= LEDS_ALL_LEDS; 71 | } 72 | 73 | static inline void LEDs_TurnOnLEDs(const uint8_t LEDMask) 74 | { 75 | PORTD &= ~LEDMask; 76 | } 77 | 78 | static inline void LEDs_TurnOffLEDs(const uint8_t LEDMask) 79 | { 80 | PORTD |= LEDMask; 81 | } 82 | 83 | static inline void LEDs_SetAllLEDs(const uint8_t LEDMask) 84 | { 85 | PORTD = ((PORTD | LEDS_ALL_LEDS) & ~LEDMask); 86 | } 87 | 88 | static inline void LEDs_ChangeLEDs(const uint8_t LEDMask, const uint8_t ActiveMask) 89 | { 90 | PORTD = ((PORTD | ActiveMask) & ~LEDMask); 91 | } 92 | 93 | static inline void LEDs_ToggleLEDs(const uint8_t LEDMask) 94 | { 95 | PORTD ^= LEDMask; 96 | } 97 | 98 | static inline uint8_t LEDs_GetLEDs(void) ATTR_WARN_UNUSED_RESULT; 99 | static inline uint8_t LEDs_GetLEDs(void) 100 | { 101 | return (PORTD & LEDS_ALL_LEDS); 102 | } 103 | #endif 104 | 105 | /* Disable C linkage for C++ Compilers: */ 106 | #if defined(__cplusplus) 107 | } 108 | #endif 109 | 110 | #endif 111 | -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/Descriptors.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * USB Device Descriptors, for library use when in USB device mode. Descriptors are special 34 | * computer-readable structures which the host requests upon device enumeration, to determine 35 | * the device's capabilities and functions. 36 | */ 37 | 38 | #include "Descriptors.h" 39 | 40 | /* On some devices, there is a factory set internal serial number which can be automatically sent to the host as 41 | * the device's serial number when the Device Descriptor's .SerialNumStrIndex entry is set to USE_INTERNAL_SERIAL. 42 | * This allows the host to track a device across insertions on different ports, allowing them to retain allocated 43 | * resources like COM port numbers and drivers. On demos using this feature, give a warning on unsupported devices 44 | * so that the user can supply their own serial number descriptor instead or remove the USE_INTERNAL_SERIAL value 45 | * from the Device Descriptor (forcing the host to generate a serial number for each device from the VID, PID and 46 | * port location). 47 | */ 48 | #if (USE_INTERNAL_SERIAL == NO_DESCRIPTOR) 49 | #warning USE_INTERNAL_SERIAL is not available on this AVR - please manually construct a device serial descriptor. 50 | #endif 51 | 52 | /** Device descriptor structure. This descriptor, located in FLASH memory, describes the overall 53 | * device characteristics, including the supported USB version, control endpoint size and the 54 | * number of device configurations. The descriptor is read out by the USB host when the enumeration 55 | * process begins. 56 | */ 57 | USB_Descriptor_Device_t PROGMEM DeviceDescriptor = 58 | { 59 | .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, 60 | 61 | .USBSpecification = VERSION_BCD(01.10), 62 | .Class = 0x02, 63 | .SubClass = 0x00, 64 | .Protocol = 0x00, 65 | 66 | .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, 67 | 68 | .VendorID = 0x1B4F, // SparkFun VID 69 | 70 | .ProductID = 0x0001, // SparkFun USBtoSerial 71 | .ReleaseNumber = 0x0000, 72 | 73 | .ManufacturerStrIndex = 0x01, 74 | .ProductStrIndex = 0x02, 75 | .SerialNumStrIndex = USE_INTERNAL_SERIAL, 76 | 77 | .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS 78 | }; 79 | 80 | /** Configuration descriptor structure. This descriptor, located in FLASH memory, describes the usage 81 | * of the device in one of its supported configurations, including information about any device interfaces 82 | * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting 83 | * a configuration so that the host may correctly communicate with the USB device. 84 | */ 85 | USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor = 86 | { 87 | .Config = 88 | { 89 | .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, 90 | 91 | .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), 92 | .TotalInterfaces = 2, 93 | 94 | .ConfigurationNumber = 1, 95 | .ConfigurationStrIndex = NO_DESCRIPTOR, 96 | 97 | .ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED), 98 | 99 | .MaxPowerConsumption = USB_CONFIG_POWER_MA(100) 100 | }, 101 | 102 | .CDC_CCI_Interface = 103 | { 104 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 105 | 106 | .InterfaceNumber = 0, 107 | .AlternateSetting = 0, 108 | 109 | .TotalEndpoints = 1, 110 | 111 | .Class = 0x02, 112 | .SubClass = 0x02, 113 | .Protocol = 0x01, 114 | 115 | .InterfaceStrIndex = NO_DESCRIPTOR 116 | }, 117 | 118 | .CDC_Functional_IntHeader = 119 | { 120 | .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, 121 | .SubType = 0x00, 122 | 123 | .Data = {0x01, 0x10} 124 | }, 125 | 126 | .CDC_Functional_AbstractControlManagement = 127 | { 128 | .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24}, 129 | .SubType = 0x02, 130 | 131 | .Data = {0x06} 132 | }, 133 | 134 | .CDC_Functional_Union = 135 | { 136 | .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, 137 | .SubType = 0x06, 138 | 139 | .Data = {0x00, 0x01} 140 | }, 141 | 142 | .CDC_NotificationEndpoint = 143 | { 144 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 145 | 146 | .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM), 147 | .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 148 | .EndpointSize = CDC_NOTIFICATION_EPSIZE, 149 | .PollingIntervalMS = 0xFF 150 | }, 151 | 152 | .CDC_DCI_Interface = 153 | { 154 | .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, 155 | 156 | .InterfaceNumber = 1, 157 | .AlternateSetting = 0, 158 | 159 | .TotalEndpoints = 2, 160 | 161 | .Class = 0x0A, 162 | .SubClass = 0x00, 163 | .Protocol = 0x00, 164 | 165 | .InterfaceStrIndex = NO_DESCRIPTOR 166 | }, 167 | 168 | .CDC_DataOutEndpoint = 169 | { 170 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 171 | 172 | .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM), 173 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 174 | .EndpointSize = CDC_TXRX_EPSIZE, 175 | .PollingIntervalMS = 0x01 176 | }, 177 | 178 | .CDC_DataInEndpoint = 179 | { 180 | .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, 181 | 182 | .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM), 183 | .Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), 184 | .EndpointSize = CDC_TXRX_EPSIZE, 185 | .PollingIntervalMS = 0x01 186 | } 187 | }; 188 | 189 | /** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests 190 | * the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate 191 | * via the language ID table available at USB.org what languages the device supports for its string descriptors. 192 | */ 193 | USB_Descriptor_String_t PROGMEM LanguageString = 194 | { 195 | .Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String}, 196 | 197 | .UnicodeString = {LANGUAGE_ID_ENG} 198 | }; 199 | 200 | /** Manufacturer descriptor string. This is a Unicode string containing the manufacturer's details in human readable 201 | * form, and is read out upon request by the host when the appropriate string ID is requested, listed in the Device 202 | * Descriptor. 203 | */ 204 | USB_Descriptor_String_t PROGMEM ManufacturerString = 205 | { 206 | .Header = {.Size = USB_STRING_LEN(26), .Type = DTYPE_String}, 207 | 208 | .UnicodeString = L"SparkFun (www.sparkfun.com)" 209 | }; 210 | 211 | /** Product descriptor string. This is a Unicode string containing the product's details in human readable form, 212 | * and is read out upon request by the host when the appropriate string ID is requested, listed in the Device 213 | * Descriptor. 214 | */ 215 | USB_Descriptor_String_t PROGMEM ProductString = 216 | { 217 | .Header = {.Size = USB_STRING_LEN(20), .Type = DTYPE_String}, 218 | 219 | .UnicodeString = L"SparkFun USBtoSerial" 220 | }; 221 | 222 | /** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors" 223 | * documentation) by the application code so that the address and size of a requested descriptor can be given 224 | * to the USB library. When the device receives a Get Descriptor request on the control endpoint, this function 225 | * is called so that the descriptor details can be passed back and the appropriate descriptor sent back to the 226 | * USB host. 227 | */ 228 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 229 | const uint8_t wIndex, 230 | void** const DescriptorAddress) 231 | { 232 | const uint8_t DescriptorType = (wValue >> 8); 233 | const uint8_t DescriptorNumber = (wValue & 0xFF); 234 | 235 | void* Address = NULL; 236 | uint16_t Size = NO_DESCRIPTOR; 237 | 238 | switch (DescriptorType) 239 | { 240 | case DTYPE_Device: 241 | Address = (void*)&DeviceDescriptor; 242 | Size = sizeof(USB_Descriptor_Device_t); 243 | break; 244 | case DTYPE_Configuration: 245 | Address = (void*)&ConfigurationDescriptor; 246 | Size = sizeof(USB_Descriptor_Configuration_t); 247 | break; 248 | case DTYPE_String: 249 | switch (DescriptorNumber) 250 | { 251 | case 0x00: 252 | Address = (void*)&LanguageString; 253 | Size = pgm_read_byte(&LanguageString.Header.Size); 254 | break; 255 | case 0x01: 256 | Address = (void*)&ManufacturerString; 257 | Size = pgm_read_byte(&ManufacturerString.Header.Size); 258 | break; 259 | case 0x02: 260 | Address = (void*)&ProductString; 261 | Size = pgm_read_byte(&ProductString.Header.Size); 262 | break; 263 | } 264 | 265 | break; 266 | } 267 | 268 | *DescriptorAddress = Address; 269 | return Size; 270 | } 271 | -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/Descriptors.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for Descriptors.c. 34 | */ 35 | 36 | #ifndef _DESCRIPTORS_H_ 37 | #define _DESCRIPTORS_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | #include 43 | #include 44 | 45 | /* Macros: */ 46 | /** Endpoint number of the CDC device-to-host notification IN endpoint. */ 47 | #define CDC_NOTIFICATION_EPNUM 2 48 | 49 | /** Endpoint number of the CDC device-to-host data IN endpoint. */ 50 | #define CDC_TX_EPNUM 3 51 | 52 | /** Endpoint number of the CDC host-to-device data OUT endpoint. */ 53 | #define CDC_RX_EPNUM 4 54 | 55 | /** Size in bytes of the CDC device-to-host notification IN endpoint. */ 56 | #define CDC_NOTIFICATION_EPSIZE 8 57 | 58 | /** Size in bytes of the CDC data IN and OUT endpoints. */ 59 | #define CDC_TXRX_EPSIZE 16 60 | 61 | /* Type Defines: */ 62 | /** Type define for the device configuration descriptor structure. This must be defined in the 63 | * application code, as the configuration descriptor contains several sub-descriptors which 64 | * vary between devices, and which describe the device's usage to the host. 65 | */ 66 | typedef struct 67 | { 68 | USB_Descriptor_Configuration_Header_t Config; 69 | USB_Descriptor_Interface_t CDC_CCI_Interface; 70 | CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_IntHeader; 71 | CDC_FUNCTIONAL_DESCRIPTOR(1) CDC_Functional_AbstractControlManagement; 72 | CDC_FUNCTIONAL_DESCRIPTOR(2) CDC_Functional_Union; 73 | USB_Descriptor_Endpoint_t CDC_NotificationEndpoint; 74 | USB_Descriptor_Interface_t CDC_DCI_Interface; 75 | USB_Descriptor_Endpoint_t CDC_DataOutEndpoint; 76 | USB_Descriptor_Endpoint_t CDC_DataInEndpoint; 77 | } USB_Descriptor_Configuration_t; 78 | 79 | /* Function Prototypes: */ 80 | uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, 81 | const uint8_t wIndex, 82 | void** const DescriptorAddress) ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3); 83 | 84 | #endif 85 | -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/Lib/LightweightRingBuff.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Ultra lightweight ring buffer, for fast insertion/deletion. 34 | */ 35 | 36 | #ifndef _ULW_RING_BUFF_H_ 37 | #define _ULW_RING_BUFF_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | 42 | #include 43 | #include 44 | 45 | /* Defines: */ 46 | /** Size of each ring buffer, in data elements - must be between 1 and 255. */ 47 | #define BUFFER_SIZE 128 48 | 49 | /** Maximum number of data elements to buffer before forcing a flush. 50 | * Must be less than BUFFER_SIZE 51 | */ 52 | #define BUFFER_NEARLY_FULL 96 53 | 54 | /** Type of data to store into the buffer. */ 55 | #define RingBuff_Data_t uint8_t 56 | 57 | /** Datatype which may be used to store the count of data stored in a buffer, retrieved 58 | * via a call to \ref RingBuffer_GetCount(). 59 | */ 60 | #if (BUFFER_SIZE <= 0xFF) 61 | #define RingBuff_Count_t uint8_t 62 | #else 63 | #define RingBuff_Count_t uint16_t 64 | #endif 65 | 66 | /* Type Defines: */ 67 | /** Type define for a new ring buffer object. Buffers should be initialized via a call to 68 | * \ref RingBuffer_InitBuffer() before use. 69 | */ 70 | typedef struct 71 | { 72 | RingBuff_Data_t Buffer[BUFFER_SIZE]; /**< Internal ring buffer data, referenced by the buffer pointers. */ 73 | RingBuff_Data_t* In; /**< Current storage location in the circular buffer */ 74 | RingBuff_Data_t* Out; /**< Current retrieval location in the circular buffer */ 75 | RingBuff_Count_t Count; 76 | } RingBuff_t; 77 | 78 | /* Inline Functions: */ 79 | /** Initializes a ring buffer ready for use. Buffers must be initialized via this function 80 | * before any operations are called upon them. Already initialized buffers may be reset 81 | * by re-initializing them using this function. 82 | * 83 | * \param[out] Buffer Pointer to a ring buffer structure to initialize 84 | */ 85 | static inline void RingBuffer_InitBuffer(RingBuff_t* const Buffer) 86 | { 87 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) 88 | { 89 | Buffer->In = Buffer->Buffer; 90 | Buffer->Out = Buffer->Buffer; 91 | } 92 | } 93 | 94 | /** Retrieves the minimum number of bytes stored in a particular buffer. This value is computed 95 | * by entering an atomic lock on the buffer while the IN and OUT locations are fetched, so that 96 | * the buffer cannot be modified while the computation takes place. This value should be cached 97 | * when reading out the contents of the buffer, so that as small a time as possible is spent 98 | * in an atomic lock. 99 | * 100 | * \note The value returned by this function is guaranteed to only be the minimum number of bytes 101 | * stored in the given buffer; this value may change as other threads write new data and so 102 | * the returned number should be used only to determine how many successive reads may safely 103 | * be performed on the buffer. 104 | * 105 | * \param[in] Buffer Pointer to a ring buffer structure whose count is to be computed 106 | */ 107 | static inline RingBuff_Count_t RingBuffer_GetCount(RingBuff_t* const Buffer) 108 | { 109 | RingBuff_Count_t Count; 110 | 111 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) 112 | { 113 | Count = Buffer->Count; 114 | } 115 | 116 | return Count; 117 | } 118 | 119 | /** Atomically determines if the specified ring buffer contains any free space. This should 120 | * be tested before storing data to the buffer, to ensure that no data is lost due to a 121 | * buffer overrun. 122 | * 123 | * \param[in,out] Buffer Pointer to a ring buffer structure to insert into 124 | * 125 | * \return Boolean true if the buffer contains no free space, false otherwise 126 | */ 127 | static inline bool RingBuffer_IsFull(RingBuff_t* const Buffer) 128 | { 129 | return (RingBuffer_GetCount(Buffer) == BUFFER_SIZE); 130 | } 131 | 132 | /** Atomically determines if the specified ring buffer contains any data. This should 133 | * be tested before removing data from the buffer, to ensure that the buffer does not 134 | * underflow. 135 | * 136 | * If the data is to be removed in a loop, store the total number of bytes stored in the 137 | * buffer (via a call to the \ref RingBuffer_GetCount() function) in a temporary variable 138 | * to reduce the time spent in atomicity locks. 139 | * 140 | * \param[in,out] Buffer Pointer to a ring buffer structure to insert into 141 | * 142 | * \return Boolean true if the buffer contains no free space, false otherwise 143 | */ 144 | static inline bool RingBuffer_IsEmpty(RingBuff_t* const Buffer) 145 | { 146 | return (RingBuffer_GetCount(Buffer) == 0); 147 | } 148 | 149 | /** Inserts an element into the ring buffer. 150 | * 151 | * \note Only one execution thread (main program thread or an ISR) may insert into a single buffer 152 | * otherwise data corruption may occur. Insertion and removal may occur from different execution 153 | * threads. 154 | * 155 | * \param[in,out] Buffer Pointer to a ring buffer structure to insert into 156 | * \param[in] Data Data element to insert into the buffer 157 | */ 158 | static inline void RingBuffer_Insert(RingBuff_t* const Buffer, 159 | const RingBuff_Data_t Data) 160 | { 161 | *Buffer->In = Data; 162 | 163 | if (++Buffer->In == &Buffer->Buffer[BUFFER_SIZE]) 164 | Buffer->In = Buffer->Buffer; 165 | 166 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) 167 | { 168 | Buffer->Count++; 169 | } 170 | } 171 | 172 | /** Removes an element from the ring buffer. 173 | * 174 | * \note Only one execution thread (main program thread or an ISR) may remove from a single buffer 175 | * otherwise data corruption may occur. Insertion and removal may occur from different execution 176 | * threads. 177 | * 178 | * \param[in,out] Buffer Pointer to a ring buffer structure to retrieve from 179 | * 180 | * \return Next data element stored in the buffer 181 | */ 182 | static inline RingBuff_Data_t RingBuffer_Remove(RingBuff_t* const Buffer) 183 | { 184 | RingBuff_Data_t Data = *Buffer->Out; 185 | 186 | if (++Buffer->Out == &Buffer->Buffer[BUFFER_SIZE]) 187 | Buffer->Out = Buffer->Buffer; 188 | 189 | ATOMIC_BLOCK(ATOMIC_RESTORESTATE) 190 | { 191 | Buffer->Count--; 192 | } 193 | 194 | return Data; 195 | } 196 | 197 | #endif 198 | -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/makefile: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bitsmashed/SparkFun-USBtoSerial/9af40178a83abf6712ae7fd74b576ac0fef3585c/Projects/sparkfun_USBtoSerial-v10/makefile -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/sparkfun_USBtoSerial.c: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Main source file for the Arduino-usbserial project. This file contains the main tasks of 34 | * the project and is responsible for the initial application hardware configuration. 35 | */ 36 | 37 | #include "sparkfun_USBtoSerial.h" 38 | 39 | #define sbi(var, mask) ((var) |= (uint8_t)(1 << mask)) 40 | #define cbi(var, mask) ((var) &= (uint8_t)~(1 << mask)) 41 | 42 | /** Circular buffer to hold data from the host before it is sent to the device via the serial port. */ 43 | RingBuff_t USBtoUSART_Buffer; 44 | 45 | /** Circular buffer to hold data from the serial port before it is sent to the host. */ 46 | RingBuff_t USARTtoUSB_Buffer; 47 | 48 | /** Pulse generation counters to keep track of the number of milliseconds remaining for each pulse type */ 49 | volatile struct 50 | { 51 | uint8_t TxLEDPulse; /**< Milliseconds remaining for data Tx LED pulse */ 52 | uint8_t RxLEDPulse; /**< Milliseconds remaining for data Rx LED pulse */ 53 | uint8_t PingPongLEDPulse; /**< Milliseconds remaining for enumeration Tx/Rx ping-pong LED pulse */ 54 | } PulseMSRemaining; 55 | 56 | /** LUFA CDC Class driver interface configuration and state information. This structure is 57 | * passed to all CDC Class driver functions, so that multiple instances of the same class 58 | * within a device can be differentiated from one another. 59 | */ 60 | USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface = 61 | { 62 | .Config = 63 | { 64 | .ControlInterfaceNumber = 0, 65 | 66 | .DataINEndpointNumber = CDC_TX_EPNUM, 67 | .DataINEndpointSize = CDC_TXRX_EPSIZE, 68 | .DataINEndpointDoubleBank = false, 69 | 70 | .DataOUTEndpointNumber = CDC_RX_EPNUM, 71 | .DataOUTEndpointSize = CDC_TXRX_EPSIZE, 72 | .DataOUTEndpointDoubleBank = false, 73 | 74 | .NotificationEndpointNumber = CDC_NOTIFICATION_EPNUM, 75 | .NotificationEndpointSize = CDC_NOTIFICATION_EPSIZE, 76 | .NotificationEndpointDoubleBank = false, 77 | }, 78 | }; 79 | 80 | /** Main program entry point. This routine contains the overall program flow, including initial 81 | * setup of all components and the main program loop. 82 | */ 83 | int main(void) 84 | { 85 | SetupHardware(); 86 | 87 | RingBuffer_InitBuffer(&USBtoUSART_Buffer); 88 | RingBuffer_InitBuffer(&USARTtoUSB_Buffer); 89 | 90 | sei(); 91 | 92 | for (;;) 93 | { 94 | /* Only try to read in bytes from the CDC interface if the transmit buffer is not full */ 95 | if (!(RingBuffer_IsFull(&USBtoUSART_Buffer))) 96 | { 97 | int16_t ReceivedByte = CDC_Device_ReceiveByte(&VirtualSerial_CDC_Interface); 98 | 99 | /* Read bytes from the USB OUT endpoint into the USART transmit buffer */ 100 | if (!(ReceivedByte < 0)) 101 | RingBuffer_Insert(&USBtoUSART_Buffer, ReceivedByte); 102 | } 103 | 104 | /* Check if the UART receive buffer flush timer has expired or the buffer is nearly full */ 105 | RingBuff_Count_t BufferCount = RingBuffer_GetCount(&USARTtoUSB_Buffer); 106 | if ((TIFR0 & (1 << TOV0)) || (BufferCount > BUFFER_NEARLY_FULL)) 107 | { 108 | TIFR0 |= (1 << TOV0); 109 | 110 | if (USARTtoUSB_Buffer.Count) { 111 | LEDs_TurnOnLEDs(LEDMASK_TX); 112 | PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS; 113 | cbi(PORTB, 0); 114 | } 115 | 116 | /* Read bytes from the USART receive buffer into the USB IN endpoint */ 117 | while (BufferCount--) 118 | CDC_Device_SendByte(&VirtualSerial_CDC_Interface, RingBuffer_Remove(&USARTtoUSB_Buffer)); 119 | 120 | /* Turn off TX LED(s) once the TX pulse period has elapsed */ 121 | if (PulseMSRemaining.TxLEDPulse && !(--PulseMSRemaining.TxLEDPulse)){ 122 | LEDs_TurnOffLEDs(LEDMASK_TX); 123 | sbi(PORTB, 0); 124 | } 125 | 126 | /* Turn off RX LED(s) once the RX pulse period has elapsed */ 127 | if (PulseMSRemaining.RxLEDPulse && !(--PulseMSRemaining.RxLEDPulse)){ 128 | LEDs_TurnOffLEDs(LEDMASK_RX); 129 | sbi(PORTB, 0); 130 | } 131 | } 132 | 133 | /* Load the next byte from the USART transmit buffer into the USART */ 134 | if (!(RingBuffer_IsEmpty(&USBtoUSART_Buffer))) { 135 | Serial_TxByte(RingBuffer_Remove(&USBtoUSART_Buffer)); 136 | 137 | cbi(PORTB, 0); 138 | LEDs_TurnOnLEDs(LEDMASK_RX); 139 | PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS; 140 | } 141 | 142 | CDC_Device_USBTask(&VirtualSerial_CDC_Interface); 143 | USB_USBTask(); 144 | } 145 | } 146 | 147 | /** Configures the board hardware and chip peripherals for the demo's functionality. */ 148 | void SetupHardware(void) 149 | { 150 | /* Disable watchdog if enabled by bootloader/fuses */ 151 | MCUSR &= ~(1 << WDRF); 152 | wdt_disable(); 153 | 154 | /* Hardware Initialization */ 155 | Serial_Init(9600, false); 156 | LEDs_Init(); 157 | USB_Init(); 158 | 159 | /* Start the flush timer so that overflows occur rapidly to push received bytes to the USB interface */ 160 | TCCR0B = (1 << CS02); 161 | 162 | /* Pull target /RESET line high */ 163 | AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; 164 | AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK; 165 | 166 | //turn off stat LED connected to PB0 167 | DDRB |= (1<<0); 168 | sbi(PORTB, 0); 169 | } 170 | 171 | /** Event handler for the library USB Configuration Changed event. */ 172 | void EVENT_USB_Device_ConfigurationChanged(void) 173 | { 174 | CDC_Device_ConfigureEndpoints(&VirtualSerial_CDC_Interface); 175 | } 176 | 177 | /** Event handler for the library USB Unhandled Control Request event. */ 178 | void EVENT_USB_Device_UnhandledControlRequest(void) 179 | { 180 | CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface); 181 | } 182 | 183 | /** Event handler for the CDC Class driver Line Encoding Changed event. 184 | * 185 | * \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced 186 | */ 187 | void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) 188 | { 189 | uint8_t ConfigMask = 0; 190 | 191 | switch (CDCInterfaceInfo->State.LineEncoding.ParityType) 192 | { 193 | case CDC_PARITY_Odd: 194 | ConfigMask = ((1 << UPM11) | (1 << UPM10)); 195 | break; 196 | case CDC_PARITY_Even: 197 | ConfigMask = (1 << UPM11); 198 | break; 199 | } 200 | 201 | if (CDCInterfaceInfo->State.LineEncoding.CharFormat == CDC_LINEENCODING_TwoStopBits) 202 | ConfigMask |= (1 << USBS1); 203 | 204 | switch (CDCInterfaceInfo->State.LineEncoding.DataBits) 205 | { 206 | case 6: 207 | ConfigMask |= (1 << UCSZ10); 208 | break; 209 | case 7: 210 | ConfigMask |= (1 << UCSZ11); 211 | break; 212 | case 8: 213 | ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10)); 214 | break; 215 | } 216 | 217 | /* Must turn off USART before reconfiguring it, otherwise incorrect operation may occur */ 218 | UCSR1B = 0; 219 | UCSR1A = 0; 220 | UCSR1C = 0; 221 | 222 | /* Special case 57600 baud for compatibility with the ATmega328 bootloader. */ 223 | UBRR1 = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600) 224 | ? SERIAL_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS) 225 | : SERIAL_2X_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS); 226 | 227 | UCSR1C = ConfigMask; 228 | UCSR1A = (CDCInterfaceInfo->State.LineEncoding.BaudRateBPS == 57600) ? 0 : (1 << U2X1); 229 | UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1)); 230 | } 231 | 232 | /** ISR to manage the reception of data from the serial port, placing received bytes into a circular buffer 233 | * for later transmission to the host. 234 | */ 235 | ISR(USART1_RX_vect, ISR_BLOCK) 236 | { 237 | uint8_t ReceivedByte = UDR1; 238 | 239 | if (USB_DeviceState == DEVICE_STATE_Configured) 240 | RingBuffer_Insert(&USARTtoUSB_Buffer, ReceivedByte); 241 | } 242 | 243 | /** Event handler for the CDC Class driver Host-to-Device Line Encoding Changed event. 244 | * 245 | * \param[in] CDCInterfaceInfo Pointer to the CDC class interface configuration structure being referenced 246 | */ 247 | void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo) 248 | { 249 | bool CurrentDTRState = (CDCInterfaceInfo->State.ControlLineStates.HostToDevice & CDC_CONTROL_LINE_OUT_DTR); 250 | 251 | if (CurrentDTRState) 252 | AVR_RESET_LINE_PORT &= ~AVR_RESET_LINE_MASK; 253 | else 254 | AVR_RESET_LINE_PORT |= AVR_RESET_LINE_MASK; 255 | } 256 | -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/sparkfun_USBtoSerial.h: -------------------------------------------------------------------------------- 1 | /* 2 | LUFA Library 3 | Copyright (C) Dean Camera, 2010. 4 | 5 | dean [at] fourwalledcubicle [dot] com 6 | www.fourwalledcubicle.com 7 | */ 8 | 9 | /* 10 | Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) 11 | 12 | Permission to use, copy, modify, distribute, and sell this 13 | software and its documentation for any purpose is hereby granted 14 | without fee, provided that the above copyright notice appear in 15 | all copies and that both that the copyright notice and this 16 | permission notice and warranty disclaimer appear in supporting 17 | documentation, and that the name of the author not be used in 18 | advertising or publicity pertaining to distribution of the 19 | software without specific, written prior permission. 20 | 21 | The author disclaim all warranties with regard to this 22 | software, including all implied warranties of merchantability 23 | and fitness. In no event shall the author be liable for any 24 | special, indirect or consequential damages or any damages 25 | whatsoever resulting from loss of use, data or profits, whether 26 | in an action of contract, negligence or other tortious action, 27 | arising out of or in connection with the use or performance of 28 | this software. 29 | */ 30 | 31 | /** \file 32 | * 33 | * Header file for sparkfun-usbserial.c. 34 | */ 35 | 36 | #ifndef _SPARKFUN_USBSERIAL_H_ 37 | #define _SPARKFUN_USBSERIAL_H_ 38 | 39 | /* Includes: */ 40 | #include 41 | #include 42 | #include 43 | #include 44 | 45 | #include "Descriptors.h" 46 | 47 | #include "Lib/LightweightRingBuff.h" 48 | 49 | #include 50 | #include 51 | #include 52 | #include 53 | #include 54 | 55 | /* Macros: */ 56 | /** LED mask for the library LED driver, to indicate TX activity. */ 57 | #define LEDMASK_TX LEDS_LED1 58 | 59 | /** LED mask for the library LED driver, to indicate RX activity. */ 60 | #define LEDMASK_RX LEDS_LED2 61 | 62 | /** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */ 63 | #define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2) 64 | 65 | /** LED mask for the library LED driver, to indicate that the USB interface is busy. */ 66 | #define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2) 67 | 68 | /* Function Prototypes: */ 69 | void SetupHardware(void); 70 | 71 | void EVENT_USB_Device_Connect(void); 72 | void EVENT_USB_Device_Disconnect(void); 73 | void EVENT_USB_Device_ConfigurationChanged(void); 74 | void EVENT_USB_Device_UnhandledControlRequest(void); 75 | 76 | void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); 77 | void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo); 78 | 79 | #endif /* _SPARKFUN_USBSERIAL_H_ */ 80 | -------------------------------------------------------------------------------- /Projects/sparkfun_USBtoSerial-v10/sparkfun_USBtoSerial.hex: -------------------------------------------------------------------------------- 1 | :1000000096C00000AFC00000ADC00000ABC0000053 2 | :10001000A9C00000A7C00000A5C00000A3C0000048 3 | :10002000A1C000009FC000009DC0000054C400009B 4 | :1000300018C4000097C0000095C0000093C00000E5 5 | :1000400091C000008FC000008DC000008BC0000078 6 | :1000500089C0000087C0000085C0000008C1000002 7 | :1000600081C000007FC000007DC000007BC0000098 8 | :1000700079C0000012011001020000084F1B0100AE 9 | :1000800000000102000109023E00020100C0320925 10 | :1000900004000001020201000524000110042402F2 11 | :1000A000060524060001070582030800FF09040174 12 | :1000B00000020A0000000705040210000107058382 13 | :1000C00002100001040309043603530070006100AC 14 | :1000D00072006B00460075006E002000280077005B 15 | :1000E000770077002E0073007000610072006B00D3 16 | :1000F000660075006E002E0063006F006D00290021 17 | :1001000000002A0353007000610072006B0046007B 18 | :1001100075006E00200055005300420074006F000F 19 | :10012000530065007200690061006C00000011243A 20 | :100130001FBECFEFD2E0DEBFCDBF11E0A0E0B1E047 21 | :10014000E4E4FFE002C005900D92A631B107D9F7B3 22 | :1001500012E0A6E1B1E001C01D92AF32B107E1F7B4 23 | :10016000F3D0EEC64DCF9C01DC01AE57BF4FED91F1 24 | :10017000FC91119741911196FC93EE9380589F4FFB 25 | :10018000E817F90711F42D933C939FB7F894F90100 26 | :10019000EC57FF4F8081815080839FBF842F08954B 27 | :1001A000DF92EF92FF920F931F93FC0184898130BD 28 | :1001B00019F0823021F405C040E3D42E04C0DD24C0 29 | :1001C00002C030E2D32E8389823011F488E0D82A2D 30 | :1001D0008589873031F0883031F0863031F482E023 31 | :1001E00003C084E001C086E0D82A1092C9001092B2 32 | :1001F000C8001092CA00E784F0880189128980E063 33 | :10020000E81681EEF80680E0080780E0180719F488 34 | :1002100020E130E00FC0C801B7019695879577952A 35 | :10022000679560587B47814E9F4FA801970166D61E 36 | :10023000215030403093CD002093CC00D092CA00A2 37 | :1002400080E0E81681EEF80680E0080780E01807F5 38 | :1002500011F082E001C080E08093C80088E98093BB 39 | :10026000C9001F910F91FF90EF90DF9008951F92AA 40 | :100270000F920FB60F9211242F938F939F93EF93AA 41 | :10028000FF939091CE008EB38430F1F4E091990108 42 | :10029000F0919A019083E0919901F0919A01CF0138 43 | :1002A000019690939A01809399018959914021F484 44 | :1002B00089E191E0928381839FB7F89480919D01B9 45 | :1002C0008F5F80939D019FBFFF91EF919F918F91D1 46 | :1002D0002F910F900FBE0F901F901895FC018585F0 47 | :1002E00080FF02C05F9808955F9A089580E091E0D2 48 | :1002F0009BC580E091E04EC584B7877F84BF28E12D 49 | :100300000FB6F89420936000109260000FBE87E64D 50 | :1003100090E09093CD008093CC0086E08093CA005B 51 | :100320001092C8002093C900539A5A9A8AB18063E8 52 | :100330008AB98BB180638BB989D284E085BD5F9A1D 53 | :10034000579A209A289A08950F931F93CF93DF937B 54 | :10035000D3DF2FB7F8948EE991E090931F0280933A 55 | :100360001E0290932102809320022FBF2FB7F89492 56 | :1003700089E191E090939A018093990190939C0177 57 | :1003800080939B012FBF7894CEE9D1E003E08FB733 58 | :10039000F894909122028FBF903809F180E091E0AB 59 | :1003A0006FD497FD1CC0E0911E02F0911F02808364 60 | :1003B000E0911E02F0911F02CF01019690931F025F 61 | :1003C00080931E028E51924011F4D283C1839FB755 62 | :1003D000F894809122028F5F809322029FBF8FB793 63 | :1003E000F89410919D018FBFA89902C0113690F129 64 | :1003F000A89A80919D01882369F05D980093160169 65 | :10040000289808C089E191E0AEDE682F80E091E095 66 | :100410009DD411501123B1F780911601882359F012 67 | :1004200080911601815080931601809116018823D6 68 | :1004300011F45D9A289A80911701882359F08091D0 69 | :10044000170181508093170180911701882311F4BF 70 | :100450005C9A289A8FB7F894909122028FBF9923C3 71 | :1004600071F08EE991E07FDE982F8091C80085FFC2 72 | :10047000FCCF9093CE0028985C980093170180E001 73 | :1004800091E055D4EAD383CFDA01923049F093302A 74 | :1004900061F09130F9F4E4E7F0E022E130E01EC0D1 75 | :1004A000E6E8F0E02EE330E019C0813049F0813019 76 | :1004B00018F0823079F408C0E4ECF0E0849107C0D1 77 | :1004C000E8ECF0E0849103C0E2E0F1E08491282FB1 78 | :1004D00030E004C0E0E0F0E020E030E0ED93FC9399 79 | :1004E000C901089528E030E040E003C04F5F220FCB 80 | :1004F000331F28173907D0F3842F8295807F089502 81 | :100500008093E9008091EB0081608093EB00109272 82 | :10051000ED006093EC004093ED008091EE00881FA9 83 | :100520008827881F08951092F40090E09093E900C6 84 | :100530001092F0001092E8001092ED008091EB0014 85 | :100540008E7F8093EB009F5F953081F708958091B7 86 | :10055000270288238CF403C08EB38823B1F08091E6 87 | :10056000E80082FFF9CF8091E8008B778093E80064 88 | :1005700008958EB3882349F08091E80080FFF9CF79 89 | :100580008091E8008E778093E800089594E680914A 90 | :10059000EC0080FF05C08091E80080FF05C023C00B 91 | :1005A0008091E80082FD1FC08EB3882311F482E0A1 92 | :1005B00008958EB3853011F483E008958091EB00A7 93 | :1005C00085FF02C081E008958091E10082FFDFCFC6 94 | :1005D0008091E1008B7F8093E100992311F484E006 95 | :1005E00008959150D4CF80E008959C0140912D0250 96 | :1005F00050912E024617570718F4F90120E038C031 97 | :100600006115710511F0AB01F8CF8091E8008E778C 98 | :100610008093E80040E050E0F0CF8091E80083FF55 99 | :1006200002C081E008958091E80082FD2DC08EB364 100 | :10063000882381F18EB3853079F18091E80080FFC5 101 | :1006400017C09091F20006C081918093F100415053 102 | :1006500050409F5F4115510511F09830A8F320E0FC 103 | :10066000983009F421E08091E8008E778093E800CB 104 | :100670004115510591F6222381F606C08EB38823D9 105 | :1006800049F08EB3853041F08091E80082FFF6CFCB 106 | :1006900080E0089582E0089583E008959C014091F0 107 | :1006A0002D0250912E024617570710F490E03BC0E0 108 | :1006B0006115710511F0AB01F9CF8091E8008E77DB 109 | :1006C0008093E80040E050E0F1CF8091E80083FFA4 110 | :1006D00002C081E008958091E80082FD30C08EB3B1 111 | :1006E000882399F18EB3853091F18091E80080FFE5 112 | :1006F0001AC08091F20009C0F9012F5F3F4FE491C9 113 | :10070000E093F100415050408F5F4115510511F0C9 114 | :10071000883090F390E0883009F491E08091E8000F 115 | :100720008E778093E8004115510579F6992369F693 116 | :1007300006C08EB3882349F08EB3853041F0809196 117 | :10074000E80082FFF6CF80E0089582E0089583E01C 118 | :1007500008959C016115710529F48091E8008B775B 119 | :100760008093E800F90120C08091E80083FF02C077 120 | :1007700081E008958EB3882339F18EB3853031F14D 121 | :100780008091E80082FFF0CF06C08091F100819354 122 | :100790006150704021F08091F2008823B1F7809180 123 | :1007A000E8008B778093E80061157105E9F606C0D3 124 | :1007B0008EB3882349F08EB3853041F08091E800F4 125 | :1007C00080FFF6CF80E0089582E0089583E00895E9 126 | :1007D00042D044D01EBA10922502109224021092E8 127 | :1007E000230284E089BD89B5826089BD09B400FE19 128 | :1007F000FDCF8091D800982F9F779093D800806884 129 | :100800008093D800809163008E7F809363008091F5 130 | :10081000D8008F7D8093D8008091E0008E7F8093F8 131 | :10082000E0008091E1008E7F8093E1008091E20002 132 | :1008300081608093E2008091E100877F8093E100F6 133 | :100840008091E20088608093E2000895C1DF81E03A 134 | :100850008093260208951092E20008951092E1001C 135 | :1008600008951F920F920FB60F9211241F932F938A 136 | :100870003F934F935F936F937F938F939F93AF9328 137 | :10088000BF93EF93FF93E9EEF0E0108117701082B1 138 | :10089000E0EFF0E08081877F80837894C3D0F89484 139 | :1008A000A9EEB0E01C92E0EFF0E0808188608083E8 140 | :1008B0001C93FF91EF91BF91AF919F918F917F9189 141 | :1008C0006F915F914F913F912F911F910F900FBEAC 142 | :1008D0000F901F9018951F920F920FB60F92112430 143 | :1008E0002F933F934F935F936F937F938F939F9338 144 | :1008F000AF93BF93EF93FF938091E10080FF1BC004 145 | :100900008091E20080FF17C08091E1008E7F80938C 146 | :10091000E1008091E2008E7F8093E2008091E2000E 147 | :1009200080618093E2008091D80080628093D8003B 148 | :1009300019BC1EBA91D18091E10084FF29C0809139 149 | :10094000E20084FF25C084E089BD89B5826089BD4D 150 | :1009500009B400FEFDCF8091D8008F7D8093D80030 151 | :100960008091E1008F7E8093E1008091E2008F7E94 152 | :100970008093E2008091E20081608093E2008091A8 153 | :100980002502882311F481E001C084E08EBB64D18C 154 | :100990008091E10083FF27C08091E20083FF23C0A4 155 | :1009A0008091E100877F8093E10082E08EBB10920E 156 | :1009B00025028091E1008E7F8093E1008091E2002A 157 | :1009C0008E7F8093E2008091E20080618093E2005C 158 | :1009D000AADD80E060E042E093DD8091F000886075 159 | :1009E0008093F00039D18091E10082FF0AC08091AC 160 | :1009F000E20082FF06C08091E1008B7F8093E100DE 161 | :100A00002BD1FF91EF91BF91AF919F918F917F91EA 162 | :100A10006F915F914F913F912F910F900FBE0F906B 163 | :100A20001F9018951F93DF93CF9300D0CDB7DEB7FB 164 | :100A3000E7E2F2E08091F100819382E0EF32F80783 165 | :100A4000C9F78091270230912802353009F487C018 166 | :100A5000363040F43130C9F1313070F0333009F0C4 167 | :100A6000E6C033C0383009F4B8C0393009F4C7C023 168 | :100A7000363009F0DCC092C0803821F0823809F0AD 169 | :100A8000D6C008C09091230280912402882399F057 170 | :100A9000926011C080912B0287708093E900809151 171 | :100AA000EB0090E025E0969587952A95E1F7982F41 172 | :100AB00091701092E9008091E800877F8093E800B0 173 | :100AC0009093F1001092F10093C0882319F08230C6 174 | :100AD00009F0ADC090E08F719070009721F00297FF 175 | :100AE00009F0A6C00CC080912902813009F0A0C095 176 | :100AF00010922402333069F5809324022AC0809139 177 | :100B00002902882331F520912B02277009F490C027 178 | :100B10002093E9008091EB0080FF8AC0333021F4FC 179 | :100B20008091EB00806213C08091EB008061809324 180 | :100B3000EB0081E090E002C0880F991F2A95E2F750 181 | :100B40008093EA001092EA008091EB008860809325 182 | :100B5000EB001092E9008091E800877F4CC0882369 183 | :100B600009F065C0109129028091E800877F809389 184 | :100B7000E800EDDC04C08EB3882309F459C08091ED 185 | :100B8000E80080FFF8CF812F8F7711F492E001C049 186 | :100B900093E09EBB80688093E3004AC08058823017 187 | :100BA00008F045C08091290290912A0260912B02A1 188 | :100BB000AE014F5F5F4F68DCBC010097C9F18091C7 189 | :100BC000E800877F8093E80089819A8167DD8091C2 190 | :100BD000E8008B778093E8002BC0803841F5809146 191 | :100BE000E800877F8093E800809125028093F100E0 192 | :100BF0008091E8008E778093E800A9DC19C08823F3 193 | :100C0000B1F490912902923098F48091E800877FA6 194 | :100C10008093E800909325029ADC80912502882336 195 | :100C200011F483E001C084E08EBB63DB01C05EDBB6 196 | :100C30008091E80083FF0AC08091EB00806280937E 197 | :100C4000EB008091E800877F8093E8000F900F9081 198 | :100C5000CF91DF911F91089508951F938EB388233C 199 | :100C600061F01091E9001092E9008091E80083FFA3 200 | :100C700001C0D8DE17701093E9001F910895089500 201 | :100C8000FC018EB3843021F587859089A189B289D2 202 | :100C90000097A105B105E1F085818093E90080917D 203 | :100CA000E80082FF15C08091F200882319F42FEF2D 204 | :100CB0003FEF04C08091F100282F30E08091F200D6 205 | :100CC000882341F48091E8008B778093E80002C08C 206 | :100CD0002FEF3FEFC9010895FC018EB3843011F569 207 | :100CE00087859089A189B2890097A105B105D1F0C6 208 | :100CF00081818093E9008091F2008823A9F090918E 209 | :100D0000E8008091E8008E778093E80095FD0CC0A4 210 | :100D10003DDC982F882349F48091E8008E778093FA 211 | :100D2000E80003C092E001C090E0892F0895FC0123 212 | :100D30008EB3843051F487859089A189B289009758 213 | :100D4000A105B10511F0CF01C7CF08951F93FC0194 214 | :100D5000162F8EB38430D9F487859089A189B28902 215 | :100D60000097A105B10599F081818093E9008091F8 216 | :100D7000E80085FD08C08091E8008E778093E80048 217 | :100D800005DC882329F41093F10080E001C082E0A3 218 | :100D90001F9108950F931F93CF93DF93EC010D964E 219 | :100DA000FC0189E0DF011D928A95E9F72A813B81E8 220 | :100DB00009818C81882311F410E001C014E0C9017D 221 | :100DC00091DB182B1260802F61E8412F99DB88237B 222 | :100DD00029F12E813F810D818885882311F410E04F 223 | :100DE00001C014E0C9017EDB182B1260802F60E87F 224 | :100DF000412F86DB882391F02A853B8509858C85E8 225 | :100E0000882311F410E001C014E0C9016BDB182B3A 226 | :100E10001260802F61EC412F73DB01C080E0DF9115 227 | :100E2000CF911F910F910895CF93DF93EC018091A3 228 | :100E3000E80083FF60C0888190E020912B02309110 229 | :100E40002C022817390709F056C0809128028132F8 230 | :100E500061F0823220F4803209F04DC019C0823234 231 | :100E600069F1833209F047C038C080912702813A86 232 | :100E700009F041C08091E800877F8093E800CE01AF 233 | :100E80000F9667E070E0B1DB8091E8008B7713C0CC 234 | :100E900080912702813279F58091E800877F8093E5 235 | :100EA000E800CE010F9667E070E053DCCE0178D900 236 | :100EB0008091E8008E778093E8001DC08091270222 237 | :100EC0008132C9F48091E800877F8093E8008091A7 238 | :100ED00029028D87CE0102DA0DC08091270281326E 239 | :100EE00051F48091E800877F8093E800CE01609103 240 | :100EF0002902C5DE2CDBDF91CF910895A1E21A2EE5 241 | :100F0000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1FAD 242 | :100F1000A217B307E407F50720F0A21BB30BE40BFD 243 | :100F2000F50B661F771F881F991F1A9469F7609544 244 | :100F30007095809590959B01AC01BD01CF010895FE 245 | :040F4000F894FFCF53 246 | :100F4400000310000004100000020800000000006C 247 | :060F540000000000000097 248 | :00000001FF 249 | -------------------------------------------------------------------------------- /README.txt: -------------------------------------------------------------------------------- 1 | USB to Serial firmware used on the SparkFun ATmega8U2 Breakout Board, DEV-10277. 2 | 3 | This project is based off of the LUFA project and Arduino USB to Serial project. The firmware needs to be compiled against LUFA 100807. To do this, download LUFA and add only the LUFA directory (/LUFA 100807/LUFA) to the sparkfun_USBtoSerial project along side the Projects and Bootloaders directories. 4 | 5 | Use: 6 | The USB to Serial Project firmware allows the Atmega8U2 to enumerate as a SparkFun COM Port, similar to the common FTDI chip. When asked for a driver, point to the sparkfun_USBtoSerial_driver.inf file. 7 | 8 | Load code: 9 | The sparkFun_USBtoSerial_combined.hex has both the bootloader and USB to Serial firmware. This is the hex file installed on the SparkFun Atmega8U2 Breakout. Here is the command to burn the combined hex: 10 | Load combined hex: 11 | 12 | STK500 -datmega8u2 -cUSB -I150kHz -e -pf -vf -ifsparkfun_USBtoSerial_combined.hex -ms -fD9FF -EF4 -lCF -LCF 13 | 14 | Directories: 15 | The Bootloaders directory contains the DFU bootloader firmware. 16 | 17 | The Projects folder contains the USB to Serial firmware using the SparkFun VID and needs to be used with the sparkfun_USBtoSerial_driver.inf driver. SparkFun paid for the VID, so please only use for development only. 18 | 19 | ATmega8U2 Hardware Config: 20 | 21 | Fuses - HF: 0xD9, LF: 0xFF, EF:0xF4, Lock:0x0F 22 | 16MHz crystal 23 | -------------------------------------------------------------------------------- /sparkfun_USBtoSerial_combined.hex: -------------------------------------------------------------------------------- 1 | :101000004BC0000064C0000062C0000060C000006F 2 | :101010005EC000005CC000005AC0000058C0000064 3 | :1010200056C0000054C0000052C00000CBC40000F5 4 | :101030004EC000004CC000004AC0000048C0000084 5 | :1010400046C0000044C0000042C0000040C0000094 6 | :101050003EC000003CC000003AC0000038C00000A4 7 | :1010600036C0000034C0000032C0000030C00000B4 8 | :101070002EC000002CC000002AC0000028C00000C4 9 | :1010800026C0000024C0000022C0000020C00000D4 10 | :101090001EC000001CC0000011241FBECFEFD2E014 11 | :1010A000DEBFCDBF11E0A0E0B1E0E4EBFCE102C0A7 12 | :1010B00005900D92A436B107D9F711E0A4E6B1E08E 13 | :1010C00001C01D92A338B107E1F74FD3F1C598CF06 14 | :1010D000982F15C08091F200882371F48091E80068 15 | :1010E0008B7F8093E80003C08EB3882351F08091FA 16 | :1010F000E80082FFF9CF02C08091F100915099235E 17 | :1011000049F7089520917201309171018091700129 18 | :1011100090916F018093690190936A01C901809356 19 | :101120006B0190936C01089580916D01843009F4F6 20 | :101130005AC0853030F4813059F0833009F0C3C093 21 | :101140001FC0853009F4A0C0863009F0BCC0AFC014 22 | :1011500080916E01823008F0B6C0D4DF80916E01BC 23 | :10116000882361F48091690190916A0123E0FC0178 24 | :1011700020935700E89507B600FCFDCF85E008C036 25 | :1011800080916E01882311F0823029F4BBDF89E061 26 | :10119000809301010895813009F095C020E030E08E 27 | :1011A00040E050E0F90184918F3F81F0CA01AA2705 28 | :1011B000BB278093680130936A01209369018AE01C 29 | :1011C0008093010185E08093650108952F5F3F4F73 30 | :1011D0004F4F5F4F2030F0E13F07F0E04F07F0E066 31 | :1011E0005F0701F7089580916E01833051F581E02A 32 | :1011F000809364018091730190917401892B71F047 33 | :1012000080916F01813009F05EC0809172019091F0 34 | :1012100071019093670180936601089580916F0139 35 | :10122000882361F42CE088E190E00FB6F894A8954B 36 | :10123000809360000FBE209360000895109200011B 37 | :101240000895882309F03FC080916F018F3F09F016 38 | :101250003AC0E0E0F0E093E085E090935700E89535 39 | :1012600007B600FCFDCF80935700E89507B600FC59 40 | :10127000FDCFE058FF4F20E1E030F20771F781E148 41 | :1012800080935700E8950895E0916F0180916E0179 42 | :10129000882321F4F0E0EB5FFE4F05C0813099F424 43 | :1012A000F0E0EE52FF4F80818093780108958091A5 44 | :1012B0006E01833041F480916F01882321F4809185 45 | :1012C00070018093680108952F923F924F925F9230 46 | :1012D0006F927F929F92AF92BF92CF92DF92EF92E6 47 | :1012E000FF920F931F93CF93DF9380918101909191 48 | :1012F000820190937401809373018091750188231A 49 | :1013000051F0809175018150809375018091750134 50 | :10131000882309F45D9A80917601882351F08091A9 51 | :10132000760181508093760180917601882309F4BB 52 | :101330005C9A80917C01833009F4B2C1843030F42E 53 | :10134000813071F0823009F0E3C111C1853009F4B8 54 | :10135000C5C1853008F4BAC1863009F0D9C1CDC104 55 | :101360005C9883E0809376018091E800877F80938A 56 | :10137000E80080916401882329F0D6DE5D9A5C9AAA 57 | :10138000109264012091730130917401211531058F 58 | :1013900029F42AC08EB3882309F4BAC18091E800E9 59 | :1013A00082FFF8CF8091F10080936D012150304091 60 | :1013B0003093740120937301EEE6F1E00CC080914C 61 | :1013C000F10081932150304081E0E337F80719F4B0 62 | :1013D0003183208308C08091F200882381F7309305 63 | :1013E000740120937301A0DE80910101853009F022 64 | :1013F000BAC08091730190917401892B21F482E02D 65 | :1014000080930101B0C08AE163DE809169018F7130 66 | :101410005FDEC0916B01D0916C0120916901309128 67 | :101420006A0121968E01021B130B219780916E0198 68 | :10143000882309F093C0180136942794C901A0911C 69 | :101440006801B0E09C01AD0162E0E62EF12C012DB7 70 | :10145000112DE20EF31E041F151F59016A0190E0C1 71 | :1014600099249394B5E0A3E048C08091F2008823CA 72 | :1014700071F48091E8008B7F8093E80004C08EB304 73 | :10148000882309F445C18091E80082FFF8CF0894D1 74 | :10149000210831088091F100682F8091F100782FA8 75 | :1014A000F5010B0190925700E89511249F5F90344D 76 | :1014B00019F021143104A1F4F901B0935700E89513 77 | :1014C00007B600FCFDCF2114310451F0F701A093C1 78 | :1014D0005700E89507B600FCFDCFA801970190E002 79 | :1014E00042E0442E512C612C712CE40CF51C061D9D 80 | :1014F000171DA40CB51CC61CD71C2114310409F0FF 81 | :10150000B4CFD0936A01C093690181E18093570001 82 | :10151000E89527C08091F200882371F48091E8005B 83 | :101520008B7F8093E80004C08EB3882309F4F0C059 84 | :101530008091E80082FFF8CF6091F100809169010D 85 | :1015400090916A01A7D38091690190916A010196F7 86 | :1015500090936A01809369010150104001151105B3 87 | :10156000C9F680E1B5DD8091E8008B7FC3C0809132 88 | :10157000E800877F8093E8005D9883E080937501A1 89 | :1015800004C08EB3882309F4C3C08091E80080FFB3 90 | :10159000F8CF80910101893091F08A3069F480910F 91 | :1015A0006E01813049F48091690190916A018093C4 92 | :1015B000F1009093F1009BC08091780196C06091FA 93 | :1015C0006B0170916C012091690130916A016F5F2C 94 | :1015D0007F4F7B01E21AF30A6150704080916E01E7 95 | :1015E000882389F5870116950795C901A09168019F 96 | :1015F000B0E09C01AD011FC08091F200803271F417 97 | :101600008091E8008E7F8093E80004C08EB3882329 98 | :1016100009F47EC08091E80080FFF8CFF901859140 99 | :1016200094918093F1009093F100015010402E5F4F 100 | :101630003F4F4F4F5F4F01151105F1F670936A014F 101 | :101640006093690129C0823039F523C08091F2008E 102 | :10165000803271F48091E8008E7F8093E80004C0AE 103 | :101660008EB3882309F454C08091E80080FFF8CF3E 104 | :101670000091690110916A01C80104D38093F100BF 105 | :101680000F5F1F4F10936A01009369010894E108EE 106 | :10169000F108E114F104D1F682E08093010127C042 107 | :1016A0008091E800877F8093E800809165018093B6 108 | :1016B000F1001092F1001092F1001092F10080916F 109 | :1016C00001018093F1001092F10011C08091E800B7 110 | :1016D000877F8093E8001092650119C08091E8002F 111 | :1016E000877F8093E800809101018093F1008091D1 112 | :1016F000E8008E7F8093E8000AC08091E800877F31 113 | :101700008093E8005D9A5C9A82E08093010187D023 114 | :10171000DF91CF911F910F91FF90EF90DF90CF90CD 115 | :10172000BF90AF909F907F906F905F904F903F9051 116 | :101730002F9008952BD181E085BF15BE089584B701 117 | :10174000877F84BF88E10FB6F89480936000109281 118 | :1017500060000FBE81E085BF82E085BF8AB18063F3 119 | :101760008AB98BB180638BB90CC1E9DF789401C071 120 | :1017700080D2809100018823D9F780916401882369 121 | :10178000B9F7D8DFE0916601F09167010995FA0198 122 | :10179000923071F0933089F0913029F488E091E033 123 | :1017A00022E130E019C080E090E020E030E014C099 124 | :1017B0008AE191E02BE130E00FC0882339F4809179 125 | :1017C0003501282F30E085E391E006C08091390192 126 | :1017D000282F30E089E391E091838083C901089547 127 | :1017E0008091EB0081608093EB001092ED0060939C 128 | :1017F000EC004093ED008091EE00881F8827881F41 129 | :1018000008951092F4001092F0001092E8001092E7 130 | :10181000ED00EBEEF0E080818E7F80830895809173 131 | :101820007B0188238CF403C08EB38823B1F08091B0 132 | :10183000E80082FFF9CF8091E8008B7F8093E80079 133 | :1018400008958EB3882349F08091E80080FFF9CF96 134 | :101850008091E8008E7F8093E80008959C0140917C 135 | :101860008101509182014617570718F4F90120E0D1 136 | :1018700038C06115710511F0AB01F8CF8091E80017 137 | :101880008E7F8093E80040E050E0F0CF8091E80048 138 | :1018900083FF02C081E008958091E80082FD2DC0A1 139 | :1018A0008EB3882381F18EB3853079F18091E80081 140 | :1018B00080FF17C09091F20006C081918093F100E3 141 | :1018C000415050409F5F4115510511F09032A8F3EF 142 | :1018D00020E0903209F421E08091E8008E7F80932F 143 | :1018E000E8004115510591F6222381F606C08EB31A 144 | :1018F000882349F08EB3853041F08091E80082FF63 145 | :10190000F6CF80E0089582E0089583E0089554D0F2 146 | :1019100056D01EBA1092790184E089BD89B58260E3 147 | :1019200089BD09B400FEFDCF8091D800982F9F7724 148 | :101930009093D80080688093D800809163008E7F58 149 | :10194000809363008091D8008F7D8093D800809130 150 | :10195000E0008E7F8093E0008091E1008E7F809395 151 | :10196000E1008091E20081608093E2008091E100DB 152 | :10197000877F8093E1008091E20088608093E2009D 153 | :101980000895C5DF81E080937A010895C0DFE0EE1D 154 | :10199000F0E0808181608083E8EDF0E080818F77E6 155 | :1019A00080830AD00CD019BCE3E6F0E0808181602E 156 | :1019B000808310927A0108951092E20008951092A7 157 | :1019C000E10008951F920F920FB60F9211242F93EA 158 | :1019D0003F934F935F936F937F938F939F93AF93B7 159 | :1019E000BF93EF93FF938091E10080FF1BC0809134 160 | :1019F000E20080FF17C08091E1008E7F8093E100BC 161 | :101A00008091E2008E7F8093E2008091E20080610D 162 | :101A10008093E2008091D80080628093D80019BC46 163 | :101A20001EBA26D18091E10084FF29C08091E20096 164 | :101A300084FF25C084E089BD89B5826089BD09B471 165 | :101A400000FEFDCF8091D8008F7D8093D8008091DB 166 | :101A5000E1008F7E8093E1008091E2008F7E809391 167 | :101A6000E2008091E20081608093E2008091790140 168 | :101A7000882311F481E001C084E08EBBF9D080910D 169 | :101A8000E10083FF22C08091E20083FF1EC08091AD 170 | :101A9000E100877F8093E10082E08EBB10927901A4 171 | :101AA0008091E1008E7F8093E1008091E2008E7F43 172 | :101AB0008093E2008091E20080618093E200A1DEE9 173 | :101AC00080E060E042E28CDED3D08091E10082FFD2 174 | :101AD0000AC08091E20082FF06C08091E1008B7F06 175 | :101AE0008093E100C5D0FF91EF91BF91AF919F919D 176 | :101AF0008F917F916F915F914F913F912F910F90B7 177 | :101B00000FBE0F901F9018951F93DF93CF9300D0B7 178 | :101B1000CDB7DEB7EBE7F1E08091F100819381E092 179 | :101B2000E338F807C9F790917B0180917C018530FB 180 | :101B300011F1863040F48130B9F0813070F083309B 181 | :101B400009F081C011C0883009F453C0893009F40C 182 | :101B500062C0863009F077C02DC0903809F474C097 183 | :101B6000923809F070C070C0992309F46DC09230AA 184 | :101B700009F069C069C0992309F065C010917D0121 185 | :101B80008091E800877F8093E80049DE04C08EB32F 186 | :101B9000882309F459C08091E80080FFF8CF812F95 187 | :101BA0008F7711F492E001C093E09EBB8068809330 188 | :101BB000E3004AC09058923008F045C080917D0102 189 | :101BC00090917E0160917F01AE014F5F5F4FDFDD3D 190 | :101BD000BC010097C9F18091E800877F8093E800FD 191 | :101BE00089819A813BDE8091E8008B7F8093E800B9 192 | :101BF0002BC0903841F58091E800877F8093E80002 193 | :101C0000809179018093F1008091E8008E7F80932C 194 | :101C1000E80005DE19C09923B1F490917D0192305E 195 | :101C200098F48091E800877F8093E8009093790191 196 | :101C3000F6DD80917901882311F483E001C084E00E 197 | :101C40008EBB16D001C040DB8091E80083FF0AC044 198 | :101C50008091EB0080628093EB008091E800877FA9 199 | :101C60008093E8000F900F90CF91DF911F9108951E 200 | :101C700008958EB3882329F08091E80083FF01C086 201 | :101C800043CF0895F999FECF92BD81BDF89A992767 202 | :101C900080B50895262FF999FECF1FBA92BD81BD58 203 | :101CA00020BD0FB6F894FA9AF99A0FBE01960895DE 204 | :041CB000F894FFCFD6 205 | :101CB40001021E938220DCFB1201100100000020AF 206 | :101CC400EB03F72F00000001000109021B000101D2 207 | :101CD4000080320904000000FE0102000921030013 208 | :101CE40000000C0001040309042803530070006180 209 | :101CF4000072006B00460075006E00200042006F09 210 | :101D0400006F0074006C006F006100640065007275 211 | :041D140000000000CB 212 | :0400000300001000E9 213 | :1000000096C00000AFC00000ADC00000ABC0000053 214 | :10001000A9C00000A7C00000A5C00000A3C0000048 215 | :10002000A1C000009FC000009DC0000054C400009B 216 | :1000300018C4000097C0000095C0000093C00000E5 217 | :1000400091C000008FC000008DC000008BC0000078 218 | :1000500089C0000087C0000085C0000008C1000002 219 | :1000600081C000007FC000007DC000007BC0000098 220 | :1000700079C0000012011001020000084F1B0100AE 221 | :1000800000000102000109023E00020100C0320925 222 | :1000900004000001020201000524000110042402F2 223 | :1000A000060524060001070582030800FF09040174 224 | :1000B00000020A0000000705040210000107058382 225 | :1000C00002100001040309043603530070006100AC 226 | :1000D00072006B00460075006E002000280077005B 227 | :1000E000770077002E0073007000610072006B00D3 228 | :1000F000660075006E002E0063006F006D00290021 229 | :1001000000002A0353007000610072006B0046007B 230 | :1001100075006E00200055005300420074006F000F 231 | :10012000530065007200690061006C00000011243A 232 | :100130001FBECFEFD2E0DEBFCDBF11E0A0E0B1E047 233 | :10014000E4E4FFE002C005900D92A631B107D9F7B3 234 | :1001500012E0A6E1B1E001C01D92AF32B107E1F7B4 235 | :10016000F3D0EEC64DCF9C01DC01AE57BF4FED91F1 236 | :10017000FC91119741911196FC93EE9380589F4FFB 237 | :10018000E817F90711F42D933C939FB7F894F90100 238 | :10019000EC57FF4F8081815080839FBF842F08954B 239 | :1001A000DF92EF92FF920F931F93FC0184898130BD 240 | :1001B00019F0823021F405C040E3D42E04C0DD24C0 241 | :1001C00002C030E2D32E8389823011F488E0D82A2D 242 | :1001D0008589873031F0883031F0863031F482E023 243 | :1001E00003C084E001C086E0D82A1092C9001092B2 244 | :1001F000C8001092CA00E784F0880189128980E063 245 | :10020000E81681EEF80680E0080780E0180719F488 246 | :1002100020E130E00FC0C801B7019695879577952A 247 | :10022000679560587B47814E9F4FA801970166D61E 248 | :10023000215030403093CD002093CC00D092CA00A2 249 | :1002400080E0E81681EEF80680E0080780E01807F5 250 | :1002500011F082E001C080E08093C80088E98093BB 251 | :10026000C9001F910F91FF90EF90DF9008951F92AA 252 | :100270000F920FB60F9211242F938F939F93EF93AA 253 | :10028000FF939091CE008EB38430F1F4E091990108 254 | :10029000F0919A019083E0919901F0919A01CF0138 255 | :1002A000019690939A01809399018959914021F484 256 | :1002B00089E191E0928381839FB7F89480919D01B9 257 | :1002C0008F5F80939D019FBFFF91EF919F918F91D1 258 | :1002D0002F910F900FBE0F901F901895FC018585F0 259 | :1002E00080FF02C05F9808955F9A089580E091E0D2 260 | :1002F0009BC580E091E04EC584B7877F84BF28E12D 261 | :100300000FB6F89420936000109260000FBE87E64D 262 | :1003100090E09093CD008093CC0086E08093CA005B 263 | :100320001092C8002093C900539A5A9A8AB18063E8 264 | :100330008AB98BB180638BB989D284E085BD5F9A1D 265 | :10034000579A209A289A08950F931F93CF93DF937B 266 | :10035000D3DF2FB7F8948EE991E090931F0280933A 267 | :100360001E0290932102809320022FBF2FB7F89492 268 | :1003700089E191E090939A018093990190939C0177 269 | :1003800080939B012FBF7894CEE9D1E003E08FB733 270 | :10039000F894909122028FBF903809F180E091E0AB 271 | :1003A0006FD497FD1CC0E0911E02F0911F02808364 272 | :1003B000E0911E02F0911F02CF01019690931F025F 273 | :1003C00080931E028E51924011F4D283C1839FB755 274 | :1003D000F894809122028F5F809322029FBF8FB793 275 | :1003E000F89410919D018FBFA89902C0113690F129 276 | :1003F000A89A80919D01882369F05D980093160169 277 | :10040000289808C089E191E0AEDE682F80E091E095 278 | :100410009DD411501123B1F780911601882359F012 279 | :1004200080911601815080931601809116018823D6 280 | :1004300011F45D9A289A80911701882359F08091D0 281 | :10044000170181508093170180911701882311F4BF 282 | :100450005C9A289A8FB7F894909122028FBF9923C3 283 | :1004600071F08EE991E07FDE982F8091C80085FFC2 284 | :10047000FCCF9093CE0028985C980093170180E001 285 | :1004800091E055D4EAD383CFDA01923049F093302A 286 | :1004900061F09130F9F4E4E7F0E022E130E01EC0D1 287 | :1004A000E6E8F0E02EE330E019C0813049F0813019 288 | :1004B00018F0823079F408C0E4ECF0E0849107C0D1 289 | :1004C000E8ECF0E0849103C0E2E0F1E08491282FB1 290 | :1004D00030E004C0E0E0F0E020E030E0ED93FC9399 291 | :1004E000C901089528E030E040E003C04F5F220FCB 292 | :1004F000331F28173907D0F3842F8295807F089502 293 | :100500008093E9008091EB0081608093EB00109272 294 | :10051000ED006093EC004093ED008091EE00881FA9 295 | :100520008827881F08951092F40090E09093E900C6 296 | :100530001092F0001092E8001092ED008091EB0014 297 | :100540008E7F8093EB009F5F953081F708958091B7 298 | :10055000270288238CF403C08EB38823B1F08091E6 299 | :10056000E80082FFF9CF8091E8008B778093E80064 300 | :1005700008958EB3882349F08091E80080FFF9CF79 301 | :100580008091E8008E778093E800089594E680914A 302 | :10059000EC0080FF05C08091E80080FF05C023C00B 303 | :1005A0008091E80082FD1FC08EB3882311F482E0A1 304 | :1005B00008958EB3853011F483E008958091EB00A7 305 | :1005C00085FF02C081E008958091E10082FFDFCFC6 306 | :1005D0008091E1008B7F8093E100992311F484E006 307 | :1005E00008959150D4CF80E008959C0140912D0250 308 | :1005F00050912E024617570718F4F90120E038C031 309 | :100600006115710511F0AB01F8CF8091E8008E778C 310 | :100610008093E80040E050E0F0CF8091E80083FF55 311 | :1006200002C081E008958091E80082FD2DC08EB364 312 | :10063000882381F18EB3853079F18091E80080FFC5 313 | :1006400017C09091F20006C081918093F100415053 314 | :1006500050409F5F4115510511F09830A8F320E0FC 315 | :10066000983009F421E08091E8008E778093E800CB 316 | :100670004115510591F6222381F606C08EB38823D9 317 | :1006800049F08EB3853041F08091E80082FFF6CFCB 318 | :1006900080E0089582E0089583E008959C014091F0 319 | :1006A0002D0250912E024617570710F490E03BC0E0 320 | :1006B0006115710511F0AB01F9CF8091E8008E77DB 321 | :1006C0008093E80040E050E0F1CF8091E80083FFA4 322 | :1006D00002C081E008958091E80082FD30C08EB3B1 323 | :1006E000882399F18EB3853091F18091E80080FFE5 324 | :1006F0001AC08091F20009C0F9012F5F3F4FE491C9 325 | :10070000E093F100415050408F5F4115510511F0C9 326 | :10071000883090F390E0883009F491E08091E8000F 327 | :100720008E778093E8004115510579F6992369F693 328 | :1007300006C08EB3882349F08EB3853041F0809196 329 | :10074000E80082FFF6CF80E0089582E0089583E01C 330 | :1007500008959C016115710529F48091E8008B775B 331 | :100760008093E800F90120C08091E80083FF02C077 332 | :1007700081E008958EB3882339F18EB3853031F14D 333 | :100780008091E80082FFF0CF06C08091F100819354 334 | :100790006150704021F08091F2008823B1F7809180 335 | :1007A000E8008B778093E80061157105E9F606C0D3 336 | :1007B0008EB3882349F08EB3853041F08091E800F4 337 | :1007C00080FFF6CF80E0089582E0089583E00895E9 338 | :1007D00042D044D01EBA10922502109224021092E8 339 | :1007E000230284E089BD89B5826089BD09B400FE19 340 | :1007F000FDCF8091D800982F9F779093D800806884 341 | :100800008093D800809163008E7F809363008091F5 342 | :10081000D8008F7D8093D8008091E0008E7F8093F8 343 | :10082000E0008091E1008E7F8093E1008091E20002 344 | :1008300081608093E2008091E100877F8093E100F6 345 | :100840008091E20088608093E2000895C1DF81E03A 346 | :100850008093260208951092E20008951092E1001C 347 | :1008600008951F920F920FB60F9211241F932F938A 348 | :100870003F934F935F936F937F938F939F93AF9328 349 | :10088000BF93EF93FF93E9EEF0E0108117701082B1 350 | :10089000E0EFF0E08081877F80837894C3D0F89484 351 | :1008A000A9EEB0E01C92E0EFF0E0808188608083E8 352 | :1008B0001C93FF91EF91BF91AF919F918F917F9189 353 | :1008C0006F915F914F913F912F911F910F900FBEAC 354 | :1008D0000F901F9018951F920F920FB60F92112430 355 | :1008E0002F933F934F935F936F937F938F939F9338 356 | :1008F000AF93BF93EF93FF938091E10080FF1BC004 357 | :100900008091E20080FF17C08091E1008E7F80938C 358 | :10091000E1008091E2008E7F8093E2008091E2000E 359 | :1009200080618093E2008091D80080628093D8003B 360 | :1009300019BC1EBA91D18091E10084FF29C0809139 361 | :10094000E20084FF25C084E089BD89B5826089BD4D 362 | :1009500009B400FEFDCF8091D8008F7D8093D80030 363 | :100960008091E1008F7E8093E1008091E2008F7E94 364 | :100970008093E2008091E20081608093E2008091A8 365 | :100980002502882311F481E001C084E08EBB64D18C 366 | :100990008091E10083FF27C08091E20083FF23C0A4 367 | :1009A0008091E100877F8093E10082E08EBB10920E 368 | :1009B00025028091E1008E7F8093E1008091E2002A 369 | :1009C0008E7F8093E2008091E20080618093E2005C 370 | :1009D000AADD80E060E042E093DD8091F000886075 371 | :1009E0008093F00039D18091E10082FF0AC08091AC 372 | :1009F000E20082FF06C08091E1008B7F8093E100DE 373 | :100A00002BD1FF91EF91BF91AF919F918F917F91EA 374 | :100A10006F915F914F913F912F910F900FBE0F906B 375 | :100A20001F9018951F93DF93CF9300D0CDB7DEB7FB 376 | :100A3000E7E2F2E08091F100819382E0EF32F80783 377 | :100A4000C9F78091270230912802353009F487C018 378 | :100A5000363040F43130C9F1313070F0333009F0C4 379 | :100A6000E6C033C0383009F4B8C0393009F4C7C023 380 | :100A7000363009F0DCC092C0803821F0823809F0AD 381 | :100A8000D6C008C09091230280912402882399F057 382 | :100A9000926011C080912B0287708093E900809151 383 | :100AA000EB0090E025E0969587952A95E1F7982F41 384 | :100AB00091701092E9008091E800877F8093E800B0 385 | :100AC0009093F1001092F10093C0882319F08230C6 386 | :100AD00009F0ADC090E08F719070009721F00297FF 387 | :100AE00009F0A6C00CC080912902813009F0A0C095 388 | :100AF00010922402333069F5809324022AC0809139 389 | :100B00002902882331F520912B02277009F490C027 390 | :100B10002093E9008091EB0080FF8AC0333021F4FC 391 | :100B20008091EB00806213C08091EB008061809324 392 | :100B3000EB0081E090E002C0880F991F2A95E2F750 393 | :100B40008093EA001092EA008091EB008860809325 394 | :100B5000EB001092E9008091E800877F4CC0882369 395 | :100B600009F065C0109129028091E800877F809389 396 | :100B7000E800EDDC04C08EB3882309F459C08091ED 397 | :100B8000E80080FFF8CF812F8F7711F492E001C049 398 | :100B900093E09EBB80688093E3004AC08058823017 399 | :100BA00008F045C08091290290912A0260912B02A1 400 | :100BB000AE014F5F5F4F68DCBC010097C9F18091C7 401 | :100BC000E800877F8093E80089819A8167DD8091C2 402 | :100BD000E8008B778093E8002BC0803841F5809146 403 | :100BE000E800877F8093E800809125028093F100E0 404 | :100BF0008091E8008E778093E800A9DC19C08823F3 405 | :100C0000B1F490912902923098F48091E800877FA6 406 | :100C10008093E800909325029ADC80912502882336 407 | :100C200011F483E001C084E08EBB63DB01C05EDBB6 408 | :100C30008091E80083FF0AC08091EB00806280937E 409 | :100C4000EB008091E800877F8093E8000F900F9081 410 | :100C5000CF91DF911F91089508951F938EB388233C 411 | :100C600061F01091E9001092E9008091E80083FFA3 412 | :100C700001C0D8DE17701093E9001F910895089500 413 | :100C8000FC018EB3843021F587859089A189B289D2 414 | :100C90000097A105B105E1F085818093E90080917D 415 | :100CA000E80082FF15C08091F200882319F42FEF2D 416 | :100CB0003FEF04C08091F100282F30E08091F200D6 417 | :100CC000882341F48091E8008B778093E80002C08C 418 | :100CD0002FEF3FEFC9010895FC018EB3843011F569 419 | :100CE00087859089A189B2890097A105B105D1F0C6 420 | :100CF00081818093E9008091F2008823A9F090918E 421 | :100D0000E8008091E8008E778093E80095FD0CC0A4 422 | :100D10003DDC982F882349F48091E8008E778093FA 423 | :100D2000E80003C092E001C090E0892F0895FC0123 424 | :100D30008EB3843051F487859089A189B289009758 425 | :100D4000A105B10511F0CF01C7CF08951F93FC0194 426 | :100D5000162F8EB38430D9F487859089A189B28902 427 | :100D60000097A105B10599F081818093E9008091F8 428 | :100D7000E80085FD08C08091E8008E778093E80048 429 | :100D800005DC882329F41093F10080E001C082E0A3 430 | :100D90001F9108950F931F93CF93DF93EC010D964E 431 | :100DA000FC0189E0DF011D928A95E9F72A813B81E8 432 | :100DB00009818C81882311F410E001C014E0C9017D 433 | :100DC00091DB182B1260802F61E8412F99DB88237B 434 | :100DD00029F12E813F810D818885882311F410E04F 435 | :100DE00001C014E0C9017EDB182B1260802F60E87F 436 | :100DF000412F86DB882391F02A853B8509858C85E8 437 | :100E0000882311F410E001C014E0C9016BDB182B3A 438 | :100E10001260802F61EC412F73DB01C080E0DF9115 439 | :100E2000CF911F910F910895CF93DF93EC018091A3 440 | :100E3000E80083FF60C0888190E020912B02309110 441 | :100E40002C022817390709F056C0809128028132F8 442 | :100E500061F0823220F4803209F04DC019C0823234 443 | :100E600069F1833209F047C038C080912702813A86 444 | :100E700009F041C08091E800877F8093E800CE01AF 445 | :100E80000F9667E070E0B1DB8091E8008B7713C0CC 446 | :100E900080912702813279F58091E800877F8093E5 447 | :100EA000E800CE010F9667E070E053DCCE0178D900 448 | :100EB0008091E8008E778093E8001DC08091270222 449 | :100EC0008132C9F48091E800877F8093E8008091A7 450 | :100ED00029028D87CE0102DA0DC08091270281326E 451 | :100EE00051F48091E800877F8093E800CE01609103 452 | :100EF0002902C5DE2CDBDF91CF910895A1E21A2EE5 453 | :100F0000AA1BBB1BFD010DC0AA1FBB1FEE1FFF1FAD 454 | :100F1000A217B307E407F50720F0A21BB30BE40BFD 455 | :100F2000F50B661F771F881F991F1A9469F7609544 456 | :100F30007095809590959B01AC01BD01CF010895FE 457 | :040F4000F894FFCF53 458 | :100F4400000310000004100000020800000000006C 459 | :060F540000000000000097 460 | :00000001FF 461 | 462 | -------------------------------------------------------------------------------- /sparkfun_USBtoSerial_driver.inf: -------------------------------------------------------------------------------- 1 | ;************************************************************ 2 | ; Windows USB CDC ACM Setup File 3 | ; Copyright (c) 2000 Microsoft Corporation 4 | 5 | 6 | [Version] 7 | Signature="$Windows NT$" 8 | Class=Ports 9 | ClassGuid={4D36E978-E325-11CE-BFC1-08002BE10318} 10 | Provider=%MFGNAME% 11 | LayoutFile=layout.inf 12 | CatalogFile=%MFGFILENAME%.cat 13 | DriverVer=11/15/2007,5.1.2600.0 14 | 15 | [Manufacturer] 16 | %MFGNAME%=DeviceList, NTamd64 17 | 18 | [DestinationDirs] 19 | DefaultDestDir=12 20 | 21 | 22 | ;------------------------------------------------------------------------------ 23 | ; Windows 2000/XP/Vista-32bit Sections 24 | ;------------------------------------------------------------------------------ 25 | 26 | [DriverInstall.nt] 27 | include=mdmcpq.inf 28 | CopyFiles=DriverCopyFiles.nt 29 | AddReg=DriverInstall.nt.AddReg 30 | 31 | [DriverCopyFiles.nt] 32 | usbser.sys,,,0x20 33 | 34 | [DriverInstall.nt.AddReg] 35 | HKR,,DevLoader,,*ntkern 36 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 37 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 38 | 39 | [DriverInstall.nt.Services] 40 | AddService=usbser, 0x00000002, DriverService.nt 41 | 42 | [DriverService.nt] 43 | DisplayName=%SERVICE% 44 | ServiceType=1 45 | StartType=3 46 | ErrorControl=1 47 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 48 | 49 | ;------------------------------------------------------------------------------ 50 | ; Vista-64bit Sections 51 | ;------------------------------------------------------------------------------ 52 | 53 | [DriverInstall.NTamd64] 54 | include=mdmcpq.inf 55 | CopyFiles=DriverCopyFiles.NTamd64 56 | AddReg=DriverInstall.NTamd64.AddReg 57 | 58 | [DriverCopyFiles.NTamd64] 59 | %DRIVERFILENAME%.sys,,,0x20 60 | 61 | [DriverInstall.NTamd64.AddReg] 62 | HKR,,DevLoader,,*ntkern 63 | HKR,,NTMPDriver,,%DRIVERFILENAME%.sys 64 | HKR,,EnumPropPages32,,"MsPorts.dll,SerialPortPropPageProvider" 65 | 66 | [DriverInstall.NTamd64.Services] 67 | AddService=usbser, 0x00000002, DriverService.NTamd64 68 | 69 | [DriverService.NTamd64] 70 | DisplayName=%SERVICE% 71 | ServiceType=1 72 | StartType=3 73 | ErrorControl=1 74 | ServiceBinary=%12%\%DRIVERFILENAME%.sys 75 | 76 | 77 | ;------------------------------------------------------------------------------ 78 | ; Vendor and Product ID Definitions 79 | ;------------------------------------------------------------------------------ 80 | ; When developing your USB device, the VID and PID used in the PC side 81 | ; application program and the firmware on the microcontroller must match. 82 | ; Modify the below line to use your VID and PID. Use the format as shown below. 83 | ; Note: One INF file can be used for multiple devices with different VID and PIDs. 84 | ; For each supported device, append ",USB\VID_xxxx&PID_yyyy" to the end of the line. 85 | ;------------------------------------------------------------------------------ 86 | [SourceDisksFiles] 87 | [SourceDisksNames] 88 | [DeviceList] 89 | %DESCRIPTION%=DriverInstall, USB\VID_1B4F&PID_0001 90 | 91 | [DeviceList.NTamd64] 92 | %DESCRIPTION%=DriverInstall, USB\VID_1B4F&PID_0001 93 | 94 | 95 | ;------------------------------------------------------------------------------ 96 | ; String Definitions 97 | ;------------------------------------------------------------------------------ 98 | ;Modify these strings to customize your device 99 | ;------------------------------------------------------------------------------ 100 | [Strings] 101 | MFGFILENAME="CDC_vista" 102 | DRIVERFILENAME ="usbser" 103 | MFGNAME="http://www.sparkfun.com" 104 | INSTDISK="LUFA USB-RS232 CDC Driver Installer" 105 | DESCRIPTION="SparkFun COM Port" 106 | SERVICE="USB RS-232 Emulation Driver" --------------------------------------------------------------------------------