Clean up excessive whitespace at the end of each line using the wspurify tool made by Laszlo Monda
This commit is contained in:
parent
a8871c7fba
commit
5a4def7478
760 changed files with 12883 additions and 12164 deletions
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -43,7 +43,7 @@ int main(void)
|
|||
{
|
||||
SetupHardware();
|
||||
V2Protocol_Init();
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
sei();
|
||||
|
||||
|
@ -54,7 +54,7 @@ int main(void)
|
|||
mode - either VBUS, or sourced from the VTARGET pin of the programming connectors */
|
||||
LEDs_ChangeLEDs(LEDMASK_VBUSPOWER, (PIND & (1 << 0)) ? 0 : LEDMASK_VBUSPOWER);
|
||||
#endif
|
||||
|
||||
|
||||
AVRISP_Task();
|
||||
USB_USBTask();
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ void SetupHardware(void)
|
|||
|
||||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
USB_Init();
|
||||
}
|
||||
|
||||
/** Event handler for the library USB Connection event. */
|
||||
|
@ -100,9 +100,9 @@ void EVENT_USB_Device_ConfigurationChanged(void)
|
|||
ConfigSuccess &= Endpoint_ConfigureEndpoint(AVRISP_DATA_IN_EPNUM, EP_TYPE_BULK, ENDPOINT_DIR_IN,
|
||||
AVRISP_DATA_EPSIZE, ENDPOINT_BANK_SINGLE);
|
||||
#endif
|
||||
|
||||
|
||||
/* Indicate endpoint configuration success or failure */
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
LEDs_SetAllLEDs(ConfigSuccess ? LEDMASK_USB_READY : LEDMASK_USB_ERROR);
|
||||
}
|
||||
|
||||
/** Processes incoming V2 Protocol commands from the host, returning a response when required. */
|
||||
|
@ -115,7 +115,7 @@ void AVRISP_Task(void)
|
|||
V2Params_UpdateParamValues();
|
||||
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_OUT_EPNUM);
|
||||
|
||||
|
||||
/* Check to see if a V2 Protocol command has been received */
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -45,11 +45,11 @@
|
|||
#include <LUFA/Version.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#if defined(ADC)
|
||||
#include <LUFA/Drivers/Peripheral/ADC.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "Lib/V2Protocol.h"
|
||||
|
||||
|
@ -68,16 +68,17 @@
|
|||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2)
|
||||
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the target is being powered by VBUS. */
|
||||
#define LEDMASK_VBUSPOWER LEDS_LED3
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void AVRISP_Task(void);
|
||||
|
||||
|
||||
void EVENT_USB_Device_Connect(void);
|
||||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage AVRISP MKII Programmer Project
|
||||
*
|
||||
* \section SSec_Compat Project Compatibility:
|
||||
|
@ -28,7 +28,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Vendor Specific Class</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
@ -42,7 +42,7 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Firmware for an AVRStudio compatible AVRISP-MKII clone programmer. This project will enable the USB AVR series of
|
||||
* microcontrollers to act as a clone of the official Atmel AVRISP-MKII programmer, usable within AVRStudio. In its
|
||||
|
@ -240,31 +240,31 @@
|
|||
* <td>VTARGET_ADC_CHANNEL</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>ADC channel number (on supported AVRs) to use for VTARGET level detection, if NO_VTARGET_DETECT is not defined.
|
||||
* <i>Ignored when compiled for targets lacking an ADC.</i></td>
|
||||
* <i>Ignored when compiled for targets lacking an ADC.</i></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>ENABLE_ISP_PROTOCOL</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Define to enable SPI programming protocol support. <i>Ignored when compiled for the XPLAIN board.</i></td>
|
||||
* <td>Define to enable SPI programming protocol support. <i>Ignored when compiled for the XPLAIN board.</i></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>ENABLE_XPROG_PROTOCOL</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Define to enable PDI and TPI programming protocol support. <i>Ignored when compiled for the XPLAIN board.</i></td>
|
||||
* <td>Define to enable PDI and TPI programming protocol support. <i>Ignored when compiled for the XPLAIN board.</i></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>NO_VTARGET_DETECT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Define to disable VTARGET sampling and reporting on AVR models with an ADC converter. This will cause the programmer
|
||||
* to report a fixed 5V target voltage to the host regardless of the real target voltage. <i>Ignored when compiled for
|
||||
* targets lacking an ADC.</i></td>
|
||||
* targets lacking an ADC.</i></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>VTARGET_REF_VOLTS</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
* <td>Indicates the programmer AVR's AVCC reference voltage when measuring the target's supply voltage. Note that the supply
|
||||
* voltage should never exceed the reference voltage on the programmer AVR without some form of protection to prevent damage
|
||||
* to the ADC. <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
|
||||
* to the ADC. <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>VTARGET_SCALE_FACTOR</td>
|
||||
|
@ -272,8 +272,8 @@
|
|||
* <td>Indicates the target's supply voltage scale factor when applied to the ADC. A simple resistive divider can be used on the
|
||||
* ADC pin for measuring the target's supply voltage, so that voltages above the programmer AVR's AVCC reference voltage can be
|
||||
* measured. This should be the reciprocal of the division performed - e.g. if the VTARGET voltage is halved, this should be set
|
||||
* to 2. <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
|
||||
* </tr>
|
||||
* to 2. <i>Ignored when compiled for targets lacking an ADC, or when NO_VTARGET_DETECT is defined.</i></td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <td>LIBUSB_DRIVER_COMPAT</td>
|
||||
* <td>Makefile LUFA_OPTS</td>
|
||||
|
@ -282,3 +282,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -30,9 +30,9 @@
|
|||
|
||||
/** \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
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
@ -45,22 +45,22 @@
|
|||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0xFF,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2104,
|
||||
.ReleaseNumber = VERSION_BCD(02.00),
|
||||
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = 0x03,
|
||||
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
@ -71,41 +71,41 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.AVRISP_Interface =
|
||||
.AVRISP_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
|
||||
.Class = 0xFF,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.AVRISP_DataInEndpoint =
|
||||
.AVRISP_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | AVRISP_DATA_IN_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = AVRISP_DATA_EPSIZE,
|
||||
|
@ -115,7 +115,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
.AVRISP_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | AVRISP_DATA_OUT_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = AVRISP_DATA_EPSIZE,
|
||||
|
@ -130,7 +130,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
|
@ -141,7 +141,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
|||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
|
@ -152,7 +152,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"LUFA AVRISP MkII Clone"
|
||||
};
|
||||
|
||||
|
@ -162,7 +162,7 @@ USB_Descriptor_String_t PROGMEM ProductString =
|
|||
USB_Descriptor_String_t PROGMEM SerialString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"0000A00128255"
|
||||
};
|
||||
|
||||
|
@ -181,41 +181,42 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
|
||||
const void* Address = NULL;
|
||||
uint16_t Size = NO_DESCRIPTOR;
|
||||
|
||||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
case 0x03:
|
||||
Address = &SerialString;
|
||||
Size = pgm_read_byte(&SerialString.Header.Size);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
|
@ -79,3 +79,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -53,7 +53,7 @@ void ISPProtocol_EnterISPMode(void)
|
|||
uint8_t PollIndex;
|
||||
uint8_t EnterProgBytes[4];
|
||||
} Enter_ISP_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&Enter_ISP_Params, sizeof(Enter_ISP_Params), NO_STREAM_CALLBACK);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -61,9 +61,9 @@ void ISPProtocol_EnterISPMode(void)
|
|||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
uint8_t ResponseStatus = STATUS_CMD_FAILED;
|
||||
|
||||
|
||||
CurrentAddress = 0;
|
||||
|
||||
|
||||
/* Set up the synchronous USART to generate the .5MHz recovery clock on XCK pin */
|
||||
UBRR1 = (F_CPU / 500000UL);
|
||||
UCSR1B = (1 << TXEN1);
|
||||
|
@ -71,7 +71,7 @@ void ISPProtocol_EnterISPMode(void)
|
|||
DDRD |= (1 << 5);
|
||||
|
||||
/* Perform execution delay, initialize SPI bus */
|
||||
ISPProtocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS);
|
||||
ISPProtocol_DelayMS(Enter_ISP_Params.ExecutionDelayMS);
|
||||
ISPTarget_Init();
|
||||
|
||||
/* Continuously attempt to synchronize with the target until either the number of attempts specified
|
||||
|
@ -88,7 +88,7 @@ void ISPProtocol_EnterISPMode(void)
|
|||
ISPProtocol_DelayMS(Enter_ISP_Params.ByteDelay);
|
||||
ResponseBytes[RByte] = ISPTarget_TransferByte(Enter_ISP_Params.EnterProgBytes[RByte]);
|
||||
}
|
||||
|
||||
|
||||
/* Check if polling disabled, or if the polled value matches the expected value */
|
||||
if (!(Enter_ISP_Params.PollIndex) || (ResponseBytes[Enter_ISP_Params.PollIndex - 1] == Enter_ISP_Params.PollValue))
|
||||
{
|
||||
|
@ -116,7 +116,7 @@ void ISPProtocol_LeaveISPMode(void)
|
|||
} Leave_ISP_Params;
|
||||
|
||||
Endpoint_Read_Stream_LE(&Leave_ISP_Params, sizeof(Leave_ISP_Params), NO_STREAM_CALLBACK);
|
||||
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
@ -155,13 +155,13 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
uint8_t PollValue2;
|
||||
uint8_t ProgData[256]; // Note, the Jungo driver has a very short ACK timeout period, need to buffer the
|
||||
} Write_Memory_Params; // whole page and ACK the packet as fast as possible to prevent it from aborting
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&Write_Memory_Params, (sizeof(Write_Memory_Params) -
|
||||
sizeof(Write_Memory_Params.ProgData)), NO_STREAM_CALLBACK);
|
||||
|
||||
|
||||
Write_Memory_Params.BytesToWrite = SwapEndian_16(Write_Memory_Params.BytesToWrite);
|
||||
|
||||
|
||||
if (Write_Memory_Params.BytesToWrite > sizeof(Write_Memory_Params.ProgData))
|
||||
{
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -173,14 +173,14 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
Endpoint_ClearIN();
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&Write_Memory_Params.ProgData, Write_Memory_Params.BytesToWrite, NO_STREAM_CALLBACK);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
uint8_t ProgrammingStatus = STATUS_CMD_OK;
|
||||
uint8_t ProgrammingStatus = STATUS_CMD_OK;
|
||||
uint16_t PollAddress = 0;
|
||||
uint8_t PollValue = (V2Command == CMD_PROGRAM_FLASH_ISP) ? Write_Memory_Params.PollValue1 :
|
||||
Write_Memory_Params.PollValue2;
|
||||
|
@ -190,7 +190,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
if (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_WRITES_MASK)
|
||||
{
|
||||
uint16_t StartAddress = (CurrentAddress & 0xFFFF);
|
||||
|
||||
|
||||
/* Check to see if we need to send a LOAD EXTENDED ADDRESS command to the target */
|
||||
if (MustLoadExtendedAddress)
|
||||
{
|
||||
|
@ -203,12 +203,12 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
{
|
||||
bool IsOddByte = (CurrentByte & 0x01);
|
||||
uint8_t ByteToWrite = *(NextWriteByte++);
|
||||
|
||||
|
||||
ISPTarget_SendByte(Write_Memory_Params.ProgrammingCommands[0]);
|
||||
ISPTarget_SendByte(CurrentAddress >> 8);
|
||||
ISPTarget_SendByte(CurrentAddress & 0xFF);
|
||||
ISPTarget_SendByte(ByteToWrite);
|
||||
|
||||
|
||||
/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
|
||||
* or low byte at the current word address */
|
||||
if (V2Command == CMD_PROGRAM_FLASH_ISP)
|
||||
|
@ -220,14 +220,14 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
|
||||
Write_Memory_Params.ProgrammingCommands[2] |= READ_WRITE_HIGH_BYTE_MASK;
|
||||
|
||||
PollAddress = (CurrentAddress & 0xFFFF);
|
||||
}
|
||||
PollAddress = (CurrentAddress & 0xFFFF);
|
||||
}
|
||||
|
||||
/* EEPROM increments the address on each byte, flash needs to increment on each word */
|
||||
if (IsOddByte || (V2Command == CMD_PROGRAM_EEPROM_ISP))
|
||||
CurrentAddress++;
|
||||
}
|
||||
|
||||
|
||||
/* If the current page must be committed, send the PROGRAM PAGE command to the target */
|
||||
if (Write_Memory_Params.ProgrammingMode & PROG_MODE_COMMIT_PAGE_MASK)
|
||||
{
|
||||
|
@ -235,12 +235,12 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
ISPTarget_SendByte(StartAddress >> 8);
|
||||
ISPTarget_SendByte(StartAddress & 0xFF);
|
||||
ISPTarget_SendByte(0x00);
|
||||
|
||||
|
||||
/* Check if polling is possible and enabled, if not switch to timed delay mode */
|
||||
if (!(PollAddress) && (Write_Memory_Params.ProgrammingMode & PROG_MODE_PAGED_VALUE_MASK))
|
||||
{
|
||||
Write_Memory_Params.ProgrammingMode &= ~PROG_MODE_PAGED_VALUE_MASK;
|
||||
Write_Memory_Params.ProgrammingMode |= PROG_MODE_PAGED_TIMEDELAY_MASK;
|
||||
Write_Memory_Params.ProgrammingMode |= PROG_MODE_PAGED_TIMEDELAY_MASK;
|
||||
}
|
||||
|
||||
ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue,
|
||||
|
@ -248,7 +248,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
|
||||
/* Check to see if the FLASH address has crossed the extended address boundary */
|
||||
if ((V2Command == CMD_PROGRAM_FLASH_ISP) && !(CurrentAddress & 0xFFFF))
|
||||
MustLoadExtendedAddress = true;
|
||||
MustLoadExtendedAddress = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -258,7 +258,7 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
{
|
||||
bool IsOddByte = (CurrentByte & 0x01);
|
||||
uint8_t ByteToWrite = *(NextWriteByte++);
|
||||
|
||||
|
||||
/* Check to see if we need to send a LOAD EXTENDED ADDRESS command to the target */
|
||||
if (MustLoadExtendedAddress)
|
||||
{
|
||||
|
@ -270,12 +270,12 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
ISPTarget_SendByte(CurrentAddress >> 8);
|
||||
ISPTarget_SendByte(CurrentAddress & 0xFF);
|
||||
ISPTarget_SendByte(ByteToWrite);
|
||||
|
||||
|
||||
/* AVR FLASH addressing requires us to modify the write command based on if we are writing a high
|
||||
* or low byte at the current word address */
|
||||
if (V2Command == CMD_PROGRAM_FLASH_ISP)
|
||||
Write_Memory_Params.ProgrammingCommands[0] ^= READ_WRITE_HIGH_BYTE_MASK;
|
||||
|
||||
|
||||
/* Save previous programming mode in case we modify it for the current word */
|
||||
uint8_t PreviousProgrammingMode = Write_Memory_Params.ProgrammingMode;
|
||||
|
||||
|
@ -283,18 +283,18 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
{
|
||||
if (IsOddByte && (V2Command == CMD_PROGRAM_FLASH_ISP))
|
||||
Write_Memory_Params.ProgrammingCommands[2] |= READ_WRITE_HIGH_BYTE_MASK;
|
||||
|
||||
|
||||
PollAddress = (CurrentAddress & 0xFFFF);
|
||||
}
|
||||
else if (!(Write_Memory_Params.ProgrammingMode & PROG_MODE_WORD_READYBUSY_MASK))
|
||||
{
|
||||
Write_Memory_Params.ProgrammingMode &= ~PROG_MODE_WORD_VALUE_MASK;
|
||||
Write_Memory_Params.ProgrammingMode |= PROG_MODE_WORD_TIMEDELAY_MASK;
|
||||
Write_Memory_Params.ProgrammingMode |= PROG_MODE_WORD_TIMEDELAY_MASK;
|
||||
}
|
||||
|
||||
|
||||
ProgrammingStatus = ISPTarget_WaitForProgComplete(Write_Memory_Params.ProgrammingMode, PollAddress, PollValue,
|
||||
Write_Memory_Params.DelayMS, Write_Memory_Params.ProgrammingCommands[2]);
|
||||
|
||||
|
||||
/* Restore previous programming mode mask in case the current word needed to change it */
|
||||
Write_Memory_Params.ProgrammingMode = PreviousProgrammingMode;
|
||||
|
||||
|
@ -308,9 +308,9 @@ void ISPProtocol_ProgramMemory(uint8_t V2Command)
|
|||
if ((CurrentByte & 0x01) || (V2Command == CMD_PROGRAM_EEPROM_ISP))
|
||||
{
|
||||
CurrentAddress++;
|
||||
|
||||
|
||||
if ((V2Command != CMD_PROGRAM_EEPROM_ISP) && !(CurrentAddress & 0xFFFF))
|
||||
MustLoadExtendedAddress = true;
|
||||
MustLoadExtendedAddress = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -332,14 +332,14 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
|
|||
uint16_t BytesToRead;
|
||||
uint8_t ReadMemoryCommand;
|
||||
} Read_Memory_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&Read_Memory_Params, sizeof(Read_Memory_Params), NO_STREAM_CALLBACK);
|
||||
Read_Memory_Params.BytesToRead = SwapEndian_16(Read_Memory_Params.BytesToRead);
|
||||
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
Endpoint_Write_Byte(V2Command);
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
|
||||
|
@ -358,28 +358,28 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
|
|||
ISPTarget_SendByte(CurrentAddress >> 8);
|
||||
ISPTarget_SendByte(CurrentAddress & 0xFF);
|
||||
Endpoint_Write_Byte(ISPTarget_ReceiveByte());
|
||||
|
||||
|
||||
/* Check if the endpoint bank is currently full, if so send the packet */
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_WaitUntilReady();
|
||||
}
|
||||
|
||||
|
||||
/* AVR FLASH addressing requires us to modify the read command based on if we are reading a high
|
||||
* or low byte at the current word address */
|
||||
if (V2Command == CMD_READ_FLASH_ISP)
|
||||
Read_Memory_Params.ReadMemoryCommand ^= READ_WRITE_HIGH_BYTE_MASK;
|
||||
|
||||
|
||||
/* EEPROM just increments the address each byte, flash needs to increment on each word and
|
||||
* also check to ensure that a LOAD EXTENDED ADDRESS command is issued each time the extended
|
||||
* address boundary has been crossed */
|
||||
if ((CurrentByte & 0x01) || (V2Command == CMD_READ_EEPROM_ISP))
|
||||
{
|
||||
CurrentAddress++;
|
||||
|
||||
|
||||
if ((V2Command != CMD_READ_EEPROM_ISP) && !(CurrentAddress & 0xFFFF))
|
||||
MustLoadExtendedAddress = true;
|
||||
MustLoadExtendedAddress = true;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -387,13 +387,13 @@ void ISPProtocol_ReadMemory(uint8_t V2Command)
|
|||
|
||||
bool IsEndpointFull = !(Endpoint_IsReadWriteAllowed());
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Ensure last packet is a short packet to terminate the transfer */
|
||||
if (IsEndpointFull)
|
||||
{
|
||||
Endpoint_WaitUntilReady();
|
||||
Endpoint_WaitUntilReady();
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_WaitUntilReady();
|
||||
Endpoint_WaitUntilReady();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -406,15 +406,15 @@ void ISPProtocol_ChipErase(void)
|
|||
uint8_t PollMethod;
|
||||
uint8_t EraseCommandBytes[4];
|
||||
} Erase_Chip_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&Erase_Chip_Params, sizeof(Erase_Chip_Params), NO_STREAM_CALLBACK);
|
||||
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
uint8_t ResponseStatus = STATUS_CMD_OK;
|
||||
|
||||
|
||||
/* Send the chip erase commands as given by the host to the device */
|
||||
for (uint8_t SByte = 0; SByte < sizeof(Erase_Chip_Params.EraseCommandBytes); SByte++)
|
||||
ISPTarget_SendByte(Erase_Chip_Params.EraseCommandBytes[SByte]);
|
||||
|
@ -424,7 +424,7 @@ void ISPProtocol_ChipErase(void)
|
|||
ISPProtocol_DelayMS(Erase_Chip_Params.EraseDelayMS);
|
||||
else
|
||||
ResponseStatus = ISPTarget_WaitWhileTargetBusy();
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_CHIP_ERASE_ISP);
|
||||
Endpoint_Write_Byte(ResponseStatus);
|
||||
Endpoint_ClearIN();
|
||||
|
@ -442,7 +442,7 @@ void ISPProtocol_ReadFuseLockSigOSCCAL(uint8_t V2Command)
|
|||
uint8_t RetByte;
|
||||
uint8_t ReadCommandBytes[4];
|
||||
} Read_FuseLockSigOSCCAL_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&Read_FuseLockSigOSCCAL_Params, sizeof(Read_FuseLockSigOSCCAL_Params), NO_STREAM_CALLBACK);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -454,7 +454,7 @@ void ISPProtocol_ReadFuseLockSigOSCCAL(uint8_t V2Command)
|
|||
/* Send the Fuse or Lock byte read commands as given by the host to the device, store response */
|
||||
for (uint8_t RByte = 0; RByte < sizeof(ResponseBytes); RByte++)
|
||||
ResponseBytes[RByte] = ISPTarget_TransferByte(Read_FuseLockSigOSCCAL_Params.ReadCommandBytes[RByte]);
|
||||
|
||||
|
||||
Endpoint_Write_Byte(V2Command);
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
Endpoint_Write_Byte(ResponseBytes[Read_FuseLockSigOSCCAL_Params.RetByte - 1]);
|
||||
|
@ -473,7 +473,7 @@ void ISPProtocol_WriteFuseLock(uint8_t V2Command)
|
|||
{
|
||||
uint8_t WriteCommandBytes[4];
|
||||
} Write_FuseLockSig_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&Write_FuseLockSig_Params, sizeof(Write_FuseLockSig_Params), NO_STREAM_CALLBACK);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
|
@ -483,7 +483,7 @@ void ISPProtocol_WriteFuseLock(uint8_t V2Command)
|
|||
/* Send the Fuse or Lock byte program commands as given by the host to the device */
|
||||
for (uint8_t SByte = 0; SByte < sizeof(Write_FuseLockSig_Params.WriteCommandBytes); SByte++)
|
||||
ISPTarget_SendByte(Write_FuseLockSig_Params.WriteCommandBytes[SByte]);
|
||||
|
||||
|
||||
Endpoint_Write_Byte(V2Command);
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
|
@ -500,14 +500,14 @@ void ISPProtocol_SPIMulti(void)
|
|||
uint8_t RxStartAddr;
|
||||
uint8_t TxData[255];
|
||||
} SPI_Multi_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&SPI_Multi_Params, (sizeof(SPI_Multi_Params) - sizeof(SPI_Multi_Params.TxData)), NO_STREAM_CALLBACK);
|
||||
Endpoint_Read_Stream_LE(&SPI_Multi_Params.TxData, SPI_Multi_Params.TxBytes, NO_STREAM_CALLBACK);
|
||||
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_SPI_MULTI);
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
|
||||
|
@ -521,7 +521,7 @@ void ISPProtocol_SPIMulti(void)
|
|||
ISPTarget_SendByte(SPI_Multi_Params.TxData[CurrTxPos]);
|
||||
else
|
||||
ISPTarget_SendByte(0);
|
||||
|
||||
|
||||
CurrTxPos++;
|
||||
}
|
||||
|
||||
|
@ -532,28 +532,28 @@ void ISPProtocol_SPIMulti(void)
|
|||
Endpoint_Write_Byte(ISPTarget_TransferByte(SPI_Multi_Params.TxData[CurrTxPos++]));
|
||||
else
|
||||
Endpoint_Write_Byte(ISPTarget_ReceiveByte());
|
||||
|
||||
|
||||
/* Check to see if we have filled the endpoint bank and need to send the packet */
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
{
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_WaitUntilReady();
|
||||
}
|
||||
|
||||
|
||||
CurrRxPos++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
|
||||
bool IsEndpointFull = !(Endpoint_IsReadWriteAllowed());
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Ensure last packet is a short packet to terminate the transfer */
|
||||
if (IsEndpointFull)
|
||||
{
|
||||
Endpoint_WaitUntilReady();
|
||||
Endpoint_WaitUntilReady();
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_WaitUntilReady();
|
||||
Endpoint_WaitUntilReady();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,4 +567,4 @@ void ISPProtocol_DelayMS(uint8_t DelayMS)
|
|||
_delay_ms(1);
|
||||
}
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -39,15 +39,15 @@
|
|||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
#include "../V2Protocol.h"
|
||||
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
#undef ENABLE_ISP_PROTOCOL
|
||||
|
||||
|
||||
#if !defined(ENABLE_XPROG_PROTOCOL)
|
||||
#define ENABLE_XPROG_PROTOCOL
|
||||
#endif
|
||||
|
@ -77,3 +77,4 @@
|
|||
void ISPProtocol_SPIMulti(void);
|
||||
void ISPProtocol_DelayMS(uint8_t DelayMS);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -132,10 +132,10 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
|
|||
TCCR1B = 0;
|
||||
|
||||
if (PINB & (1 << 3))
|
||||
SoftSPI_Data |= 0x01;
|
||||
SoftSPI_Data |= 0x01;
|
||||
}
|
||||
|
||||
PORTB ^= (1 << 1);
|
||||
PORTB ^= (1 << 1);
|
||||
}
|
||||
|
||||
/** Initialises the appropriate SPI driver (hardware or software, depending on the selected ISP speed) ready for
|
||||
|
@ -155,7 +155,7 @@ void ISPTarget_Init(void)
|
|||
else
|
||||
{
|
||||
HardwareSPIMode = false;
|
||||
|
||||
|
||||
DDRB |= ((1 << 1) | (1 << 2));
|
||||
PORTB |= ((1 << 0) | (1 << 3));
|
||||
|
||||
|
@ -176,7 +176,7 @@ void ISPTarget_ShutDown(void)
|
|||
else
|
||||
{
|
||||
DDRB &= ~((1 << 1) | (1 << 2));
|
||||
PORTB &= ~((1 << 0) | (1 << 3));
|
||||
PORTB &= ~((1 << 0) | (1 << 3));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ uint8_t ISPTarget_TransferSoftSPIByte(const uint8_t Byte)
|
|||
TCCR1B = ((1 << WGM12) | (1 << CS11));
|
||||
while (SoftSPI_BitsRemaining && TimeoutTicksRemaining);
|
||||
TCCR1B = 0;
|
||||
|
||||
|
||||
return SoftSPI_Data;
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ void ISPTarget_ChangeTargetResetLine(const bool ResetTarget)
|
|||
if (ResetTarget)
|
||||
{
|
||||
AUX_LINE_DDR |= AUX_LINE_MASK;
|
||||
|
||||
|
||||
if (!(V2Params_GetParameterValue(PARAM_RESET_POLARITY)))
|
||||
AUX_LINE_PORT |= AUX_LINE_MASK;
|
||||
else
|
||||
|
@ -254,7 +254,7 @@ void ISPTarget_LoadExtendedAddress(void)
|
|||
ISPTarget_SendByte(LOAD_EXTENDED_ADDRESS_CMD);
|
||||
ISPTarget_SendByte(0x00);
|
||||
ISPTarget_SendByte((CurrentAddress & 0x00FF0000) >> 16);
|
||||
ISPTarget_SendByte(0x00);
|
||||
ISPTarget_SendByte(0x00);
|
||||
}
|
||||
|
||||
/** Waits until the last issued target memory programming command has completed, via the check mode given and using
|
||||
|
@ -296,8 +296,8 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode,
|
|||
|
||||
if (!(TimeoutTicksRemaining))
|
||||
ProgrammingStatus = STATUS_CMD_TOUT;
|
||||
|
||||
break;
|
||||
|
||||
break;
|
||||
case PROG_MODE_WORD_READYBUSY_MASK:
|
||||
case PROG_MODE_PAGED_READYBUSY_MASK:
|
||||
ProgrammingStatus = ISPTarget_WaitWhileTargetBusy();
|
||||
|
@ -308,3 +308,4 @@ uint8_t ISPTarget_WaitForProgComplete(const uint8_t ProgrammingMode,
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -43,13 +43,13 @@
|
|||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Peripheral/SPI.h>
|
||||
|
||||
|
||||
#include "../V2ProtocolParams.h"
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
#undef ENABLE_ISP_PROTOCOL
|
||||
|
||||
|
||||
#if !defined(ENABLE_XPROG_PROTOCOL)
|
||||
#define ENABLE_XPROG_PROTOCOL
|
||||
#endif
|
||||
|
@ -58,7 +58,7 @@
|
|||
/* Macros: */
|
||||
/** Low level device command to issue an extended FLASH address, for devices with other 128KB of FLASH. */
|
||||
#define LOAD_EXTENDED_ADDRESS_CMD 0x4D
|
||||
|
||||
|
||||
/** Macro to convert an ISP frequency to a number of timer clock cycles for the software SPI driver */
|
||||
#define TIMER_COMP(freq) ((((F_CPU / 8) / freq) / 2) - 1)
|
||||
|
||||
|
@ -121,3 +121,4 @@
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -59,12 +59,12 @@ void V2Protocol_Init(void)
|
|||
ADC_SetupChannel(VTARGET_ADC_CHANNEL);
|
||||
ADC_StartReading(ADC_REFERENCE_AVCC | ADC_RIGHT_ADJUSTED | VTARGET_ADC_CHANNEL_MASK);
|
||||
#endif
|
||||
|
||||
|
||||
/* Timeout timer initialization (10ms period) */
|
||||
OCR0A = ((F_CPU / 1024) / 100);
|
||||
TCCR0A = (1 << WGM01);
|
||||
TIMSK0 = (1 << OCIE0A);
|
||||
|
||||
|
||||
V2Params_LoadNonVolatileParamValues();
|
||||
}
|
||||
|
||||
|
@ -75,11 +75,11 @@ void V2Protocol_Init(void)
|
|||
void V2Protocol_ProcessCommand(void)
|
||||
{
|
||||
uint8_t V2Command = Endpoint_Read_Byte();
|
||||
|
||||
|
||||
/* Start the timeout management timer */
|
||||
TimeoutTicksRemaining = COMMAND_TIMEOUT_TICKS;
|
||||
TCCR0B = ((1 << CS02) | (1 << CS00));
|
||||
|
||||
|
||||
switch (V2Command)
|
||||
{
|
||||
case CMD_SIGN_ON:
|
||||
|
@ -104,7 +104,7 @@ void V2Protocol_ProcessCommand(void)
|
|||
break;
|
||||
case CMD_PROGRAM_FLASH_ISP:
|
||||
case CMD_PROGRAM_EEPROM_ISP:
|
||||
ISPProtocol_ProgramMemory(V2Command);
|
||||
ISPProtocol_ProgramMemory(V2Command);
|
||||
break;
|
||||
case CMD_READ_FLASH_ISP:
|
||||
case CMD_READ_EEPROM_ISP:
|
||||
|
@ -139,7 +139,7 @@ void V2Protocol_ProcessCommand(void)
|
|||
V2Protocol_UnknownCommand(V2Command);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Disable the timeout management timer */
|
||||
TCCR0B = 0;
|
||||
|
||||
|
@ -193,10 +193,10 @@ static void V2Protocol_ResetProtection(void)
|
|||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_RESET_PROTECTION);
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
|
||||
|
@ -209,18 +209,18 @@ static void V2Protocol_GetSetParam(const uint8_t V2Command)
|
|||
{
|
||||
uint8_t ParamID = Endpoint_Read_Byte();
|
||||
uint8_t ParamValue;
|
||||
|
||||
|
||||
if (V2Command == CMD_SET_PARAMETER)
|
||||
ParamValue = Endpoint_Read_Byte();
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
Endpoint_Write_Byte(V2Command);
|
||||
|
||||
|
||||
uint8_t ParamPrivs = V2Params_GetParameterPrivileges(ParamID);
|
||||
|
||||
|
||||
if ((V2Command == CMD_SET_PARAMETER) && (ParamPrivs & PARAM_PRIV_WRITE))
|
||||
{
|
||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
|
@ -232,7 +232,7 @@ static void V2Protocol_GetSetParam(const uint8_t V2Command)
|
|||
Endpoint_Write_Byte(V2Params_GetParameterValue(ParamID));
|
||||
}
|
||||
else
|
||||
{
|
||||
{
|
||||
Endpoint_Write_Byte(STATUS_CMD_FAILED);
|
||||
}
|
||||
|
||||
|
@ -250,7 +250,7 @@ static void V2Protocol_LoadAddress(void)
|
|||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
if (CurrentAddress & (1UL << 31))
|
||||
MustLoadExtendedAddress = true;
|
||||
|
||||
|
@ -258,3 +258,4 @@ static void V2Protocol_LoadAddress(void)
|
|||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "../Descriptors.h"
|
||||
#include "V2ProtocolConstants.h"
|
||||
#include "V2ProtocolParams.h"
|
||||
|
@ -48,12 +48,12 @@
|
|||
/* Preprocessor Checks: */
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
#undef ENABLE_ISP_PROTOCOL
|
||||
|
||||
|
||||
#if !defined(ENABLE_XPROG_PROTOCOL)
|
||||
#define ENABLE_XPROG_PROTOCOL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(USB_SERIES_4_AVR) && ((VTARGET_ADC_CHANNEL == 2) || (VTARGET_ADC_CHANNEL == 3))
|
||||
#error The U4 AVR chips do not contain ADC channels 2 or 3. Please change VTARGET_ADC_CHANNEL or define NO_VTARGET_DETECT in the makefile.
|
||||
#endif
|
||||
|
@ -66,10 +66,10 @@
|
|||
|
||||
/** Programmer ID string, returned to the host during the CMD_SIGN_ON command processing. */
|
||||
#define PROGRAMMER_ID "AVRISP_MK2"
|
||||
|
||||
|
||||
/** Timeout period for each issued command from the host before it is aborted (in 10ms ticks). */
|
||||
#define COMMAND_TIMEOUT_TICKS 100
|
||||
|
||||
|
||||
/** Command timeout counter register, GPIOR for speed. */
|
||||
#define TimeoutTicksRemaining GPIOR1
|
||||
|
||||
|
@ -83,7 +83,7 @@
|
|||
/* Function Prototypes: */
|
||||
void V2Protocol_Init(void);
|
||||
void V2Protocol_ProcessCommand(void);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_V2PROTOCOL_C)
|
||||
static void V2Protocol_UnknownCommand(const uint8_t V2Command);
|
||||
static void V2Protocol_SignOn(void);
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -86,3 +86,4 @@
|
|||
#define PARAM_DISCHARGEDELAY 0xA4
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -40,7 +40,7 @@
|
|||
uint8_t EEMEM EEPROM_Rest_Polarity = 0x00;
|
||||
|
||||
/* Volatile Parameter Values for RAM storage */
|
||||
static ParameterItem_t ParameterTable[] =
|
||||
static ParameterItem_t ParameterTable[] =
|
||||
{
|
||||
{ .ParamID = PARAM_BUILD_NUMBER_LOW,
|
||||
.ParamPrivileges = PARAM_PRIV_READ,
|
||||
|
@ -109,11 +109,11 @@ void V2Params_UpdateParamValues(void)
|
|||
* \param[in] ParamID Parameter ID whose privileges are to be retrieved from the table
|
||||
*
|
||||
* \return Privileges for the requested parameter, as a mask of PARAM_PRIV_* masks
|
||||
*/
|
||||
*/
|
||||
uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID)
|
||||
{
|
||||
ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
|
||||
|
||||
|
||||
if (ParamInfo == NULL)
|
||||
return 0;
|
||||
|
||||
|
@ -129,14 +129,14 @@ uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID)
|
|||
* \param[in] ParamID Parameter ID whose value is to be retrieved from the table
|
||||
*
|
||||
* \return Current value of the parameter in the table, or 0 if not found
|
||||
*/
|
||||
*/
|
||||
uint8_t V2Params_GetParameterValue(const uint8_t ParamID)
|
||||
{
|
||||
ParameterItem_t* ParamInfo = V2Params_GetParamFromTable(ParamID);
|
||||
|
||||
|
||||
if (ParamInfo == NULL)
|
||||
return 0;
|
||||
|
||||
|
||||
return ParamInfo->ParamValue;
|
||||
}
|
||||
|
||||
|
@ -163,7 +163,7 @@ void V2Params_SetParameterValue(const uint8_t ParamID,
|
|||
|
||||
/* The target RESET line polarity is a non-volatile parameter, save to EEPROM when changed */
|
||||
if (ParamID == PARAM_RESET_POLARITY)
|
||||
eeprom_update_byte(&EEPROM_Rest_Polarity, Value);
|
||||
eeprom_update_byte(&EEPROM_Rest_Polarity, Value);
|
||||
}
|
||||
|
||||
/** Retrieves a parameter entry (including ID, value and privileges) from the parameter table that matches the given
|
||||
|
@ -182,9 +182,10 @@ static ParameterItem_t* V2Params_GetParamFromTable(const uint8_t ParamID)
|
|||
{
|
||||
if (ParamID == CurrTableItem->ParamID)
|
||||
return CurrTableItem;
|
||||
|
||||
|
||||
CurrTableItem++;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -45,7 +45,7 @@
|
|||
#if defined(ADC)
|
||||
#include <LUFA/Drivers/Peripheral/ADC.h>
|
||||
#endif
|
||||
|
||||
|
||||
#include "V2Protocol.h"
|
||||
#include "V2ProtocolConstants.h"
|
||||
#include "ISP/ISPTarget.h"
|
||||
|
@ -56,7 +56,7 @@
|
|||
|
||||
/** Parameter privilege mask to allow the host PC to change the parameter's value. */
|
||||
#define PARAM_PRIV_WRITE (1 << 1)
|
||||
|
||||
|
||||
/** Total number of parameters in the parameter table */
|
||||
#define TABLE_PARAM_COUNT (sizeof(ParameterTable) / sizeof(ParameterTable[0]))
|
||||
|
||||
|
@ -72,12 +72,12 @@
|
|||
/* Function Prototypes: */
|
||||
void V2Params_LoadNonVolatileParamValues(void);
|
||||
void V2Params_UpdateParamValues(void);
|
||||
|
||||
|
||||
uint8_t V2Params_GetParameterPrivileges(const uint8_t ParamID);
|
||||
uint8_t V2Params_GetParameterValue(const uint8_t ParamID);
|
||||
void V2Params_SetParameterValue(const uint8_t ParamID,
|
||||
const uint8_t Value);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_V2PROTOCOL_PARAMS_C)
|
||||
static ParameterItem_t* V2Params_GetParamFromTable(const uint8_t ParamID);
|
||||
#endif
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -138,17 +138,17 @@ bool TINYNVM_ReadMemory(const uint16_t ReadAddress,
|
|||
/* Set the NVM control register to the NO OP command for memory reading */
|
||||
TINYNVM_SendWriteNVMRegister(XPROG_Param_NVMCMDRegAddr);
|
||||
XPROGTarget_SendByte(TINY_NVM_CMD_NOOP);
|
||||
|
||||
|
||||
/* Send the address of the location to read from */
|
||||
TINYNVM_SendPointerAddress(ReadAddress);
|
||||
|
||||
|
||||
while (ReadSize-- && TimeoutTicksRemaining)
|
||||
{
|
||||
/* Read the byte of data from the target */
|
||||
XPROGTarget_SendByte(TPI_CMD_SLD | TPI_POINTER_INDIRECT_PI);
|
||||
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
|
||||
}
|
||||
|
||||
|
||||
return (TimeoutTicksRemaining != 0);
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,7 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
|
|||
/* Wait until the NVM controller is no longer busy */
|
||||
if (!(TINYNVM_WaitWhileNVMControllerBusy()))
|
||||
return false;
|
||||
|
||||
|
||||
/* Must have an integer number of words to write - if extra byte, word-align via a dummy high byte */
|
||||
if (WriteLength & 0x01)
|
||||
WriteBuffer[WriteLength++] = 0xFF;
|
||||
|
@ -175,10 +175,10 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
|
|||
/* Set the NVM control register to the WORD WRITE command for memory reading */
|
||||
TINYNVM_SendWriteNVMRegister(XPROG_Param_NVMCMDRegAddr);
|
||||
XPROGTarget_SendByte(TINY_NVM_CMD_WORDWRITE);
|
||||
|
||||
|
||||
/* Send the address of the location to write to */
|
||||
TINYNVM_SendPointerAddress(WriteAddress);
|
||||
|
||||
|
||||
while (WriteLength)
|
||||
{
|
||||
/* Wait until the NVM controller is no longer busy */
|
||||
|
@ -188,7 +188,7 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
|
|||
/* Write the low byte of data to the target */
|
||||
XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);
|
||||
XPROGTarget_SendByte(*(WriteBuffer++));
|
||||
|
||||
|
||||
/* Write the high byte of data to the target */
|
||||
XPROGTarget_SendByte(TPI_CMD_SST | TPI_POINTER_INDIRECT_PI);
|
||||
XPROGTarget_SendByte(*(WriteBuffer++));
|
||||
|
@ -196,7 +196,7 @@ bool TINYNVM_WriteMemory(const uint16_t WriteAddress,
|
|||
/* Need to decrement the write length twice, since we read out a whole word */
|
||||
WriteLength -= 2;
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -226,8 +226,9 @@ bool TINYNVM_EraseMemory(const uint8_t EraseCommand,
|
|||
/* Wait until the NVM controller is no longer busy */
|
||||
if (!(TINYNVM_WaitWhileNVMControllerBusy()))
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -40,16 +40,16 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
|
||||
#include "XPROGProtocol.h"
|
||||
#include "XPROGTarget.h"
|
||||
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
#undef ENABLE_ISP_PROTOCOL
|
||||
|
||||
|
||||
#if !defined(ENABLE_XPROG_PROTOCOL)
|
||||
#define ENABLE_XPROG_PROTOCOL
|
||||
#endif
|
||||
|
@ -61,7 +61,7 @@
|
|||
#define TINY_NVM_CMD_SECTIONERASE 0x14
|
||||
#define TINY_NVM_CMD_WORDWRITE 0x1D
|
||||
|
||||
/* Function Prototypes: */
|
||||
/* Function Prototypes: */
|
||||
bool TINYNVM_WaitWhileNVMBusBusy(void);
|
||||
bool TINYNVM_WaitWhileNVMControllerBusy(void);
|
||||
bool TINYNVM_ReadMemory(const uint16_t ReadAddress,
|
||||
|
@ -80,3 +80,4 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -76,13 +76,13 @@ bool XMEGANVM_WaitWhileNVMBusBusy(void)
|
|||
{
|
||||
/* Send the LDCS command to read the PDI STATUS register to see the NVM bus is active */
|
||||
XPROGTarget_SendByte(PDI_CMD_LDCS | PDI_STATUS_REG);
|
||||
|
||||
|
||||
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
|
||||
|
||||
|
||||
/* We might have timed out waiting for the status register read response, check here */
|
||||
if (!(TimeoutTicksRemaining))
|
||||
return false;
|
||||
|
||||
|
||||
/* Check the status register read response to see if the NVM bus is enabled */
|
||||
if (StatusRegister & PDI_STATUS_NVM)
|
||||
return true;
|
||||
|
@ -102,7 +102,7 @@ bool XMEGANVM_WaitWhileNVMControllerBusy(void)
|
|||
/* Send a LDS command to read the NVM STATUS register to check the BUSY flag */
|
||||
XPROGTarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_STATUS);
|
||||
|
||||
|
||||
uint8_t StatusRegister = XPROGTarget_ReceiveByte();
|
||||
|
||||
/* We might have timed out waiting for the status register read response, check here */
|
||||
|
@ -127,7 +127,7 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
|
|||
/* Wait until the NVM controller is no longer busy */
|
||||
if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
|
||||
return false;
|
||||
|
||||
|
||||
/* Set the NVM command to the correct CRC read command */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
|
||||
|
@ -145,7 +145,7 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
|
|||
/* Wait until the NVM controller is no longer busy */
|
||||
if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
|
||||
return false;
|
||||
|
||||
|
||||
/* Load the PDI pointer register with the DAT0 register start address */
|
||||
XPROGTarget_SendByte(PDI_CMD_ST | (PDI_POINTER_DIRECT << 2) | PDI_DATSIZE_4BYTES);
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_DAT0);
|
||||
|
@ -153,12 +153,12 @@ bool XMEGANVM_GetMemoryCRC(const uint8_t CRCCommand, uint32_t* const CRCDest)
|
|||
/* Send the REPEAT command to grab the CRC bytes */
|
||||
XPROGTarget_SendByte(PDI_CMD_REPEAT | PDI_DATSIZE_1BYTE);
|
||||
XPROGTarget_SendByte(XMEGA_CRC_LENGTH - 1);
|
||||
|
||||
|
||||
/* Read in the CRC bytes from the target */
|
||||
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
|
||||
for (uint8_t i = 0; i < XMEGA_CRC_LENGTH; i++)
|
||||
((uint8_t*)CRCDest)[i] = XPROGTarget_ReceiveByte();
|
||||
|
||||
|
||||
return (TimeoutTicksRemaining != 0);
|
||||
}
|
||||
|
||||
|
@ -175,7 +175,7 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16
|
|||
/* Wait until the NVM controller is no longer busy */
|
||||
if (!(XMEGANVM_WaitWhileNVMControllerBusy()))
|
||||
return false;
|
||||
|
||||
|
||||
/* Send the READNVM command to the NVM controller for reading of an arbitrary location */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
|
||||
|
@ -188,12 +188,12 @@ bool XMEGANVM_ReadMemory(const uint32_t ReadAddress, uint8_t* ReadBuffer, uint16
|
|||
/* Send the REPEAT command with the specified number of bytes to read */
|
||||
XPROGTarget_SendByte(PDI_CMD_REPEAT | PDI_DATSIZE_1BYTE);
|
||||
XPROGTarget_SendByte(ReadSize - 1);
|
||||
|
||||
|
||||
/* Send a LD command with indirect access and post-increment to read out the bytes */
|
||||
XPROGTarget_SendByte(PDI_CMD_LD | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
|
||||
while (ReadSize-- && TimeoutTicksRemaining)
|
||||
*(ReadBuffer++) = XPROGTarget_ReceiveByte();
|
||||
|
||||
|
||||
return (TimeoutTicksRemaining != 0);
|
||||
}
|
||||
|
||||
|
@ -215,12 +215,12 @@ bool XMEGANVM_WriteByteMemory(const uint8_t WriteCommand, const uint32_t WriteAd
|
|||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
|
||||
XPROGTarget_SendByte(WriteCommand);
|
||||
|
||||
|
||||
/* Send new memory byte to the memory of the target */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendAddress(WriteAddress);
|
||||
XPROGTarget_SendByte(Byte);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -275,13 +275,13 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t Eras
|
|||
/* Send the REPEAT command with the specified number of bytes to write */
|
||||
XPROGTarget_SendByte(PDI_CMD_REPEAT | PDI_DATSIZE_1BYTE);
|
||||
XPROGTarget_SendByte(WriteSize - 1);
|
||||
|
||||
|
||||
/* Send a ST command with indirect access and post-increment to write the bytes */
|
||||
XPROGTarget_SendByte(PDI_CMD_ST | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
|
||||
while (WriteSize--)
|
||||
XPROGTarget_SendByte(*(WriteBuffer++));
|
||||
}
|
||||
|
||||
|
||||
if (PageMode & XPRG_PAGEMODE_WRITE)
|
||||
{
|
||||
/* Wait until the NVM controller is no longer busy */
|
||||
|
@ -292,7 +292,7 @@ bool XMEGANVM_WritePageMemory(const uint8_t WriteBuffCommand, const uint8_t Eras
|
|||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
|
||||
XPROGTarget_SendByte(WritePageCommand);
|
||||
|
||||
|
||||
/* Send the address of the first page location to write the memory page */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendAddress(WriteAddress);
|
||||
|
@ -322,11 +322,11 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
|
|||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
|
||||
XPROGTarget_SendByte(EraseCommand);
|
||||
|
||||
|
||||
/* Set CMDEX bit in NVM CTRLA register to start the erase sequence */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
|
||||
XPROGTarget_SendByte(1 << 0);
|
||||
XPROGTarget_SendByte(1 << 0);
|
||||
}
|
||||
else if (EraseCommand == XMEGA_NVM_CMD_ERASEEEPROM)
|
||||
{
|
||||
|
@ -356,21 +356,21 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
|
|||
/* Send the REPEAT command with the specified number of bytes to write */
|
||||
XPROGTarget_SendByte(PDI_CMD_REPEAT | PDI_DATSIZE_1BYTE);
|
||||
XPROGTarget_SendByte(XPROG_Param_EEPageSize - 1);
|
||||
|
||||
|
||||
/* Send a ST command with indirect access and post-increment to tag each byte in the EEPROM page buffer */
|
||||
XPROGTarget_SendByte(PDI_CMD_ST | (PDI_POINTER_INDIRECT_PI << 2) | PDI_DATSIZE_1BYTE);
|
||||
for (uint8_t PageByte = 0; PageByte < XPROG_Param_EEPageSize; PageByte++)
|
||||
XPROGTarget_SendByte(0x00);
|
||||
|
||||
|
||||
/* Send the memory erase command to the target */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
|
||||
XPROGTarget_SendByte(EraseCommand);
|
||||
|
||||
|
||||
/* Set CMDEX bit in NVM CTRLA register to start the EEPROM erase sequence */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CTRLA);
|
||||
XPROGTarget_SendByte(1 << 0);
|
||||
XPROGTarget_SendByte(1 << 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -378,18 +378,19 @@ bool XMEGANVM_EraseMemory(const uint8_t EraseCommand, const uint32_t Address)
|
|||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendNVMRegAddress(XMEGA_NVM_REG_CMD);
|
||||
XPROGTarget_SendByte(EraseCommand);
|
||||
|
||||
|
||||
/* Other erase modes just need us to address a byte within the target memory space */
|
||||
XPROGTarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_4BYTES << 2));
|
||||
XMEGANVM_SendAddress(Address);
|
||||
XPROGTarget_SendByte(0x00);
|
||||
}
|
||||
|
||||
|
||||
/* Wait until the NVM bus is ready again */
|
||||
if (!(XMEGANVM_WaitWhileNVMBusBusy()))
|
||||
return false;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -40,16 +40,16 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
|
||||
#include "XPROGProtocol.h"
|
||||
#include "XPROGTarget.h"
|
||||
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
#undef ENABLE_ISP_PROTOCOL
|
||||
|
||||
|
||||
#if !defined(ENABLE_XPROG_PROTOCOL)
|
||||
#define ENABLE_XPROG_PROTOCOL
|
||||
#endif
|
||||
|
@ -57,7 +57,7 @@
|
|||
|
||||
/* Defines: */
|
||||
#define XMEGA_CRC_LENGTH 3
|
||||
|
||||
|
||||
#define XMEGA_NVM_REG_ADDR0 0x00
|
||||
#define XMEGA_NVM_REG_ADDR1 0x01
|
||||
#define XMEGA_NVM_REG_ADDR2 0x02
|
||||
|
@ -70,7 +70,7 @@
|
|||
#define XMEGA_NVM_REG_INTCTRL 0x0D
|
||||
#define XMEGA_NVM_REG_STATUS 0x0F
|
||||
#define XMEGA_NVM_REG_LOCKBITS 0x10
|
||||
|
||||
|
||||
#define XMEGA_NVM_CMD_NOOP 0x00
|
||||
#define XMEGA_NVM_CMD_CHIPERASE 0x40
|
||||
#define XMEGA_NVM_CMD_READNVM 0x43
|
||||
|
@ -118,7 +118,8 @@
|
|||
|
||||
#if defined(INCLUDE_FROM_XMEGANVM_C)
|
||||
static void XMEGANVM_SendNVMRegAddress(const uint8_t Register);
|
||||
static void XMEGANVM_SendAddress(const uint32_t AbsoluteAddress);
|
||||
static void XMEGANVM_SendAddress(const uint32_t AbsoluteAddress);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -61,18 +61,18 @@ void XPROGProtocol_SetMode(void)
|
|||
{
|
||||
uint8_t Protocol;
|
||||
} SetMode_XPROG_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&SetMode_XPROG_Params, sizeof(SetMode_XPROG_Params), NO_STREAM_CALLBACK);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
XPROG_SelectedProtocol = SetMode_XPROG_Params.Protocol;
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_XPROG_SETMODE);
|
||||
Endpoint_Write_Byte((SetMode_XPROG_Params.Protocol != XPRG_PROTOCOL_JTAG) ? STATUS_CMD_OK : STATUS_CMD_FAILED);
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/** Handler for the CMD_XPROG command, which wraps up XPROG commands in a V2 wrapper which need to be
|
||||
|
@ -81,7 +81,7 @@ void XPROGProtocol_SetMode(void)
|
|||
void XPROGProtocol_Command(void)
|
||||
{
|
||||
uint8_t XPROGCommand = Endpoint_Read_Byte();
|
||||
|
||||
|
||||
switch (XPROGCommand)
|
||||
{
|
||||
case XPRG_CMD_ENTER_PROGMODE:
|
||||
|
@ -114,7 +114,7 @@ static void XPROGProtocol_EnterXPROGMode(void)
|
|||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
bool NVMBusEnabled = false;
|
||||
|
||||
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
|
||||
|
@ -123,11 +123,11 @@ static void XPROGProtocol_EnterXPROGMode(void)
|
|||
XPROGTarget_EnableTargetPDI();
|
||||
|
||||
/* Store the RESET key into the RESET PDI register to keep the XMEGA in reset */
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
|
||||
XPROGTarget_SendByte(PDI_RESET_KEY);
|
||||
|
||||
/* Lower direction change guard time to 0 USART bits */
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_CTRL_REG);
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_CTRL_REG);
|
||||
XPROGTarget_SendByte(0x07);
|
||||
|
||||
/* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */
|
||||
|
@ -142,20 +142,20 @@ static void XPROGProtocol_EnterXPROGMode(void)
|
|||
{
|
||||
/* Enable TPI programming mode with the attached target */
|
||||
XPROGTarget_EnableTargetTPI();
|
||||
|
||||
|
||||
/* Lower direction change guard time to 0 USART bits */
|
||||
XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);
|
||||
XPROGTarget_SendByte(0x07);
|
||||
|
||||
|
||||
/* Enable access to the XPROG NVM bus by sending the documented NVM access key to the device */
|
||||
XPROGTarget_SendByte(TPI_CMD_SKEY);
|
||||
XPROGTarget_SendByte(TPI_CMD_SKEY);
|
||||
for (uint8_t i = sizeof(TPI_NVMENABLE_KEY); i > 0; i--)
|
||||
XPROGTarget_SendByte(TPI_NVMENABLE_KEY[i - 1]);
|
||||
|
||||
/* Wait until the NVM bus becomes active */
|
||||
NVMBusEnabled = TINYNVM_WaitWhileNVMBusBusy();
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_XPROG);
|
||||
Endpoint_Write_Byte(XPRG_CMD_ENTER_PROGMODE);
|
||||
Endpoint_Write_Byte(NVMBusEnabled ? XPRG_ERR_OK : XPRG_ERR_FAILED);
|
||||
|
@ -170,17 +170,17 @@ static void XPROGProtocol_LeaveXPROGMode(void)
|
|||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
|
||||
{
|
||||
XMEGANVM_WaitWhileNVMBusBusy();
|
||||
|
||||
/* Clear the RESET key in the RESET PDI register to allow the XMEGA to run */
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
|
||||
XPROGTarget_SendByte(0x00);
|
||||
|
||||
/* Do it twice to make sure it takes affect (silicon bug?) */
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
|
||||
XPROGTarget_SendByte(PDI_CMD_STCS | PDI_RESET_REG);
|
||||
XPROGTarget_SendByte(0x00);
|
||||
|
||||
XPROGTarget_DisableTargetPDI();
|
||||
|
@ -190,12 +190,12 @@ static void XPROGProtocol_LeaveXPROGMode(void)
|
|||
TINYNVM_WaitWhileNVMBusBusy();
|
||||
|
||||
/* Clear the NVMEN bit in the TPI CONTROL register to disable TPI mode */
|
||||
XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);
|
||||
XPROGTarget_SendByte(TPI_CMD_SSTCS | TPI_CTRL_REG);
|
||||
XPROGTarget_SendByte(0x00);
|
||||
|
||||
|
||||
XPROGTarget_DisableTargetTPI();
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_XPROG);
|
||||
Endpoint_Write_Byte(XPRG_CMD_LEAVE_PROGMODE);
|
||||
Endpoint_Write_Byte(XPRG_ERR_OK);
|
||||
|
@ -219,11 +219,11 @@ static void XPROGProtocol_Erase(void)
|
|||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
uint8_t EraseCommand;
|
||||
|
||||
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
|
||||
{
|
||||
{
|
||||
/* Determine which NVM command to send to the device depending on the memory to erase */
|
||||
switch (Erase_XPROG_Params.MemoryType)
|
||||
{
|
||||
|
@ -255,7 +255,7 @@ static void XPROGProtocol_Erase(void)
|
|||
EraseCommand = XMEGA_NVM_CMD_NOOP;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Erase the target memory, indicate timeout if occurred */
|
||||
if (!(XMEGANVM_EraseMemory(EraseCommand, Erase_XPROG_Params.Address)))
|
||||
ReturnStatus = XPRG_ERR_TIMEOUT;
|
||||
|
@ -266,16 +266,16 @@ static void XPROGProtocol_Erase(void)
|
|||
EraseCommand = TINY_NVM_CMD_CHIPERASE;
|
||||
else
|
||||
EraseCommand = TINY_NVM_CMD_SECTIONERASE;
|
||||
|
||||
|
||||
/* Erase the target memory, indicate timeout if occurred */
|
||||
if (!(TINYNVM_EraseMemory(EraseCommand, Erase_XPROG_Params.Address)))
|
||||
ReturnStatus = XPRG_ERR_TIMEOUT;
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_XPROG);
|
||||
Endpoint_Write_Byte(XPRG_CMD_ERASE);
|
||||
Endpoint_Write_Byte(ReturnStatus);
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/** Handler for the XPROG WRITE_MEMORY command to write to a specific memory space within the attached device. */
|
||||
|
@ -291,7 +291,7 @@ static void XPROGProtocol_WriteMemory(void)
|
|||
uint16_t Length;
|
||||
uint8_t ProgData[256];
|
||||
} WriteMemory_XPROG_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&WriteMemory_XPROG_Params, (sizeof(WriteMemory_XPROG_Params) -
|
||||
sizeof(WriteMemory_XPROG_Params).ProgData), NO_STREAM_CALLBACK);
|
||||
WriteMemory_XPROG_Params.Address = SwapEndian_32(WriteMemory_XPROG_Params.Address);
|
||||
|
@ -309,7 +309,7 @@ static void XPROGProtocol_WriteMemory(void)
|
|||
uint8_t WriteBuffCommand = XMEGA_NVM_CMD_LOADFLASHPAGEBUFF;
|
||||
uint8_t EraseBuffCommand = XMEGA_NVM_CMD_ERASEFLASHPAGEBUFF;
|
||||
bool PagedMemory = true;
|
||||
|
||||
|
||||
switch (WriteMemory_XPROG_Params.MemoryType)
|
||||
{
|
||||
case XPRG_MEM_TYPE_APPL:
|
||||
|
@ -321,7 +321,7 @@ static void XPROGProtocol_WriteMemory(void)
|
|||
case XPRG_MEM_TYPE_EEPROM:
|
||||
WriteCommand = XMEGA_NVM_CMD_ERASEWRITEEEPROMPAGE;
|
||||
WriteBuffCommand = XMEGA_NVM_CMD_LOADEEPROMPAGEBUFF;
|
||||
EraseBuffCommand = XMEGA_NVM_CMD_ERASEEEPROMPAGEBUFF;
|
||||
EraseBuffCommand = XMEGA_NVM_CMD_ERASEEEPROMPAGEBUFF;
|
||||
break;
|
||||
case XPRG_MEM_TYPE_USERSIG:
|
||||
WriteCommand = XMEGA_NVM_CMD_WRITEUSERSIG;
|
||||
|
@ -335,9 +335,9 @@ static void XPROGProtocol_WriteMemory(void)
|
|||
PagedMemory = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Send the appropriate memory write commands to the device, indicate timeout if occurred */
|
||||
if ((PagedMemory && !(XMEGANVM_WritePageMemory(WriteBuffCommand, EraseBuffCommand, WriteCommand,
|
||||
if ((PagedMemory && !(XMEGANVM_WritePageMemory(WriteBuffCommand, EraseBuffCommand, WriteCommand,
|
||||
WriteMemory_XPROG_Params.PageMode, WriteMemory_XPROG_Params.Address,
|
||||
WriteMemory_XPROG_Params.ProgData, WriteMemory_XPROG_Params.Length))) ||
|
||||
(!PagedMemory && !(XMEGANVM_WriteByteMemory(WriteCommand, WriteMemory_XPROG_Params.Address,
|
||||
|
@ -355,10 +355,10 @@ static void XPROGProtocol_WriteMemory(void)
|
|||
ReturnStatus = XPRG_ERR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_XPROG);
|
||||
Endpoint_Write_Byte(XPRG_CMD_WRITE_MEM);
|
||||
Endpoint_Write_Byte(ReturnStatus);
|
||||
Endpoint_Write_Byte(ReturnStatus);
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
|
@ -375,7 +375,7 @@ static void XPROGProtocol_ReadMemory(void)
|
|||
uint32_t Address;
|
||||
uint16_t Length;
|
||||
} ReadMemory_XPROG_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&ReadMemory_XPROG_Params, sizeof(ReadMemory_XPROG_Params), NO_STREAM_CALLBACK);
|
||||
ReadMemory_XPROG_Params.Address = SwapEndian_32(ReadMemory_XPROG_Params.Address);
|
||||
ReadMemory_XPROG_Params.Length = SwapEndian_16(ReadMemory_XPROG_Params.Length);
|
||||
|
@ -385,7 +385,7 @@ static void XPROGProtocol_ReadMemory(void)
|
|||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
uint8_t ReadBuffer[256];
|
||||
|
||||
|
||||
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
|
||||
{
|
||||
/* Read the PDI target's memory, indicate timeout if occurred */
|
||||
|
@ -402,10 +402,10 @@ static void XPROGProtocol_ReadMemory(void)
|
|||
Endpoint_Write_Byte(CMD_XPROG);
|
||||
Endpoint_Write_Byte(XPRG_CMD_READ_MEM);
|
||||
Endpoint_Write_Byte(ReturnStatus);
|
||||
|
||||
|
||||
if (ReturnStatus == XPRG_ERR_OK)
|
||||
Endpoint_Write_Stream_LE(ReadBuffer, ReadMemory_XPROG_Params.Length, NO_STREAM_CALLBACK);
|
||||
|
||||
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
|
@ -415,18 +415,18 @@ static void XPROGProtocol_ReadMemory(void)
|
|||
static void XPROGProtocol_ReadCRC(void)
|
||||
{
|
||||
uint8_t ReturnStatus = XPRG_ERR_OK;
|
||||
|
||||
|
||||
struct
|
||||
{
|
||||
uint8_t CRCType;
|
||||
} ReadCRC_XPROG_Params;
|
||||
|
||||
|
||||
Endpoint_Read_Stream_LE(&ReadCRC_XPROG_Params, sizeof(ReadCRC_XPROG_Params), NO_STREAM_CALLBACK);
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
uint32_t MemoryCRC;
|
||||
|
||||
if (XPROG_SelectedProtocol == XPRG_PROTOCOL_PDI)
|
||||
|
@ -446,7 +446,7 @@ static void XPROGProtocol_ReadCRC(void)
|
|||
CRCCommand = XMEGA_NVM_CMD_FLASHCRC;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Perform and retrieve the memory CRC, indicate timeout if occurred */
|
||||
if (!(XMEGANVM_GetMemoryCRC(CRCCommand, &MemoryCRC)))
|
||||
ReturnStatus = XPRG_ERR_TIMEOUT;
|
||||
|
@ -456,18 +456,18 @@ static void XPROGProtocol_ReadCRC(void)
|
|||
/* TPI does not support memory CRC */
|
||||
ReturnStatus = XPRG_ERR_FAILED;
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_XPROG);
|
||||
Endpoint_Write_Byte(XPRG_CMD_CRC);
|
||||
Endpoint_Write_Byte(ReturnStatus);
|
||||
|
||||
|
||||
if (ReturnStatus == XPRG_ERR_OK)
|
||||
{
|
||||
Endpoint_Write_Byte(MemoryCRC >> 16);
|
||||
Endpoint_Write_Word_LE(MemoryCRC & 0xFFFF);
|
||||
Endpoint_Write_Word_LE(MemoryCRC & 0xFFFF);
|
||||
}
|
||||
|
||||
Endpoint_ClearIN();
|
||||
|
||||
Endpoint_ClearIN();
|
||||
}
|
||||
|
||||
/** Handler for the XPROG SET_PARAM command to set a XPROG parameter for use when communicating with the
|
||||
|
@ -478,7 +478,7 @@ static void XPROGProtocol_SetParam(void)
|
|||
uint8_t ReturnStatus = XPRG_ERR_OK;
|
||||
|
||||
uint8_t XPROGParam = Endpoint_Read_Byte();
|
||||
|
||||
|
||||
/* Determine which parameter is being set, store the new parameter value */
|
||||
switch (XPROGParam)
|
||||
{
|
||||
|
@ -502,7 +502,7 @@ static void XPROGProtocol_SetParam(void)
|
|||
Endpoint_ClearOUT();
|
||||
Endpoint_SelectEndpoint(AVRISP_DATA_IN_EPNUM);
|
||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||
|
||||
|
||||
Endpoint_Write_Byte(CMD_XPROG);
|
||||
Endpoint_Write_Byte(XPRG_CMD_SET_PARAM);
|
||||
Endpoint_Write_Byte(ReturnStatus);
|
||||
|
@ -510,3 +510,4 @@ static void XPROGProtocol_SetParam(void)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -40,10 +40,10 @@
|
|||
#include <avr/io.h>
|
||||
#include <util/delay.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/Peripheral/SerialStream.h>
|
||||
|
||||
|
||||
#include "../V2Protocol.h"
|
||||
#include "XPROGTarget.h"
|
||||
#include "XMEGANVM.h"
|
||||
|
@ -52,12 +52,12 @@
|
|||
/* Preprocessor Checks: */
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
#undef ENABLE_ISP_PROTOCOL
|
||||
|
||||
|
||||
#if !defined(ENABLE_XPROG_PROTOCOL)
|
||||
#define ENABLE_XPROG_PROTOCOL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Macros: */
|
||||
#define XPRG_CMD_ENTER_PROGMODE 0x01
|
||||
#define XPRG_CMD_LEAVE_PROGMODE 0x02
|
||||
|
@ -100,25 +100,25 @@
|
|||
#define XPRG_PARAM_EEPPAGESIZE 0x02
|
||||
#define XPRG_PARAM_NVMCMD_REG 0x03
|
||||
#define XPRG_PARAM_NVMCSR_REG 0x04
|
||||
|
||||
|
||||
#define XPRG_PROTOCOL_PDI 0x00
|
||||
#define XPRG_PROTOCOL_JTAG 0x01
|
||||
#define XPRG_PROTOCOL_TPI 0x02
|
||||
|
||||
|
||||
#define XPRG_PAGEMODE_WRITE (1 << 1)
|
||||
#define XPRG_PAGEMODE_ERASE (1 << 0)
|
||||
|
||||
|
||||
/* External Variables: */
|
||||
extern uint32_t XPROG_Param_NVMBase;
|
||||
extern uint16_t XPROG_Param_EEPageSize;
|
||||
extern uint8_t XPROG_Param_NVMCSRRegAddr;
|
||||
extern uint8_t XPROG_Param_NVMCMDRegAddr;
|
||||
extern uint8_t XPROG_SelectedProtocol;
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void XPROGProtocol_SetMode(void);
|
||||
void XPROGProtocol_Command(void);
|
||||
|
||||
|
||||
#if (defined(INCLUDE_FROM_XPROGPROTOCOL_C) && defined(ENABLE_XPROG_PROTOCOL))
|
||||
static void XPROGProtocol_EnterXPROGMode(void);
|
||||
static void XPROGProtocol_LeaveXPROGMode(void);
|
||||
|
@ -128,5 +128,6 @@
|
|||
static void XPROGProtocol_ReadMemory(void);
|
||||
static void XPROGProtocol_ReadCRC(void);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -49,11 +49,11 @@ void XPROGTarget_EnableTargetPDI(void)
|
|||
/* Set Tx and XCK as outputs, Rx as input */
|
||||
DDRD |= (1 << 5) | (1 << 3);
|
||||
DDRD &= ~(1 << 2);
|
||||
|
||||
|
||||
/* Set DATA line high for at least 90ns to disable /RESET functionality */
|
||||
PORTD |= (1 << 3);
|
||||
_delay_us(1);
|
||||
|
||||
|
||||
/* Set up the synchronous USART for XMEGA communications - 8 data bits, even parity, 2 stop bits */
|
||||
UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED);
|
||||
UCSR1B = (1 << TXEN1);
|
||||
|
@ -77,7 +77,7 @@ void XPROGTarget_EnableTargetTPI(void)
|
|||
/* Set Tx and XCK as outputs, Rx as input */
|
||||
DDRD |= (1 << 5) | (1 << 3);
|
||||
DDRD &= ~(1 << 2);
|
||||
|
||||
|
||||
/* Set up the synchronous USART for TINY communications - 8 data bits, even parity, 2 stop bits */
|
||||
UBRR1 = (F_CPU / XPROG_HARDWARE_SPEED);
|
||||
UCSR1B = (1 << TXEN1);
|
||||
|
@ -133,7 +133,7 @@ void XPROGTarget_SendByte(const uint8_t Byte)
|
|||
/* Switch to Tx mode if currently in Rx mode */
|
||||
if (!(IsSending))
|
||||
XPROGTarget_SetTxMode();
|
||||
|
||||
|
||||
/* Wait until there is space in the hardware Tx buffer before writing */
|
||||
while (!(UCSR1A & (1 << UDRE1)));
|
||||
UCSR1A |= (1 << TXC1);
|
||||
|
@ -202,3 +202,4 @@ static void XPROGTarget_SetRxMode(void)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -40,27 +40,27 @@
|
|||
#include <avr/io.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
|
||||
#include "../V2Protocol.h"
|
||||
#include "XPROGProtocol.h"
|
||||
|
||||
|
||||
/* Preprocessor Checks: */
|
||||
#if ((BOARD == BOARD_XPLAIN) || (BOARD == BOARD_XPLAIN_REV1))
|
||||
#undef ENABLE_ISP_PROTOCOL
|
||||
|
||||
|
||||
#if !defined(ENABLE_XPROG_PROTOCOL)
|
||||
#define ENABLE_XPROG_PROTOCOL
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/** Serial carrier TPI/PDI speed when hardware TPI/PDI mode is used. */
|
||||
#define XPROG_HARDWARE_SPEED 500000
|
||||
|
||||
/** Total number of bits in a single USART frame. */
|
||||
#define BITS_IN_USART_FRAME 12
|
||||
|
||||
|
||||
#define PDI_CMD_LDS 0x00
|
||||
#define PDI_CMD_LD 0x20
|
||||
#define PDI_CMD_STS 0x40
|
||||
|
@ -69,11 +69,11 @@
|
|||
#define PDI_CMD_REPEAT 0xA0
|
||||
#define PDI_CMD_STCS 0xC0
|
||||
#define PDI_CMD_KEY 0xE0
|
||||
|
||||
|
||||
#define PDI_STATUS_REG 0
|
||||
#define PDI_RESET_REG 1
|
||||
#define PDI_CTRL_REG 2
|
||||
|
||||
|
||||
#define PDI_STATUS_NVM (1 << 1)
|
||||
|
||||
#define PDI_RESET_KEY 0x59
|
||||
|
@ -83,7 +83,7 @@
|
|||
#define PDI_DATSIZE_2BYTES 1
|
||||
#define PDI_DATSIZE_3BYTES 2
|
||||
#define PDI_DATSIZE_4BYTES 3
|
||||
|
||||
|
||||
#define PDI_POINTER_INDIRECT 0
|
||||
#define PDI_POINTER_INDIRECT_PI 1
|
||||
#define PDI_POINTER_DIRECT 2
|
||||
|
@ -100,14 +100,14 @@
|
|||
#define TPI_STATUS_REG 0x00
|
||||
#define TPI_CTRL_REG 0x02
|
||||
#define TPI_ID_REG 0x0F
|
||||
|
||||
|
||||
#define TPI_STATUS_NVM (1 << 1)
|
||||
|
||||
#define TPI_NVMENABLE_KEY (uint8_t[]){0x12, 0x89, 0xAB, 0x45, 0xCD, 0xD8, 0x88, 0xFF}
|
||||
|
||||
#define TPI_POINTER_INDIRECT 0
|
||||
#define TPI_POINTER_INDIRECT_PI 4
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void XPROGTarget_EnableTargetPDI(void);
|
||||
void XPROGTarget_EnableTargetTPI(void);
|
||||
|
@ -117,10 +117,11 @@
|
|||
uint8_t XPROGTarget_ReceiveByte(void);
|
||||
void XPROGTarget_SendBreak(void);
|
||||
bool XPROGTarget_WaitWhileNVMBusBusy(void);
|
||||
|
||||
|
||||
#if (defined(INCLUDE_FROM_XPROGTARGET_C) && defined(ENABLE_XPROG_PROTOCOL))
|
||||
static void XPROGTarget_SetTxMode(void);
|
||||
static void XPROGTarget_SetRxMode(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -158,7 +158,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -171,7 +171,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -285,7 +285,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -298,7 +298,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -310,7 +310,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -322,7 +322,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -345,7 +345,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -379,7 +379,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -413,7 +413,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -442,7 +442,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -461,10 +461,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -529,11 +529,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -560,9 +560,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -660,14 +660,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -689,7 +689,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -733,3 +733,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -60,7 +60,7 @@ uint8_t FlushPeriodRemaining = RECEIVE_BUFFER_FLUSH_MS;
|
|||
*/
|
||||
USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.ControlInterfaceNumber = 0,
|
||||
|
||||
|
@ -84,9 +84,9 @@ USB_ClassInfo_CDC_Device_t VirtualSerial_CDC_Interface =
|
|||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
|
||||
RingBuffer_InitBuffer(&Tx_Buffer);
|
||||
|
||||
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
|
@ -98,9 +98,9 @@ int main(void)
|
|||
UDR1 = ReceivedByte;
|
||||
|
||||
LEDs_TurnOnLEDs(LEDMASK_TX);
|
||||
PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS;
|
||||
PulseMSRemaining.TxLEDPulse = TX_RX_LED_PULSE_MS;
|
||||
}
|
||||
|
||||
|
||||
/* Check if the millisecond timer has elapsed */
|
||||
if (TIFR0 & (1 << OCF0A))
|
||||
{
|
||||
|
@ -110,14 +110,14 @@ int main(void)
|
|||
LEDs_TurnOffLEDs(LEDMASK_BUSY);
|
||||
AVR_RESET_LINE_DDR &= ~AVR_RESET_LINE_MASK;
|
||||
}
|
||||
|
||||
|
||||
/* Check if the LEDs should be ping-ponging (during enumeration) */
|
||||
if (PulseMSRemaining.PingPongLEDPulse && !(--PulseMSRemaining.PingPongLEDPulse))
|
||||
{
|
||||
LEDs_ToggleLEDs(LEDMASK_TX | LEDMASK_RX);
|
||||
PulseMSRemaining.PingPongLEDPulse = PING_PONG_LED_PULSE_MS;
|
||||
}
|
||||
|
||||
|
||||
/* Turn off TX LED(s) once the TX pulse period has elapsed */
|
||||
if (PulseMSRemaining.TxLEDPulse && !(--PulseMSRemaining.TxLEDPulse))
|
||||
LEDs_TurnOffLEDs(LEDMASK_TX);
|
||||
|
@ -139,14 +139,14 @@ int main(void)
|
|||
LEDs_TurnOnLEDs(LEDMASK_RX);
|
||||
PulseMSRemaining.RxLEDPulse = TX_RX_LED_PULSE_MS;
|
||||
}
|
||||
|
||||
|
||||
FlushPeriodRemaining = RECEIVE_BUFFER_FLUSH_MS;
|
||||
}
|
||||
|
||||
/* Clear the millisecond timer CTC flag (cleared by writing logic one to the register) */
|
||||
TIFR0 |= (1 << OCF0A);
|
||||
TIFR0 |= (1 << OCF0A);
|
||||
}
|
||||
|
||||
|
||||
CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
|
||||
USB_USBTask();
|
||||
}
|
||||
|
@ -167,7 +167,7 @@ void SetupHardware(void)
|
|||
OCR0A = (F_CPU / 64 / 1000);
|
||||
TCCR0A = (1 << WGM01);
|
||||
TCCR0B = ((1 << CS01) | (1 << CS00));
|
||||
|
||||
|
||||
/* Tristate target /RESET Line */
|
||||
AVR_RESET_LINE_PORT &= ~AVR_RESET_LINE_MASK;
|
||||
AVR_RESET_LINE_DDR &= ~AVR_RESET_LINE_MASK;
|
||||
|
@ -216,10 +216,10 @@ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCI
|
|||
switch (CDCInterfaceInfo->State.LineEncoding.ParityType)
|
||||
{
|
||||
case CDC_PARITY_Odd:
|
||||
ConfigMask = ((1 << UPM11) | (1 << UPM10));
|
||||
ConfigMask = ((1 << UPM11) | (1 << UPM10));
|
||||
break;
|
||||
case CDC_PARITY_Even:
|
||||
ConfigMask = (1 << UPM11);
|
||||
ConfigMask = (1 << UPM11);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -238,7 +238,7 @@ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCI
|
|||
ConfigMask |= ((1 << UCSZ11) | (1 << UCSZ10));
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/* Must turn off USART before reconfiguring it, otherwise incorrect operation may occur */
|
||||
UCSR1B = 0;
|
||||
UCSR1A = 0;
|
||||
|
@ -246,10 +246,10 @@ void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCI
|
|||
|
||||
/* Set the new baud rate before configuring the USART */
|
||||
UBRR1 = SERIAL_2X_UBBRVAL(CDCInterfaceInfo->State.LineEncoding.BaudRateBPS);
|
||||
|
||||
|
||||
/* Reconfigure the USART in double speed mode for a wider baud rate range at the expense of accuracy */
|
||||
UCSR1C = ConfigMask;
|
||||
UCSR1A = (1 << U2X1);
|
||||
UCSR1A = (1 << U2X1);
|
||||
UCSR1B = ((1 << RXCIE1) | (1 << TXEN1) | (1 << RXEN1));
|
||||
}
|
||||
|
||||
|
@ -276,10 +276,11 @@ void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const C
|
|||
if (!(PreviousDTRState) && CurrentDTRState)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_BUSY);
|
||||
|
||||
|
||||
AVR_RESET_LINE_DDR |= AVR_RESET_LINE_MASK;
|
||||
PulseMSRemaining.ResetPulse = AVR_RESET_PULSE_MS;
|
||||
}
|
||||
|
||||
|
||||
PreviousDTRState = CurrentDTRState;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -56,10 +56,10 @@
|
|||
|
||||
/** LED mask for the library LED driver, to indicate RX activity. */
|
||||
#define LEDMASK_RX LEDS_LED2
|
||||
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_ERROR (LEDS_LED1 | LEDS_LED2)
|
||||
|
||||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_BUSY (LEDS_LED1 | LEDS_LED2)
|
||||
|
||||
|
@ -70,8 +70,9 @@
|
|||
void EVENT_USB_Device_Disconnect(void);
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
|
||||
|
||||
void EVENT_CDC_Device_LineEncodingChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
|
||||
void EVENT_CDC_Device_ControLineStateChanged(USB_ClassInfo_CDC_Device_t* const CDCInterfaceInfo);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Benito Arduino Programmer Project
|
||||
*
|
||||
* \section SSec_Compat Project Compatibility:
|
||||
|
@ -28,7 +28,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Communications Device Class (CDC)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Abstract Control Model (ACM)</td>
|
||||
* </tr>
|
||||
|
@ -43,7 +43,7 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Firmware for a USB AVR powered programmer for Arduino boards using the official Arduino bootloader. This
|
||||
* project acts like a regular USB to Serial bridge, except that asserting the DTR line will cause a pulse
|
||||
|
@ -103,3 +103,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -30,9 +30,9 @@
|
|||
|
||||
/** \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
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
@ -45,22 +45,22 @@
|
|||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x02,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2060,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
@ -71,102 +71,102 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 2,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.CDC_CCI_Interface =
|
||||
|
||||
.CDC_CCI_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
|
||||
.Class = 0x02,
|
||||
.SubClass = 0x02,
|
||||
.Protocol = 0x01,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.CDC_Functional_Header =
|
||||
.CDC_Functional_Header =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
||||
|
||||
|
||||
.CDCSpecification = VERSION_BCD(01.10),
|
||||
},
|
||||
|
||||
.CDC_Functional_ACM =
|
||||
.CDC_Functional_ACM =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
||||
|
||||
|
||||
.Capabilities = 0x06,
|
||||
},
|
||||
|
||||
.CDC_Functional_Union =
|
||||
|
||||
.CDC_Functional_Union =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
||||
|
||||
|
||||
.MasterInterfaceNumber = 0,
|
||||
.SlaveInterfaceNumber = 1,
|
||||
},
|
||||
|
||||
.CDC_NotificationEndpoint =
|
||||
.CDC_NotificationEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||
.PollingIntervalMS = 0xFF
|
||||
},
|
||||
|
||||
.CDC_DCI_Interface =
|
||||
.CDC_DCI_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 1,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
|
||||
.Class = 0x0A,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.CDC_DataOutEndpoint =
|
||||
.CDC_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
.PollingIntervalMS = 0x00
|
||||
},
|
||||
|
||||
.CDC_DataInEndpoint =
|
||||
|
||||
.CDC_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
|
@ -181,7 +181,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
|
@ -192,7 +192,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
|||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
|
@ -203,7 +203,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(25), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Benito Arduino Programmer"
|
||||
};
|
||||
|
||||
|
@ -225,34 +225,35 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
|
@ -47,10 +47,10 @@
|
|||
#define CDC_NOTIFICATION_EPNUM 2
|
||||
|
||||
/** Endpoint number of the CDC device-to-host data IN endpoint. */
|
||||
#define CDC_TX_EPNUM 3
|
||||
#define CDC_TX_EPNUM 3
|
||||
|
||||
/** Endpoint number of the CDC host-to-device data OUT endpoint. */
|
||||
#define CDC_RX_EPNUM 4
|
||||
#define CDC_RX_EPNUM 4
|
||||
|
||||
/** Size in bytes of the CDC device-to-host notification IN endpoint. */
|
||||
#define CDC_NOTIFICATION_EPSIZE 8
|
||||
|
@ -83,3 +83,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -39,20 +39,20 @@
|
|||
* or deletions) must not overlap. If there is possibility of two or more of the same kind of
|
||||
* operating occuring at the same point in time, atomic (mutex) locking should be used.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _ULW_RING_BUFF_H_
|
||||
#define _ULW_RING_BUFF_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <util/atomic.h>
|
||||
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Defines: */
|
||||
/** Size of each ring buffer, in data elements - must be between 1 and 255. */
|
||||
#define BUFFER_SIZE 255
|
||||
|
||||
|
||||
/** Type of data to store into the buffer. */
|
||||
#define RingBuff_Data_t uint8_t
|
||||
|
||||
|
@ -76,7 +76,7 @@
|
|||
RingBuff_Data_t* Out; /**< Current retrieval location in the circular buffer */
|
||||
RingBuff_Count_t Count;
|
||||
} RingBuff_t;
|
||||
|
||||
|
||||
/* Inline Functions: */
|
||||
/** Initializes a ring buffer ready for use. Buffers must be initialized via this function
|
||||
* before any operations are called upon them. Already initialized buffers may be reset
|
||||
|
@ -92,7 +92,7 @@
|
|||
Buffer->Out = Buffer->Buffer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/** Retrieves the minimum number of bytes stored in a particular buffer. This value is computed
|
||||
* by entering an atomic lock on the buffer while the IN and OUT locations are fetched, so that
|
||||
* the buffer cannot be modified while the computation takes place. This value should be cached
|
||||
|
@ -109,15 +109,15 @@
|
|||
static inline RingBuff_Count_t RingBuffer_GetCount(RingBuff_t* const Buffer)
|
||||
{
|
||||
RingBuff_Count_t Count;
|
||||
|
||||
|
||||
ATOMIC_BLOCK(ATOMIC_RESTORESTATE)
|
||||
{
|
||||
Count = Buffer->Count;
|
||||
}
|
||||
|
||||
|
||||
return Count;
|
||||
}
|
||||
|
||||
|
||||
/** Atomically determines if the specified ring buffer contains any free space. This should
|
||||
* be tested before storing data to the buffer, to ensure that no data is lost due to a
|
||||
* buffer overrun.
|
||||
|
@ -125,7 +125,7 @@
|
|||
* \param[in,out] Buffer Pointer to a ring buffer structure to insert into
|
||||
*
|
||||
* \return Boolean true if the buffer contains no free space, false otherwise
|
||||
*/
|
||||
*/
|
||||
static inline bool RingBuffer_IsFull(RingBuff_t* const Buffer)
|
||||
{
|
||||
return (RingBuffer_GetCount(Buffer) == BUFFER_SIZE);
|
||||
|
@ -142,7 +142,7 @@
|
|||
* \param[in,out] Buffer Pointer to a ring buffer structure to insert into
|
||||
*
|
||||
* \return Boolean true if the buffer contains no free space, false otherwise
|
||||
*/
|
||||
*/
|
||||
static inline bool RingBuffer_IsEmpty(RingBuff_t* const Buffer)
|
||||
{
|
||||
return (RingBuffer_GetCount(Buffer) == 0);
|
||||
|
@ -161,7 +161,7 @@
|
|||
const RingBuff_Data_t Data)
|
||||
{
|
||||
*Buffer->In = Data;
|
||||
|
||||
|
||||
if (++Buffer->In == &Buffer->Buffer[BUFFER_SIZE])
|
||||
Buffer->In = Buffer->Buffer;
|
||||
|
||||
|
@ -184,7 +184,7 @@
|
|||
static inline RingBuff_Data_t RingBuffer_Remove(RingBuff_t* const Buffer)
|
||||
{
|
||||
RingBuff_Data_t Data = *Buffer->Out;
|
||||
|
||||
|
||||
if (++Buffer->Out == &Buffer->Buffer[BUFFER_SIZE])
|
||||
Buffer->Out = Buffer->Buffer;
|
||||
|
||||
|
@ -192,8 +192,9 @@
|
|||
{
|
||||
Buffer->Count--;
|
||||
}
|
||||
|
||||
|
||||
return Data;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = atmega32u2
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = BENITO
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -144,7 +144,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -157,7 +157,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -271,7 +271,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -284,7 +284,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -296,7 +296,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -308,7 +308,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -331,7 +331,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -365,7 +365,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -399,7 +399,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -428,7 +428,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -447,10 +447,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -515,11 +515,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -546,9 +546,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -646,14 +646,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -675,7 +675,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -719,3 +719,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -30,9 +30,9 @@
|
|||
|
||||
/** \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
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
@ -59,22 +59,22 @@
|
|||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0xEF,
|
||||
.SubClass = 0x02,
|
||||
.Protocol = 0x01,
|
||||
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2063,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
@ -85,38 +85,38 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = USB_CONFIG_ATTR_BUSPOWERED,
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.MS_Interface =
|
||||
.MS_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
|
||||
.Class = 0x08,
|
||||
.SubClass = 0x06,
|
||||
.Protocol = 0x50,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MS_DataInEndpoint =
|
||||
.MS_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
@ -126,7 +126,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
.PollingIntervalMS = 0x00
|
||||
},
|
||||
|
||||
.MS_DataOutEndpoint =
|
||||
.MS_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
@ -144,7 +144,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
|
@ -155,7 +155,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
|||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
|
@ -166,7 +166,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(26), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"LUFA Standalone Programmer"
|
||||
};
|
||||
|
||||
|
@ -188,36 +188,37 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
|
@ -60,15 +60,15 @@
|
|||
#define CDC_TXRX_EPSIZE 16
|
||||
|
||||
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
||||
#define MASS_STORAGE_IN_EPNUM 3
|
||||
#define MASS_STORAGE_IN_EPNUM 3
|
||||
|
||||
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
||||
#define MASS_STORAGE_OUT_EPNUM 4
|
||||
#define MASS_STORAGE_OUT_EPNUM 4
|
||||
|
||||
/** Size in bytes of the Mass Storage data endpoints. */
|
||||
#define MASS_STORAGE_IO_EPSIZE 64
|
||||
|
||||
/* Type Defines: */
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
|
@ -80,7 +80,7 @@
|
|||
USB_Descriptor_Endpoint_t MS_DataInEndpoint;
|
||||
USB_Descriptor_Endpoint_t MS_DataOutEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
|
@ -88,3 +88,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -93,11 +93,12 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
bool CommandSuccess;
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
|
||||
return CommandSuccess;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "StandaloneProgrammer.h"
|
||||
|
||||
|
@ -59,3 +59,4 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -41,7 +41,7 @@ USB_ClassInfo_MS_Host_t DiskHost_MS_Interface =
|
|||
{
|
||||
.DataINPipeNumber = 1,
|
||||
.DataINPipeDoubleBank = false,
|
||||
|
||||
|
||||
.DataOUTPipeNumber = 2,
|
||||
.DataOUTPipeDoubleBank = false,
|
||||
},
|
||||
|
@ -52,7 +52,7 @@ void DiskHost_USBTask(void)
|
|||
if (USB_HostState == HOST_STATE_Addressed)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ENUMERATING);
|
||||
|
||||
|
||||
uint16_t ConfigDescriptorSize;
|
||||
uint8_t ConfigDescriptorData[512];
|
||||
|
||||
|
@ -71,14 +71,14 @@ void DiskHost_USBTask(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (USB_Host_SetDeviceConfiguration(1) != HOST_SENDCONTROL_Successful)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
uint8_t MaxLUNIndex;
|
||||
if (MS_Host_GetMaxLUN(&DiskHost_MS_Interface, &MaxLUNIndex))
|
||||
{
|
||||
|
@ -86,17 +86,17 @@ void DiskHost_USBTask(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if (MS_Host_ResetMSInterface(&DiskHost_MS_Interface))
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
|
||||
/* Note: For the RequestSense call to work, the host state machine must be in the
|
||||
|
||||
/* Note: For the RequestSense call to work, the host state machine must be in the
|
||||
* Configured state, or the call will be aborted */
|
||||
SCSI_Request_Sense_Response_t SenseData;
|
||||
if (MS_Host_RequestSense(&DiskHost_MS_Interface, 0, &SenseData) != 0)
|
||||
|
@ -105,13 +105,13 @@ void DiskHost_USBTask(void)
|
|||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
pf_mount(&DiskFATState);
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
}
|
||||
|
||||
MS_Host_USBTask(&DiskHost_MS_Interface);
|
||||
MS_Host_USBTask(&DiskHost_MS_Interface);
|
||||
}
|
||||
|
||||
void EVENT_USB_Host_DeviceAttached(void)
|
||||
|
@ -125,3 +125,4 @@ void EVENT_USB_Host_DeviceUnattached(void)
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -38,7 +38,7 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
#include "Descriptors.h"
|
||||
#include "StandaloneProgrammer.h"
|
||||
|
||||
|
@ -54,9 +54,10 @@
|
|||
/* Function Prototypes: */
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
void DiskHost_USBTask(void);
|
||||
|
||||
|
||||
void EVENT_USB_Host_DeviceAttached(void);
|
||||
void EVENT_USB_Host_DeviceUnattached(void);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -78,7 +78,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -87,7 +87,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
{
|
||||
/* Clear the current endpoint bank */
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
|
||||
/* Wait until the host has sent another packet */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
|
@ -126,7 +126,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
|
||||
/* Send the Dataflash buffer write command */
|
||||
Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
}
|
||||
|
||||
/* Write one 16-byte chunk of data to the Dataflash */
|
||||
|
@ -146,7 +146,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
@ -155,9 +155,9 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -202,15 +202,15 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
|
||||
|
||||
/* Wait until endpoint is ready before continuing */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -219,12 +219,12 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
{
|
||||
/* Clear the endpoint bank to send its contents to the host */
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Wait until the endpoint is ready for more data */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Check if end of Dataflash page reached */
|
||||
if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
|
||||
{
|
||||
|
@ -234,7 +234,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||
|
||||
|
||||
/* Send the Dataflash main memory page read command */
|
||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||
|
@ -242,7 +242,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read one 16-byte chunk of data from the Dataflash */
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
|
@ -261,10 +261,10 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
|
||||
|
@ -272,11 +272,11 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
||||
|
||||
/* If the endpoint is full, send its contents to the host */
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
Endpoint_ClearIN();
|
||||
|
@ -316,11 +316,11 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
|||
/* Send the Dataflash buffer write command */
|
||||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, CurrDFPageByte);
|
||||
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -360,18 +360,18 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
|||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Write one 16-byte chunk of data to the Dataflash */
|
||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||
Dataflash_SendByte(*(BufferPtr++));
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
BytesInBlockDiv16++;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -417,7 +417,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -430,7 +430,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
|
||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||
|
||||
|
||||
/* Send the Dataflash main memory page read command */
|
||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||
|
@ -438,19 +438,19 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read one 16-byte chunk of data from the Dataflash */
|
||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||
*(BufferPtr++) = Dataflash_ReceiveByte();
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -465,7 +465,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
/* Select first Dataflash chip, send the read status register command */
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||
|
||||
|
||||
/* Check if sector protection is enabled */
|
||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||
{
|
||||
|
@ -477,12 +477,12 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
|
||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||
}
|
||||
|
||||
|
||||
/* Select second Dataflash chip (if present on selected board), send read status register command */
|
||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||
|
||||
|
||||
/* Check if sector protection is enabled */
|
||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||
{
|
||||
|
@ -495,7 +495,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Deselect current Dataflash chip */
|
||||
Dataflash_DeselectChip();
|
||||
}
|
||||
|
@ -529,7 +529,8 @@ bool DataflashManager_CheckDataflashOperation(void)
|
|||
if (ReturnByte != DF_MANUFACTURER_ATMEL)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,13 +32,13 @@
|
|||
*
|
||||
* Header file for DataflashManager.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DATAFLASH_MANAGER_H_
|
||||
#define _DATAFLASH_MANAGER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
#include "StandaloneProgrammer.h"
|
||||
#include "Descriptors.h"
|
||||
|
||||
|
@ -59,12 +59,12 @@
|
|||
* storage media (Dataflash) using a different native block size. Do not change this value.
|
||||
*/
|
||||
#define VIRTUAL_MEMORY_BLOCK_SIZE 512
|
||||
|
||||
|
||||
/** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not
|
||||
* change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.
|
||||
*/
|
||||
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
|
@ -84,3 +84,4 @@
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -34,3 +34,4 @@ AGREEMENTS
|
|||
REVISION HISTORY
|
||||
|
||||
Jun 15, 2010 R0.01a First release (Branched from FatFs R0.07b)
|
||||
|
||||
|
|
|
@ -34,3 +34,4 @@ BOOL assign_drives (int argc, char *argv[]);
|
|||
|
||||
#define _DISKIO
|
||||
#endif
|
||||
|
||||
|
|
|
@ -35,3 +35,4 @@ typedef enum { FALSE = 0, TRUE } BOOL;
|
|||
|
||||
#define _INTEGER
|
||||
#endif
|
||||
|
||||
|
|
|
@ -400,7 +400,7 @@ FRESULT follow_path ( /* FR_OK(0): successful, !=0: error code */
|
|||
}
|
||||
dj->sclust =
|
||||
#if _FS_FAT32
|
||||
((DWORD)LD_WORD(dir+DIR_FstClusHI) << 16) |
|
||||
((DWORD)LD_WORD(dir+DIR_FstClusHI) << 16) |
|
||||
#endif
|
||||
LD_WORD(dir+DIR_FstClusLO);
|
||||
}
|
||||
|
|
|
@ -235,3 +235,4 @@ FRESULT pf_readdir (DIR*, FILINFO*); /* Read a directory item */
|
|||
|
||||
|
||||
#endif /* _FATFS */
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -34,7 +34,7 @@ struct
|
|||
{
|
||||
uint16_t SigBytes[4];
|
||||
bool EnforceSigBytes;
|
||||
|
||||
|
||||
uint32_t ProgrammingSpeed;
|
||||
} ProgrammerConfig;
|
||||
|
||||
|
@ -47,14 +47,14 @@ bool ProgrammerConfig_ProcessConfiguration(void)
|
|||
puts(" >> ERROR: CONF.txt File Not Found.\r\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
char LineBuff[100];
|
||||
char* CurrentLine;
|
||||
|
||||
|
||||
do
|
||||
{
|
||||
CurrentLine = fgets(LineBuff, sizeof(LineBuff), &DiskStream);
|
||||
|
||||
|
||||
if (CurrentLine)
|
||||
{
|
||||
sscanf(CurrentLine, "SIGNATURE = %02x %02x %02x %02x", &ProgrammerConfig.SigBytes[0],
|
||||
|
@ -65,13 +65,14 @@ bool ProgrammerConfig_ProcessConfiguration(void)
|
|||
sscanf(CurrentLine, "SPEED = %lu", &ProgrammerConfig.ProgrammingSpeed);
|
||||
}
|
||||
} while (CurrentLine);
|
||||
|
||||
|
||||
printf(" >> *** Configuration: ***\r\n");
|
||||
printf(" >> Device Signature: 0x%02x 0x%02x 0x%02x 0x%02x\r\n", ProgrammerConfig.SigBytes[0],
|
||||
ProgrammerConfig.SigBytes[1],
|
||||
ProgrammerConfig.SigBytes[2],
|
||||
ProgrammerConfig.SigBytes[3]);
|
||||
printf(" >> Programming Speed: %lu Hz\r\n", ProgrammerConfig.ProgrammingSpeed);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -35,10 +35,11 @@
|
|||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#include "../StandaloneProgrammer.h"
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool ProgrammerConfig_ProcessConfiguration(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -34,7 +34,7 @@
|
|||
* devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information,
|
||||
* which wrap around standard SCSI device commands for controlling the actual storage medium.
|
||||
*/
|
||||
|
||||
|
||||
#define INCLUDE_FROM_SCSI_C
|
||||
#include "SCSI.h"
|
||||
|
||||
|
@ -42,22 +42,22 @@
|
|||
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
||||
* features and capabilities.
|
||||
*/
|
||||
SCSI_Inquiry_Response_t InquiryData =
|
||||
SCSI_Inquiry_Response_t InquiryData =
|
||||
{
|
||||
.DeviceType = DEVICE_TYPE_BLOCK,
|
||||
.PeripheralQualifier = 0,
|
||||
|
||||
|
||||
.Removable = true,
|
||||
|
||||
|
||||
.Version = 0,
|
||||
|
||||
|
||||
.ResponseDataFormat = 2,
|
||||
.NormACA = false,
|
||||
.TrmTsk = false,
|
||||
.AERC = false,
|
||||
|
||||
.AdditionalLength = 0x1F,
|
||||
|
||||
|
||||
.SoftReset = false,
|
||||
.CmdQue = false,
|
||||
.Linked = false,
|
||||
|
@ -65,7 +65,7 @@ SCSI_Inquiry_Response_t InquiryData =
|
|||
.WideBus16Bit = false,
|
||||
.WideBus32Bit = false,
|
||||
.RelAddr = false,
|
||||
|
||||
|
||||
.VendorID = "LUFA",
|
||||
.ProductID = "Dataflash Disk",
|
||||
.RevisionID = {'0','.','0','0'},
|
||||
|
@ -97,13 +97,13 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
|||
switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
|
||||
{
|
||||
case SCSI_CMD_INQUIRY:
|
||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_REQUEST_SENSE:
|
||||
CommandSuccess = SCSI_Command_Request_Sense(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_READ_CAPACITY_10:
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
||||
|
@ -135,7 +135,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
|||
SCSI_SET_SENSE(SCSI_SENSE_KEY_GOOD,
|
||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -166,11 +166,11 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
|
||||
/* Pad out remaining bytes with 0x00 */
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
|
||||
|
@ -179,7 +179,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -194,7 +194,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
|||
{
|
||||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
@ -222,10 +222,10 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
|||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -249,21 +249,21 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Check to see if all attached Dataflash ICs are functional */
|
||||
if (!(DataflashManager_CheckDataflashOperation()))
|
||||
{
|
||||
/* Update SENSE key with a hardware error condition and return command fail */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -281,13 +281,13 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
{
|
||||
uint32_t BlockAddress;
|
||||
uint16_t TotalBlocks;
|
||||
|
||||
|
||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
||||
|
||||
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
||||
|
||||
|
||||
/* Check if the block address is outside the maximum allowable value for the LUN */
|
||||
if (BlockAddress >= VIRTUAL_MEMORY_BLOCKS)
|
||||
{
|
||||
|
@ -298,7 +298,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||
if (IsDataRead == DATA_READ)
|
||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||
|
@ -307,7 +307,8 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
|
||||
/* Update the bytes transferred counter and succeed the command */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* Header file for SCSI.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SCSI_H_
|
||||
#define _SCSI_H_
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
#include "StandaloneProgrammer.h"
|
||||
#include "Descriptors.h"
|
||||
#include "DataflashManager.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
||||
* is for convenience, as it allows for all three sense values (returned upon request to the host to give information about
|
||||
|
@ -68,14 +68,14 @@
|
|||
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
||||
#define DEVICE_TYPE_BLOCK 0x00
|
||||
|
||||
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
||||
#define DEVICE_TYPE_CDROM 0x05
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(USB_CAN_BE_DEVICE)
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_SCSI_C)
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
@ -85,5 +85,6 @@
|
|||
const bool IsDataRead);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -67,7 +67,7 @@ void EVENT_USB_UIDChange(void)
|
|||
}
|
||||
#endif
|
||||
|
||||
/** Task to determine if the user is wishes to start the programming sequence, and if so executes the
|
||||
/** Task to determine if the user is wishes to start the programming sequence, and if so executes the
|
||||
* required functions to program the attached target (if any) with the files loaded to the Dataflash.
|
||||
*/
|
||||
void Programmer_Task(void)
|
||||
|
@ -80,7 +80,7 @@ void Programmer_Task(void)
|
|||
HasAttempted = true;
|
||||
else
|
||||
return;
|
||||
|
||||
|
||||
puts("==== PROGRAMMING CYCLE STARTED ====\r\n");
|
||||
|
||||
#if defined(USB_CAN_BE_BOTH)
|
||||
|
@ -113,7 +113,7 @@ int main(void)
|
|||
for (;;)
|
||||
{
|
||||
Programmer_Task();
|
||||
|
||||
|
||||
if (USB_CurrentMode == USB_MODE_HOST)
|
||||
{
|
||||
#if defined(USB_CAN_BE_HOST)
|
||||
|
@ -126,7 +126,7 @@ int main(void)
|
|||
DiskDevice_USBTask();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
USB_USBTask();
|
||||
}
|
||||
}
|
||||
|
@ -159,3 +159,4 @@ void SetupHardware(void)
|
|||
DataflashManager_ResetDataflashProtections();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -70,19 +70,20 @@
|
|||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
|
||||
/* External Variables: */
|
||||
extern FILE DiskStream;
|
||||
extern FATFS DiskFATState;
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
#if defined(INCLUDE_FROM_STANDALONEPROG_C)
|
||||
static int Disk_getchar(FILE* Stream);
|
||||
#endif
|
||||
|
||||
|
||||
void EVENT_USB_UIDChange(void);
|
||||
|
||||
|
||||
void SetupHardware(void);
|
||||
void Programmer_Task(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -144,7 +144,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -157,7 +157,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -271,7 +271,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -284,7 +284,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -296,7 +296,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -308,7 +308,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -331,7 +331,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -365,7 +365,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -399,7 +399,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -428,7 +428,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -447,10 +447,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -515,11 +515,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -546,9 +546,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -646,14 +646,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -675,7 +675,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -719,3 +719,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -30,9 +30,9 @@
|
|||
|
||||
/** \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
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
@ -83,102 +83,102 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 2,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.CDC_CCI_Interface =
|
||||
|
||||
.CDC_CCI_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
|
||||
.Class = 0x02,
|
||||
.SubClass = 0x02,
|
||||
.Protocol = 0x01,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.CDC_Functional_Header =
|
||||
.CDC_Functional_Header =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
||||
|
||||
|
||||
.CDCSpecification = VERSION_BCD(01.10),
|
||||
},
|
||||
|
||||
.CDC_Functional_ACM =
|
||||
.CDC_Functional_ACM =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
||||
|
||||
|
||||
.Capabilities = 0x06,
|
||||
},
|
||||
|
||||
.CDC_Functional_Union =
|
||||
|
||||
.CDC_Functional_Union =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
||||
|
||||
|
||||
.MasterInterfaceNumber = 0,
|
||||
.SlaveInterfaceNumber = 1,
|
||||
},
|
||||
|
||||
.CDC_NotificationEndpoint =
|
||||
.CDC_NotificationEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||
.PollingIntervalMS = 0xFF
|
||||
},
|
||||
|
||||
.CDC_DCI_Interface =
|
||||
.CDC_DCI_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 1,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
|
||||
.Class = 0x0A,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.CDC_DataOutEndpoint =
|
||||
.CDC_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
.PollingIntervalMS = 0x00
|
||||
},
|
||||
|
||||
.CDC_DataInEndpoint =
|
||||
|
||||
.CDC_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
|
@ -241,30 +241,31 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* Header file for Descriptors.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
|
@ -83,3 +83,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -33,7 +33,7 @@
|
|||
* Main source file for the LEDNotfier project. This file contains the main tasks of
|
||||
* the demo and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "LEDNotifier.h"
|
||||
|
||||
/** LUFA CDC Class driver interface configuration and state information. This structure is
|
||||
|
@ -89,7 +89,7 @@ ISR(TIMER0_COMPA_vect, ISR_BLOCK)
|
|||
|
||||
if (SoftPWM_Count >= SoftPWM_Channel3_Duty)
|
||||
LEDMask &= ~LEDS_LED3;
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
|
@ -104,24 +104,24 @@ static FILE USBSerialStream;
|
|||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
|
||||
/* Create a regular blocking character stream for the interface so that it can be used with the stdio.h functions */
|
||||
CDC_Device_CreateBlockingStream(&VirtualSerial_CDC_Interface, &USBSerialStream);
|
||||
|
||||
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
{
|
||||
/* Read in next LED colour command from the host */
|
||||
uint8_t ColourUpdate = fgetc(&USBSerialStream);
|
||||
|
||||
|
||||
/* Top 3 bits select the LED, bottom 5 control the brightness */
|
||||
uint8_t Channel = (ColourUpdate & 0b11100000);
|
||||
uint8_t Duty = (ColourUpdate & 0b00011111);
|
||||
|
||||
|
||||
if (Channel & (1 << 5))
|
||||
SoftPWM_Channel1_Duty = Duty;
|
||||
|
||||
|
||||
if (Channel & (1 << 6))
|
||||
SoftPWM_Channel2_Duty = Duty;
|
||||
|
||||
|
@ -146,7 +146,7 @@ void SetupHardware(void)
|
|||
/* Hardware Initialization */
|
||||
LEDs_Init();
|
||||
USB_Init();
|
||||
|
||||
|
||||
/* Timer Initialization */
|
||||
OCR0A = 100;
|
||||
TCCR0A = (1 << WGM01);
|
||||
|
@ -165,3 +165,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
{
|
||||
CDC_Device_ProcessControlRequest(&VirtualSerial_CDC_Interface);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -50,11 +50,12 @@
|
|||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/CDC.h>
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage USB LED Notifier Project
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Communications Device Class (CDC)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Abstract Control Model (ACM)</td>
|
||||
* </tr>
|
||||
|
@ -39,7 +39,7 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* USB LED Notifier Project. This project is designed for the Busware BUI board, however it can run easily on any
|
||||
* USB AVR. It is a generic RGB LED controller (via a three channel software PWM) which listens for commands from the
|
||||
|
@ -60,3 +60,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = BUI
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -148,7 +148,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -506,11 +506,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -10,13 +10,13 @@
|
|||
Copyright 2010 Denver Gingerich (denver [at] ossguy [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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -31,11 +31,11 @@
|
|||
|
||||
/** \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
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
/** HID report descriptor. This is a HID class specific descriptor, which defines the structure of the
|
||||
|
@ -79,22 +79,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM KeyboardReport[] =
|
|||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x00,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2042,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
@ -105,49 +105,49 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 1,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.HID_Interface =
|
||||
|
||||
.HID_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0x00,
|
||||
.AlternateSetting = 0x00,
|
||||
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
|
||||
.Class = 0x03,
|
||||
.SubClass = 0x01,
|
||||
.Protocol = 0x01,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.HID_KeyboardHID =
|
||||
{
|
||||
.HID_KeyboardHID =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||
|
||||
|
||||
.HIDSpec = VERSION_BCD(01.11),
|
||||
.CountryCode = 0x00,
|
||||
.TotalReportDescriptors = 1,
|
||||
.HIDReportType = HID_DTYPE_Report,
|
||||
.HIDReportLength = sizeof(KeyboardReport)
|
||||
},
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
@ -160,11 +160,11 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
* the string descriptor with index 0 (the first index). It is actually an array of 16-bit integers, which indicate
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors. */
|
||||
* via the language ID table available at USB.org what languages the device supports for its string descriptors. */
|
||||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
|
@ -175,7 +175,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
|||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(32), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Dean Camera and Denver Gingerich"
|
||||
};
|
||||
|
||||
|
@ -186,7 +186,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(20), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Magnetic Card Reader"
|
||||
};
|
||||
|
||||
|
@ -232,7 +232,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case HID_DTYPE_HID:
|
||||
Address = &ConfigurationDescriptor.HID_KeyboardHID;
|
||||
|
@ -243,7 +243,8 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
Size = sizeof(KeyboardReport);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -10,13 +10,13 @@
|
|||
Copyright 2010 Denver Gingerich (denver [at] ossguy [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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -55,11 +55,11 @@
|
|||
USB_HID_Descriptor_HID_t HID_KeyboardHID; /**< Keyboard HID descriptor */
|
||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint; /**< Keyboard key report endpoint descriptor */
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the keyboard key press reporting endpoint. */
|
||||
#define KEYBOARD_EPNUM 1
|
||||
|
||||
|
||||
/** Size of the keyboard report endpoints, in bytes. */
|
||||
#define KEYBOARD_EPSIZE 8
|
||||
|
||||
|
@ -70,3 +70,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -10,13 +10,13 @@
|
|||
Copyright 2010 Denver Gingerich (denver [at] ossguy [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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -41,7 +41,7 @@ void BitBuffer_Init(BitBuffer_t* const Buffer)
|
|||
{
|
||||
/* Reset the number of stored bits in the buffer */
|
||||
Buffer->Elements = 0;
|
||||
|
||||
|
||||
/* Reset the data in and out pointer structures in the buffer to the first buffer bit */
|
||||
Buffer->In.CurrentByte = Buffer->Data;
|
||||
Buffer->In.ByteMask = (1 << 0);
|
||||
|
@ -56,10 +56,10 @@ void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer,
|
|||
/* If the bit to store is true, set the next bit in the buffer */
|
||||
if (Bit)
|
||||
*Buffer->In.CurrentByte |= Buffer->In.ByteMask;
|
||||
|
||||
|
||||
/* Increment the number of stored bits in the buffer counter */
|
||||
Buffer->Elements++;
|
||||
|
||||
|
||||
/* Check if the current buffer byte is full of stored bits */
|
||||
if (Buffer->In.ByteMask == (1 << 7))
|
||||
{
|
||||
|
@ -68,8 +68,8 @@ void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer,
|
|||
Buffer->In.CurrentByte++;
|
||||
else
|
||||
Buffer->In.CurrentByte = Buffer->Data;
|
||||
|
||||
/* Reset the storage bit mask in the current buffer byte to the first bit */
|
||||
|
||||
/* Reset the storage bit mask in the current buffer byte to the first bit */
|
||||
Buffer->In.ByteMask = (1 << 0);
|
||||
}
|
||||
else
|
||||
|
@ -81,7 +81,7 @@ void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer,
|
|||
|
||||
/** Function to retrieve the next bit stored in the given bit buffer. */
|
||||
bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer)
|
||||
{
|
||||
{
|
||||
/* Retrieve the value of the next bit stored in the buffer */
|
||||
bool Bit = ((*Buffer->Out.CurrentByte & Buffer->Out.ByteMask) != 0);
|
||||
|
||||
|
@ -90,17 +90,17 @@ bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer)
|
|||
|
||||
/* Decrement the number of stored bits in the buffer counter */
|
||||
Buffer->Elements--;
|
||||
|
||||
/* Check if the current buffer byte is empty of stored bits */
|
||||
|
||||
/* Check if the current buffer byte is empty of stored bits */
|
||||
if (Buffer->Out.ByteMask == (1 << 7))
|
||||
{
|
||||
/* Check if the end of the buffer has been reached, if so reset to start of buffer, otherwise advance to next bit */
|
||||
if (Buffer->Out.CurrentByte != &Buffer->Data[sizeof(Buffer->Data) - 1])
|
||||
Buffer->Out.CurrentByte++;
|
||||
else
|
||||
Buffer->Out.CurrentByte = Buffer->Data;
|
||||
|
||||
/* Reset the retrieval bit mask in the current buffer byte to the first bit */
|
||||
Buffer->Out.CurrentByte = Buffer->Data;
|
||||
|
||||
/* Reset the retrieval bit mask in the current buffer byte to the first bit */
|
||||
Buffer->Out.ByteMask = (1 << 0);
|
||||
}
|
||||
else
|
||||
|
@ -112,3 +112,4 @@ bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer)
|
|||
/* Return the retrieved bit from the buffer */
|
||||
return Bit;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -10,13 +10,13 @@
|
|||
Copyright 2010 Denver Gingerich (denver [at] ossguy [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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -40,7 +40,7 @@
|
|||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
|
||||
#include <LUFA/Common/Common.h>
|
||||
|
||||
/* Macros: */
|
||||
|
@ -51,7 +51,7 @@
|
|||
#else
|
||||
#define MAX_BITS 1024
|
||||
#endif
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for a pointer to a bit in a bit buffer. */
|
||||
typedef struct
|
||||
|
@ -65,18 +65,18 @@
|
|||
{
|
||||
uint8_t Data[MAX_BITS / 8]; /**< Buffer to hold the stored bits in packed form */
|
||||
uint16_t Elements; /**< Number of stored bits in the bit buffer */
|
||||
|
||||
|
||||
BitBufferPointer_t In; /**< Bit pointer to the next storage location in the buffer */
|
||||
BitBufferPointer_t Out; /**< Bit pointer to the next retrieval location in the buffer */
|
||||
} BitBuffer_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
|
||||
/* Function Prototypes: */
|
||||
/** Initialises or resets a given bit buffer, ready to store new bits.
|
||||
*
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to initialize
|
||||
*/
|
||||
void BitBuffer_Init(BitBuffer_t* const Buffer) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
|
||||
/** Stores a bit into the next location inside a given bit buffer.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to store a bit into
|
||||
|
@ -84,7 +84,7 @@
|
|||
*/
|
||||
void BitBuffer_StoreNextBit(BitBuffer_t* const Buffer,
|
||||
const bool Bit) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
|
||||
/** Retrieves a bit from the next location inside a given bit buffer.
|
||||
*
|
||||
* \param[in,out] Buffer Bit buffer to store a bit into
|
||||
|
@ -92,5 +92,6 @@
|
|||
* \return Next bit from the buffer
|
||||
*/
|
||||
bool BitBuffer_GetNextBit(BitBuffer_t* const Buffer) ATTR_NON_NULL_PTR_ARG(1);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,13 +2,13 @@
|
|||
Copyright 2010 Denver Gingerich (denver [at] ossguy [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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -98,3 +98,4 @@
|
|||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -10,13 +10,13 @@
|
|||
Copyright 2010 Denver Gingerich (denver [at] ossguy [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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -28,13 +28,13 @@
|
|||
arising out of or in connection with the use or performance of
|
||||
this software.
|
||||
*/
|
||||
|
||||
|
||||
/** \file
|
||||
*
|
||||
* Main source file for the MagStripe reader program. This file contains the main tasks of
|
||||
* the project and is responsible for the initial application hardware configuration.
|
||||
*/
|
||||
|
||||
|
||||
#include "Magstripe.h"
|
||||
|
||||
/** Bit buffers to hold the read bits for each of the three magnetic card tracks before they are transmitted
|
||||
|
@ -73,10 +73,10 @@ USB_ClassInfo_HID_Device_t Keyboard_HID_Interface =
|
|||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
|
||||
for (uint8_t Buffer = 0; Buffer < TOTAL_TRACKS; Buffer++)
|
||||
BitBuffer_Init(&TrackDataBuffers[Buffer]);
|
||||
|
||||
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
|
@ -113,7 +113,7 @@ void ReadMagstripeData(void)
|
|||
const struct
|
||||
{
|
||||
uint8_t ClockMask;
|
||||
uint8_t DataMask;
|
||||
uint8_t DataMask;
|
||||
} TrackInfo[] = {{MAG_T1_CLOCK, MAG_T1_DATA},
|
||||
{MAG_T2_CLOCK, MAG_T2_DATA},
|
||||
{MAG_T3_CLOCK, MAG_T3_DATA}};
|
||||
|
@ -128,7 +128,7 @@ void ReadMagstripeData(void)
|
|||
bool DataPinLevel = ((Magstripe_LCL & TrackInfo[Track].DataMask) != 0);
|
||||
bool ClockPinLevel = ((Magstripe_LCL & TrackInfo[Track].ClockMask) != 0);
|
||||
bool ClockLevelChanged = (((Magstripe_LCL ^ Magstripe_Prev) & TrackInfo[Track].ClockMask) != 0);
|
||||
|
||||
|
||||
/* Sample data on rising clock edges from the card reader */
|
||||
if (ClockPinLevel && ClockLevelChanged)
|
||||
BitBuffer_StoreNextBit(&TrackDataBuffers[Track], DataPinLevel);
|
||||
|
@ -137,7 +137,7 @@ void ReadMagstripeData(void)
|
|||
Magstripe_Prev = Magstripe_LCL;
|
||||
Magstripe_LCL = Magstripe_GetStatus();
|
||||
}
|
||||
|
||||
|
||||
CurrentTrackBuffer = &TrackDataBuffers[0];
|
||||
}
|
||||
|
||||
|
@ -200,7 +200,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
|||
/* Still data in the current track; convert next bit to a 1 or 0 keypress */
|
||||
KeyboardReport->KeyCode[0] = BitBuffer_GetNextBit(CurrentTrackBuffer) ? KEY_1 : KEY_0;
|
||||
}
|
||||
|
||||
|
||||
*ReportSize = sizeof(USB_KeyboardReport_Data_t);
|
||||
return false;
|
||||
}
|
||||
|
@ -221,3 +221,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
|||
{
|
||||
// Unused (but mandatory for the HID class driver) in this demo, since there are no Host->Device reports
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -10,13 +10,13 @@
|
|||
Copyright 2010 Denver Gingerich (denver [at] ossguy [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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -54,10 +54,10 @@
|
|||
/* Macros: */
|
||||
/** Total number of tracks which can be read from the card, between 1 and 3. */
|
||||
#define TOTAL_TRACKS 3
|
||||
|
||||
|
||||
/** HID keyboard keycode to indicate that no is currently pressed. */
|
||||
#define KEY_NONE 0
|
||||
|
||||
|
||||
/** HID keyboard keycode to indicate that the "1" key is currently pressed. */
|
||||
#define KEY_1 30
|
||||
|
||||
|
@ -66,11 +66,11 @@
|
|||
|
||||
/** HID keyboard keycode to indicate that the enter key is currently pressed. */
|
||||
#define KEY_ENTER 40
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
void ReadMagstripeData(void);
|
||||
|
||||
|
||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
void EVENT_USB_Device_StartOfFrame(void);
|
||||
|
@ -81,9 +81,10 @@
|
|||
void* ReportData,
|
||||
uint16_t* const ReportSize);
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
const uint8_t ReportID,
|
||||
const uint8_t ReportID,
|
||||
const uint8_t ReportType,
|
||||
const void* ReportData,
|
||||
const uint16_t ReportSize);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Denver Gingerich's USBSnoop Magnetic Card Reader Project
|
||||
*
|
||||
* \section SSec_Compat Project Compatibility:
|
||||
|
@ -26,7 +26,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>Keyboard</td>
|
||||
* </tr>
|
||||
|
@ -40,18 +40,18 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Firmware for a USB AVR powered USB TTL magnetic stripe reader (using a card
|
||||
* reader such as the Omron V3B-4K) by Denver Gingerich. This project is designed
|
||||
* to be used with the open source Stripe Snoop project at <a>http://stripesnoop.sourceforge.net/</a>.
|
||||
*
|
||||
*
|
||||
* See <a>http://ossguy.com/ss_usb/</a> for the USB reader hardware project website,
|
||||
* including construction and support details.
|
||||
*
|
||||
*
|
||||
* To use, connect your magnetic card reader device to the USB AVR as follows (pin and port mapping may be adjusted
|
||||
* from the project makefile):
|
||||
*
|
||||
*
|
||||
* <table>
|
||||
* <tr>
|
||||
* <td><b>Signal:</b></td>
|
||||
|
@ -162,3 +162,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = NONE
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 16000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -147,7 +147,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -160,7 +160,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -274,7 +274,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -287,7 +287,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -299,7 +299,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -311,7 +311,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -334,7 +334,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -368,7 +368,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -402,7 +402,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -431,7 +431,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -450,10 +450,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -518,11 +518,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -549,9 +549,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -649,14 +649,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -678,7 +678,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -722,3 +722,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -50,7 +50,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
uint8_t ConfigDescriptorData[512];
|
||||
void* CurrConfigLocation = ConfigDescriptorData;
|
||||
uint16_t CurrConfigBytesRem;
|
||||
|
||||
|
||||
USB_Descriptor_Interface_t* HIDInterface = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataINEndpoint = NULL;
|
||||
USB_Descriptor_Endpoint_t* DataOUTEndpoint = NULL;
|
||||
|
@ -79,7 +79,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
* but only found the mandatory IN endpoint, it's safe to continue with the device enumeration */
|
||||
if (DataINEndpoint)
|
||||
break;
|
||||
|
||||
|
||||
/* Get the next HID interface from the configuration descriptor */
|
||||
if (USB_GetNextDescriptorComp(&CurrConfigBytesRem, &CurrConfigLocation,
|
||||
DComp_NextHIDInterface) != DESCRIPTOR_SEARCH_COMP_Found)
|
||||
|
@ -87,7 +87,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
/* Descriptor not found, error out */
|
||||
return NoCompatibleInterfaceFound;
|
||||
}
|
||||
|
||||
|
||||
/* Save the interface in case we need to refer back to it later */
|
||||
HIDInterface = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Interface_t);
|
||||
|
||||
|
@ -97,7 +97,7 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
/* Skip the remainder of the loop as we have not found an endpoint yet */
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
/* Retrieve the endpoint address from the endpoint descriptor */
|
||||
USB_Descriptor_Endpoint_t* EndpointData = DESCRIPTOR_PCAST(CurrConfigLocation, USB_Descriptor_Endpoint_t);
|
||||
|
||||
|
@ -107,20 +107,20 @@ uint8_t ProcessConfigurationDescriptor(void)
|
|||
else
|
||||
DataOUTEndpoint = EndpointData;
|
||||
}
|
||||
|
||||
|
||||
/* Configure the HID data IN pipe */
|
||||
Pipe_ConfigurePipe(HID_DATA_IN_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_IN,
|
||||
DataINEndpoint->EndpointAddress, DataINEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
Pipe_SetInterruptPeriod(DataINEndpoint->PollingIntervalMS);
|
||||
|
||||
|
||||
/* Check if the HID interface contained an optional OUT data endpoint */
|
||||
if (DataOUTEndpoint)
|
||||
{
|
||||
/* Configure the HID data OUT pipe */
|
||||
Pipe_ConfigurePipe(HID_DATA_OUT_PIPE, EP_TYPE_INTERRUPT, PIPE_TOKEN_OUT,
|
||||
DataOUTEndpoint->EndpointAddress, DataOUTEndpoint->EndpointSize, PIPE_BANK_SINGLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* Valid data found, return success */
|
||||
return SuccessfulConfigRead;
|
||||
}
|
||||
|
@ -145,7 +145,7 @@ uint8_t DComp_NextHIDInterface(void* CurrentDescriptor)
|
|||
return DESCRIPTOR_SEARCH_Found;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
@ -176,3 +176,4 @@ uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor)
|
|||
/* Current descriptor does not match what this comparator is looking for */
|
||||
return DESCRIPTOR_SEARCH_NotFound;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -38,16 +38,16 @@
|
|||
|
||||
/* Includes: */
|
||||
#include <LUFA/Drivers/USB/USB.h>
|
||||
|
||||
|
||||
#include "MissileLauncher.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Interface Class value for the Human Interface Device class. */
|
||||
#define HID_CLASS 0x03
|
||||
|
||||
/** Pipe number for the HID data IN pipe. */
|
||||
#define HID_DATA_IN_PIPE 1
|
||||
|
||||
|
||||
/** Pipe number for the HID data OUT pipe. */
|
||||
#define HID_DATA_OUT_PIPE 2
|
||||
|
||||
|
@ -60,7 +60,7 @@
|
|||
DescriptorTooLarge = 2, /**< The device's Configuration Descriptor is too large to process */
|
||||
InvalidConfigDataReturned = 3, /**< The device returned an invalid Configuration Descriptor */
|
||||
NoCompatibleInterfaceFound = 4, /**< A compatible interface with the required endpoints was not found */
|
||||
};
|
||||
};
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint8_t ProcessConfigurationDescriptor(void);
|
||||
|
@ -69,3 +69,4 @@
|
|||
uint8_t DComp_NextHIDInterfaceDataEndpoint(void* CurrentDescriptor);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
USB Missile Launcher Demo
|
||||
Copyright (C) Dave Fletcher, 2010.
|
||||
fletch at fletchtronics dot net
|
||||
|
||||
|
||||
Based on research by Scott Weston at
|
||||
http://code.google.com/p/pymissile
|
||||
*/
|
||||
|
@ -11,13 +11,13 @@
|
|||
Copyright 2010 Dean Camera (dean [at] fourwalledcubicle [dot] com)
|
||||
Copyright 2010 Dave Fletcher (fletch [at] fletchtronics [dot] net)
|
||||
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
Permission to use, copy, modify, distribute, and sell this
|
||||
software and its documentation for any purpose is hereby granted
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -42,7 +42,7 @@
|
|||
* the application and is responsible for the initial application hardware configuration as well
|
||||
* as the sending of commands to the attached launcher toy.
|
||||
*/
|
||||
|
||||
|
||||
#include "MissileLauncher.h"
|
||||
|
||||
/** Launcher first init command report data sequence */
|
||||
|
@ -103,7 +103,7 @@ int main(void)
|
|||
for (;;)
|
||||
{
|
||||
Read_Joystick_Status();
|
||||
|
||||
|
||||
HID_Host_Task();
|
||||
USB_USBTask();
|
||||
}
|
||||
|
@ -173,7 +173,7 @@ void Send_Command(uint8_t* const Command)
|
|||
Send_Command_Report(CMD_INITB, 8);
|
||||
Send_Command_Report(Command, LAUNCHER_CMD_BUFFER_SIZE);
|
||||
}
|
||||
|
||||
|
||||
CmdState = Command;
|
||||
}
|
||||
|
||||
|
@ -231,13 +231,13 @@ void DiscardNextReport(void)
|
|||
{
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Clear the IN endpoint, ready for next data packet */
|
||||
Pipe_ClearIN();
|
||||
|
||||
|
||||
/* Refreeze HID data IN pipe */
|
||||
Pipe_Freeze();
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ void WriteNextReport(uint8_t* const ReportOUTData,
|
|||
{
|
||||
/* Select and unfreeze HID data OUT pipe */
|
||||
Pipe_SelectPipe(HID_DATA_OUT_PIPE);
|
||||
|
||||
|
||||
/* Not all HID devices have an OUT endpoint (some require OUT reports to be sent over the
|
||||
* control endpoint instead) - check to see if the OUT endpoint has been initialized */
|
||||
if (Pipe_IsConfigured())
|
||||
|
@ -264,13 +264,13 @@ void WriteNextReport(uint8_t* const ReportOUTData,
|
|||
{
|
||||
/* Refreeze the data OUT pipe */
|
||||
Pipe_Freeze();
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Write out HID report data */
|
||||
Pipe_Write_Stream_LE(ReportOUTData, ReportLength);
|
||||
|
||||
Pipe_Write_Stream_LE(ReportOUTData, ReportLength);
|
||||
|
||||
/* Clear the OUT endpoint, send last data packet */
|
||||
Pipe_ClearOUT();
|
||||
|
||||
|
@ -324,12 +324,12 @@ void HID_Host_Task(void)
|
|||
{
|
||||
/* Indicate error status */
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||
|
||||
|
||||
/* Wait until USB device disconnected */
|
||||
USB_HostState = HOST_STATE_WaitForDeviceRemoval;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
USB_HostState = HOST_STATE_Configured;
|
||||
break;
|
||||
case HOST_STATE_Configured:
|
||||
|
@ -338,3 +338,4 @@ void HID_Host_Task(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -50,9 +50,9 @@
|
|||
#include <LUFA/Drivers/Board/Buttons.h>
|
||||
#include <LUFA/Drivers/Board/Joystick.h>
|
||||
#include <LUFA/Drivers/Board/LEDs.h>
|
||||
|
||||
|
||||
#include "ConfigDescriptor.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** HID Class specific request to send a HID report to the device. */
|
||||
#define REQ_SetReport 0x09
|
||||
|
@ -68,10 +68,10 @@
|
|||
|
||||
/** LED mask for the library LED driver, to indicate that an error has occurred in the USB interface. */
|
||||
#define LEDMASK_USB_ERROR (LEDS_LED1 | LEDS_LED3)
|
||||
|
||||
|
||||
/** Size of the Launcher report command buffer. */
|
||||
#define LAUNCHER_CMD_BUFFER_SIZE 64
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
||||
|
@ -92,5 +92,6 @@
|
|||
void DiscardNextReport(void);
|
||||
void WriteNextReport(uint8_t* const ReportOUTData,
|
||||
const uint16_t ReportLength);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage David Fletcher's Missile Launcher
|
||||
*
|
||||
* \section SSec_Compat Project Compatibility:
|
||||
|
@ -25,7 +25,7 @@
|
|||
* <td><b>USB Class:</b></td>
|
||||
* <td>Human Interface Device (HID)</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclass:</b></td>
|
||||
* <td>N/A</td>
|
||||
* </tr>
|
||||
|
@ -39,7 +39,7 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Missile Launcher host. This is a host driver for the popular USB-controller table top toy missile launchers,
|
||||
* which can typically aim and fire small foam "missiles" from a spring-loaded turret. This project controls the
|
||||
|
@ -57,3 +57,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -132,7 +132,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -145,7 +145,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -259,7 +259,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -272,7 +272,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -284,7 +284,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -296,7 +296,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -319,7 +319,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -353,7 +353,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -387,7 +387,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -416,7 +416,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -435,10 +435,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -503,11 +503,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -534,9 +534,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -634,14 +634,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -663,7 +663,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -707,3 +707,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -200,3 +200,4 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,3 +58,4 @@
|
|||
const void** const DescriptorAddress)
|
||||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@
|
|||
int main(void)
|
||||
{
|
||||
SetupHardware();
|
||||
|
||||
|
||||
sei();
|
||||
|
||||
for (;;)
|
||||
|
@ -103,7 +103,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case 0x01:
|
||||
if (USB_ControlRequest.bmRequestType == (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE))
|
||||
|
@ -130,7 +130,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
ControlData[1] = (PORTC & RELAY4) ? 2 : 3;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (ControlData[1])
|
||||
Endpoint_Write_Control_Stream_LE(ControlData, sizeof(ControlData));
|
||||
|
||||
|
@ -140,3 +140,4 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -62,3 +62,4 @@
|
|||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -92,4 +92,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
*/
|
||||
*/
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -135,7 +135,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -148,7 +148,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -262,7 +262,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -275,7 +275,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -287,7 +287,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -299,7 +299,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -322,7 +322,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -356,7 +356,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -390,7 +390,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -419,7 +419,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -438,10 +438,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -506,11 +506,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -537,9 +537,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -637,14 +637,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -666,7 +666,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -710,3 +710,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -30,9 +30,9 @@
|
|||
|
||||
/** \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
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
@ -83,22 +83,22 @@ USB_Descriptor_HIDReport_Datatype_t PROGMEM GenericReport[] =
|
|||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x00,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x2063,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
@ -109,38 +109,38 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 2,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.MS_Interface =
|
||||
|
||||
.MS_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
|
||||
.Class = 0x08,
|
||||
.SubClass = 0x06,
|
||||
.Protocol = 0x50,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.MS_DataInEndpoint =
|
||||
.MS_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
@ -150,7 +150,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
.PollingIntervalMS = 0x00
|
||||
},
|
||||
|
||||
.MS_DataOutEndpoint =
|
||||
.MS_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
@ -159,27 +159,27 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
.EndpointSize = MASS_STORAGE_IO_EPSIZE,
|
||||
.PollingIntervalMS = 0x00
|
||||
},
|
||||
|
||||
.HID_Interface =
|
||||
|
||||
.HID_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 1,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
|
||||
.Class = 0x03,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = HID_BOOTP_NonBootProtocol,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.HID_GenericHID =
|
||||
.HID_GenericHID =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_HID_Descriptor_HID_t), .Type = HID_DTYPE_HID},
|
||||
|
||||
|
||||
.HIDSpec = VERSION_BCD(01.11),
|
||||
.CountryCode = 0x00,
|
||||
.TotalReportDescriptors = 1,
|
||||
|
@ -187,15 +187,15 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
.HIDReportLength = sizeof(GenericReport)
|
||||
},
|
||||
|
||||
.HID_ReportINEndpoint =
|
||||
.HID_ReportINEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | GENERIC_IN_EPNUM),
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = GENERIC_EPSIZE,
|
||||
.PollingIntervalMS = 0x0A
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/** Language descriptor structure. This descriptor, located in FLASH memory, is returned when the host requests
|
||||
|
@ -205,7 +205,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
|
@ -216,7 +216,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
|||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
|
@ -227,7 +227,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(22), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Temperature Datalogger"
|
||||
};
|
||||
|
||||
|
@ -249,42 +249,43 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
case HID_DTYPE_HID:
|
||||
case HID_DTYPE_HID:
|
||||
Address = &ConfigurationDescriptor.HID_GenericHID;
|
||||
Size = sizeof(USB_HID_Descriptor_HID_t);
|
||||
break;
|
||||
case HID_DTYPE_Report:
|
||||
case HID_DTYPE_Report:
|
||||
Address = &GenericReport;
|
||||
Size = sizeof(GenericReport);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DESCRIPTORS_H_
|
||||
#define _DESCRIPTORS_H_
|
||||
|
||||
|
@ -15,15 +15,15 @@
|
|||
#include <LUFA/Drivers/USB/USB.h>
|
||||
#include <LUFA/Drivers/USB/Class/MassStorage.h>
|
||||
#include <LUFA/Drivers/USB/Class/HID.h>
|
||||
|
||||
|
||||
#include "TempDataLogger.h"
|
||||
|
||||
/* Macros: */
|
||||
/** Endpoint number of the Mass Storage device-to-host data IN endpoint. */
|
||||
#define MASS_STORAGE_IN_EPNUM 3
|
||||
#define MASS_STORAGE_IN_EPNUM 3
|
||||
|
||||
/** Endpoint number of the Mass Storage host-to-device data OUT endpoint. */
|
||||
#define MASS_STORAGE_OUT_EPNUM 4
|
||||
#define MASS_STORAGE_OUT_EPNUM 4
|
||||
|
||||
/** Size in bytes of the Mass Storage data endpoints. */
|
||||
#define MASS_STORAGE_IO_EPSIZE 64
|
||||
|
@ -33,11 +33,11 @@
|
|||
|
||||
/** Size in bytes of the Generic HID reporting endpoint. */
|
||||
#define GENERIC_EPSIZE 16
|
||||
|
||||
|
||||
/** Size in bytes of the Generic HID reports (including report ID byte). */
|
||||
#define GENERIC_REPORT_SIZE sizeof(Device_Report_t)
|
||||
|
||||
/* Type Defines: */
|
||||
|
||||
/* Type Defines: */
|
||||
/** Type define for the device configuration descriptor structure. This must be defined in the
|
||||
* application code, as the configuration descriptor contains several sub-descriptors which
|
||||
* vary between devices, and which describe the device's usage to the host.
|
||||
|
@ -52,7 +52,7 @@
|
|||
USB_HID_Descriptor_HID_t HID_GenericHID;
|
||||
USB_Descriptor_Endpoint_t HID_ReportINEndpoint;
|
||||
} USB_Descriptor_Configuration_t;
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
||||
const uint8_t wIndex,
|
||||
|
@ -60,3 +60,4 @@
|
|||
ATTR_WARN_UNUSED_RESULT ATTR_NON_NULL_PTR_ARG(3);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -15,7 +15,7 @@ void DS1307_SetDate(const uint8_t Day,
|
|||
return;
|
||||
#endif
|
||||
|
||||
DS1307_DateRegs_t CurrentRTCDate;
|
||||
DS1307_DateRegs_t CurrentRTCDate;
|
||||
CurrentRTCDate.Byte1.Fields.TenDay = (Day / 10);
|
||||
CurrentRTCDate.Byte1.Fields.Day = (Day % 10);
|
||||
CurrentRTCDate.Byte2.Fields.TenMonth = (Month / 10);
|
||||
|
@ -29,7 +29,7 @@ void DS1307_SetDate(const uint8_t Day,
|
|||
TWI_SendByte(CurrentRTCDate.Byte1.IntVal);
|
||||
TWI_SendByte(CurrentRTCDate.Byte2.IntVal);
|
||||
TWI_SendByte(CurrentRTCDate.Byte3.IntVal);
|
||||
|
||||
|
||||
TWI_StopTransmission();
|
||||
}
|
||||
}
|
||||
|
@ -51,18 +51,18 @@ void DS1307_SetTime(const uint8_t Hour,
|
|||
CurrentRTCTime.Byte3.Fields.TenHour = (Hour / 10);
|
||||
CurrentRTCTime.Byte3.Fields.Hour = (Hour % 10);
|
||||
CurrentRTCTime.Byte3.Fields.TwelveHourMode = false;
|
||||
|
||||
|
||||
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
|
||||
{
|
||||
TWI_SendByte(DS1307_TIMEREG_START);
|
||||
TWI_SendByte(CurrentRTCTime.Byte1.IntVal);
|
||||
TWI_SendByte(CurrentRTCTime.Byte2.IntVal);
|
||||
TWI_SendByte(CurrentRTCTime.Byte3.IntVal);
|
||||
|
||||
|
||||
TWI_StopTransmission();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void DS1307_GetDate(uint8_t* const Day,
|
||||
uint8_t* const Month,
|
||||
uint8_t* const Year)
|
||||
|
@ -77,7 +77,7 @@ void DS1307_GetDate(uint8_t* const Day,
|
|||
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
|
||||
{
|
||||
TWI_SendByte(DS1307_DATEREG_START);
|
||||
|
||||
|
||||
TWI_StopTransmission();
|
||||
}
|
||||
|
||||
|
@ -88,7 +88,7 @@ void DS1307_GetDate(uint8_t* const Day,
|
|||
TWI_ReceiveByte(&CurrentRTCDate.Byte1.IntVal, false);
|
||||
TWI_ReceiveByte(&CurrentRTCDate.Byte2.IntVal, false);
|
||||
TWI_ReceiveByte(&CurrentRTCDate.Byte3.IntVal, true);
|
||||
|
||||
|
||||
TWI_StopTransmission();
|
||||
}
|
||||
|
||||
|
@ -111,10 +111,10 @@ void DS1307_GetTime(uint8_t* const Hour,
|
|||
if (TWI_StartTransmission(DS1307_ADDRESS_WRITE, 10))
|
||||
{
|
||||
TWI_SendByte(DS1307_TIMEREG_START);
|
||||
|
||||
|
||||
TWI_StopTransmission();
|
||||
}
|
||||
|
||||
|
||||
DS1307_TimeRegs_t CurrentRTCTime;
|
||||
|
||||
if (TWI_StartTransmission(DS1307_ADDRESS_READ, 10))
|
||||
|
@ -122,7 +122,7 @@ void DS1307_GetTime(uint8_t* const Hour,
|
|||
TWI_ReceiveByte(&CurrentRTCTime.Byte1.IntVal, false);
|
||||
TWI_ReceiveByte(&CurrentRTCTime.Byte2.IntVal, false);
|
||||
TWI_ReceiveByte(&CurrentRTCTime.Byte3.IntVal, true);
|
||||
|
||||
|
||||
TWI_StopTransmission();
|
||||
}
|
||||
|
||||
|
@ -130,3 +130,4 @@ void DS1307_GetTime(uint8_t* const Hour,
|
|||
*Minute = (CurrentRTCTime.Byte2.Fields.TenMin * 10) + CurrentRTCTime.Byte2.Fields.Min;
|
||||
*Hour = (CurrentRTCTime.Byte3.Fields.TenHour * 10) + CurrentRTCTime.Byte3.Fields.Hour;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
/*
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -24,10 +24,10 @@
|
|||
unsigned int TenSec : 3;
|
||||
unsigned int CH : 1;
|
||||
} Fields;
|
||||
|
||||
|
||||
uint8_t IntVal;
|
||||
} Byte1;
|
||||
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
|
@ -36,10 +36,10 @@
|
|||
unsigned int TenMin : 3;
|
||||
unsigned int Reserved : 1;
|
||||
} Fields;
|
||||
|
||||
|
||||
uint8_t IntVal;
|
||||
} Byte2;
|
||||
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
|
@ -49,7 +49,7 @@
|
|||
unsigned int TwelveHourMode : 1;
|
||||
unsigned int Reserved : 1;
|
||||
} Fields;
|
||||
|
||||
|
||||
uint8_t IntVal;
|
||||
} Byte3;
|
||||
} DS1307_TimeRegs_t;
|
||||
|
@ -64,7 +64,7 @@
|
|||
unsigned int TenDay : 2;
|
||||
unsigned int Reserved : 2;
|
||||
} Fields;
|
||||
|
||||
|
||||
uint8_t IntVal;
|
||||
} Byte1;
|
||||
|
||||
|
@ -76,10 +76,10 @@
|
|||
unsigned int TenMonth : 1;
|
||||
unsigned int Reserved : 3;
|
||||
} Fields;
|
||||
|
||||
|
||||
uint8_t IntVal;
|
||||
} Byte2;
|
||||
|
||||
|
||||
union
|
||||
{
|
||||
struct
|
||||
|
@ -87,7 +87,7 @@
|
|||
unsigned int Year : 4;
|
||||
unsigned int TenYear : 4;
|
||||
} Fields;
|
||||
|
||||
|
||||
uint8_t IntVal;
|
||||
} Byte3;
|
||||
} DS1307_DateRegs_t;
|
||||
|
@ -95,7 +95,7 @@
|
|||
/* Macros: */
|
||||
#define DS1307_TIMEREG_START 0x00
|
||||
#define DS1307_DATEREG_START 0x04
|
||||
|
||||
|
||||
#define DS1307_ADDRESS_READ 0b11010001
|
||||
#define DS1307_ADDRESS_WRITE 0b11010000
|
||||
|
||||
|
@ -114,3 +114,4 @@
|
|||
uint8_t* const Second);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -77,7 +77,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -86,7 +86,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
{
|
||||
/* Clear the current endpoint bank */
|
||||
Endpoint_ClearOUT();
|
||||
|
||||
|
||||
/* Wait until the host has sent another packet */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
|
@ -125,7 +125,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
|
||||
/* Send the Dataflash buffer write command */
|
||||
Dataflash_SendByte(UsingSecondBuffer ? DF_CMD_BUFF2WRITE : DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
}
|
||||
|
||||
/* Write one 16-byte chunk of data to the Dataflash */
|
||||
|
@ -145,7 +145,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
Dataflash_SendByte(Endpoint_Read_Byte());
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
@ -154,9 +154,9 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceIn
|
|||
|
||||
/* Check if the current command is being aborted by the host */
|
||||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -201,15 +201,15 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
|
||||
|
||||
/* Wait until endpoint is ready before continuing */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -218,12 +218,12 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
{
|
||||
/* Clear the endpoint bank to send its contents to the host */
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Wait until the endpoint is ready for more data */
|
||||
if (Endpoint_WaitUntilReady())
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Check if end of Dataflash page reached */
|
||||
if (CurrDFPageByteDiv16 == (DATAFLASH_PAGE_SIZE >> 4))
|
||||
{
|
||||
|
@ -233,7 +233,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||
|
||||
|
||||
/* Send the Dataflash main memory page read command */
|
||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||
|
@ -241,7 +241,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read one 16-byte chunk of data from the Dataflash */
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
|
@ -260,10 +260,10 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
Endpoint_Write_Byte(Dataflash_ReceiveByte());
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
|
||||
|
@ -271,11 +271,11 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
if (MSInterfaceInfo->State.IsMassStoreReset)
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
||||
|
||||
/* If the endpoint is full, send its contents to the host */
|
||||
if (!(Endpoint_IsReadWriteAllowed()))
|
||||
Endpoint_ClearIN();
|
||||
|
@ -315,11 +315,11 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
|||
/* Send the Dataflash buffer write command */
|
||||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, CurrDFPageByte);
|
||||
|
||||
|
||||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -359,18 +359,18 @@ void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress,
|
|||
Dataflash_SendByte(DF_CMD_BUFF1WRITE);
|
||||
Dataflash_SendAddressBytes(0, 0);
|
||||
}
|
||||
|
||||
|
||||
/* Write one 16-byte chunk of data to the Dataflash */
|
||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||
Dataflash_SendByte(*(BufferPtr++));
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
BytesInBlockDiv16++;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter and reset the sub block counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -416,7 +416,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
while (TotalBlocks)
|
||||
{
|
||||
uint8_t BytesInBlockDiv16 = 0;
|
||||
|
||||
|
||||
/* Write an endpoint packet sized data block to the Dataflash */
|
||||
while (BytesInBlockDiv16 < (VIRTUAL_MEMORY_BLOCK_SIZE >> 4))
|
||||
{
|
||||
|
@ -429,7 +429,7 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
|
||||
/* Select the next Dataflash chip based on the new Dataflash page index */
|
||||
Dataflash_SelectChipFromPage(CurrDFPage);
|
||||
|
||||
|
||||
/* Send the Dataflash main memory page read command */
|
||||
Dataflash_SendByte(DF_CMD_MAINMEMPAGEREAD);
|
||||
Dataflash_SendAddressBytes(CurrDFPage, 0);
|
||||
|
@ -437,19 +437,19 @@ void DataflashManager_ReadBlocks_RAM(const uint32_t BlockAddress,
|
|||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
Dataflash_SendByte(0x00);
|
||||
}
|
||||
}
|
||||
|
||||
/* Read one 16-byte chunk of data from the Dataflash */
|
||||
for (uint8_t ByteNum = 0; ByteNum < 16; ByteNum++)
|
||||
*(BufferPtr++) = Dataflash_ReceiveByte();
|
||||
|
||||
|
||||
/* Increment the Dataflash page 16 byte block counter */
|
||||
CurrDFPageByteDiv16++;
|
||||
|
||||
|
||||
/* Increment the block 16 byte block counter */
|
||||
BytesInBlockDiv16++;
|
||||
}
|
||||
|
||||
|
||||
/* Decrement the blocks remaining counter */
|
||||
TotalBlocks--;
|
||||
}
|
||||
|
@ -464,7 +464,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
/* Select first Dataflash chip, send the read status register command */
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP1);
|
||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||
|
||||
|
||||
/* Check if sector protection is enabled */
|
||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||
{
|
||||
|
@ -476,12 +476,12 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[2]);
|
||||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||
}
|
||||
|
||||
|
||||
/* Select second Dataflash chip (if present on selected board), send read status register command */
|
||||
#if (DATAFLASH_TOTALCHIPS == 2)
|
||||
Dataflash_SelectChip(DATAFLASH_CHIP2);
|
||||
Dataflash_SendByte(DF_CMD_GETSTATUS);
|
||||
|
||||
|
||||
/* Check if sector protection is enabled */
|
||||
if (Dataflash_ReceiveByte() & DF_STATUS_SECTORPROTECTION_ON)
|
||||
{
|
||||
|
@ -494,7 +494,7 @@ void DataflashManager_ResetDataflashProtections(void)
|
|||
Dataflash_SendByte(DF_CMD_SECTORPROTECTIONOFF[3]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* Deselect current Dataflash chip */
|
||||
Dataflash_DeselectChip();
|
||||
}
|
||||
|
@ -528,6 +528,7 @@ bool DataflashManager_CheckDataflashOperation(void)
|
|||
if (ReturnByte != DF_MANUFACTURER_ATMEL)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,13 +32,13 @@
|
|||
*
|
||||
* Header file for DataflashManager.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _DATAFLASH_MANAGER_H_
|
||||
#define _DATAFLASH_MANAGER_H_
|
||||
|
||||
/* Includes: */
|
||||
#include <avr/io.h>
|
||||
|
||||
|
||||
#include "TempDataLogger.h"
|
||||
#include "Descriptors.h"
|
||||
|
||||
|
@ -60,12 +60,12 @@
|
|||
* storage media (Dataflash) using a different native block size. Do not change this value.
|
||||
*/
|
||||
#define VIRTUAL_MEMORY_BLOCK_SIZE 512
|
||||
|
||||
|
||||
/** Total number of blocks of the virtual memory for reporting to the host as the device's total capacity. Do not
|
||||
* change this value; change VIRTUAL_MEMORY_BYTES instead to alter the media size.
|
||||
*/
|
||||
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const uint32_t BlockAddress,
|
||||
|
@ -81,5 +81,6 @@
|
|||
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
|
||||
void DataflashManager_ResetDataflashProtections(void);
|
||||
bool DataflashManager_CheckDataflashOperation(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -115,3 +115,4 @@ REVISION HISTORY
|
|||
Changed some types on the API, XCHAR->TCHAR.
|
||||
Changed fname member in the FILINFO structure on Unicode cfg.
|
||||
String functions support UTF-8 encoding files on Unicode cfg.
|
||||
|
||||
|
|
|
@ -97,3 +97,4 @@ DWORD get_fattime (void)
|
|||
((DWORD)Minute << 5) |
|
||||
(((DWORD)Second >> 1) << 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -69,3 +69,4 @@ DRESULT disk_ioctl (BYTE, BYTE, void*);
|
|||
|
||||
#define _DISKIO
|
||||
#endif
|
||||
|
||||
|
|
|
@ -2289,7 +2289,7 @@ FRESULT f_close (
|
|||
#if _FS_REENTRANT
|
||||
res = validate(fp->fs, fp->id);
|
||||
if (res == FR_OK) {
|
||||
res = dec_lock(fp->fs, fp->lockid);
|
||||
res = dec_lock(fp->fs, fp->lockid);
|
||||
unlock_fs(fp->fs, FR_OK);
|
||||
}
|
||||
#else
|
||||
|
@ -3539,7 +3539,7 @@ int f_printf (
|
|||
res++;
|
||||
}
|
||||
do {
|
||||
cc = f_putc(s[--i], fil);
|
||||
cc = f_putc(s[--i], fil);
|
||||
res++;
|
||||
} while (i && cc != EOF);
|
||||
if (cc != EOF) cc = 0;
|
||||
|
@ -3551,3 +3551,4 @@ int f_printf (
|
|||
|
||||
#endif /* !_FS_READONLY */
|
||||
#endif /* _USE_STRFUNC */
|
||||
|
||||
|
|
|
@ -611,3 +611,4 @@ void ff_rel_grant (_SYNC_t); /* Unlock sync object */
|
|||
#endif
|
||||
|
||||
#endif /* _FATFS */
|
||||
|
||||
|
|
|
@ -179,3 +179,4 @@
|
|||
|
||||
|
||||
#endif /* _FFCONFIG */
|
||||
|
||||
|
|
|
@ -37,3 +37,4 @@ typedef unsigned char BOOL;
|
|||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -34,29 +34,29 @@
|
|||
* devices use a thin "Bulk-Only Transport" protocol for issuing commands and status information,
|
||||
* which wrap around standard SCSI device commands for controlling the actual storage medium.
|
||||
*/
|
||||
|
||||
|
||||
#define INCLUDE_FROM_SCSI_C
|
||||
#include "SCSI.h"
|
||||
|
||||
/** Structure to hold the SCSI response data to a SCSI INQUIRY command. This gives information about the device's
|
||||
* features and capabilities.
|
||||
*/
|
||||
SCSI_Inquiry_Response_t InquiryData =
|
||||
SCSI_Inquiry_Response_t InquiryData =
|
||||
{
|
||||
.DeviceType = DEVICE_TYPE_BLOCK,
|
||||
.PeripheralQualifier = 0,
|
||||
|
||||
|
||||
.Removable = true,
|
||||
|
||||
|
||||
.Version = 0,
|
||||
|
||||
|
||||
.ResponseDataFormat = 2,
|
||||
.NormACA = false,
|
||||
.TrmTsk = false,
|
||||
.AERC = false,
|
||||
|
||||
.AdditionalLength = 0x1F,
|
||||
|
||||
|
||||
.SoftReset = false,
|
||||
.CmdQue = false,
|
||||
.Linked = false,
|
||||
|
@ -64,7 +64,7 @@ SCSI_Inquiry_Response_t InquiryData =
|
|||
.WideBus16Bit = false,
|
||||
.WideBus32Bit = false,
|
||||
.RelAddr = false,
|
||||
|
||||
|
||||
.VendorID = "LUFA",
|
||||
.ProductID = "Dataflash Disk",
|
||||
.RevisionID = {'0','.','0','0'},
|
||||
|
@ -96,13 +96,13 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
|||
switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
|
||||
{
|
||||
case SCSI_CMD_INQUIRY:
|
||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_REQUEST_SENSE:
|
||||
CommandSuccess = SCSI_Command_Request_Sense(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_READ_CAPACITY_10:
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
CommandSuccess = SCSI_Command_Read_Capacity_10(MSInterfaceInfo);
|
||||
break;
|
||||
case SCSI_CMD_SEND_DIAGNOSTIC:
|
||||
CommandSuccess = SCSI_Command_Send_Diagnostic(MSInterfaceInfo);
|
||||
|
@ -134,7 +134,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
|||
SCSI_SET_SENSE(SCSI_SENSE_KEY_GOOD,
|
||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -165,11 +165,11 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Endpoint_Write_Stream_LE(&InquiryData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
|
||||
/* Pad out remaining bytes with 0x00 */
|
||||
Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK);
|
||||
|
||||
|
@ -178,7 +178,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf
|
|||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -193,7 +193,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf
|
|||
{
|
||||
uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
|
||||
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
|
||||
|
||||
|
||||
uint8_t PadBytes[AllocationLength - BytesTransferred];
|
||||
|
||||
Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK);
|
||||
|
@ -221,10 +221,10 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* const MSInt
|
|||
Endpoint_Write_Stream_BE(&LastBlockAddressInLUN, sizeof(LastBlockAddressInLUN), NO_STREAM_CALLBACK);
|
||||
Endpoint_Write_Stream_BE(&MediaBlockSize, sizeof(MediaBlockSize), NO_STREAM_CALLBACK);
|
||||
Endpoint_ClearIN();
|
||||
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -248,21 +248,21 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* const MSInte
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Check to see if all attached Dataflash ICs are functional */
|
||||
if (!(DataflashManager_CheckDataflashOperation()))
|
||||
{
|
||||
/* Update SENSE key with a hardware error condition and return command fail */
|
||||
SCSI_SET_SENSE(SCSI_SENSE_KEY_HARDWARE_ERROR,
|
||||
SCSI_ASENSE_NO_ADDITIONAL_INFORMATION,
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
SCSI_ASENSEQ_NO_QUALIFIER);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Succeed the command and update the bytes transferred counter */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -280,13 +280,13 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
{
|
||||
uint32_t BlockAddress;
|
||||
uint16_t TotalBlocks;
|
||||
|
||||
|
||||
/* Load in the 32-bit block address (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]);
|
||||
|
||||
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */
|
||||
TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]);
|
||||
|
||||
|
||||
/* Check if the block address is outside the maximum allowable value for the LUN */
|
||||
if (BlockAddress >= VIRTUAL_MEMORY_BLOCKS)
|
||||
{
|
||||
|
@ -297,7 +297,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
|
||||
if (IsDataRead == DATA_READ)
|
||||
DataflashManager_ReadBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
|
||||
|
@ -306,6 +306,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa
|
|||
|
||||
/* Update the bytes transferred counter and succeed the command */
|
||||
MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -32,7 +32,7 @@
|
|||
*
|
||||
* Header file for SCSI.c.
|
||||
*/
|
||||
|
||||
|
||||
#ifndef _SCSI_H_
|
||||
#define _SCSI_H_
|
||||
|
||||
|
@ -46,7 +46,7 @@
|
|||
#include "../TempDataLogger.h"
|
||||
#include "../Descriptors.h"
|
||||
#include "DataflashManager.h"
|
||||
|
||||
|
||||
/* Macros: */
|
||||
/** Macro to set the current SCSI sense data to the given key, additional sense code and additional sense qualifier. This
|
||||
* is for convenience, as it allows for all three sense values (returned upon request to the host to give information about
|
||||
|
@ -68,13 +68,13 @@
|
|||
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a Block Media device. */
|
||||
#define DEVICE_TYPE_BLOCK 0x00
|
||||
|
||||
|
||||
/** Value for the DeviceType entry in the SCSI_Inquiry_Response_t enum, indicating a CD-ROM device. */
|
||||
#define DEVICE_TYPE_CDROM 0x05
|
||||
|
||||
|
||||
/* Function Prototypes: */
|
||||
bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
||||
|
||||
#if defined(INCLUDE_FROM_SCSI_C)
|
||||
static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo);
|
||||
|
@ -83,5 +83,6 @@
|
|||
static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo,
|
||||
const bool IsDataRead);
|
||||
#endif
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -74,7 +74,7 @@ USB_ClassInfo_HID_Device_t Generic_HID_Interface =
|
|||
.ReportINEndpointNumber = GENERIC_IN_EPNUM,
|
||||
.ReportINEndpointSize = GENERIC_EPSIZE,
|
||||
.ReportINEndpointDoubleBank = false,
|
||||
|
||||
|
||||
.PrevReportINBuffer = PrevHIDReportBuffer,
|
||||
.PrevReportINBufferSize = sizeof(PrevHIDReportBuffer),
|
||||
},
|
||||
|
@ -104,12 +104,12 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
|
|||
/* Check to see if the logging interval has expired */
|
||||
if (CurrentLoggingTicks++ < LoggingInterval500MS_SRAM)
|
||||
return;
|
||||
|
||||
|
||||
/* Reset log tick counter to prepare for next logging interval */
|
||||
CurrentLoggingTicks = 0;
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
|
||||
|
||||
/* Only log when not connected to a USB host */
|
||||
if (USB_DeviceState == DEVICE_STATE_Unattached)
|
||||
{
|
||||
|
@ -128,7 +128,7 @@ ISR(TIMER1_COMPA_vect, ISR_BLOCK)
|
|||
f_write(&TempLogFile, LineBuffer, BytesWritten, &BytesWritten);
|
||||
f_sync(&TempLogFile);
|
||||
}
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMask);
|
||||
}
|
||||
|
||||
|
@ -141,7 +141,7 @@ int main(void)
|
|||
|
||||
/* Fetch logging interval from EEPROM */
|
||||
LoggingInterval500MS_SRAM = eeprom_read_byte(&LoggingInterval500MS_EEPROM);
|
||||
|
||||
|
||||
/* Check if the logging interval is invalid (0xFF) indicating that the EEPROM is blank */
|
||||
if (LoggingInterval500MS_SRAM == 0xFF)
|
||||
LoggingInterval500MS_SRAM = DEFAULT_LOG_INTERVAL;
|
||||
|
@ -155,7 +155,7 @@ int main(void)
|
|||
/* Discard the first sample from the temperature sensor, as it is generally incorrect */
|
||||
volatile uint8_t Dummy = Temperature_GetTemperature();
|
||||
(void)Dummy;
|
||||
|
||||
|
||||
for (;;)
|
||||
{
|
||||
MS_Device_USBTask(&Disk_MS_Interface);
|
||||
|
@ -206,7 +206,7 @@ void SetupHardware(void)
|
|||
Dataflash_Init();
|
||||
USB_Init();
|
||||
TWI_Init();
|
||||
|
||||
|
||||
/* 500ms logging interval timer configuration */
|
||||
OCR1A = ((F_CPU / 1024) / 2);
|
||||
TCCR1B = (1 << WGM12) | (1 << CS12) | (1 << CS10);
|
||||
|
@ -229,7 +229,7 @@ void EVENT_USB_Device_Connect(void)
|
|||
void EVENT_USB_Device_Disconnect(void)
|
||||
{
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_NOTREADY);
|
||||
|
||||
|
||||
/* Mount and open the log file on the Dataflash FAT partition */
|
||||
OpenLogFile();
|
||||
}
|
||||
|
@ -259,18 +259,18 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
bool CALLBACK_MS_Device_SCSICommandReceived(USB_ClassInfo_MS_Device_t* const MSInterfaceInfo)
|
||||
{
|
||||
bool CommandSuccess;
|
||||
|
||||
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_BUSY);
|
||||
CommandSuccess = SCSI_DecodeSCSICommand(MSInterfaceInfo);
|
||||
LEDs_SetAllLEDs(LEDMASK_USB_READY);
|
||||
|
||||
|
||||
return CommandSuccess;
|
||||
}
|
||||
|
||||
/** HID class driver callback function for the creation of HID reports to the host.
|
||||
*
|
||||
* \param[in] HIDInterfaceInfo Pointer to the HID class interface configuration structure being referenced
|
||||
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the
|
||||
* \param[in,out] ReportID Report ID requested by the host if non-zero, otherwise callback should set to the
|
||||
* generated report ID
|
||||
* \param[in] ReportType Type of the report to create, either HID_REPORT_ITEM_In or HID_REPORT_ITEM_Feature
|
||||
* \param[out] ReportData Pointer to a buffer where the created report should be stored
|
||||
|
@ -288,7 +288,7 @@ bool CALLBACK_HID_Device_CreateHIDReport(USB_ClassInfo_HID_Device_t* const HIDIn
|
|||
|
||||
DS1307_GetDate(&ReportParams->Day, &ReportParams->Month, &ReportParams->Year);
|
||||
DS1307_GetTime(&ReportParams->Hour, &ReportParams->Minute, &ReportParams->Second);
|
||||
|
||||
|
||||
ReportParams->LogInterval500MS = LoggingInterval500MS_SRAM;
|
||||
|
||||
*ReportSize = sizeof(Device_Report_t);
|
||||
|
@ -310,10 +310,10 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
|||
const uint16_t ReportSize)
|
||||
{
|
||||
Device_Report_t* ReportParams = (Device_Report_t*)ReportData;
|
||||
|
||||
|
||||
DS1307_SetDate(ReportParams->Day, ReportParams->Month, ReportParams->Year);
|
||||
DS1307_SetTime(ReportParams->Hour, ReportParams->Minute, ReportParams->Second);
|
||||
|
||||
|
||||
/* If the logging interval has changed from its current value, write it to EEPROM */
|
||||
if (LoggingInterval500MS_SRAM != ReportParams->LogInterval500MS)
|
||||
{
|
||||
|
@ -321,3 +321,4 @@ void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDI
|
|||
eeprom_update_byte(&LoggingInterval500MS_EEPROM, LoggingInterval500MS_SRAM);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -42,7 +42,7 @@
|
|||
#include <avr/power.h>
|
||||
#include <avr/interrupt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
||||
#include "Lib/SCSI.h"
|
||||
|
@ -73,13 +73,13 @@
|
|||
|
||||
/** LED mask for the library LED driver, to indicate that the USB interface is busy. */
|
||||
#define LEDMASK_USB_BUSY LEDS_LED2
|
||||
|
||||
|
||||
/** Filename for the log data when written to the dataflash FAT filesystem. */
|
||||
#define LOG_FILENAME "TEMPLOG.txt"
|
||||
|
||||
|
||||
/** Default log interval when the EEPROM is blank, in 500ms ticks. */
|
||||
#define DEFAULT_LOG_INTERVAL 20
|
||||
|
||||
|
||||
/* Type Defines: */
|
||||
typedef struct
|
||||
{
|
||||
|
@ -90,7 +90,7 @@
|
|||
uint8_t Hour;
|
||||
uint8_t Minute;
|
||||
uint8_t Second;
|
||||
|
||||
|
||||
uint8_t LogInterval500MS;
|
||||
} Device_Report_t;
|
||||
|
||||
|
@ -111,9 +111,10 @@
|
|||
void* ReportData,
|
||||
uint16_t* const ReportSize);
|
||||
void CALLBACK_HID_Device_ProcessHIDReport(USB_ClassInfo_HID_Device_t* const HIDInterfaceInfo,
|
||||
const uint8_t ReportID,
|
||||
const uint8_t ReportID,
|
||||
const uint8_t ReportType,
|
||||
const void* ReportData,
|
||||
const uint16_t ReportSize);
|
||||
|
||||
#endif
|
||||
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
the terms and conditions of version 3 of the GNU General Public
|
||||
License, supplemented by the additional permissions listed below.
|
||||
|
||||
0. Additional Definitions.
|
||||
0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the GNU
|
||||
|
@ -111,7 +111,7 @@ the following:
|
|||
a copy of the Library already present on the user's computer
|
||||
system, and (b) will operate properly with a modified version
|
||||
of the Library that is interface-compatible with the Linked
|
||||
Version.
|
||||
Version.
|
||||
|
||||
e) Provide Installation Information, but only if you would otherwise
|
||||
be required to provide such information under section 6 of the
|
||||
|
@ -163,3 +163,4 @@ whether future versions of the GNU Lesser General Public License shall
|
|||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
|
||||
|
|
|
@ -672,3 +672,4 @@ may consider it more useful to permit linking proprietary applications with
|
|||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<http://www.gnu.org/philosophy/why-not-lgpl.html>.
|
||||
|
||||
|
|
|
@ -19,3 +19,4 @@ methods.
|
|||
|
||||
LogitechMX5000.cs is a simple example of how the library can be used. Other
|
||||
examples on common devices are welcomed.
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
* 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.
|
||||
*/
|
||||
|
||||
|
||||
/** \mainpage Temperature Datalogger Project
|
||||
*
|
||||
* \section SSec_Compat Demo Compatibility:
|
||||
|
@ -28,7 +28,7 @@
|
|||
* <td>Mass Storage Device \n
|
||||
* Human Interface Device</td>
|
||||
* </tr>
|
||||
* <tr>
|
||||
* <tr>
|
||||
* <td><b>USB Subclasses:</b></td>
|
||||
* <td>Bulk-Only Transport \n
|
||||
* Keyboard Subclass</td>
|
||||
|
@ -47,7 +47,7 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*
|
||||
* \section SSec_Description Project Description:
|
||||
* \section SSec_Description Project Description:
|
||||
*
|
||||
* Temperature Data Logger project. This project is a very basic USB data logger for the current temperature as reported by
|
||||
* the board's temperature sensor, writing the temperature to a file stored on the board's Dataflash in a FAT filesystem
|
||||
|
@ -83,3 +83,4 @@
|
|||
* </tr>
|
||||
* </table>
|
||||
*/
|
||||
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
# make doxygen = Generate DoxyGen documentation for the project (must have
|
||||
# DoxyGen installed)
|
||||
#
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# make debug = Start either simulavr or avarice as specified for debugging,
|
||||
# with avr-gdb or avr-insight as the front end for debugging.
|
||||
#
|
||||
# make filename.s = Just compile filename.c into the assembler code only.
|
||||
|
@ -64,14 +64,14 @@ MCU = at90usb1287
|
|||
|
||||
|
||||
# Target board (see library "Board Types" documentation, NONE for projects not requiring
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# LUFA board drivers). If USER is selected, put custom board drivers in a directory called
|
||||
# "Board" inside the application directory.
|
||||
BOARD = USBKEY
|
||||
|
||||
|
||||
# Processor frequency.
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# This will define a symbol, F_CPU, in all source code files equal to the
|
||||
# processor frequency in Hz. You can then use this symbol in your source code to
|
||||
# calculate timings. Do NOT tack on a 'UL' at the end, this will be done
|
||||
# automatically to create a 32-bit value in your source code.
|
||||
#
|
||||
|
@ -84,7 +84,7 @@ F_CPU = 8000000
|
|||
|
||||
|
||||
# Input clock frequency.
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# This will define a symbol, F_CLOCK, in all source code files equal to the
|
||||
# input clock frequency (before any prescaling is performed) in Hz. This value may
|
||||
# differ from F_CPU if prescaling is used on the latter, and is required as the
|
||||
# raw input clock is fed directly to the PLL sections of the AVR for high speed
|
||||
|
@ -146,7 +146,7 @@ SRC = $(TARGET).c \
|
|||
|
||||
|
||||
# List C++ source files here. (C dependencies are automatically generated.)
|
||||
CPPSRC =
|
||||
CPPSRC =
|
||||
|
||||
|
||||
# List Assembler source files here.
|
||||
|
@ -159,7 +159,7 @@ CPPSRC =
|
|||
ASRC =
|
||||
|
||||
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# Optimization level, can be [0, 1, 2, 3, s].
|
||||
# 0 = turn off optimization. s = optimize for size.
|
||||
# (Note: 3 is not always the best optimization level. See avr-libc FAQ.)
|
||||
OPT = s
|
||||
|
@ -273,7 +273,7 @@ CPPFLAGS += $(patsubst %,-I%,$(EXTRAINCDIRS))
|
|||
# for use in COFF files, additional information about filenames
|
||||
# and function names needs to be present in the assembler source
|
||||
# files -- see avr-libc docs [FIXME: not yet described there]
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# -listing-cont-lines: Sets the maximum number of continuation lines of hex
|
||||
# dump that will be displayed for a given single line of source input.
|
||||
ASFLAGS = $(ADEFS) -Wa,-adhlns=$(<:%.S=$(OBJDIR)/%.lst),-gstabs,--listing-cont-lines=100
|
||||
|
||||
|
@ -286,7 +286,7 @@ PRINTF_LIB_MIN = -Wl,-u,vfprintf -lprintf_min
|
|||
PRINTF_LIB_FLOAT = -Wl,-u,vfprintf -lprintf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard printf version.
|
||||
PRINTF_LIB =
|
||||
PRINTF_LIB =
|
||||
#PRINTF_LIB = $(PRINTF_LIB_MIN)
|
||||
#PRINTF_LIB = $(PRINTF_LIB_FLOAT)
|
||||
|
||||
|
@ -298,7 +298,7 @@ SCANF_LIB_MIN = -Wl,-u,vfscanf -lscanf_min
|
|||
SCANF_LIB_FLOAT = -Wl,-u,vfscanf -lscanf_flt
|
||||
|
||||
# If this is left blank, then it will use the Standard scanf version.
|
||||
SCANF_LIB =
|
||||
SCANF_LIB =
|
||||
#SCANF_LIB = $(SCANF_LIB_MIN)
|
||||
#SCANF_LIB = $(SCANF_LIB_FLOAT)
|
||||
|
||||
|
@ -310,7 +310,7 @@ MATH_LIB = -lm
|
|||
# Each directory must be seperated by a space.
|
||||
# Use forward slashes for directory separators.
|
||||
# For a directory that has spaces, enclose it in quotes.
|
||||
EXTRALIBDIRS =
|
||||
EXTRALIBDIRS =
|
||||
|
||||
|
||||
|
||||
|
@ -333,7 +333,7 @@ EXTMEMOPTS =
|
|||
# -Map: create map file
|
||||
# --cref: add cross reference to map file
|
||||
LDFLAGS = -Wl,-Map=$(TARGET).map,--cref
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--relax
|
||||
LDFLAGS += -Wl,--gc-sections
|
||||
LDFLAGS += $(EXTMEMOPTS)
|
||||
LDFLAGS += $(patsubst %,-L%,$(EXTRALIBDIRS))
|
||||
|
@ -367,7 +367,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
|
|||
#AVRDUDE_NO_VERIFY = -V
|
||||
|
||||
# Increase verbosity level. Please use this when submitting bug
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# reports about avrdude. See <http://savannah.nongnu.org/projects/avrdude>
|
||||
# to submit bug reports.
|
||||
#AVRDUDE_VERBOSE = -v -v
|
||||
|
||||
|
@ -401,7 +401,7 @@ JTAG_DEV = /dev/com1
|
|||
DEBUG_PORT = 4242
|
||||
|
||||
# Debugging host used to communicate between GDB / avarice / simulavr, normally
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# just set to localhost unless doing some sort of crazy debugging when
|
||||
# avarice is running on a different computer.
|
||||
DEBUG_HOST = localhost
|
||||
|
||||
|
@ -430,7 +430,7 @@ WINSHELL = cmd
|
|||
MSG_ERRORS_NONE = Errors: none
|
||||
MSG_BEGIN = -------- begin --------
|
||||
MSG_END = -------- end --------
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_BEFORE = Size before:
|
||||
MSG_SIZE_AFTER = Size after:
|
||||
MSG_COFF = Converting to AVR COFF:
|
||||
MSG_EXTENDED_COFF = Converting to AVR Extended COFF:
|
||||
|
@ -449,10 +449,10 @@ MSG_CREATING_LIBRARY = Creating library:
|
|||
|
||||
|
||||
# Define all object files.
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
OBJ = $(SRC:%.c=$(OBJDIR)/%.o) $(CPPSRC:%.cpp=$(OBJDIR)/%.o) $(ASRC:%.S=$(OBJDIR)/%.o)
|
||||
|
||||
# Define all listing files.
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
LST = $(SRC:%.c=$(OBJDIR)/%.lst) $(CPPSRC:%.cpp=$(OBJDIR)/%.lst) $(ASRC:%.S=$(OBJDIR)/%.lst)
|
||||
|
||||
|
||||
# Compiler flags to generate dependency files.
|
||||
|
@ -517,11 +517,11 @@ sizeafter:
|
|||
|
||||
|
||||
# Display compiler version information.
|
||||
gccversion :
|
||||
gccversion :
|
||||
@$(CC) --version
|
||||
|
||||
|
||||
# Program the device.
|
||||
# Program the device.
|
||||
program: $(TARGET).hex $(TARGET).eep
|
||||
$(AVRDUDE) $(AVRDUDE_FLAGS) $(AVRDUDE_WRITE_FLASH) $(AVRDUDE_WRITE_EEPROM)
|
||||
|
||||
|
@ -548,9 +548,9 @@ dfu-ee: $(TARGET).hex $(TARGET).eep
|
|||
|
||||
|
||||
# Generate avr-gdb config/init file which does the following:
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# define the reset signal, load the target file, connect to target, and set
|
||||
# a breakpoint at main().
|
||||
gdb-config:
|
||||
gdb-config:
|
||||
@$(REMOVE) $(GDBINIT_FILE)
|
||||
@echo define reset >> $(GDBINIT_FILE)
|
||||
@echo SIGNAL SIGHUP >> $(GDBINIT_FILE)
|
||||
|
@ -648,14 +648,14 @@ extcoff: $(TARGET).elf
|
|||
$(OBJDIR)/%.o : %.c
|
||||
@echo
|
||||
@echo $(MSG_COMPILING) $<
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create object files from C++ source files.
|
||||
$(OBJDIR)/%.o : %.cpp
|
||||
@echo
|
||||
@echo $(MSG_COMPILING_CPP) $<
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
$(CC) -c $(ALL_CPPFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Compile: create assembler files from C source files.
|
||||
|
@ -677,7 +677,7 @@ $(OBJDIR)/%.o : %.S
|
|||
|
||||
# Create preprocessed source for use in sending a bug report.
|
||||
%.i : %.c
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
$(CC) -E -mmcu=$(MCU) -I. $(CFLAGS) $< -o $@
|
||||
|
||||
|
||||
# Target: clean project.
|
||||
|
@ -721,3 +721,4 @@ $(shell mkdir $(OBJDIR) 2>/dev/null)
|
|||
build elf hex eep lss sym coff extcoff doxygen clean \
|
||||
clean_list clean_doxygen program dfu flip flip-ee dfu-ee \
|
||||
debug gdb-config
|
||||
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
/*
|
||||
LUFA Library
|
||||
Copyright (C) Dean Camera, 2010.
|
||||
|
||||
|
||||
dean [at] fourwalledcubicle [dot] com
|
||||
www.fourwalledcubicle.com
|
||||
*/
|
||||
|
@ -9,13 +9,13 @@
|
|||
/*
|
||||
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
|
||||
without fee, provided that the above copyright notice appear in
|
||||
without fee, provided that the above copyright notice appear in
|
||||
all copies and that both that the copyright notice and this
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
permission notice and warranty disclaimer appear in supporting
|
||||
documentation, and that the name of the author not be used in
|
||||
advertising or publicity pertaining to distribution of the
|
||||
software without specific, written prior permission.
|
||||
|
||||
The author disclaim all warranties with regard to this
|
||||
|
@ -30,9 +30,9 @@
|
|||
|
||||
/** \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
|
||||
* the device's capabilities and functions.
|
||||
* the device's capabilities and functions.
|
||||
*/
|
||||
|
||||
#include "Descriptors.h"
|
||||
|
@ -57,22 +57,22 @@
|
|||
USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Device_t), .Type = DTYPE_Device},
|
||||
|
||||
|
||||
.USBSpecification = VERSION_BCD(01.10),
|
||||
.Class = 0x02,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.Endpoint0Size = FIXED_CONTROL_ENDPOINT_SIZE,
|
||||
|
||||
|
||||
.VendorID = 0x03EB,
|
||||
.ProductID = 0x204B,
|
||||
.ReleaseNumber = VERSION_BCD(00.01),
|
||||
|
||||
|
||||
.ManufacturerStrIndex = 0x01,
|
||||
.ProductStrIndex = 0x02,
|
||||
.SerialNumStrIndex = USE_INTERNAL_SERIAL,
|
||||
|
||||
|
||||
.NumberOfConfigurations = FIXED_NUM_CONFIGURATIONS
|
||||
};
|
||||
|
||||
|
@ -83,102 +83,102 @@ USB_Descriptor_Device_t PROGMEM DeviceDescriptor =
|
|||
*/
|
||||
USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||
{
|
||||
.Config =
|
||||
.Config =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Configuration_Header_t), .Type = DTYPE_Configuration},
|
||||
|
||||
.TotalConfigurationSize = sizeof(USB_Descriptor_Configuration_t),
|
||||
.TotalInterfaces = 2,
|
||||
|
||||
|
||||
.ConfigurationNumber = 1,
|
||||
.ConfigurationStrIndex = NO_DESCRIPTOR,
|
||||
|
||||
|
||||
.ConfigAttributes = (USB_CONFIG_ATTR_BUSPOWERED | USB_CONFIG_ATTR_SELFPOWERED),
|
||||
|
||||
|
||||
.MaxPowerConsumption = USB_CONFIG_POWER_MA(100)
|
||||
},
|
||||
|
||||
.CDC_CCI_Interface =
|
||||
|
||||
.CDC_CCI_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 0,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 1,
|
||||
|
||||
|
||||
.Class = 0x02,
|
||||
.SubClass = 0x02,
|
||||
.Protocol = 0x01,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.CDC_Functional_Header =
|
||||
.CDC_Functional_Header =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalHeader_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_Header,
|
||||
|
||||
|
||||
.CDCSpecification = VERSION_BCD(01.10),
|
||||
},
|
||||
|
||||
.CDC_Functional_ACM =
|
||||
.CDC_Functional_ACM =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalACM_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_ACM,
|
||||
|
||||
|
||||
.Capabilities = 0x06,
|
||||
},
|
||||
|
||||
.CDC_Functional_Union =
|
||||
|
||||
.CDC_Functional_Union =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_CDC_Descriptor_FunctionalUnion_t), .Type = DTYPE_CSInterface},
|
||||
.Subtype = CDC_DSUBTYPE_CSInterface_Union,
|
||||
|
||||
|
||||
.MasterInterfaceNumber = 0,
|
||||
.SlaveInterfaceNumber = 1,
|
||||
},
|
||||
|
||||
.CDC_NotificationEndpoint =
|
||||
.CDC_NotificationEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_NOTIFICATION_EPNUM),
|
||||
.Attributes = (EP_TYPE_INTERRUPT | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_NOTIFICATION_EPSIZE,
|
||||
.PollingIntervalMS = 0xFF
|
||||
},
|
||||
|
||||
.CDC_DCI_Interface =
|
||||
.CDC_DCI_Interface =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Interface_t), .Type = DTYPE_Interface},
|
||||
|
||||
.InterfaceNumber = 1,
|
||||
.AlternateSetting = 0,
|
||||
|
||||
|
||||
.TotalEndpoints = 2,
|
||||
|
||||
|
||||
.Class = 0x0A,
|
||||
.SubClass = 0x00,
|
||||
.Protocol = 0x00,
|
||||
|
||||
|
||||
.InterfaceStrIndex = NO_DESCRIPTOR
|
||||
},
|
||||
|
||||
.CDC_DataOutEndpoint =
|
||||
.CDC_DataOutEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | CDC_RX_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
.PollingIntervalMS = 0x00
|
||||
},
|
||||
|
||||
.CDC_DataInEndpoint =
|
||||
|
||||
.CDC_DataInEndpoint =
|
||||
{
|
||||
.Header = {.Size = sizeof(USB_Descriptor_Endpoint_t), .Type = DTYPE_Endpoint},
|
||||
|
||||
|
||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | CDC_TX_EPNUM),
|
||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||
.EndpointSize = CDC_TXRX_EPSIZE,
|
||||
|
@ -193,7 +193,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
|||
USB_Descriptor_String_t PROGMEM LanguageString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(1), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = {LANGUAGE_ID_ENG}
|
||||
};
|
||||
|
||||
|
@ -204,7 +204,7 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
|||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"Dean Camera"
|
||||
};
|
||||
|
||||
|
@ -215,7 +215,7 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
|||
USB_Descriptor_String_t PROGMEM ProductString =
|
||||
{
|
||||
.Header = {.Size = USB_STRING_LEN(23), .Type = DTYPE_String},
|
||||
|
||||
|
||||
.UnicodeString = L"LUFA USB-RS232 Adapter"
|
||||
};
|
||||
|
||||
|
@ -237,34 +237,35 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue,
|
|||
|
||||
switch (DescriptorType)
|
||||
{
|
||||
case DTYPE_Device:
|
||||
case DTYPE_Device:
|
||||
Address = &DeviceDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Device_t);
|
||||
break;
|
||||
case DTYPE_Configuration:
|
||||
case DTYPE_Configuration:
|
||||
Address = &ConfigurationDescriptor;
|
||||
Size = sizeof(USB_Descriptor_Configuration_t);
|
||||
break;
|
||||
case DTYPE_String:
|
||||
case DTYPE_String:
|
||||
switch (DescriptorNumber)
|
||||
{
|
||||
case 0x00:
|
||||
case 0x00:
|
||||
Address = &LanguageString;
|
||||
Size = pgm_read_byte(&LanguageString.Header.Size);
|
||||
break;
|
||||
case 0x01:
|
||||
case 0x01:
|
||||
Address = &ManufacturerString;
|
||||
Size = pgm_read_byte(&ManufacturerString.Header.Size);
|
||||
break;
|
||||
case 0x02:
|
||||
case 0x02:
|
||||
Address = &ProductString;
|
||||
Size = pgm_read_byte(&ProductString.Header.Size);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
*DescriptorAddress = Address;
|
||||
return Size;
|
||||
}
|
||||
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue