]> Gitweb @ Texas Instruments - Open Source Git Repositories - git.TI.com/gitweb - msp430-bsl/msp430-bsl.git/blob - USB_API/USB_CDC_API/UsbCdc.h
Initial commit.
[msp430-bsl/msp430-bsl.git] / USB_API / USB_CDC_API / UsbCdc.h
1 /*
2  * UsbCdc.h
3  *
4  * CDC specific USB functions
5  *
6  * Copyright (C) 2009 Texas Instruments Incorporated - http://www.ti.com/ 
7  * 
8  * 
9  *  Redistribution and use in source and binary forms, with or without 
10  *  modification, are permitted provided that the following conditions 
11  *  are met:
12  *
13  *    Redistributions of source code must retain the above copyright 
14  *    notice, this list of conditions and the following disclaimer.
15  *
16  *    Redistributions in binary form must reproduce the above copyright
17  *    notice, this list of conditions and the following disclaimer in the 
18  *    documentation and/or other materials provided with the   
19  *    distribution.
20  *
21  *    Neither the name of Texas Instruments Incorporated nor the names of
22  *    its contributors may be used to endorse or promote products derived
23  *    from this software without specific prior written permission.
24  *
25  *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
26  *  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
27  *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
28  *  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
29  *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
30  *  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
31  *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
32  *  DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
33  *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
34  *  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
35  *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
36  *
37  */
39 /*----------------------------------------------------------------------------+
40 |                                                                             |
41 |                              Texas Instruments                              |
42 |                                                                             |
43 |                          MSP430 USB-Example (CDC Driver)                    |
44 |                                                                             |
45 +-----------------------------------------------------------------------------+
46 |  Source: UsbCdc.h, File Version 1.00 2009/12/03                             |
47 |  Author: RSTO                                                               |
48 |                                                                             |
49 |  WHO          WHEN         WHAT                                             |
50 |  ---          ----------   ------------------------------------------------ |
51 |  RSTO         2008/09/03   born                                             |
52 |  RSTO         2008/12/23   enhancements of CDC API                          |
53 |  RSTO         2009/05/15   added param to USBCDC_rejectData()               |
54 |  RSTO         2009/05/26   added USBCDC_bytesInUSBBuffer()                  |
55 |  MSP,Biju     2009/12/03   file versioning started                          |
56 |                                                                             |
57 +----------------------------------------------------------------------------*/
58 #ifndef _UsbCdc_H_
59 #define _UsbCdc_H_
61 #ifdef __cplusplus
62 extern "C"
63 {
64 #endif
67 #define kUSBCDC_sendStarted         0x01
68 #define kUSBCDC_sendComplete        0x02
69 #define kUSBCDC_intfBusyError       0x03
70 #define kUSBCDC_receiveStarted      0x04
71 #define kUSBCDC_receiveCompleted    0x05
72 #define kUSBCDC_receiveInProgress   0x06
73 #define kUSBCDC_generalError        0x07
74 #define kUSBCDC_busNotAvailable     0x08
77 /*----------------------------------------------------------------------------
78 These functions can be used in application
79 +----------------------------------------------------------------------------*/
81 /*
82 Sends data over interface intfNum, of size size and starting at address data.
83   Returns:  kUSBCDC_sendStarted
84             kUSBCDC_sendComplete
85             kUSBCDC_intfBusyError
86 */
87 BYTE USBCDC_sendData(const BYTE* data, WORD size, BYTE intfNum);
89 /*
90 Receives data over interface intfNum, of size size, into memory starting at address data.
91 */
92 BYTE USBCDC_receiveData(BYTE* data, WORD size, BYTE intfNum);
94 /*
95 Aborts an active receive operation on interface intfNum.
96   size: the number of bytes that were received and transferred
97   to the data location established for this receive operation.
98 */
99 BYTE USBCDC_abortReceive(WORD* size, BYTE intfNum);
102 #define kUSBCDC_noDataWaiting 1 //returned by USBCDC_rejectData() if no data pending
104 /*
105 This function rejects payload data that has been received from the host.
106 */
107 BYTE USBCDC_rejectData(BYTE intfNum);
109 /*
110 Aborts an active send operation on interface intfNum.  Returns the number of bytes that were sent prior to the abort, in size.
111 */
112 BYTE USBCDC_abortSend(WORD* size, BYTE intfNum);
115 #define kUSBCDC_waitingForSend      0x01
116 #define kUSBCDC_waitingForReceive   0x02
117 #define kUSBCDC_dataWaiting         0x04
118 #define kUSBCDC_busNotAvailable     0x08
119 #define kUSB_allCdcEvents           0xFF
121 /*
122 This function indicates the status of the interface intfNum.
123   If a send operation is active for this interface,
124   the function also returns the number of bytes that have been transmitted to the host.
125   If a receiver operation is active for this interface, the function also returns
126   the number of bytes that have been received from the host and are waiting at the assigned address.
128 returns kUSBCDC_waitingForSend (indicates that a call to USBCDC_SendData()
129   has been made, for which data transfer has not been completed)
131 returns kUSBCDC_waitingForReceive (indicates that a receive operation
132   has been initiated, but not all data has yet been received)
134 returns kUSBCDC_dataWaiting (indicates that data has been received
135   from the host, waiting in the USB receive buffers)
136 */
137 BYTE USBCDC_intfStatus(BYTE intfNum, WORD* bytesSent, WORD* bytesReceived);
139 /*
140 Returns how many bytes are in the buffer are received and ready to be read.
141 */
142 BYTE USBCDC_bytesInUSBBuffer(BYTE intfNum);
145 /*----------------------------------------------------------------------------
146 Event-Handling routines
147 +----------------------------------------------------------------------------*/
149 /*
150 This event indicates that data has been received for interface intfNum, but no data receive operation is underway.
151 returns TRUE to keep CPU awake
152 */
153 BYTE USBCDC_handleDataReceived(BYTE intfNum);
155 /*
156 This event indicates that a send operation on interface intfNum has just been completed.
157 returns TRUE to keep CPU awake
158 */
159 BYTE USBCDC_handleSendCompleted(BYTE intfNum);
161 /*
162 This event indicates that a receive operation on interface intfNum has just been completed.
163 returns TRUE to keep CPU awake
164 */
165 BYTE USBCDC_handleReceiveCompleted(BYTE intfNum);
168 /*----------------------------------------------------------------------------
169 These functions is to be used ONLY by USB stack, and not by application
170 +----------------------------------------------------------------------------*/
172 /**
173 Send a packet with the settings of the second uart back to the usb host
174 */
175 VOID usbGetLineCoding0(VOID);
176 VOID usbGetLineCoding1(VOID);
177 VOID usbGetLineCoding2(VOID);
179 /**
180 Prepare EP0 to receive a packet with the settings for the second uart
181 */
182 VOID usbSetLineCoding0(VOID);
183 VOID usbSetLineCoding1(VOID);
184 VOID usbSetLineCoding2(VOID);
186 /**
187 Function set or reset RTS
188 */
189 VOID usbSetControlLineState0(VOID);
190 VOID usbSetControlLineState1(VOID);
191 VOID usbSetControlLineState2(VOID);
193 /**
194 Readout the settings (send from usb host) for the second uart
195 */
196 VOID Handler_SetLineCoding0(VOID);
197 VOID Handler_SetLineCoding1(VOID);
198 VOID Handler_SetLineCoding2(VOID);
200 #ifdef __cplusplus
202 #endif
203 #endif //_UsbCdc_H_