forked from mfulz_github/qmk_firmware
Rename reserved members of all structs so that they are uniformly named across all demos/projects/bootloaders.
Added start of the Incomplete TMC demo's command parser code.
This commit is contained in:
parent
6e2920bc84
commit
cd39c38d5f
|
@ -64,12 +64,12 @@
|
|||
{
|
||||
uint8_t FirstInterfaceNumber;
|
||||
|
||||
uint8_t RESERVED;
|
||||
uint8_t Reserved;
|
||||
|
||||
uint8_t CompatibleID[8];
|
||||
uint8_t SubCompatibleID[8];
|
||||
|
||||
uint8_t RESERVED2[6];
|
||||
uint8_t Reserved2[6];
|
||||
} USB_OSCompatibleSection_t;
|
||||
|
||||
typedef struct
|
||||
|
@ -79,7 +79,7 @@
|
|||
uint16_t Index;
|
||||
uint8_t TotalSections;
|
||||
|
||||
uint8_t RESERVED[7];
|
||||
uint8_t Reserved[7];
|
||||
|
||||
USB_OSCompatibleSection_t SideshowCompatID;
|
||||
} USB_OSCompatibleIDDescriptor_t;
|
||||
|
|
|
@ -36,7 +36,7 @@
|
|||
*/
|
||||
TMC_Capabilities_t Capabilities =
|
||||
{
|
||||
.Status = TMC_REQUEST_STATUS_SUCCESS,
|
||||
.Status = TMC_STATUS_SUCCESS,
|
||||
.TMCVersion = VERSION_BCD(1.00),
|
||||
|
||||
.Interface =
|
||||
|
@ -53,19 +53,16 @@ TMC_Capabilities_t Capabilities =
|
|||
};
|
||||
|
||||
/** Current TMC control request that is being processed */
|
||||
uint8_t RequestInProgess = 0;
|
||||
uint8_t RequestInProgess = 0;
|
||||
|
||||
/** Stream callback abort flag for bulk IN data */
|
||||
bool IsTMCBulkINReset = false;
|
||||
bool IsTMCBulkINReset = false;
|
||||
|
||||
/** Stream callback abort flag for bulk OUT data */
|
||||
bool IsTMCBulkOUTReset = false;
|
||||
bool IsTMCBulkOUTReset = false;
|
||||
|
||||
/** Last used tag value for bulk IN transfers */
|
||||
uint8_t NextTransferINTag = 0;
|
||||
|
||||
/** Last used tag value for bulk IN transfers */
|
||||
uint8_t NextTransferOUTTag = 0;
|
||||
/** Last used tag value for data transfers */
|
||||
uint8_t CurrentTransferTag = 0;
|
||||
|
||||
|
||||
/** Main program entry point. This routine contains the overall program flow, including initial
|
||||
|
@ -145,7 +142,7 @@ void EVENT_USB_Device_ConfigurationChanged(void)
|
|||
*/
|
||||
void EVENT_USB_Device_UnhandledControlRequest(void)
|
||||
{
|
||||
uint8_t TMCRequestStatus = TMC_REQUEST_STATUS_SUCCESS;
|
||||
uint8_t TMCRequestStatus = TMC_STATUS_SUCCESS;
|
||||
|
||||
/* Process TMC specific control requests */
|
||||
switch (USB_ControlRequest.bRequest)
|
||||
|
@ -155,14 +152,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
/* Check that no split transaction is already in progress and the data OUT transfer tag is valid */
|
||||
/* Check that no split transaction is already in progress and the data transfer tag is valid */
|
||||
if (RequestInProgess != 0)
|
||||
{
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS;
|
||||
}
|
||||
else if (USB_ControlRequest.wValue != NextTransferOUTTag)
|
||||
else if (USB_ControlRequest.wValue != CurrentTransferTag)
|
||||
{
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_TRANSFER_NOT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_TRANSFER_NOT_IN_PROGRESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -188,9 +185,9 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
|
||||
/* Check that an ABORT BULK OUT transaction has been requested and that the request has completed */
|
||||
if (RequestInProgess != Req_InitiateAbortBulkOut)
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
else if (IsTMCBulkOUTReset)
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_PENDING;
|
||||
TMCRequestStatus = TMC_STATUS_PENDING;
|
||||
else
|
||||
RequestInProgess = 0;
|
||||
|
||||
|
@ -209,14 +206,14 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
{
|
||||
Endpoint_ClearSETUP();
|
||||
|
||||
/* Check that no split transaction is already in progress and the data IN transfer tag is valid */
|
||||
/* Check that no split transaction is already in progress and the data transfer tag is valid */
|
||||
if (RequestInProgess != 0)
|
||||
{
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_IN_PROGRESS;
|
||||
}
|
||||
else if (USB_ControlRequest.wValue != NextTransferINTag)
|
||||
else if (USB_ControlRequest.wValue != CurrentTransferTag)
|
||||
{
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_TRANSFER_NOT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_TRANSFER_NOT_IN_PROGRESS;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -229,7 +226,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
|
||||
/* Write the request response bytes */
|
||||
Endpoint_Write_Byte(TMCRequestStatus);
|
||||
Endpoint_Write_Byte(NextTransferINTag);
|
||||
Endpoint_Write_Byte(CurrentTransferTag);
|
||||
|
||||
Endpoint_ClearIN();
|
||||
Endpoint_ClearStatusStage();
|
||||
|
@ -243,9 +240,9 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
|
||||
/* Check that an ABORT BULK IN transaction has been requested and that the request has completed */
|
||||
if (RequestInProgess != Req_InitiateAbortBulkIn)
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
else if (IsTMCBulkINReset)
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_PENDING;
|
||||
TMCRequestStatus = TMC_STATUS_PENDING;
|
||||
else
|
||||
RequestInProgess = 0;
|
||||
|
||||
|
@ -267,7 +264,7 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
/* Check that no split transaction is already in progress */
|
||||
if (RequestInProgess != 0)
|
||||
{
|
||||
Endpoint_Write_Byte(TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS);
|
||||
Endpoint_Write_Byte(TMC_STATUS_SPLIT_IN_PROGRESS);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -294,9 +291,9 @@ void EVENT_USB_Device_UnhandledControlRequest(void)
|
|||
|
||||
/* Check that a CLEAR transaction has been requested and that the request has completed */
|
||||
if (RequestInProgess != Req_InitiateClear)
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
TMCRequestStatus = TMC_STATUS_SPLIT_NOT_IN_PROGRESS;
|
||||
else if (IsTMCBulkINReset || IsTMCBulkOUTReset)
|
||||
TMCRequestStatus = TMC_REQUEST_STATUS_PENDING;
|
||||
TMCRequestStatus = TMC_STATUS_PENDING;
|
||||
else
|
||||
RequestInProgess = 0;
|
||||
|
||||
|
@ -337,8 +334,26 @@ void TMC_Task(void)
|
|||
|
||||
if (Endpoint_IsOUTReceived())
|
||||
{
|
||||
// TEMP - Indicate data received
|
||||
LEDs_SetAllLEDs(LEDS_ALL_LEDS);
|
||||
TMC_MessageHeader_t MessageHeader;
|
||||
|
||||
Endpoint_Read_Stream_LE(&MessageHeader, sizeof(MessageHeader), StreamCallback_AbortOUTOnRequest);
|
||||
CurrentTransferTag = MessageHeader.Tag;
|
||||
|
||||
switch (MessageHeader.MessageID)
|
||||
{
|
||||
case TMC_MESSAGEID_DEV_DEP_MSG_OUT:
|
||||
|
||||
break;
|
||||
case TMC_MESSAGEID_DEV_DEP_MSG_IN:
|
||||
|
||||
break;
|
||||
case TMC_MESSAGEID_DEV_VENDOR_OUT:
|
||||
|
||||
break;
|
||||
case TMC_MESSAGEID_DEV_VENDOR_IN:
|
||||
break;
|
||||
}
|
||||
|
||||
Endpoint_ClearOUT();
|
||||
}
|
||||
|
||||
|
|
|
@ -65,18 +65,23 @@
|
|||
#define Req_GetCapabilities 0x07
|
||||
#define Req_IndicatorPulse 0x40
|
||||
|
||||
#define TMC_REQUEST_STATUS_SUCCESS 0x01
|
||||
#define TMC_REQUEST_STATUS_PENDING 0x02
|
||||
#define TMC_REQUEST_STATUS_FAILED 0x80
|
||||
#define TMC_REQUEST_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
|
||||
#define TMC_REQUEST_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
|
||||
#define TMC_REQUEST_STATUS_SPLIT_IN_PROGRESS 0x83
|
||||
#define TMC_STATUS_SUCCESS 0x01
|
||||
#define TMC_STATUS_PENDING 0x02
|
||||
#define TMC_STATUS_FAILED 0x80
|
||||
#define TMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
|
||||
#define TMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
|
||||
#define TMC_STATUS_SPLIT_IN_PROGRESS 0x83
|
||||
|
||||
#define TMC_MESSAGEID_DEV_DEP_MSG_OUT 0x01
|
||||
#define TMC_MESSAGEID_DEV_DEP_MSG_IN 0x02
|
||||
#define TMC_MESSAGEID_DEV_VENDOR_OUT 0x7E
|
||||
#define TMC_MESSAGEID_DEV_VENDOR_IN 0x7F
|
||||
|
||||
/* Type Defines */
|
||||
typedef struct
|
||||
{
|
||||
uint8_t Status;
|
||||
uint8_t _RESERVED1;
|
||||
uint8_t Reserved;
|
||||
|
||||
uint16_t TMCVersion;
|
||||
|
||||
|
@ -85,18 +90,26 @@
|
|||
unsigned char ListenOnly : 1;
|
||||
unsigned char TalkOnly : 1;
|
||||
unsigned char PulseIndicateSupported : 1;
|
||||
unsigned char _RESERVED : 5;
|
||||
unsigned char Reserved : 5;
|
||||
} Interface;
|
||||
|
||||
struct
|
||||
{
|
||||
unsigned char SupportsAbortINOnMatch : 1;
|
||||
unsigned char _RESERVED : 7;
|
||||
unsigned char Reserved : 7;
|
||||
} Device;
|
||||
|
||||
uint8_t _RESERVED2[6];
|
||||
uint8_t _RESERVED3[12];
|
||||
uint8_t Reserved2[6];
|
||||
uint8_t Reserved3[12];
|
||||
} TMC_Capabilities_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8_t MessageID;
|
||||
uint8_t Tag;
|
||||
uint8_t InverseTag;
|
||||
uint8_t Reserved;
|
||||
} TMC_MessageHeader_t;
|
||||
|
||||
/* Function Prototypes: */
|
||||
void SetupHardware(void);
|
||||
|
|
|
@ -83,23 +83,23 @@
|
|||
unsigned char DeviceType : 5;
|
||||
unsigned char PeripheralQualifier : 3;
|
||||
|
||||
unsigned char _RESERVED1 : 7;
|
||||
unsigned char Reserved : 7;
|
||||
unsigned char Removable : 1;
|
||||
|
||||
uint8_t Version;
|
||||
|
||||
unsigned char ResponseDataFormat : 4;
|
||||
unsigned char _RESERVED2 : 1;
|
||||
unsigned char Reserved2 : 1;
|
||||
unsigned char NormACA : 1;
|
||||
unsigned char TrmTsk : 1;
|
||||
unsigned char AERC : 1;
|
||||
|
||||
uint8_t AdditionalLength;
|
||||
uint8_t _RESERVED3[2];
|
||||
uint8_t Reserved3[2];
|
||||
|
||||
unsigned char SoftReset : 1;
|
||||
unsigned char CmdQue : 1;
|
||||
unsigned char _RESERVED4 : 1;
|
||||
unsigned char Reserved4 : 1;
|
||||
unsigned char Linked : 1;
|
||||
unsigned char Sync : 1;
|
||||
unsigned char WideBus16Bit : 1;
|
||||
|
@ -121,7 +121,7 @@
|
|||
uint8_t SegmentNumber;
|
||||
|
||||
unsigned char SenseKey : 4;
|
||||
unsigned char _RESERVED1 : 1;
|
||||
unsigned char Reserved : 1;
|
||||
unsigned char ILI : 1;
|
||||
unsigned char EOM : 1;
|
||||
unsigned char FileMark : 1;
|
||||
|
|
|
@ -219,7 +219,7 @@
|
|||
uint32_t SequenceNumber; /**< Data sequence number of the packet */
|
||||
uint32_t AcknowledgmentNumber; /**< Data acknowledgment number of the packet */
|
||||
|
||||
unsigned char Reserved : 4; /**< Reserved, must be all 0 */
|
||||
unsigned char Reserved : 4; /**< Reserved, must be all 0 */
|
||||
unsigned char DataOffset : 4; /**< Offset of the data from the start of the header, in 4 byte chunks */
|
||||
uint8_t Flags; /**< TCP packet flags */
|
||||
uint16_t WindowSize; /**< Current data window size (bytes remaining in reception buffer) */
|
||||
|
|
|
@ -465,7 +465,7 @@ uint8_t MassStore_ReadDeviceBlock(const uint8_t LUNIndex,
|
|||
(BlockAddress >> 16),
|
||||
(BlockAddress >> 8),
|
||||
(BlockAddress & 0xFF), // LSB of Block Address
|
||||
0x00, // Unused (reserved)
|
||||
0x00, // Reserved
|
||||
0x00, // MSB of Total Blocks to Read
|
||||
Blocks, // LSB of Total Blocks to Read
|
||||
0x00 // Unused (control)
|
||||
|
|
|
@ -113,7 +113,7 @@
|
|||
uint8_t SegmentNumber;
|
||||
|
||||
unsigned char SenseKey : 4;
|
||||
unsigned char _RESERVED1 : 1;
|
||||
unsigned char Reserved : 1;
|
||||
unsigned char ILI : 1;
|
||||
unsigned char EOM : 1;
|
||||
unsigned char FileMark : 1;
|
||||
|
@ -136,23 +136,23 @@
|
|||
unsigned char DeviceType : 5;
|
||||
unsigned char PeripheralQualifier : 3;
|
||||
|
||||
unsigned char _RESERVED1 : 7;
|
||||
unsigned char Reserved : 7;
|
||||
unsigned char Removable : 1;
|
||||
|
||||
uint8_t Version;
|
||||
|
||||
unsigned char ResponseDataFormat : 4;
|
||||
unsigned char _RESERVED2 : 1;
|
||||
unsigned char Reserved2 : 1;
|
||||
unsigned char NormACA : 1;
|
||||
unsigned char TrmTsk : 1;
|
||||
unsigned char AERC : 1;
|
||||
|
||||
uint8_t AdditionalLength;
|
||||
uint8_t _RESERVED3[2];
|
||||
uint8_t Reserved3[2];
|
||||
|
||||
unsigned char SoftReset : 1;
|
||||
unsigned char CmdQue : 1;
|
||||
unsigned char _RESERVED4 : 1;
|
||||
unsigned char Reserved4 : 1;
|
||||
unsigned char Linked : 1;
|
||||
unsigned char Sync : 1;
|
||||
unsigned char WideBus16Bit : 1;
|
||||
|
|
|
@ -246,7 +246,7 @@
|
|||
uint8_t SegmentNumber;
|
||||
|
||||
unsigned char SenseKey : 4;
|
||||
unsigned char _RESERVED1 : 1;
|
||||
unsigned char Reserved : 1;
|
||||
unsigned char ILI : 1;
|
||||
unsigned char EOM : 1;
|
||||
unsigned char FileMark : 1;
|
||||
|
@ -273,23 +273,23 @@
|
|||
unsigned char DeviceType : 5;
|
||||
unsigned char PeripheralQualifier : 3;
|
||||
|
||||
unsigned char _RESERVED1 : 7;
|
||||
unsigned char Reserved : 7;
|
||||
unsigned char Removable : 1;
|
||||
|
||||
uint8_t Version;
|
||||
|
||||
unsigned char ResponseDataFormat : 4;
|
||||
unsigned char _RESERVED2 : 1;
|
||||
unsigned char Reserved2 : 1;
|
||||
unsigned char NormACA : 1;
|
||||
unsigned char TrmTsk : 1;
|
||||
unsigned char AERC : 1;
|
||||
|
||||
uint8_t AdditionalLength;
|
||||
uint8_t _RESERVED3[2];
|
||||
uint8_t Reserved3[2];
|
||||
|
||||
unsigned char SoftReset : 1;
|
||||
unsigned char CmdQue : 1;
|
||||
unsigned char _RESERVED4 : 1;
|
||||
unsigned char Reserved4 : 1;
|
||||
unsigned char Linked : 1;
|
||||
unsigned char Sync : 1;
|
||||
unsigned char WideBus16Bit : 1;
|
||||
|
|
|
@ -546,7 +546,7 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,
|
|||
(BlockAddress >> 16),
|
||||
(BlockAddress >> 8),
|
||||
(BlockAddress & 0xFF), // LSB of Block Address
|
||||
0x00, // Unused (reserved)
|
||||
0x00, // Reserved
|
||||
0x00, // MSB of Total Blocks to Read
|
||||
Blocks, // LSB of Total Blocks to Read
|
||||
0x00 // Unused (control)
|
||||
|
@ -590,7 +590,7 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo
|
|||
(BlockAddress >> 16),
|
||||
(BlockAddress >> 8),
|
||||
(BlockAddress & 0xFF), // LSB of Block Address
|
||||
0x00, // Unused (reserved)
|
||||
0x00, // Reserved
|
||||
0x00, // MSB of Total Blocks to Write
|
||||
Blocks, // LSB of Total Blocks to Write
|
||||
0x00 // Unused (control)
|
||||
|
|
|
@ -25,7 +25,7 @@
|
|||
* -# Multiple-Report HID device
|
||||
* -# Device/Host USB bridge
|
||||
* -# Alternative (USB-IF endorsed) USB-CDC Ethernet Class
|
||||
* -# USB Test and Measurement Class
|
||||
* -# Finish Test and Measurement Class demo
|
||||
* -# Finish BluetoothHost demo
|
||||
* -# Finish SideShow demo
|
||||
* -# Finish StandaloneProgrammer project
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
{
|
||||
unsigned int Min : 4;
|
||||
unsigned int TenMin : 3;
|
||||
unsigned int _RESERVED : 1;
|
||||
unsigned int Reserved : 1;
|
||||
} Fields;
|
||||
|
||||
uint8_t IntVal;
|
||||
|
@ -47,7 +47,7 @@
|
|||
unsigned int Hour : 4;
|
||||
unsigned int TenHour : 2;
|
||||
unsigned int TwelveHourMode : 1;
|
||||
unsigned int _RESERVED : 1;
|
||||
unsigned int Reserved : 1;
|
||||
} Fields;
|
||||
|
||||
uint8_t IntVal;
|
||||
|
@ -62,7 +62,7 @@
|
|||
{
|
||||
unsigned int Day : 4;
|
||||
unsigned int TenDay : 2;
|
||||
unsigned int _RESERVED : 2;
|
||||
unsigned int Reserved : 2;
|
||||
} Fields;
|
||||
|
||||
uint8_t IntVal;
|
||||
|
@ -74,7 +74,7 @@
|
|||
{
|
||||
unsigned int Month : 4;
|
||||
unsigned int TenMonth : 1;
|
||||
unsigned int _RESERVED : 3;
|
||||
unsigned int Reserved : 3;
|
||||
} Fields;
|
||||
|
||||
uint8_t IntVal;
|
||||
|
|
Loading…
Reference in New Issue