Commit 071e02c6 authored by Dean Camera's avatar Dean Camera
Browse files

Add svn:eol-style property to source files, so that the line endings are...

Add svn:eol-style property to source files, so that the line endings are correctly converted to the target system's native end of line style.
parent e331b531
This diff is collapsed.
/* /*
LUFA Library LUFA Library
Copyright (C) Dean Camera, 2010. Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com www.fourwalledcubicle.com
*/ */
/* /*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the advertising or publicity pertaining to distribution of the
software without specific, written prior permission. software without specific, written prior permission.
The author disclaim all warranties with regard to this The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action, in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of arising out of or in connection with the use or performance of
this software. this software.
*/ */
/** \file /** \file
* *
* Header file for BootloaderCDC.c. * Header file for BootloaderCDC.c.
*/ */
#ifndef _CDC_H_ #ifndef _CDC_H_
#define _CDC_H_ #define _CDC_H_
/* Includes: */ /* Includes: */
#include <avr/io.h> #include <avr/io.h>
#include <avr/wdt.h> #include <avr/wdt.h>
#include <avr/boot.h> #include <avr/boot.h>
#include <avr/eeprom.h> #include <avr/eeprom.h>
#include <avr/power.h> #include <avr/power.h>
#include <avr/interrupt.h> #include <avr/interrupt.h>
#include <stdbool.h> #include <stdbool.h>
#include "Descriptors.h" #include "Descriptors.h"
#include <LUFA/Drivers/USB/USB.h> #include <LUFA/Drivers/USB/USB.h>
/* Macros: */ /* Macros: */
/** CDC Class Specific request to get the line encoding on a CDC-ACM virtual serial port, including the /** CDC Class Specific request to get the line encoding on a CDC-ACM virtual serial port, including the
* baud rate, parity, stop bits and data bits. * baud rate, parity, stop bits and data bits.
*/ */
#define REQ_GetLineEncoding 0x21 #define REQ_GetLineEncoding 0x21
/** CDC Class Specific request to set the line encoding on a CDC-ACM virtual serial port, including the /** CDC Class Specific request to set the line encoding on a CDC-ACM virtual serial port, including the
* baud rate, parity, stop bits and data bits. * baud rate, parity, stop bits and data bits.
*/ */
#define REQ_SetLineEncoding 0x20 #define REQ_SetLineEncoding 0x20
/** CDC Class Specific request to set the state of the serial handshake lines (such as DCD and RTS) on /** CDC Class Specific request to set the state of the serial handshake lines (such as DCD and RTS) on
* a CDC-ACM virtual serial port. * a CDC-ACM virtual serial port.
*/ */
#define REQ_SetControlLineState 0x22 #define REQ_SetControlLineState 0x22
/** Version major of the CDC bootloader. */ /** Version major of the CDC bootloader. */
#define BOOTLOADER_VERSION_MAJOR 0x01 #define BOOTLOADER_VERSION_MAJOR 0x01
/** Version minor of the CDC bootloader. */ /** Version minor of the CDC bootloader. */
#define BOOTLOADER_VERSION_MINOR 0x00 #define BOOTLOADER_VERSION_MINOR 0x00
/** Hardware version major of the CDC bootloader. */ /** Hardware version major of the CDC bootloader. */
#define BOOTLOADER_HWVERSION_MAJOR 0x01 #define BOOTLOADER_HWVERSION_MAJOR 0x01
/** Hardware version minor of the CDC bootloader. */ /** Hardware version minor of the CDC bootloader. */
#define BOOTLOADER_HWVERSION_MINOR 0x00 #define BOOTLOADER_HWVERSION_MINOR 0x00
/** Eight character bootloader firmware identifier reported to the host when requested */ /** Eight character bootloader firmware identifier reported to the host when requested */
#define SOFTWARE_IDENTIFIER "LUFACDC" #define SOFTWARE_IDENTIFIER "LUFACDC"
/* Type Defines: */ /* Type Defines: */
/** Type define for a non-returning pointer to the start of the loaded application in flash memory. */ /** Type define for a non-returning pointer to the start of the loaded application in flash memory. */
typedef void (*AppPtr_t)(void) ATTR_NO_RETURN; typedef void (*AppPtr_t)(void) ATTR_NO_RETURN;
/** Type define for the CDC-ACM virtual serial port line encoding options, including baud rate, format, parity /** Type define for the CDC-ACM virtual serial port line encoding options, including baud rate, format, parity
* and size of each data chunk in bits. * and size of each data chunk in bits.
*/ */
typedef struct typedef struct
{ {
uint32_t BaudRateBPS; /**< Baud rate in BPS */ uint32_t BaudRateBPS; /**< Baud rate in BPS */
uint8_t CharFormat; /**< Character format, an entry from the BootloaderCDC_CDC_LineCodingFormats_t enum */ uint8_t CharFormat; /**< Character format, an entry from the BootloaderCDC_CDC_LineCodingFormats_t enum */
uint8_t ParityType; /**< Parity mode, an entry from the BootloaderCDC_CDC_LineCodeingParity_t enum */ uint8_t ParityType; /**< Parity mode, an entry from the BootloaderCDC_CDC_LineCodeingParity_t enum */
uint8_t DataBits; /**< Size of each data chunk, in bits */ uint8_t DataBits; /**< Size of each data chunk, in bits */
} CDC_Line_Coding_t; } CDC_Line_Coding_t;
/* Enums: */ /* Enums: */
/** Enum for the possible line encoding formats on a CDC-ACM virtual serial port */ /** Enum for the possible line encoding formats on a CDC-ACM virtual serial port */
enum BootloaderCDC_CDC_LineCodingFormats_t enum BootloaderCDC_CDC_LineCodingFormats_t
{ {
OneStopBit = 0, /**< Single stop bit */ OneStopBit = 0, /**< Single stop bit */
OneAndAHalfStopBits = 1, /**< 1.5 stop bits */ OneAndAHalfStopBits = 1, /**< 1.5 stop bits */
TwoStopBits = 2, /**< Two stop bits */ TwoStopBits = 2, /**< Two stop bits */
}; };
/** Enum for the possible parity modes on a CDC-ACM virtual serial port */ /** Enum for the possible parity modes on a CDC-ACM virtual serial port */
enum BootloaderCDC_CDC_LineCodingParity_t enum BootloaderCDC_CDC_LineCodingParity_t
{ {
Parity_None = 0, /**< No data parity checking */ Parity_None = 0, /**< No data parity checking */
Parity_Odd = 1, /**< Odd data parity checking */ Parity_Odd = 1, /**< Odd data parity checking */
Parity_Even = 2, /**< Even data parity checking */ Parity_Even = 2, /**< Even data parity checking */
Parity_Mark = 3, /**< Mark data parity checking */ Parity_Mark = 3, /**< Mark data parity checking */
Parity_Space = 4, /**< Space data parity checking */ Parity_Space = 4, /**< Space data parity checking */
}; };
/* Function Prototypes: */ /* Function Prototypes: */
void CDC_Task(void); void CDC_Task(void);
void SetupHardware(void); void SetupHardware(void);
void EVENT_USB_Device_ConfigurationChanged(void); void EVENT_USB_Device_ConfigurationChanged(void);
void EVENT_USB_Device_UnhandledControlRequest(void); void EVENT_USB_Device_UnhandledControlRequest(void);
#if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__) #if defined(INCLUDE_FROM_BOOTLOADERCDC_C) || defined(__DOXYGEN__)
static void ReadWriteMemoryBlock(const uint8_t Command); static void ReadWriteMemoryBlock(const uint8_t Command);
static uint8_t FetchNextCommandByte(void); static uint8_t FetchNextCommandByte(void);
static void WriteNextResponseByte(const uint8_t Response); static void WriteNextResponseByte(const uint8_t Response);
#endif #endif
#endif #endif
/** \file /** \file
* *
* This file contains special DoxyGen information for the generation of the main page and other special * This file contains special DoxyGen information for the generation of the main page and other special
* documentation pages. It is not a project source file. * documentation pages. It is not a project source file.
*/ */
/** \mainpage CDC Class USB AVR Bootloader /** \mainpage CDC Class USB AVR Bootloader
* *
* \section SSec_Compat Demo Compatibility: * \section SSec_Compat Demo Compatibility:
* *
* The following list indicates what microcontrollers are compatible with this demo. * The following list indicates what microcontrollers are compatible with this demo.
* *
* - Series 7 USB AVRs * - Series 7 USB AVRs
* - Series 6 USB AVRs * - Series 6 USB AVRs
* - Series 4 USB AVRs * - Series 4 USB AVRs
* - Series 2 USB AVRs * - Series 2 USB AVRs
* *
* \section SSec_Info USB Information: * \section SSec_Info USB Information:
* *
* The following table gives a rundown of the USB utilization of this demo. * The following table gives a rundown of the USB utilization of this demo.
* *
* <table> * <table>
* <tr> * <tr>
* <td><b>USB Mode:</b></td> * <td><b>USB Mode:</b></td>
* <td>Device</td> * <td>Device</td>
* </tr> * </tr>
* <tr> * <tr>
* <td><b>USB Class:</b></td> * <td><b>USB Class:</b></td>
* <td>Communications Device Class (CDC)</td> * <td>Communications Device Class (CDC)</td>
* </tr> * </tr>
* <tr> * <tr>
* <td><b>USB Subclass:</b></td> * <td><b>USB Subclass:</b></td>
* <td>Abstract Control Model (ACM)</td> * <td>Abstract Control Model (ACM)</td>
* </tr> * </tr>
* <tr> * <tr>
* <td><b>Relevant Standards:</b></td> * <td><b>Relevant Standards:</b></td>
* <td>USBIF CDC Class Standard</td> * <td>USBIF CDC Class Standard</td>
* </tr> * </tr>
* <tr> * <tr>
* <td><b>Usable Speeds:</b></td> * <td><b>Usable Speeds:</b></td>
* <td>Full Speed Mode</td> * <td>Full Speed Mode</td>
* </tr> * </tr>
* </table> * </table>
* *
* \section SSec_Description Project Description: * \section SSec_Description Project Description:
* *
* This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109 * This bootloader enumerates to the host as a CDC Class device (virtual serial port), allowing for AVR109
* protocol compatible programming software to load firmware onto the AVR. * protocol compatible programming software to load firmware onto the AVR.
* *
* Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If * Out of the box this bootloader builds for the USB1287, and will fit into 4KB of bootloader space. If
* you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU * you wish to enlarge this space and/or change the AVR model, you will need to edit the BOOT_START and MCU
* values in the accompanying makefile. * values in the accompanying makefile.
* *
* This bootloader is compatible with the open source application AVRDUDE, or Atmel's AVRPROG. * This bootloader is compatible with the open source application AVRDUDE, or Atmel's AVRPROG.
* *
* After running this bootloader for the first time on a new computer, you will need to supply the .INF * After running this bootloader for the first time on a new computer, you will need to supply the .INF
* file located in this bootloader project's directory as the device's driver when running under Windows. * file located in this bootloader project's directory as the device's driver when running under Windows.
* This will enable Windows to use its inbuilt CDC drivers, negating the need for custom drivers for the * This will enable Windows to use its inbuilt CDC drivers, negating the need for custom drivers for the
* device. Other Operating Systems should automatically use their own inbuilt CDC-ACM drivers. * device. Other Operating Systems should automatically use their own inbuilt CDC-ACM drivers.
* *
* \section SSec_Options Project Options * \section SSec_Options Project Options
* *
* The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value. * The following defines can be found in this demo, which can control the demo behaviour when defined, or changed in value.
* *
* <table> * <table>
* <tr> * <tr>
* <td> * <td>
* None * None
* </td> * </td>
* </tr> * </tr>
* </table> * </table>
*/ */
\ No newline at end of file
/* /*
LUFA Library LUFA Library
Copyright (C) Dean Camera, 2010. Copyright (C) Dean Camera, 2010.
dean [at] fourwalledcubicle [dot] com dean [at] fourwalledcubicle [dot] com
www.fourwalledcubicle.com www.fourwalledcubicle.com
*/ */
/* /*
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com) Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
Permission to use, copy, modify, distribute, and sell this Permission to use, copy, modify, distribute, and sell this
software and its documentation for any purpose is hereby granted software and its documentation for any purpose is hereby granted
without fee, provided that the above copyright notice appear in without fee, provided that the above copyright notice appear in
all copies and that both that the copyright notice and this all copies and that both that the copyright notice and this
permission notice and warranty disclaimer appear in supporting permission notice and warranty disclaimer appear in supporting
documentation, and that the name of the author not be used in documentation, and that the name of the author not be used in
advertising or publicity pertaining to distribution of the advertising or publicity pertaining to distribution of the
software without specific, written prior permission. software without specific, written prior permission.
The author disclaim all warranties with regard to this The author disclaim all warranties with regard to this
software, including all implied warranties of merchantability software, including all implied warranties of merchantability
and fitness. In no event shall the author be liable for any and fitness. In no event shall the author be liable for any
special, indirect or consequential damages or any damages special, indirect or consequential damages or any damages
whatsoever resulting from loss of use, data or profits, whether whatsoever resulting from loss of use, data or profits, whether
in an action of contract, negligence or other tortious action, in an action of contract, negligence or other tortious action,
arising out of or in connection with the use or performance of arising out of or in connection with the use or performance of
this software. this software.
*/ */
/** \file /** \file
* *
* USB Device Descriptors, for library use when in USB device mode. Descriptors are special * USB Device Descriptors, for library use when in USB device mode. Descriptors are special
* computer-readable structures which the host requests upon device enumeration, to determine * computer-readable structures which the host requests upon device enumeration, to determine
* the device's capabilities and functions. * the device's capabilities and functions.
*/ */
#include "Descriptors.h" #include "Descriptors.h"
/** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall /** Device descriptor structure. This descriptor, located in SRAM memory, describes the overall
* device characteristics, including the supported USB version, control endpoint size and the * device characteristics, including the supported USB version, control endpoint size and the
* number of device configurations. The descriptor is read out by the USB host when the enumeration * number of device configurations. The descriptor is read out by the USB host when the enumeration
* process begins. * process begins.
*/ */
USB_Descriptor_Device_t DeviceDescriptor = USB_Descriptor_Device_t DeviceDescriptor =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device}, .Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
.USBSpecification = VERSION_BCD(01.10), .USBSpecification = VERSION_BCD(01.10),
.Class = 0x02, .Class = 0x02,
.SubClass = 0x00, .SubClass = 0x00,
.Protocol = 0x00, .Protocol = 0x00,
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE, .Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
.VendorID = 0x03EB, .VendorID = 0x03EB,
.ProductID = 0x204A, .ProductID = 0x204A,
.ReleaseNumber = 0x0000, .ReleaseNumber = 0x0000,
.ManufacturerStrIndex = NO_DESCRIPTOR, .ManufacturerStrIndex = NO_DESCRIPTOR,
.ProductStrIndex = 0x01, .ProductStrIndex = 0x01,
.SerialNumStrIndex = NO_DESCRIPTOR, .SerialNumStrIndex = NO_DESCRIPTOR,
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS .NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
}; };
/** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage /** Configuration descriptor structure. This descriptor, located in SRAM memory, describes the usage
* of the device in one of its supported configurations, including information about any device interfaces * of the device in one of its supported configurations, including information about any device interfaces
* and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting * and endpoints. The descriptor is read out by the USB host during the enumeration process when selecting
* a configuration so that the host may correctly communicate with the USB device. * a configuration so that the host may correctly communicate with the USB device.
*/ */
USB_Descriptor_Configuration_t ConfigurationDescriptor = USB_Descriptor_Configuration_t ConfigurationDescriptor =
{ {
.Config = .Config =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration}, .Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t), .TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
.TotalInterfaces = 2, .TotalInterfaces = 2,
.ConfigurationNumber = 1, .ConfigurationNumber = 1,
.ConfigurationStrIndex = NO_DESCRIPTOR, .ConfigurationStrIndex = NO_DESCRIPTOR,
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED, .ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100) .MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
}, },
.CDC_CCI_Interface = .CDC_CCI_Interface =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface}, .Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
.InterfaceNumber = 0, .InterfaceNumber = 0,
.AlternateSetting = 0, .AlternateSetting = 0,
.TotalEndpoints = 1, .TotalEndpoints = 1,
.Class = 0x02, .Class = 0x02,
.SubClass = 0x02, .SubClass = 0x02,
.Protocol = 0x01, .Protocol = 0x01,
.InterfaceStrIndex = NO_DESCRIPTOR .InterfaceStrIndex = NO_DESCRIPTOR
}, },
.CDC_Functional_IntHeader = .CDC_Functional_IntHeader =
{ {
.Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
.SubType = 0x00, .SubType = 0x00,
.Data = {0x10, 0x01} .Data = {0x10, 0x01}
}, },
.CDC_Functional_AbstractControlManagement = .CDC_Functional_AbstractControlManagement =
{ {
.Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24}, .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(1)), .Type = 0x24},
.SubType = 0x02, .SubType = 0x02,
.Data = {0x06} .Data = {0x06}
}, },
.CDC_Functional_Union = .CDC_Functional_Union =
{ {
.Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24}, .Header = {.Size = sizeof(CDC_FUNCTIONAL_DESCRIPTOR(2)), .Type = 0x24},
.SubType = 0x06, .SubType = 0x06,
.Data = {0x00, 0x01} .Data = {0x00, 0x01}
}, },
.CDC_ManagementEndpoint = .CDC_ManagementEndpoint =
{ {
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint}, .Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM), .EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA), .Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
.EndpointSize = CDC_NOTIFICATION_EPSIZE, .EndpointSize = CDC_NOTIFICATION_EPSIZE,
.PollingIntervalMS = 0x02 .PollingIntervalMS = 0x02
}, },