+bool ReadTMCHeader(TMC_MessageHeader_t* const MessageHeader)\r
+{\r
+ /* Select the Data Out endpoint */\r
+ Endpoint_SelectEndpoint(TMC_OUT_EPNUM);\r
+ \r
+ /* Abort if no command has been sent from the host */\r
+ if (!(Endpoint_IsOUTReceived()))\r
+ return false;\r
+ \r
+ /* Read in the header of the command from the host */\r
+ Endpoint_Read_Stream_LE(MessageHeader, sizeof(TMC_MessageHeader_t), StreamCallback_AbortOUTOnRequest);\r
+\r
+ /* Store the new command tag value for later use */\r
+ CurrentTransferTag = MessageHeader->Tag;\r
+ \r
+ /* Indicate if the command has been aborted or not */\r
+ return !IsTMCBulkOUTReset;\r
+}\r
+\r
+bool WriteTMCHeader(TMC_MessageHeader_t* const MessageHeader)\r
+{\r
+ /* Compute the next transfer tag value, must be between 1 and 254 */\r
+ if (++CurrentTransferTag == 0xFF)\r
+ CurrentTransferTag = 1;\r
+\r
+ /* Set the message tag of the command header */\r
+ MessageHeader->Tag = CurrentTransferTag;\r
+ MessageHeader->InverseTag = ~CurrentTransferTag;\r
+\r
+ /* Select the Data In endpoint */\r
+ Endpoint_SelectEndpoint(TMC_IN_EPNUM);\r
+\r
+ /* Send the command header to the host */\r
+ Endpoint_Write_Stream_LE(MessageHeader, sizeof(TMC_MessageHeader_t), StreamCallback_AbortINOnRequest);\r
+\r
+ /* Indicate if the command has been aborted or not */\r
+ return !IsTMCBulkINReset;\r
+}\r
+\r