1 /* --COPYRIGHT--,BSD\r
2 * Copyright (c) 2014, Texas Instruments Incorporated\r
3 * All rights reserved.\r
4 *\r
5 * Redistribution and use in source and binary forms, with or without\r
6 * modification, are permitted provided that the following conditions\r
7 * are met:\r
8 *\r
9 * * Redistributions of source code must retain the above copyright\r
10 * notice, this list of conditions and the following disclaimer.\r
11 *\r
12 * * Redistributions in binary form must reproduce the above copyright\r
13 * notice, this list of conditions and the following disclaimer in the\r
14 * documentation and/or other materials provided with the distribution.\r
15 *\r
16 * * Neither the name of Texas Instruments Incorporated nor the names of\r
17 * its contributors may be used to endorse or promote products derived\r
18 * from this software without specific prior written permission.\r
19 *\r
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"\r
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,\r
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\r
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR\r
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\r
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\r
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;\r
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,\r
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR\r
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,\r
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\r
31 * --/COPYRIGHT--*/\r
32 /* \r
33 * ======== defMSP430USB.h ========\r
34 */\r
35 \r
36 #include <stdint.h>\r
37 \r
38 #ifndef _defMSP430USB_H\r
39 #define _defMSP430USB_H\r
40 \r
41 #ifdef __cplusplus\r
42 extern "C"\r
43 {\r
44 #endif\r
45 \r
46 /*----------------------------------------------------------------------------+\r
47 | Constant Definitions |\r
48 +----------------------------------------------------------------------------*/\r
49 #define YES 1\r
50 #define NO 0\r
51 \r
52 #define TRUE 1\r
53 #define FALSE 0\r
54 \r
55 #define NOERR 0\r
56 #define ERR 1\r
57 \r
58 #define NO_ERROR 0\r
59 #define ERROR 1\r
60 \r
61 #define DISABLE 0\r
62 #define ENABLE 1\r
63 \r
64 \r
65 /*----------------------------------------------------------------------------+\r
66 | USB Constants, Type Definition & Macro |\r
67 +----------------------------------------------------------------------------*/\r
68 \r
69 //USB related Constant\r
70 #define MAX_ENDPOINT_NUMBER 0x07 //A maximum of 7 endpoints is available\r
71 #define EP0_MAX_PACKET_SIZE 0x08\r
72 #define EP0_PACKET_SIZE 0x08\r
73 #define EP_MAX_PACKET_SIZE 0x40\r
74 \r
75 //Base addresses of transmit and receive buffers\r
76 #define OEP1_X_BUFFER_ADDRESS 0x1C00 //Input Endpoint 1 X Buffer Base-address\r
77 #define OEP1_Y_BUFFER_ADDRESS 0x1C40 //Input Endpoint 1 Y Buffer Base-address\r
78 #define IEP1_X_BUFFER_ADDRESS 0x1C80 //Output Endpoint 1 X Buffer Base-address\r
79 #define IEP1_Y_BUFFER_ADDRESS 0x1CC0 //Output Endpoint 1 Y Buffer Base-address\r
80 \r
81 #define OEP2_X_BUFFER_ADDRESS 0x1D00 //Input Endpoint 2 X Buffer Base-address\r
82 #define OEP2_Y_BUFFER_ADDRESS 0x1D40 //Input Endpoint 2 Y Buffer Base-address\r
83 #define IEP2_X_BUFFER_ADDRESS 0x1D80 //Output Endpoint 2 X Buffer Base-address\r
84 #define IEP2_Y_BUFFER_ADDRESS 0x1DC0 //Output Endpoint 2 Y Buffer Base-address\r
85 \r
86 #define OEP3_X_BUFFER_ADDRESS 0x1E00 //Input Endpoint 2 X Buffer Base-address\r
87 #define OEP3_Y_BUFFER_ADDRESS 0x1E40 //Input Endpoint 2 Y Buffer Base-address\r
88 #define IEP3_X_BUFFER_ADDRESS 0x1E80 //Output Endpoint 2 X Buffer Base-address\r
89 #define IEP3_Y_BUFFER_ADDRESS 0x1EC0 //Output Endpoint 2 Y Buffer Base-address\r
90 \r
91 #define OEP4_X_BUFFER_ADDRESS 0x1F00 //Input Endpoint 2 X Buffer Base-address\r
92 #define OEP4_Y_BUFFER_ADDRESS 0x1F40 //Input Endpoint 2 Y Buffer Base-address\r
93 #define IEP4_X_BUFFER_ADDRESS 0x1F80 //Output Endpoint 2 X Buffer Base-address\r
94 #define IEP4_Y_BUFFER_ADDRESS 0x1FC0 //Output Endpoint 2 Y Buffer Base-address\r
95 \r
96 #define OEP5_X_BUFFER_ADDRESS 0x2000 //Input Endpoint 2 X Buffer Base-address\r
97 #define OEP5_Y_BUFFER_ADDRESS 0x2040 //Input Endpoint 2 Y Buffer Base-address\r
98 #define IEP5_X_BUFFER_ADDRESS 0x2080 //Output Endpoint 2 X Buffer Base-address\r
99 #define IEP5_Y_BUFFER_ADDRESS 0x20C0 //Output Endpoint 2 Y Buffer Base-address\r
100 \r
101 #define OEP6_X_BUFFER_ADDRESS 0x2100 //Input Endpoint 2 X Buffer Base-address\r
102 #define OEP6_Y_BUFFER_ADDRESS 0x2140 //Input Endpoint 2 Y Buffer Base-address\r
103 #define IEP6_X_BUFFER_ADDRESS 0x2180 //Output Endpoint 2 X Buffer Base-address\r
104 #define IEP6_Y_BUFFER_ADDRESS 0x21C0 //Output Endpoint 2 Y Buffer Base-address\r
105 \r
106 #define OEP7_X_BUFFER_ADDRESS 0x2200 //Input Endpoint 2 X Buffer Base-address\r
107 #define OEP7_Y_BUFFER_ADDRESS 0x2240 //Input Endpoint 2 Y Buffer Base-address\r
108 #define IEP7_X_BUFFER_ADDRESS 0x2280 //Output Endpoint 2 X Buffer Base-address\r
109 #define IEP7_Y_BUFFER_ADDRESS 0x22C0 //Output Endpoint 2 Y Buffer Base-address\r
110 \r
111 #define X_BUFFER 0\r
112 #define Y_BUFFER 1\r
113 \r
114 //Macros for end point numbers\r
115 #define EP1 1\r
116 #define EP2 2\r
117 #define EP3 3\r
118 #define EP4 4\r
119 #define EP5 5\r
120 #define EP6 6\r
121 #define EP7 7\r
122 \r
123 //addresses of pipes for endpoints\r
124 #define EP1_OUT_ADDR 0x01 //address for endpoint 1\r
125 #define EP2_OUT_ADDR 0x02 //address for endpoint 2\r
126 #define EP3_OUT_ADDR 0x03 //address for endpoint 3\r
127 #define EP4_OUT_ADDR 0x04 //address for endpoint 4\r
128 #define EP5_OUT_ADDR 0x05 //address for endpoint 5\r
129 #define EP6_OUT_ADDR 0x06 //address for endpoint 6\r
130 #define EP7_OUT_ADDR 0x07 //address for endpoint 7\r
131 \r
132 //Input end points\r
133 #define EP1_IN_ADDR 0x81 //address for endpoint 1\r
134 #define EP2_IN_ADDR 0x82 //address for endpoint 2\r
135 #define EP3_IN_ADDR 0x83 //address for endpoint 3\r
136 #define EP4_IN_ADDR 0x84 //address for endpoint 4\r
137 #define EP5_IN_ADDR 0x85 //address for endpoint 5\r
138 #define EP6_IN_ADDR 0x86 //address for endpoint 6\r
139 #define EP7_IN_ADDR 0x87 //address for endpoint 7\r
140 \r
141 \r
142 //EDB Data Structure\r
143 typedef struct _tEDB {\r
144 uint8_t bEPCNF; //Endpoint Configuration\r
145 uint8_t bEPBBAX; //Endpoint X Buffer Base Address\r
146 uint8_t bEPBCTX; //Endpoint X Buffer byte Count\r
147 uint8_t bSPARE0; //no used\r
148 uint8_t bSPARE1; //no used\r
149 uint8_t bEPBBAY; //Endpoint Y Buffer Base Address\r
150 uint8_t bEPBCTY; //Endpoint Y Buffer byte Count\r
151 uint8_t bEPSIZXY; //Endpoint XY Buffer Size\r
152 } tEDB, *tpEDB;\r
153 \r
154 typedef struct _tEDB0 {\r
155 uint8_t bIEPCNFG; //Input Endpoint 0 Configuration Register\r
156 uint8_t bIEPBCNT; //Input Endpoint 0 Buffer Byte Count\r
157 uint8_t bOEPCNFG; //Output Endpoint 0 Configuration Register\r
158 uint8_t bOEPBCNT; //Output Endpoint 0 Buffer Byte Count\r
159 } tEDB0, *tpEDB0;\r
160 \r
161 //EndPoint Desciptor Block Bits\r
162 #define EPCNF_USBIE 0x04 //USB Interrupt on Transaction Completion. Set By MCU\r
163 //0:No Interrupt, 1:Interrupt on completion\r
164 #define EPCNF_STALL 0x08 //USB Stall Condition Indication. Set by UBM\r
165 //0: No Stall, 1:USB Install Condition\r
166 #define EPCNF_DBUF 0x10 //Double Buffer Enable. Set by MCU\r
167 //0: Primary Buffer Only(x-buffer only), 1:Toggle Bit Selects Buffer\r
168 \r
169 #define EPCNF_TOGGLE 0x20 //USB Toggle bit. This bit reflects the toggle sequence bit of DATA0 and DATA1.\r
170 \r
171 #define EPCNF_UBME 0x80 //UBM Enable or Disable bit. Set or Clear by MCU.\r
172 //0:UBM can't use this endpoint\r
173 //1:UBM can use this endpoint\r
174 #define EPBCNT_BYTECNT_MASK 0x7F //MASK for Buffer Byte Count\r
175 #define EPBCNT_NAK 0x80 //NAK, 0:No Valid in buffer, 1:Valid packet in buffer\r
176 \r
177 //definitions for MSP430 USB-module\r
178 #define START_OF_USB_BUFFER 0x1C00\r
179 \r
180 //input and output buffers for EP0\r
181 #define USBIEP0BUF 0x2378\r
182 #define USBOEP0BUF 0x2370\r
183 \r
184 #ifdef __cplusplus\r
185 }\r
186 #endif\r
187 #endif /*_defMSP430USB_H */\r
188 //Released_Version_4_10_02\r