aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c10
-rw-r--r--Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c20
-rw-r--r--Demos/Host/LowLevel/PrinterHost/PrinterHost.c10
-rw-r--r--LUFA/DriverStubs/Joystick.h2
-rw-r--r--LUFA/Drivers/Board/BUMBLEB/Joystick.h2
-rw-r--r--LUFA/Drivers/Board/EVK527/Joystick.h2
-rw-r--r--LUFA/Drivers/Board/STK525/Joystick.h2
-rw-r--r--LUFA/Drivers/Board/STK526/Joystick.h2
-rw-r--r--LUFA/Drivers/Board/USBKEY/Joystick.h2
-rw-r--r--LUFA/Drivers/USB/Class/Host/Printer.c40
-rw-r--r--LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h2
-rw-r--r--LUFA/Drivers/USB/LowLevel/Host.c20
-rw-r--r--LUFA/Drivers/USB/LowLevel/Pipe.h2
-rw-r--r--Projects/AVRISP/Lib/PDIProtocol.c46
-rw-r--r--Projects/AVRISP/Lib/PDITarget.c2
-rw-r--r--Projects/AVRISP/Lib/PDITarget.h23
16 files changed, 121 insertions, 66 deletions
diff --git a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c
index 3b8bcde89..ffec03157 100644
--- a/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c
+++ b/Demos/Host/Incomplete/BluetoothHost/Lib/BluetoothHCICommands.c
@@ -42,11 +42,11 @@ static uint8_t Bluetooth_SendHCICommand(void* Parameters, uint8_t ParamLength)
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_DEVICE),
- bRequest: 0,
- wValue: 0,
- wIndex: 0,
- wLength: sizeof(CommandBuffer)
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_DEVICE),
+ .bRequest = 0,
+ .wValue = 0,
+ .wIndex = 0,
+ .wLength = sizeof(CommandBuffer)
};
memset(CommandBuffer, 0x00, sizeof(CommandBuffer));
diff --git a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c
index a9f41ba64..be0d57b10 100644
--- a/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c
+++ b/Demos/Host/LowLevel/PrinterHost/Lib/PrinterCommands.c
@@ -81,11 +81,11 @@ uint8_t Printer_GetDeviceID(char* DeviceIDString, uint16_t BufferSize)
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
- bRequest: REQ_GetDeviceID,
- wValue: 0,
- wIndex: 0,
- wLength: sizeof(DeviceIDStringLength),
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
+ .bRequest = REQ_GetDeviceID,
+ .wValue = 0,
+ .wIndex = 0,
+ .wLength = sizeof(DeviceIDStringLength),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
@@ -149,11 +149,11 @@ uint8_t Printer_SoftReset(void)
{
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
- bRequest: REQ_SoftReset,
- wValue: 0,
- wIndex: 0,
- wLength: 0,
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
+ .bRequest = REQ_SoftReset,
+ .wValue = 0,
+ .wIndex = 0,
+ .wLength = 0,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
diff --git a/Demos/Host/LowLevel/PrinterHost/PrinterHost.c b/Demos/Host/LowLevel/PrinterHost/PrinterHost.c
index 861325a4b..7c1876fe0 100644
--- a/Demos/Host/LowLevel/PrinterHost/PrinterHost.c
+++ b/Demos/Host/LowLevel/PrinterHost/PrinterHost.c
@@ -174,11 +174,11 @@ void USB_Printer_Host(void)
{
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
- bRequest: REQ_SetInterface,
- wValue: PrinterAltSetting,
- wIndex: PrinterInterfaceNumber,
- wLength: 0,
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
+ .bRequest = REQ_SetInterface,
+ .wValue = PrinterAltSetting,
+ .wIndex = PrinterInterfaceNumber,
+ .wLength = 0,
};
if ((ErrorCode = USB_Host_SendControlRequest(NULL)) != HOST_SENDCONTROL_Successful)
diff --git a/LUFA/DriverStubs/Joystick.h b/LUFA/DriverStubs/Joystick.h
index a09f8db9b..ce193f55b 100644
--- a/LUFA/DriverStubs/Joystick.h
+++ b/LUFA/DriverStubs/Joystick.h
@@ -80,7 +80,7 @@
static inline void Joystick_Init(void)
{
// TODO: Initialize joystick port pins as inputs with pull-ups
- };
+ }
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
diff --git a/LUFA/Drivers/Board/BUMBLEB/Joystick.h b/LUFA/Drivers/Board/BUMBLEB/Joystick.h
index edcf5320f..8723771e5 100644
--- a/LUFA/Drivers/Board/BUMBLEB/Joystick.h
+++ b/LUFA/Drivers/Board/BUMBLEB/Joystick.h
@@ -90,7 +90,7 @@
{
DDRD &= ~JOY_MASK;
PORTD |= JOY_MASK;
- };
+ }
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
diff --git a/LUFA/Drivers/Board/EVK527/Joystick.h b/LUFA/Drivers/Board/EVK527/Joystick.h
index ae90c2be6..c73c0ad9b 100644
--- a/LUFA/Drivers/Board/EVK527/Joystick.h
+++ b/LUFA/Drivers/Board/EVK527/Joystick.h
@@ -93,7 +93,7 @@
PORTF |= JOY_FMASK;
PORTC |= JOY_CMASK;
- };
+ }
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
diff --git a/LUFA/Drivers/Board/STK525/Joystick.h b/LUFA/Drivers/Board/STK525/Joystick.h
index b74655eca..2de765522 100644
--- a/LUFA/Drivers/Board/STK525/Joystick.h
+++ b/LUFA/Drivers/Board/STK525/Joystick.h
@@ -93,7 +93,7 @@
PORTB |= JOY_BMASK;
PORTE |= JOY_EMASK;
- };
+ }
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
diff --git a/LUFA/Drivers/Board/STK526/Joystick.h b/LUFA/Drivers/Board/STK526/Joystick.h
index c15b21284..3b021dea8 100644
--- a/LUFA/Drivers/Board/STK526/Joystick.h
+++ b/LUFA/Drivers/Board/STK526/Joystick.h
@@ -90,7 +90,7 @@
DDRB &= ~JOY_BMASK;
PORTB |= JOY_BMASK;
- };
+ }
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
diff --git a/LUFA/Drivers/Board/USBKEY/Joystick.h b/LUFA/Drivers/Board/USBKEY/Joystick.h
index 332dd56a3..7bc140dbb 100644
--- a/LUFA/Drivers/Board/USBKEY/Joystick.h
+++ b/LUFA/Drivers/Board/USBKEY/Joystick.h
@@ -93,7 +93,7 @@
PORTB |= JOY_BMASK;
PORTE |= JOY_EMASK;
- };
+ }
static inline uint8_t Joystick_GetStatus(void) ATTR_WARN_UNUSED_RESULT;
static inline uint8_t Joystick_GetStatus(void)
diff --git a/LUFA/Drivers/USB/Class/Host/Printer.c b/LUFA/Drivers/USB/Class/Host/Printer.c
index d85ac15cf..cb9bd6ec9 100644
--- a/LUFA/Drivers/USB/Class/Host/Printer.c
+++ b/LUFA/Drivers/USB/Class/Host/Printer.c
@@ -135,11 +135,11 @@ uint8_t PRNT_Host_SetBidirectionalMode(USB_ClassInfo_PRNT_Host_t* const PRNTInte
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
- bRequest: REQ_SetInterface,
- wValue: PRNTInterfaceInfo->State.AlternateSetting,
- wIndex: PRNTInterfaceInfo->State.InterfaceNumber,
- wLength: 0,
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_STANDARD | REQREC_INTERFACE),
+ .bRequest = REQ_SetInterface,
+ .wValue = PRNTInterfaceInfo->State.AlternateSetting,
+ .wIndex = PRNTInterfaceInfo->State.InterfaceNumber,
+ .wLength = 0,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
@@ -155,11 +155,11 @@ uint8_t PRNT_Host_GetPortStatus(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceIn
{
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
- bRequest: REQ_GetPortStatus,
- wValue: 0,
- wIndex: PRNTInterfaceInfo->State.InterfaceNumber,
- wLength: sizeof(uint8_t),
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
+ .bRequest = REQ_GetPortStatus,
+ .wValue = 0,
+ .wIndex = PRNTInterfaceInfo->State.InterfaceNumber,
+ .wLength = sizeof(uint8_t),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
@@ -171,11 +171,11 @@ uint8_t PRNT_Host_SoftReset(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo)
{
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
- bRequest: REQ_SoftReset,
- wValue: 0,
- wIndex: PRNTInterfaceInfo->State.InterfaceNumber,
- wLength: 0,
+ .bmRequestType = (REQDIR_HOSTTODEVICE | REQTYPE_CLASS | REQREC_INTERFACE),
+ .bRequest = REQ_SoftReset,
+ .wValue = 0,
+ .wIndex = PRNTInterfaceInfo->State.InterfaceNumber,
+ .wLength = 0,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
@@ -215,11 +215,11 @@ uint8_t PRNT_Host_GetDeviceID(USB_ClassInfo_PRNT_Host_t* const PRNTInterfaceInfo
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
- bRequest: REQ_GetDeviceID,
- wValue: 0,
- wIndex: PRNTInterfaceInfo->State.InterfaceNumber,
- wLength: sizeof(DeviceIDStringLength),
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_CLASS | REQREC_INTERFACE),
+ .bRequest = REQ_GetDeviceID,
+ .wValue = 0,
+ .wIndex = PRNTInterfaceInfo->State.InterfaceNumber,
+ .wLength = sizeof(DeviceIDStringLength),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
diff --git a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
index 84a6f0cf0..1b73ec34d 100644
--- a/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
+++ b/LUFA/Drivers/USB/HighLevel/ConfigDescriptor.h
@@ -263,7 +263,7 @@
{
uint16_t CurrDescriptorSize = DESCRIPTOR_CAST(*CurrConfigLoc, USB_Descriptor_Header_t).Size;
- *CurrConfigLoc += CurrDescriptorSize;
+ *((uint8_t**)CurrConfigLoc) += CurrDescriptorSize;
*BytesRem -= CurrDescriptorSize;
}
diff --git a/LUFA/Drivers/USB/LowLevel/Host.c b/LUFA/Drivers/USB/LowLevel/Host.c
index e10d34781..6d425b2d5 100644
--- a/LUFA/Drivers/USB/LowLevel/Host.c
+++ b/LUFA/Drivers/USB/LowLevel/Host.c
@@ -296,11 +296,11 @@ uint8_t USB_Host_GetDeviceDescriptor(void* const DeviceDescriptorPtr)
{
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- bRequest: REQ_GetDescriptor,
- wValue: (DTYPE_Device << 8),
- wIndex: 0,
- wLength: sizeof(USB_Descriptor_Device_t),
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_GetDescriptor,
+ .wValue = (DTYPE_Device << 8),
+ .wIndex = 0,
+ .wLength = sizeof(USB_Descriptor_Device_t),
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
@@ -312,11 +312,11 @@ uint8_t USB_Host_GetDeviceStringDescriptor(uint8_t Index, void* const Buffer, ui
{
USB_ControlRequest = (USB_Request_Header_t)
{
- bmRequestType: (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
- bRequest: REQ_GetDescriptor,
- wValue: (DTYPE_String << 8) | Index,
- wIndex: 0,
- wLength: BufferLength,
+ .bmRequestType = (REQDIR_DEVICETOHOST | REQTYPE_STANDARD | REQREC_DEVICE),
+ .bRequest = REQ_GetDescriptor,
+ .wValue = (DTYPE_String << 8) | Index,
+ .wIndex = 0,
+ .wLength = BufferLength,
};
Pipe_SelectPipe(PIPE_CONTROLPIPE);
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h
index 97257d706..120576794 100644
--- a/LUFA/Drivers/USB/LowLevel/Pipe.h
+++ b/LUFA/Drivers/USB/LowLevel/Pipe.h
@@ -1032,7 +1032,7 @@
return (4 << EPSIZE0);
else
return (5 << EPSIZE0);
- };
+ }
#endif
diff --git a/Projects/AVRISP/Lib/PDIProtocol.c b/Projects/AVRISP/Lib/PDIProtocol.c
index 776934311..ecd2fe9c3 100644
--- a/Projects/AVRISP/Lib/PDIProtocol.c
+++ b/Projects/AVRISP/Lib/PDIProtocol.c
@@ -218,7 +218,14 @@ static void PDIProtocol_ReadMemory(void)
Endpoint_ClearOUT();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
- // TODO: Send read command here via PDI protocol
+ if (ReadMemory_XPROG_Params.MemoryType == XPRG_MEM_TYPE_USERSIG)
+ {
+ PDITarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_1BYTE << 2));
+ PDITarget_SendAddress(DATAMEM_BASE | DATAMEM_NVM_CMD);
+ PDITarget_SendByte(NVM_CMD_READUSERSIG);
+
+
+ }
Endpoint_Write_Byte(CMD_XPROG);
Endpoint_Write_Byte(XPRG_CMD_READ_MEM);
@@ -233,15 +240,46 @@ static void PDIProtocol_ReadMemory(void)
static void PDIProtocol_ReadCRC(void)
{
uint8_t ReturnStatus = XPRG_ERR_OK;
-
- uint8_t CRCType = Endpoint_Read_Byte();
+ struct
+ {
+ uint8_t CRCType;
+ } ReadCRC_XPROG_Params;
+
+ Endpoint_Read_Stream_LE(&ReadCRC_XPROG_Params, sizeof(ReadCRC_XPROG_Params));
Endpoint_ClearOUT();
Endpoint_SetEndpointDirection(ENDPOINT_DIR_IN);
uint32_t MemoryCRC = 0;
+ uint8_t CRCReadCommand;
+
+ if (ReadCRC_XPROG_Params.CRCType == XPRG_CRC_APP)
+ CRCReadCommand = NVM_CMD_APPCRC;
+ else if (ReadCRC_XPROG_Params.CRCType == XPRG_CRC_BOOT)
+ CRCReadCommand = NVM_CMD_BOOTCRC;
+ else
+ CRCReadCommand = NVM_CMD_FLASHCRC;
+
+ /* Set the NVM command to the correct CRC read command */
+ PDITarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_1BYTE << 2));
+ PDITarget_SendAddress(DATAMEM_BASE | DATAMEM_NVM_CMD);
+ PDITarget_SendByte(CRCReadCommand);
+
+ /* Set CMDEX bit in NVM CTRLA register to start the CRC generation */
+ PDITarget_SendByte(PDI_CMD_STS | (PDI_DATSIZE_1BYTE << 2));
+ PDITarget_SendAddress(DATAMEM_BASE | DATAMEM_NVM_CTRLA);
+ PDITarget_SendByte(1 << 0);
+
+ /* Wait until the NVM bus and controller is no longer busy */
+ PDITarget_WaitWhileNVMBusBusy();
+ PDITarget_WaitWhileNVMControllerBusy();
- // TODO: Read device CRC for desired memory via PDI protocol
+ /* Read the three byte generated CRC value */
+ PDITarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_3BYTES << 2));
+ PDITarget_SendAddress(DATAMEM_BASE | DATAMEM_NVM_DAT0);
+ MemoryCRC = PDITarget_ReceiveByte();
+ MemoryCRC |= ((uint16_t)PDITarget_ReceiveByte() << 8);
+ MemoryCRC |= ((uint32_t)PDITarget_ReceiveByte() << 16);
Endpoint_Write_Byte(CMD_XPROG);
Endpoint_Write_Byte(XPRG_CMD_CRC);
diff --git a/Projects/AVRISP/Lib/PDITarget.c b/Projects/AVRISP/Lib/PDITarget.c
index b56fe60b6..7fa48e6aa 100644
--- a/Projects/AVRISP/Lib/PDITarget.c
+++ b/Projects/AVRISP/Lib/PDITarget.c
@@ -304,7 +304,7 @@ void PDITarget_WaitWhileNVMControllerBusy(void)
for (;;)
{
PDITarget_SendByte(PDI_CMD_LDS | (PDI_DATSIZE_1BYTE << 2));
- PDITarget_SendAddress(DATAMEM_BASE | DATAMEM_NVM_BASE | 0x0F);
+ PDITarget_SendAddress(DATAMEM_BASE | DATAMEM_NVM_STATUS);
if (!(PDITarget_ReceiveByte() & (1 << 7)))
return;
diff --git a/Projects/AVRISP/Lib/PDITarget.h b/Projects/AVRISP/Lib/PDITarget.h
index 85f627a6a..41cc1fbd7 100644
--- a/Projects/AVRISP/Lib/PDITarget.h
+++ b/Projects/AVRISP/Lib/PDITarget.h
@@ -104,6 +104,23 @@
#define USER_SIGNATURE_BASE 0x008E0400
#define DATAMEM_NVM_BASE 0x01C0
+ #define DATAMEM_NVM_ADDR0 (DATAMEM_NVM_BASE | 0x00)
+ #define DATAMEM_NVM_ADDR1 (DATAMEM_NVM_BASE | 0x01)
+ #define DATAMEM_NVM_ADDR2 (DATAMEM_NVM_BASE | 0x02)
+ #define DATAMEM_NVM_DAT0 (DATAMEM_NVM_BASE | 0x04)
+ #define DATAMEM_NVM_DAT1 (DATAMEM_NVM_BASE | 0x05)
+ #define DATAMEM_NVM_DAT2 (DATAMEM_NVM_BASE | 0x06)
+ #define DATAMEM_NVM_CMD (DATAMEM_NVM_BASE | 0x0A)
+ #define DATAMEM_NVM_CTRLA (DATAMEM_NVM_BASE | 0x0B)
+ #define DATAMEM_NVM_CTRLB (DATAMEM_NVM_BASE | 0x0C)
+ #define DATAMEM_NVM_INTCTRL (DATAMEM_NVM_BASE | 0x0D)
+ #define DATAMEM_NVM_STATUS (DATAMEM_NVM_BASE | 0x0F)
+ #define DATAMEM_NVM_LOCKBITS (DATAMEM_NVM_BASE | 0x10)
+
+ #define NVM_CMD_APPCRC 0x38
+ #define NVM_CMD_BOOTCRC 0x39
+ #define NVM_CMD_FLASHCRC 0x78
+ #define NVM_CMD_READUSERSIG 0x03
/* Function Prototypes: */
void PDITarget_EnableTargetPDI(void);
@@ -112,8 +129,8 @@
uint8_t PDITarget_ReceiveByte(void);
void PDITarget_SendBreak(void);
- void PDITarget_SendAddress(uint32_t Address);
- bool PDITarget_WaitWhileNVMBusBusy(void);
- void PDITarget_WaitWhileNVMControllerBusy(void);
+ void PDITarget_SendAddress(uint32_t Address);
+ bool PDITarget_WaitWhileNVMBusBusy(void);
+ void PDITarget_WaitWhileNVMControllerBusy(void);
#endif