PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
UsbDeviceCdcCom.h
Go to the documentation of this file.
1 /*******************************************************************************
2 * Copyright (C) 2013 Spansion LLC. All Rights Reserved.
3 *
4 * This software is owned and published by:
5 * Spansion LLC, 915 DeGuigne Dr. Sunnyvale, CA 94088-3453 ("Spansion").
6 *
7 * BY DOWNLOADING, INSTALLING OR USING THIS SOFTWARE, YOU AGREE TO BE BOUND
8 * BY ALL THE TERMS AND CONDITIONS OF THIS AGREEMENT.
9 *
10 * This software contains source code for use with Spansion
11 * components. This software is licensed by Spansion to be adapted only
12 * for use in systems utilizing Spansion components. Spansion shall not be
13 * responsible for misuse or illegal use of this software for devices not
14 * supported herein. Spansion is providing this software "AS IS" and will
15 * not be responsible for issues arising from incorrect user implementation
16 * of the software.
17 *
18 * SPANSION MAKES NO WARRANTY, EXPRESS OR IMPLIED, ARISING BY LAW OR OTHERWISE,
19 * REGARDING THE SOFTWARE (INCLUDING ANY ACOOMPANYING WRITTEN MATERIALS),
20 * ITS PERFORMANCE OR SUITABILITY FOR YOUR INTENDED USE, INCLUDING,
21 * WITHOUT LIMITATION, THE IMPLIED WARRANTY OF MERCHANTABILITY, THE IMPLIED
22 * WARRANTY OF FITNESS FOR A PARTICULAR PURPOSE OR USE, AND THE IMPLIED
23 * WARRANTY OF NONINFRINGEMENT.
24 * SPANSION SHALL HAVE NO LIABILITY (WHETHER IN CONTRACT, WARRANTY, TORT,
25 * NEGLIGENCE OR OTHERWISE) FOR ANY DAMAGES WHATSOEVER (INCLUDING, WITHOUT
26 * LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION,
27 * LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY LOSS) ARISING FROM USE OR
28 * INABILITY TO USE THE SOFTWARE, INCLUDING, WITHOUT LIMITATION, ANY DIRECT,
29 * INDIRECT, INCIDENTAL, SPECIAL OR CONSEQUENTIAL DAMAGES OR LOSS OF DATA,
30 * SAVINGS OR PROFITS,
31 * EVEN IF SPANSION HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
32 * YOU ASSUME ALL RESPONSIBILITIES FOR SELECTION OF THE SOFTWARE TO ACHIEVE YOUR
33 * INTENDED RESULTS, AND FOR THE INSTALLATION OF, USE OF, AND RESULTS OBTAINED
34 * FROM, THE SOFTWARE.
35 *
36 * This software may be replicated in part or whole for the licensed use,
37 * with the restriction that this Disclaimer and Copyright notice must be
38 * included with each copy of this software, whether used in part or whole,
39 * at all times.
40 */
41 /*****************************************************************************/
62 #ifndef __USBDEVICECDCCOM_H__
63 #define __USBDEVICECDCCOM_H__
64 
65 /*****************************************************************************/
66 /* Include files */
67 /*****************************************************************************/
68 
69 #include "usb.h"
70 
71 #ifndef USBDEVICECDCCOM_ENABLED
72  #define USBDEVICECDCCOM_ENABLED OFF
73 #endif
74 
75 #if ((FM_PERIPHERAL_USB_DEVICE_ENABLED == ON) && (USBDEVICECDCCOM_ENABLED == ON))
76 
77 #include "UsbDevice.h"
78 
79 /* C binding of definitions if building with C++ compiler */
80 #ifdef __cplusplus
81 extern "C"
82 {
83 #endif
84 
118 
119 /*****************************************************************************/
120 /* Global pre-processor symbols/macros ('#define') */
121 /*****************************************************************************/
122 
123 #define USBDEVICECDCCOM_EPOUT_BUFFERSIZE 128 //buffer Size by default 512 bytes
124 #define USBDEVICECDCCOM_MAX_RECEIVE_BUFFER 512
125 
126 #define USBDEVICECDCCOM_USE_UARTCOMMANDS 0
127 
128 
129 /* CDC Management Element Requests */
130 #define SEND_ENCAPSULATED_COMMAND 0x00
131 #define GET_ENCAPSULATED_RESPONSE 0x01
132 #define SET_COMM_FEATURE 0x02
133 #define GET_COMM_FEATURE 0x03
134 #define CLEAR_COMM_FEATURE 0x04
135 #define SET_AUX_LINE_STATE 0x10
136 #define SET_HOOK_STATE 0x11
137 #define PULSE_SETUP 0x12
138 #define SEND_PULSE 0x13
139 #define SET_PULSE_TIME 0x14
140 #define RING_AUX_JACK 0x15
141 #define SET_LINE_CODING 0x20
142 #define GET_LINE_CODING 0x21
143 #define SET_CONTROL_LINE_STATE 0x22
144 #define SEND_BREAK 0x23
145 #define SET_RINGER_PARMS 0x30
146 #define GET_RINGER_PARMS 0x31
147 #define SET_OPERATION_PARMS 0x32
148 #define GET_OPERATION_PARMS 0x33
149 #define SET_LINE_PARMS 0x34
150 #define GET_LINE_PARMS 0x35
151 #define DIAL_DIGITS 0x36
152 #define SET_UNIT_PARAMETER 0x37
153 #define GET_UNIT_PARAMETER 0x38
154 #define CLEAR_UNIT_PARAMETER 0x39
155 #define GET_PROFILE 0x3A
156 #define SET_ETHERNET_MULTICAST_FILTERS 0x40
157 #define SET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x41
158 #define GET_ETHERNET_POWER_MANAGEMENT_PATTERN_FILTER 0x42
159 #define SET_ETHERNET_PACKET_FILTER 0x43
160 #define GET_ETHERNET_STATISTIC 0x44
161 #define SET_ATM_DATA_FORMAT 0x50
162 #define GET_ATM_DEVICE_STATISTICS 0x51
163 #define SET_ATM_DEFAULT_VC 0x52
164 #define GET_ATM_VC_STATISTICS 0x53
165 
166 
167 #define DEC 0
168 #define HEX 1
169 
170 
171 #if (USBDEVICECDCCOM_USE_UARTCOMMANDS == 1)
172  #define puts(x) UsbDeviceCdcCom_SendString(x)
173  #define putch(x) UsbDeviceCdcCom_SendByte((uint8_t)x)
174  #define puthex(x,y) UsbDeviceCdcCom_SendHex(x,y)
175  #define putdec(x) UsbDeviceCdcCom_SendDec(x)
176  #define getch() ((char_t)UsbDeviceCdcCom_ReceiveByte())
177  #define Inputhex(x) UsbDeviceCdcCom_ReceiveHex(x)
178  #define binasci8(x,y,z) UsbDeviceCdcCom_SendBinAsci8(x,y,z);
179  #define binasci4(x,y,z) UsbDeviceCdcCom_SendBinAsci4(x,y,z);
180  #define bin2_dot_dec99(x) UsbDeviceCdcCom_Send_Bin2DotDec99(x);
181 #endif
182 
183 #define USBCLASSCDC_CHARFORMAT_1STOPBIT 0
184 #define USBCLASSCDC_CHARFORMAT_1_5STOPBIT 1
185 #define USBCLASSCDC_CHARFORMAT_2STOPBIT 2
186 
187 #define USBCLASSCDC_PARITYTYPE_NONE 0
188 #define USBCLASSCDC_PARITYTYPE_ODD 1
189 #define USBCLASSCDC_PARITYTYPE_EVEN 2
190 #define USBCLASSCDC_PARITYTYPE_MARK 3
191 #define USBCLASSCDC_PARITYTYPE_SPACE 4
192 
193 typedef void (*cdc_data_received_t)(uint8_t* pu8Data, uint32_t u32ReceviedSize);
194 typedef void (*cdc_data_sent_t)(void);
195 
196 typedef struct stc_cdc_linecoding
197 {
198  volatile uint32_t dwDTERate;
199  volatile uint8_t bCharFormat;
200  volatile uint8_t bParityType;
201  volatile uint8_t bDataBits;
203 
205 
206 /*****************************************************************************/
207 /* Global type definitions ('typedef') */
208 /*****************************************************************************/
209 
210 
211 
212 /*****************************************************************************/
213 /* Global variable declarations ('extern', definition in C source) */
214 /*****************************************************************************/
215 
216 
217 
218 /*****************************************************************************/
219 /* Global function prototypes ('extern', definition in C source) */
220 /*****************************************************************************/
221 
222 
223 
224 void UsbDeviceCdcCom_Init(stc_usbn_t* pstcUsb);
227 uint8_t UsbDeviceCdcCom_SendByte(char_t c);
228 uint8_t UsbDeviceCdcCom_SendString(char_t *pcBuffer);
229 uint8_t UsbDeviceCdcCom_SendBuffer(uint8_t *pu8Buffer, uint32_t u32Size);
230 void UsbDeviceCdcCom_SetSeparator(const char_t cNewSeperator);
231 void UsbDeviceCdcCom_SetEchomode(boolean_t bEchoOnOff);
232 void UsbDeviceCdcCom_SetEchoAtSeperatorOnly(boolean_t bEchoAtSeperatorOnlyOnOff);
233 uint32_t UsbDeviceCdcCom_ReceivedLength(void);
234 uint32_t UsbDeviceCdcCom_ReceiveBuffer(uint8_t *pu8Buffer);
235 uint8_t UsbDeviceCdcCom_ReceiveByte(void);
236 uint8_t UsbDeviceCdcCom_ReceiveLastByte(void);
237 uint8_t UsbDeviceCdcCom_SendHex(uint32_t n, uint8_t digits);
238 uint8_t UsbDeviceCdcCom_SendDec(uint32_t x);
239 void UsbDeviceCdcCom_SendBinAsci4(uint16_t a, uint8_t base, char_t fill);
240 void UsbDeviceCdcCom_SendBinAsci8(uint16_t a, uint8_t base, char_t fill);
241 void UsbDeviceCdcCom_SendBin2DotDec99(uint8_t a);
242 uint32_t UsbDeviceCdcCom_ReceiveHex(uint8_t digits);
246 #ifdef __cplusplus
247 }
248 #endif
249 
251 #else
252  #define UsbDeviceCdcCom_Init(x) ;
253 #endif
254 
255 
256 #endif /* __USBCLASS_H__*/