Lightweight USB stack  1.0
usb_tmc.h
1 /* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
2  *
3  * Copyright ©2020 Alexander Voronov <avv.0@ya.ru>
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  * http://www.apache.org/licenses/LICENSE-2.0
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef _USB_TMC_H_
17 #define _USB_TMC_H_
18 
19 #ifdef __cplusplus
20 extern "C" {
21 #endif
22 
23 #include <stdint.h>
24 
34 #define USB_CLASS_TMC 0xFE
35 #define USB_TMC_SUBCLASS_TMC 0x03
36 #define USB_TMC_PROTO_NONE 0x00
37 #define USB_TMC_PROTO_USB488 0x01
42 #define USB_TMC_REQ_INITIATE_ABORT_BULK_OUT 1
43 #define USB_TMC_REQ_CHECK_ABORT_BULK_OUT_STATUS 2
44 #define USB_TMC_REQ_INITIATE_ABORT_BULK_IN 3
45 #define USB_TMC_REQ_CHECK_ABORT_BULK_IN_STATUS 4
46 #define USB_TMC_REQ_INITIATE_CLEAR 5
47 #define USB_TMC_REQ_CHECK_CLEAR_STATUS 6
48 #define USB_TMC_REQ_GET_CAPABILITIES 7
49 #define USB_TMC_REQ_INDICATOR_PULSE 64
50 
54 #define USB_TMC_STATUS_SUCCESS 0x01
55 #define USB_TMC_STATUS_PENDING 0x02
56 #define USB_TMC_STATUS_FAILED 0x80
57 #define USB_TMC_STATUS_TRANSFER_NOT_IN_PROGRESS 0x81
58 #define USB_TMC_STATUS_SPLIT_NOT_IN_PROGRESS 0x82
59 #define USB_TMC_STATUS_SPLIT_IN_PROGRESS 0x83
60 
64  uint8_t USBTMC_status;
65  uint8_t Reserved0;
66  uint16_t bcdUSBTMC;
67  uint8_t InterfaceCapabilities;
68  uint8_t DeviceCapabilities;
69  uint8_t Reserved1[18];
70 } __attribute__((packed));
71 
74 #define USB_TMC_DEV_DEP_MSG_OUT 1
75 #define USB_TMC_REQUEST_DEV_DEP_MSG_IN 2
76 #define USB_TMC_DEV_DEP_MSG_IN 2
77 #define USB_TMC_VENDOR_SPECIFIC_OUT 126
78 #define USB_TMC_REQUEST_VENDOR_SPECIFIC_IN 127
79 #define USB_TMC_VENDOR_SPECIFIC_IN 127
80 
86 #define USB_TMC_TRANSFER_ATTR_EOM 0x01
87 
90 #define USB_TMC_TRANSFER_ATTR_TERM_CHAR 0x02
91 
95  struct {
96  uint32_t TransferSize;
97  uint8_t bmTransferAttributes;
98  uint8_t Reserved[3];
99  } dev_dep_msg_out;
100 
101  struct {
102  uint32_t TransferSize;
103  uint8_t bmTransferAttributes;
104  uint8_t TermChar;
105  uint8_t Reserved[2];
106  } request_dev_dep_msg_in;
107 
108  struct {
109  uint32_t TransferSize;
110  uint8_t bmTransferAttributes;
111  uint8_t Reserved[3];
112  } dev_dep_msg_in;
113 
114  struct {
115  uint32_t TransferSize;
116  uint8_t Reserved[4];
117  } vendor_specific_out;
118 
119  struct {
120  uint32_t TransferSize;
121  uint8_t Reserved[4];
122  } request_vendor_specific_in;
123 
124  struct {
125  uint32_t TransferSize;
126  uint8_t Reserved[4];
127  } vendor_specific_in;
128 };
129 
134  uint8_t MsgId;
138  uint8_t bTag;
140  uint8_t bTagInverse;
141  uint8_t Reserved;
143  union usb_tmc_bulk_header_specific MsgSpecific;
144 } __attribute__((packed));
145 
148 #if defined(__cplusplus)
149 }
150 #endif
151 
152 #endif /* _USB_TMC_H_ */
uint8_t bTagInverse
Definition: usb_tmc.h:140