USBD.h
Go to the documentation of this file.
1 /* ---------------------------------------------------------------------------- */
2 /* Atmel Microcontroller Software Support */
3 /* SAM Software Package License */
4 /* ---------------------------------------------------------------------------- */
5 /* Copyright (c) 2015, Atmel Corporation */
6 /* */
7 /* All rights reserved. */
8 /* */
9 /* Redistribution and use in source and binary forms, with or without */
10 /* modification, are permitted provided that the following condition is met: */
11 /* */
12 /* - Redistributions of source code must retain the above copyright notice, */
13 /* this list of conditions and the disclaimer below. */
14 /* */
15 /* Atmel's name may not be used to endorse or promote products derived from */
16 /* this software without specific prior written permission. */
17 /* */
18 /* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28 /* ---------------------------------------------------------------------------- */
29 
46 #ifndef USBD_H
47 #define USBD_H
48 
49 /*----------------------------------------------------------------------------
50  * Headers
51  *----------------------------------------------------------------------------*/
52 
53 
54 #include "USBDescriptors.h"
55 #include "USBRequests.h"
56 
57 #include "USBLib_Types.h"
58 
59 #include <stdio.h>
60 
61 /*------------------------------------------------------------------------------
62  * Definitions
63  *------------------------------------------------------------------------------*/
64 
65 /* Define attribute */
66 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */
67  #define WEAK __attribute__ ((weak))
68 #elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
69  #define WEAK __weak
70 #elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
71  #define WEAK __attribute__ ((weak))
72 #endif
73 
74 /* Define NO_INIT attribute */
75 #ifndef NO_INIT
76 #if defined ( __CC_ARM )
77  #define NO_INIT
78 #elif defined ( __ICCARM__ )
79  #define NO_INIT __no_init
80 #elif defined ( __GNUC__ )
81  #define NO_INIT
82 #endif
83 #endif // NO_INIT
84 
85 extern uint8_t ForceFS;
100 #define USBD_STATUS_SUCCESS USBRC_SUCCESS
101 
102 #define USBD_STATUS_LOCKED USBRC_BUSY
103 
104 #define USBD_STATUS_ABORTED USBRC_ABORTED
105 
106 #define USBD_STATUS_CANCELED USBRC_CANCELED
107 
108 #define USBD_STATUS_RESET USBRC_RESET
109 
110 #define USBD_STATUS_PARTIAL_DONE USBRC_PARTIAL_DONE
111 
112 #define USBD_STATUS_INVALID_PARAMETER USBRC_PARAM_ERR
113 
114 #define USBD_STATUS_WRONG_STATE USBRC_STATE_ERR
115 
116 #define USBD_STATUS_SW_NOT_SUPPORTED USBRC_SW_NOT_SUPPORTED
117 
118 #define USBD_STATUS_HW_NOT_SUPPORTED USBRC_HW_NOT_SUPPORTED
119 
133 #define USBD_STATE_SUSPENDED 0
134 
135 #define USBD_STATE_ATTACHED 1
136 
137 #define USBD_STATE_POWERED 2
138 
139 #define USBD_STATE_DEFAULT 3
140 
141 #define USBD_STATE_ADDRESS 4
142 
143 #define USBD_STATE_CONFIGURED 5
144 
146 /*----------------------------------------------------------------------------
147  * Types
148  *----------------------------------------------------------------------------*/
149 
155 typedef struct _USBDTransferBuffer {
157  uint8_t * pBuffer;
159  uint16_t size;
161  uint16_t transferred;
163  uint16_t buffered;
165  uint16_t remaining;
167 
168 #pragma pack(1)
169 #if defined ( __CC_ARM ) /* Keil ¦̀Vision 4 */
170 #elif defined ( __ICCARM__ ) /* IAR Ewarm 5.41+ */
171 #define __attribute__(...)
172 #elif defined ( __GNUC__ ) /* GCC CS3 2009q3-68 */
173 #endif
174 
181 typedef struct _USBDDmaDescriptor {
183  void* pNxtDesc;
185  void* pDataAddr;
187  uint32_t ctrlSettings:8,
188  reserved:8,
189  bufferLength:16;
191  uint32_t used;
192 } __attribute__((aligned(16))) USBDDmaDescriptor;
193 
194 #pragma pack()
195 
200 typedef void (*TransferCallback)(void *pArg,
201  uint8_t status,
202  uint32_t transferred,
203  uint32_t remaining);
204 
211 typedef void (*MblTransferCallback)(void *pArg,
212  uint8_t status);
213 
216 /*------------------------------------------------------------------------------
217  * Exported functions
218  *------------------------------------------------------------------------------*/
219 
220 extern void USBD_Init(void);
221 
222 extern void USBD_ConfigureSpeed(uint8_t forceFS);
223 
224 extern void USBD_Connect(void);
225 
226 extern void USBD_Disconnect(void);
227 
228 extern uint8_t USBD_Write(
229  uint8_t bEndpoint,
230  const void *pData,
231  uint32_t size,
232  TransferCallback callback,
233  void *pArg);
234 
235 extern uint8_t USBD_Read(
236  uint8_t bEndpoint,
237  void *pData,
238  uint32_t dLength,
239  TransferCallback fCallback,
240  void *pArg);
241 
242 extern uint8_t USBD_Stall(uint8_t bEndpoint);
243 
244 extern void USBD_Halt(uint8_t bEndpoint);
245 
246 extern void USBD_Unhalt(uint8_t bEndpoint);
247 
248 extern void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor);
249 
250 extern uint8_t USBD_IsHalted(uint8_t bEndpoint);
251 
252 extern void USBD_RemoteWakeUp(void);
253 
254 extern void USBD_SetAddress(uint8_t address);
255 
256 extern void USBD_SetConfiguration(uint8_t cfgnum);
257 
258 extern uint8_t USBD_GetState(void);
259 
260 extern uint8_t USBD_IsHighSpeed(void);
261 
262 extern void USBD_Test(uint8_t bIndex);
263 
264 extern void USBD_SuspendHandler(void);
265 extern void USBD_ResumeHandler(void);
266 extern void USBD_ResetHandler(void);
267 extern void USBD_RequestHandler(uint8_t bEndpoint,
268  const USBGenericRequest * pRequest);
269 
270 
271 extern void USBDCallbacks_Initialized(void);
272 extern void USBDCallbacks_Reset(void);
273 extern void USBDCallbacks_Suspended(void);
274 extern void USBDCallbacks_Resumed(void);
275 extern void USBDCallbacks_RequestReceived(const USBGenericRequest *request);
276 
277 extern void USBD_ForceFullSpeed(void);
278 
279 #endif /*#ifndef USBD_H*/
280 
uint32_t bufferLength
Definition: USBD.h:91
Buffer struct used for multi-buffer-listed transfer.
Definition: USBD.h:155
void USBD_ForceFullSpeed(void)
Definition: USBD.c:553
uint32_t ctrlSettings
Definition: USBD.h:91
void USBD_RemoteWakeUp(void)
Definition: USBD.c:475
void USBDCallbacks_RequestReceived(const USBGenericRequest *request)
Definition: USBDCallbacks.c:83
uint8_t USBD_GetState(void)
Definition: USBD.c:538
void USBD_ConfigureSpeed(uint8_t forceFS)
void USBD_Unhalt(uint8_t bEndpoint)
Definition: USBD.c:397
void * pDataAddr
Definition: USBD.h:185
uint8_t USBD_IsHalted(uint8_t bEndpoint)
Definition: USBD.c:407
void USBD_SetAddress(uint8_t address)
Definition: USBD.c:437
void USBDCallbacks_Resumed(void)
Definition: USBDCallbacks.c:76
void USBD_ResetHandler(void)
Definition: USBD.c:126
uint8_t USBD_Stall(uint8_t bEndpoint)
Definition: USBD.c:427
void USBD_SetConfiguration(uint8_t cfgnum)
Definition: USBD.c:453
struct _USBDDmaDescriptor __attribute__((aligned(16))) USBDDmaDescriptor
Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes aligned. ...
uint32_t used
Definition: USBD.h:191
void USBD_Connect(void)
Definition: USBD.c:490
uint8_t * pBuffer
Definition: USBD.h:157
uint8_t USBD_Read(uint8_t bEndpoint, void *pData, uint32_t dLength, TransferCallback fCallback, void *pArg)
Definition: USBD.c:318
void USBD_RequestHandler(uint8_t bEndpoint, const USBGenericRequest *pRequest)
Definition: USBD.c:147
uint8_t ForceFS
Definition: USBD.c:65
void USBD_ConfigureEndpoint(const USBEndpointDescriptor *pDescriptor)
Definition: USBD.c:165
void USBDCallbacks_Suspended(void)
Definition: USBDCallbacks.c:70
void USBD_ResumeHandler(void)
Definition: USBD.c:105
uint8_t USBD_Write(uint8_t bEndpoint, const void *pData, uint32_t size, TransferCallback callback, void *pArg)
Definition: USBD.c:191
uint8_t USBD_IsHighSpeed(void)
Definition: USBD.c:416
void USBDCallbacks_Reset(void)
Definition: USBDCallbacks.c:62
void USBD_Disconnect(void)
Definition: USBD.c:499
uint16_t buffered
Definition: USBD.h:163
void USBD_SuspendHandler(void)
Definition: USBD.c:83
uint32_t reserved
Definition: USBD.h:187
void(* TransferCallback)(void *pArg, uint8_t status, uint32_t transferred, uint32_t remaining)
Definition: USBD.h:200
void USBD_Halt(uint8_t bEndpoint)
Definition: USBD.c:388
void * pNxtDesc
Definition: USBD.h:183
void USBD_Test(uint8_t bIndex)
Definition: USBD.c:547
struct _USBDTransferBuffer USBDTransferBuffer
Buffer struct used for multi-buffer-listed transfer.
uint16_t remaining
Definition: USBD.h:165
Struct used for USBD DMA Link List Transfer Descriptor, must be 16-bytes aligned. ...
Definition: USBD.h:181
uint16_t transferred
Definition: USBD.h:161
void(* MblTransferCallback)(void *pArg, uint8_t status)
Definition: USBD.h:211
void USBD_Init(void)
Definition: USBD.c:518
uint16_t size
Definition: USBD.h:159
void USBDCallbacks_Initialized(void)
Definition: USBDCallbacks.c:54


inertial_sense_ros
Author(s):
autogenerated on Sat Sep 19 2020 03:19:05