MG32F157 Standard Peripherals Firmware Library
usbd_core.h
Go to the documentation of this file.
1 
17 /* Define to prevent recursive inclusion -------------------------------------*/
18 #ifndef __USBD_CORE_H
19 #define __USBD_CORE_H
20 
21 #ifdef __cplusplus
22  extern "C" {
23 #endif
24 
25 /* Includes ------------------------------------------------------------------*/
26 #include <stdint.h>
27 #include <stdbool.h>
28 #include "usb_def.h"
29 #include "usbd_hw.h"
30 
31 /* Exported types ------------------------------------------------------------*/
32 typedef struct {
33  USB_SETUP_PACKET SetupPacket;
34  uint8_t *DataPtr;
35  uint16_t DataSize;
36  uint16_t DataSent;
37  uint8_t Configuration;
38  uint8_t RemoteWakeup;
39  uint8_t DeviceState;
40  uint8_t OldDeviceState;
41  uint8_t DeviceAddress;
43 extern volatile UsbdCoreInfo_t UsbdCoreInfo;
44 extern const uint8_t UsbdMaxPacketSize0;
45 
46 typedef enum
47 {
48  USBD_CONTROL_STAGE_STALL,
49  USBD_CONTROL_STAGE_IN_DATA,
50  USBD_CONTROL_STAGE_OUT_DATA,
51  USBD_CONTROL_STAGE_STATUS
52 } UsbdControlStage;
53 
54 /* Exported constants --------------------------------------------------------*/
55 
56 #define USB_DEVICE_STATE_UNCONNECTED 0
57 #define USB_DEVICE_STATE_ATTACHED 1
58 #define USB_DEVICE_STATE_POWERED 2
59 #define USB_DEVICE_STATE_SUSPENDED 3
60 #define USB_DEVICE_STATE_ADDRESSED 4
61 #define USB_DEVICE_STATE_CONFIGURED 5
62 
63 /* Exported macro ------------------------------------------------------------*/
64 /* Exported functions --------------------------------------------------------*/
65 
66 void USBD_Init(void);
67 void USBD_DeInit(void);
68 void USBD_Connect(void);
69 void USBD_Disconnect(void);
70 
71 void USBD_Core_Reset(void);
72 void USBD_Core_Suspend(void);
73 void USBD_Core_Resume(void);
74 
75 UsbdControlStage USBD_EndPoint0_Setup_StdReq(void);
76 
77 void Handle_USBD_INT(uint8_t IntrUSB, uint8_t IntrTx, uint8_t IntrRx);
78 
79 #ifdef __cplusplus
80 }
81 #endif
82 
83 #endif /* __USBD_CORE_H */
void USBD_Init(void)
Initializes the USB device library.
Definition: usbd_core.c:38
void USBD_Connect(void)
Connects the device to the USB host.
Definition: usbd_core.c:58
void USBD_DeInit(void)
Deinitializes the USB device library.
Definition: usbd_core.c:49
void USBD_Disconnect(void)
Disconnects the device from the USB host.
Definition: usbd_core.c:67
UsbdControlStage USBD_EndPoint0_Setup_StdReq(void)
Handle Standard Device Requests.
Definition: usbd_core.c:320
void Handle_USBD_INT(uint8_t IntrUSB, uint8_t IntrTx, uint8_t IntrRx)
Handle USBD Interrupts.
Definition: usbd_intr.c:45
void USBD_Core_Resume(void)
Handle resume event.
Definition: usbd_core.c:104
void USBD_Core_Suspend(void)
Handle suspend event.
Definition: usbd_core.c:90
Definition: usbd_core.h:32
void USBD_Core_Reset(void)
Handle reset event.
Definition: usbd_core.c:77