forked from mfulz_github/qmk_firmware
Corrections to the unfinished AVRISP Programmer project to allow AVRStudio to connect to it.
This commit is contained in:
parent
6d99486791
commit
083d3615d3
|
@ -32,6 +32,7 @@
|
||||||
* - Fixed USBtoSerial demos not reading in UDR1 when the USART receives data but the USB interface is not enumerated,
|
* - Fixed USBtoSerial demos not reading in UDR1 when the USART receives data but the USB interface is not enumerated,
|
||||||
* causing continuous USART receive interrupts
|
* causing continuous USART receive interrupts
|
||||||
* - Fixed misspelt event name in the Class driver USBtoSerial demo, preventing correct operation
|
* - Fixed misspelt event name in the Class driver USBtoSerial demo, preventing correct operation
|
||||||
|
* - Fixed invalid data being returned when a GetStatus request is issued in Device mode with an unhandled data recipient
|
||||||
*
|
*
|
||||||
*
|
*
|
||||||
* \section Sec_ChangeLog090810 Version 090810
|
* \section Sec_ChangeLog090810 Version 090810
|
||||||
|
|
|
@ -97,11 +97,6 @@ void EVENT_USB_Device_ConfigurationChanged(void)
|
||||||
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
LEDs_SetAllLEDs(LEDMASK_USB_ERROR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void EVENT_USB_Device_UnhandledControlRequest(void)
|
|
||||||
{
|
|
||||||
printf("CONTROL REQUEST\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void Process_AVRISP_Commands(void)
|
void Process_AVRISP_Commands(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -69,8 +69,7 @@
|
||||||
|
|
||||||
void EVENT_USB_Device_Connect(void);
|
void EVENT_USB_Device_Connect(void);
|
||||||
void EVENT_USB_Device_Disconnect(void);
|
void EVENT_USB_Device_Disconnect(void);
|
||||||
void EVENT_USB_Device_ConfigurationChanged(void);
|
void EVENT_USB_Device_ConfigurationChanged(void);
|
||||||
void EVENT_USB_Device_UnhandledControlRequest(void);
|
|
||||||
|
|
||||||
void Process_AVRISP_Commands(void);
|
void Process_AVRISP_Commands(void);
|
||||||
|
|
||||||
|
|
|
@ -109,7 +109,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | AVRISP_DATA_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_IN | AVRISP_DATA_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = AVRISP_DATA_EPSIZE,
|
.EndpointSize = AVRISP_DATA_EPSIZE,
|
||||||
.PollingIntervalMS = 0x0A
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
|
|
||||||
.DataOutEndpoint =
|
.DataOutEndpoint =
|
||||||
|
@ -119,7 +119,7 @@ USB_Descriptor_Configuration_t PROGMEM ConfigurationDescriptor =
|
||||||
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | AVRISP_DATA_EPNUM),
|
.EndpointAddress = (ENDPOINT_DESCRIPTOR_DIR_OUT | AVRISP_DATA_EPNUM),
|
||||||
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
.Attributes = (EP_TYPE_BULK | ENDPOINT_ATTR_NO_SYNC | ENDPOINT_USAGE_DATA),
|
||||||
.EndpointSize = AVRISP_DATA_EPSIZE,
|
.EndpointSize = AVRISP_DATA_EPSIZE,
|
||||||
.PollingIntervalMS = 0x0A
|
.PollingIntervalMS = 0x00
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -140,9 +140,9 @@ USB_Descriptor_String_t PROGMEM LanguageString =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(5), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"ATMEL"
|
.UnicodeString = L"Dean Camera"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
/** Product descriptor string. This is a Unicode string containing the product's details in human readable form,
|
||||||
|
@ -151,16 +151,16 @@ USB_Descriptor_String_t PROGMEM ManufacturerString =
|
||||||
*/
|
*/
|
||||||
USB_Descriptor_String_t PROGMEM ProductString =
|
USB_Descriptor_String_t PROGMEM ProductString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(11), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(33), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"AVRISP mkII"
|
.UnicodeString = L"LUFA AVRISP MkII Clone Programmer"
|
||||||
};
|
};
|
||||||
|
|
||||||
USB_Descriptor_String_t PROGMEM SerialString =
|
USB_Descriptor_String_t PROGMEM SerialString =
|
||||||
{
|
{
|
||||||
.Header = {.Size = USB_STRING_LEN(12), .Type = DTYPE_String},
|
.Header = {.Size = USB_STRING_LEN(13), .Type = DTYPE_String},
|
||||||
|
|
||||||
.UnicodeString = L"0000A0011794"
|
.UnicodeString = L"0000A00128255"
|
||||||
};
|
};
|
||||||
|
|
||||||
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
/** This function is called by the library when in device mode, and must be overridden (see library "USB Descriptors"
|
||||||
|
@ -176,7 +176,7 @@ uint16_t CALLBACK_USB_GetDescriptor(const uint16_t wValue, const uint8_t wIndex,
|
||||||
|
|
||||||
void* Address = NULL;
|
void* Address = NULL;
|
||||||
uint16_t Size = NO_DESCRIPTOR;
|
uint16_t Size = NO_DESCRIPTOR;
|
||||||
|
|
||||||
switch (DescriptorType)
|
switch (DescriptorType)
|
||||||
{
|
{
|
||||||
case DTYPE_Device:
|
case DTYPE_Device:
|
||||||
|
|
|
@ -64,27 +64,34 @@ void V2Protocol_ProcessCommand(void)
|
||||||
{
|
{
|
||||||
uint8_t V2Command = Endpoint_Read_Byte();
|
uint8_t V2Command = Endpoint_Read_Byte();
|
||||||
|
|
||||||
printf("COMMAND %d\r\n", V2Command);
|
|
||||||
|
|
||||||
switch (V2Command)
|
switch (V2Command)
|
||||||
{
|
{
|
||||||
case CMD_SIGN_ON:
|
case CMD_SIGN_ON:
|
||||||
V2Protocol_ProcessCmdSignOn();
|
V2Protocol_ProcessCmdSignOn();
|
||||||
break;
|
break;
|
||||||
case CMD_SET_PARAMETER:
|
case CMD_SET_PARAMETER:
|
||||||
V2Protocol_ProcessCmdSetParam();
|
|
||||||
break;
|
|
||||||
case CMD_GET_PARAMETER:
|
case CMD_GET_PARAMETER:
|
||||||
V2Protocol_ProcessCmdGetParam();
|
V2Protocol_ProcessCmdGetSetParam(V2Command);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
while (Endpoint_BytesInEndpoint() == AVRISP_DATA_EPSIZE)
|
||||||
|
{
|
||||||
|
Endpoint_ClearOUT();
|
||||||
|
while (!(Endpoint_IsOUTReceived()));
|
||||||
|
}
|
||||||
|
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||||
|
|
||||||
Endpoint_Write_Byte(STATUS_CMD_UNKNOWN);
|
Endpoint_Write_Byte(STATUS_CMD_UNKNOWN);
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
printf("COMMAND 0x%02x\r\n", V2Command);
|
||||||
|
|
||||||
|
Endpoint_WaitUntilReady();
|
||||||
|
|
||||||
/* Reset Endpoint direction to OUT ready for next command */
|
/* Reset Endpoint direction to OUT ready for next command */
|
||||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT);
|
Endpoint_SetEndpointDirection(ENDPOINT_DIR_OUT);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +111,8 @@ static void V2Protocol_ProcessCmdSignOn(void)
|
||||||
{
|
{
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||||
|
Endpoint_WaitUntilReady();
|
||||||
|
|
||||||
Endpoint_Write_Byte(CMD_SIGN_ON);
|
Endpoint_Write_Byte(CMD_SIGN_ON);
|
||||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||||
Endpoint_Write_Byte(PROGRAMMER_ID_LEN);
|
Endpoint_Write_Byte(PROGRAMMER_ID_LEN);
|
||||||
|
@ -112,22 +120,26 @@ static void V2Protocol_ProcessCmdSignOn(void)
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void V2Protocol_ProcessCmdSetParam(void)
|
static void V2Protocol_ProcessCmdGetSetParam(uint8_t V2Command)
|
||||||
{
|
{
|
||||||
uint8_t ParamID = Endpoint_Read_Byte();
|
uint8_t ParamID = Endpoint_Read_Byte();
|
||||||
uint8_t ParamValue = Endpoint_Read_Byte();
|
uint8_t ParamValue = Endpoint_Read_Byte();
|
||||||
|
|
||||||
ParameterItem_t* ParameterItem = V2Protocol_GetParameterItem(ParamID);
|
|
||||||
|
|
||||||
Endpoint_ClearOUT();
|
Endpoint_ClearOUT();
|
||||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
||||||
|
Endpoint_WaitUntilReady();
|
||||||
|
|
||||||
|
ParameterItem_t* ParameterItem = V2Protocol_GetParameterItem(ParamID);
|
||||||
|
|
||||||
if (ParameterItem != NULL)
|
if (ParameterItem != NULL)
|
||||||
{
|
{
|
||||||
eeprom_write_byte(&ParameterItem->ParameterValue, ParamValue);
|
Endpoint_Write_Byte(V2Command);
|
||||||
|
Endpoint_Write_Byte(STATUS_CMD_OK);
|
||||||
|
|
||||||
Endpoint_Write_Byte(CMD_SET_PARAMETER);
|
if (V2Command == CMD_SET_PARAMETER)
|
||||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
eeprom_write_byte(&ParameterItem->ParameterValue, ParamValue);
|
||||||
|
else
|
||||||
|
Endpoint_Write_Byte(eeprom_read_byte(&ParameterItem->ParameterValue));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -136,26 +148,3 @@ static void V2Protocol_ProcessCmdSetParam(void)
|
||||||
|
|
||||||
Endpoint_ClearIN();
|
Endpoint_ClearIN();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void V2Protocol_ProcessCmdGetParam(void)
|
|
||||||
{
|
|
||||||
uint8_t ParamID = Endpoint_Read_Byte();
|
|
||||||
|
|
||||||
ParameterItem_t* ParameterItem = V2Protocol_GetParameterItem(ParamID);
|
|
||||||
|
|
||||||
Endpoint_ClearOUT();
|
|
||||||
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
|
|
||||||
|
|
||||||
if (ParameterItem != NULL)
|
|
||||||
{
|
|
||||||
Endpoint_Write_Byte(CMD_GET_PARAMETER);
|
|
||||||
Endpoint_Write_Byte(STATUS_CMD_OK);
|
|
||||||
Endpoint_Write_Byte(eeprom_read_byte(&ParameterItem->ParameterValue));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Endpoint_Write_Byte(STATUS_CMD_FAILED);
|
|
||||||
}
|
|
||||||
|
|
||||||
Endpoint_ClearIN();
|
|
||||||
}
|
|
||||||
|
|
|
@ -40,7 +40,8 @@
|
||||||
#include <avr/io.h>
|
#include <avr/io.h>
|
||||||
|
|
||||||
#include <LUFA/Drivers/USB/USB.h>
|
#include <LUFA/Drivers/USB/USB.h>
|
||||||
|
|
||||||
|
#include "../Descriptors.h"
|
||||||
#include "V2ProtocolConstants.h"
|
#include "V2ProtocolConstants.h"
|
||||||
|
|
||||||
/* Macros: */
|
/* Macros: */
|
||||||
|
@ -60,8 +61,7 @@
|
||||||
#if defined(INCLUDE_FROM_V2PROTOCOL_C)
|
#if defined(INCLUDE_FROM_V2PROTOCOL_C)
|
||||||
static ParameterItem_t* V2Protocol_GetParameterItem(uint8_t ParamID);
|
static ParameterItem_t* V2Protocol_GetParameterItem(uint8_t ParamID);
|
||||||
static void V2Protocol_ProcessCmdSignOn(void);
|
static void V2Protocol_ProcessCmdSignOn(void);
|
||||||
static void V2Protocol_ProcessCmdSetParam(void);
|
static void V2Protocol_ProcessCmdGetSetParam(uint8_t V2Command);
|
||||||
static void V2Protocol_ProcessCmdGetParam(void);
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -119,7 +119,7 @@ OBJDIR = .
|
||||||
|
|
||||||
|
|
||||||
# Path to the LUFA library
|
# Path to the LUFA library
|
||||||
LUFA_PATH = ../../
|
LUFA_PATH = ../../../
|
||||||
|
|
||||||
|
|
||||||
# LUFA library compile-time options
|
# LUFA library compile-time options
|
||||||
|
|
Loading…
Reference in New Issue