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