Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #ifndef __OTG_DEV_H__
00018 #define __OTG_DEV_H__
00019
00020
00021 #include <arch/cm3/stm/stm32xxxx.h>
00022 #include <dev/usb_stm32/usb_type.h>
00023 #include <stdint.h>
00024
00025
00026
00027
00028
00029 #define OTG_DEV_EP_TYPE_CONTROL 0
00030 #define OTG_DEV_EP_TYPE_ISOC 1
00031 #define OTG_DEV_EP_TYPE_BULK 2
00032 #define OTG_DEV_EP_TYPE_INT 3
00033
00034
00035 #define EP0_OUT 0x00
00036 #define EP0_IN 0x80
00037 #define EP1_OUT 0x01
00038 #define EP1_IN 0x81
00039 #define EP2_OUT 0x02
00040 #define EP2_IN 0x82
00041 #define EP3_OUT 0x03
00042 #define EP3_IN 0x83
00043
00044
00045
00046
00047 #define ENDP0 ((uint8_t)0)
00048 #define ENDP1 ((uint8_t)1)
00049 #define ENDP2 ((uint8_t)2)
00050 #define ENDP3 ((uint8_t)3)
00051 #define ENDP4 ((uint8_t)4)
00052 #define ENDP5 ((uint8_t)5)
00053 #define ENDP6 ((uint8_t)6)
00054 #define ENDP7 ((uint8_t)7)
00055
00056
00057 #define EP_TX_DIS DEV_EP_TX_DIS)
00058 #define EP_TX_STALL DEV_EP_TX_STALL
00059 #define EP_TX_NAK DEV_EP_TX_NAK
00060 #define EP_TX_VALID DEV_EP_TX_VALID
00061
00062
00063 #define EP_RX_DIS DEV_EP_RX_DIS
00064 #define EP_RX_STALL DEV_EP_RX_STALL
00065 #define EP_RX_NAK DEV_EP_RX_NAK
00066 #define EP_RX_VALID DEV_EP_RX_VALID
00067
00068
00069
00070 #define _GetEPTxStatus(bEpNum) ((uint16_t)OTG_DEV_GetEPTxStatus(bEpNum))
00071 #define _GetEPRxStatus(bEpNum) ((uint16_t)OTG_DEV_GetEPRxStatus(bEpNum))
00072
00073 #define _SetEPTxStatus(bEpNum,wState) (OTG_DEV_SetEPTxStatus(bEpNum, wState))
00074 #define _SetEPRxStatus(bEpNum,wState) (OTG_DEV_SetEPRxStatus(bEpNum, wState))
00075
00076 #define _SetEPTxValid(bEpNum) (OTG_DEV_SetEPTxStatus(bEpNum, EP_TX_VALID))
00077 #define _SetEPRxValid(bEpNum) (OTG_DEV_SetEPRxStatus(bEpNum, EP_RX_VALID))
00078
00079 #define _GetTxStallStatus(bEpNum) (OTG_DEV_GetEPTxStatus(bEpNum) == EP_TX_STALL)
00080 #define _GetRxStallStatus(bEpNum) (OTG_DEV_GetEPRxStatus(bEpNum) == EP_RX_STALL)
00081
00082
00083 #define OTGD_FS_DEVICE_RESET Device_Property.Reset()
00084
00085
00086
00087
00088 void OTG_DEV_Init(void);
00089 void OTG_DEV_EP_Init(uint8_t bEpAdd, uint8_t bEpType, uint16_t wEpMaxPackSize);
00090
00091 void OTG_DEV_SetEPRxStatus(uint8_t bEpnum, uint32_t status);
00092 void OTG_DEV_SetEPTxStatus(uint8_t bEpnum, uint32_t status);
00093 uint32_t OTG_DEV_GetEPRxStatus(uint8_t bEpnum);
00094 uint32_t OTG_DEV_GetEPTxStatus(uint8_t bEpnum);
00095
00096 void USB_DevDisconnect(void);
00097 void USB_DevConnect(void);
00098
00099
00100
00101 void SetEPTxStatus(uint8_t bEpNum, uint16_t wState);
00102 void SetEPRxStatus(uint8_t bEpNum, uint16_t wState);
00103 uint16_t GetEPTxStatus(uint8_t bEpNum);
00104 uint16_t GetEPRxStatus(uint8_t bEpNum);
00105 void SetEPTxValid(uint8_t bEpNum);
00106 void SetEPRxValid(uint8_t bEpNum);
00107 uint16_t GetTxStallStatus(uint8_t bEpNum);
00108 uint16_t GetRxStallStatus(uint8_t bEpNum);
00109 void SetEPTxCount(uint8_t bEpNum, uint16_t wCount);
00110 void SetEPRxCount(uint8_t bEpNum, uint16_t wCount);
00111
00112 uint16_t ToWord(uint8_t, uint8_t);
00113 uint16_t ByteSwap(uint16_t);
00114
00115
00116 #endif
00117
00118