Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_usbHidDefs.h
Go to the documentation of this file.
1 
34 #ifndef NZ_USBHIDDEFS_H
35 #define NZ_USBHIDDEFS_H
36 
37 
38 // Commands /////////////////////////////////////
39 #define CMDUSB_DEBUG_MESSAGE 0x01 //Debug message. Parameter 1 is message type. Rest is NULL terminated string. When received from
40  //device, is normally displays in "Netcruzer Terminal" Send a "Command" to the device. Message content is a NULL terminated string.
41 #define CMDUSB_COMMAND 0x02 //Send a "Command" to the device. Message content is a NULL terminated string.
42 #define CMDUSB_REQUEST_COMMAND 0x03 //Send a "Request Command" to the device. Message content is a NULL terminated string.
43 #define CMDUSB_DEVICE_INFO 0x10
44 #define CMDUSB_RESET_DEVICE 0x11
45 #define CMDUSB_SYNC 0xA5 //Sync character
46 
47 
48 //Defines for USB HID Class /////////////////////
49 //usbState Variable States
50 #define IDLE_STATE 0x00
51 #define NOT_IDLE_STATE 0x01
52 
53 #define TOTAL_PACKET_SIZE 64
54 
55 //Board IDs
56 typedef enum _BOARD_ID {
57  BOARD_ID_UNKNOWN = 0,
58  BOARD_ID_DEFAULT_DEBUG = 1,
59 
60  BOARD_ID_SBC66EC_CONFIG = 10,
61  BOARD_ID_SBC66EC_MAIN_APP = 11,
62 
63  BOARD_ID_SBC66ECL_CONFIG = 20,
64  BOARD_ID_SBC66ECL_MAIN_APP = 21,
65 
66  BOARD_ID_SBC66ZL_CONFIG = 30,
67  BOARD_ID_SBC66ZL_MAIN_APP = 31,
68 
69  BOARD_ID_SBC66ZB_CONFIG = 40,
70  BOARD_ID_SBC66ZB_MAIN_APP = 41,
71 
72  BOARD_ID_SBC66WL_CONFIG = 50,
73  BOARD_ID_SBC66WL_MAIN_APP = 51,
74 
75  BOARD_ID_SBC66WB_CONFIG = 60,
76  BOARD_ID_SBC66WB_MAIN_APP = 61,
77 
78  BOARD_ID_SBC32UL_CONFIG = 1000,
79  BOARD_ID_SBC32UL_MAIN_APP = 1001,
80 } BOARD_ID;
81 
82 #if !defined(DONT_DEFINE_PACKET_TO_FROM_PC)
83 typedef union __attribute__((packed)) _USB_HID_BOOTLOADER_COMMAND
84 {
85  unsigned char Contents[64];
86 
87  //Reply to CMDUSB_DEVICE_INFO command, returns board ID and Revision
88  struct __attribute__((packed)) {
89  unsigned char Command;
90  unsigned char reserved; //Get parameters on WORD boundaries
91  WORD BoardID; //A BOARD_ID value (Is in PacketToFromPC.Data[0] and PacketToFromPC.Data[1] )
92  WORD BoardRev; //Board revision (Is in PacketToFromPC.Data[2] and PacketToFromPC.Data[3] )
93  } DeviceInfo;
94 
95  //Structure used Sending and Receiving Data Packets via USB
96  struct __attribute__((packed)) {
97  unsigned char Command;
98  unsigned char Size; //Size of Data
99  unsigned char Data[TOTAL_PACKET_SIZE - 2]; //Byte buffer, 64-2 = 62 bytes
100  };
101 
102  //Structure for storing USB command in "Circular Buffer Packet".
103  //UsbCommandSize = Size of "Circular Buffer Packet"
104  //UsbCommandData = Data of "Circular Buffer Packet"
105  struct __attribute__((packed)) {
106  unsigned char UsbCommandSize; //Not used for most USB commands
107  unsigned char UsbCommandData[TOTAL_PACKET_SIZE - 1]; //Byte buffer, 64-1 = 63 bytes
108  };
110 #endif //#if !defined(DONT_DEFINE_PACKET_TO_FROM_PC)
111 
112 
113 //BoardRev is 1 more than actual revision. This is due to the way it was (accidentally) done
114 //in first version of bootloader. Keep consistent!
115 #if defined(BRD_SBC66EC_R1)
116  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66EC_MAIN_APP
117  #define USBHID_BOARD_REV 2
118 #elif defined(BRD_SBC66EC_R2)
119  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66EC_MAIN_APP
120  #define USBHID_BOARD_REV 3
121 #elif defined(BRD_SBC66EC_R3)
122  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66EC_MAIN_APP
123  #define USBHID_BOARD_REV 4
124 #elif defined(BRD_SBC66ECL_R2)
125  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66ECL_MAIN_APP
126  #define USBHID_BOARD_REV 3
127 #elif defined(BRD_SBC66ECL_R3)
128  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66ECL_MAIN_APP
129  #define USBHID_BOARD_REV 4
130 #elif defined(BRD_SBC66ZL_R1)
131  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66ZL_MAIN_APP
132  #define USBHID_BOARD_REV 2
133 #elif defined(BRD_SBC66ZL_R2)
134  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66ZL_MAIN_APP
135  #define USBHID_BOARD_REV 3
136 #elif defined(BRD_SBC66ZB_R1)
137  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66ZB_MAIN_APP
138  #define USBHID_BOARD_REV 2
139 #elif defined(BRD_SBC66ZB_R2)
140  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66ZB_MAIN_APP
141  #define USBHID_BOARD_REV 3
142 #elif defined(BRD_SBC66WL_R1)
143  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66WL_MAIN_APP
144  #define USBHID_BOARD_REV 2
145 #elif defined(BRD_SBC66WL_R2)
146  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66WL_MAIN_APP
147  #define USBHID_BOARD_REV 3
148 #elif defined(BRD_SBC66WB_R1)
149  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66WB_MAIN_APP
150  #define USBHID_BOARD_REV 2
151 #elif defined(BRD_SBC66WB_R2)
152  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC66WB_MAIN_APP
153  #define USBHID_BOARD_REV 3
154 #elif defined(BRD_SBC32UL_R1)
155  #define USBHID_BOARD_ID_MAIN BOARD_ID_SBC32UL_MAIN_APP
156  #define USBHID_BOARD_REV 3
157 #else
158  #error "No board defined, required for BOARD_ID_Xxxx"
159 #endif
160 
161 
162 #endif