PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
usbdevice.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 /******************************************************************************/
61 #ifndef __USBDEVICE_H__
62 #define __USBDEVICE_H__
63 
64 #include "usb.h"
65 
66 /******************************************************************************/
67 /* Include files */
68 /******************************************************************************/
69 
70 /* C binding of definitions if building with C++ compiler */
71 #ifdef __cplusplus
72 extern "C"
73 {
74 #endif
75 
96 
97 
98 
99 #define USBDEVICE_MAXCLASSES 5
100 
110 typedef void (*usbdevice_setuprequest_func_ptr_t)(stc_usbn_t* pstcUsb, stc_usb_request_t* pstcSetup);
111 
121 typedef void (*usbdevice_controltranfered_func_ptr_t)(stc_usbn_t* pstcUsb, stc_usbn_endpoint_data_t* pstcEndpoint);
122 
130 typedef void (*usbdevice_initclasses_func_ptr_t)(stc_usbn_t* pstcUsb);
131 
132 
133 
142 {
152 
161 {
162  uint8_t u8Dummy;
177  volatile uint8_t* pu8LastControlTransfer;
179 
185 typedef struct stc_usbdevice_config
186 {
194 
195 
202 {
207 
208 
209 
216 {
217  volatile stc_usbn_t* pstcInstance;
220 
226 typedef enum en_usbsend_mode
227 {
228  UsbPOLL = 0,
229  UsbIRQ = 1,
230  UsbDMA = 2,
232 
233 
234 
235 
236 en_result_t UsbDevice_ReceiveData(stc_usbn_t* pstcUsb, stc_usbn_endpoint_data_t* pstcEndpoint, uint8_t* pu8Buffer, uint32_t u32DataSize, en_usbsend_mode_t enMode);
237 
238 en_result_t UsbDevice_SendData(stc_usbn_t* pstcUsb, stc_usbn_endpoint_data_t* pstcEndpoint, uint8_t* pu8Buffer, uint32_t u32DataSize, en_usbsend_mode_t enMode);
239 
240 void UsbDevice_SendDataControl(stc_usbn_t * pstcUsb,uint8_t* pu8Buffer, uint32_t u32DataLength);
241 
242 void UsbDevice_ReceiveDataControl(stc_usbn_t * pstcUsb, usbdevice_controltranfered_func_ptr_t pfnCompletionCallback);
243 
244 en_result_t UsbDevice_RegisterVendorClass(stc_usbn_t* pstcUsb, stc_usbdevice_class_config_t* pstcUsbClassConfig, uint8_t** ppu8Buffer, uint8_t* pu8InterfaceLength);
245 
246 en_usb_status_t UsbDevice_GetStatus(stc_usbn_t* pstcUsb);
247 
249 
250 void UsbDevice_InitCallback(stc_usbn_t* pstcUsb, stc_usb_config_t* pstcUsbConfig);
251 
252 void UsbDevice_Init(stc_usbn_t* pstcUsb, stc_usb_config_t* pstcUsbConfig, stc_usbdevice_config_t* pstcConfig);
253 
255 
256 #define UsbDevice_HalEndpointStatus(x) Usb_HalEndpointStatus(x)
257 
258 #define UsbDevice_HalEndpointIsBusy(x) Usb_HalEndpointIsBusy(x)
259 
260 #define UsbDevice_HalStallEndpoint(x) Usb_HalStallEndpoint(x)
261 
262 #define UsbDevice_HalUnstallEndpoint(x) Usb_HalUnstallEndpoint(x)
263 
264 #if (L3_PERIPHERAL_ENABLE_USB0 == L3_ON)
265  void UsbDevice_Usb0ExintCallback(void);
266 #endif
267 #if (L3_PERIPHERAL_ENABLE_USB1 == L3_ON)
268  void UsbDevice_Usb1ExintCallback(void);
269 #endif
270 #ifdef __cplusplus
271 }
272 #endif
273 
274 #endif