Nut/OS  5.0.5
API Reference
otgd_fs_dev.h
Go to the documentation of this file.
00001 /******************** (C) COPYRIGHT 2010 STMicroelectronics ********************
00002 * File Name          : otg_dev.h
00003 * Author             : STMicroelectronics
00004 * Version            : V3.1.1
00005 * Date               : 04/07/2010
00006 * Description        : linking defines
00007 ********************************************************************************
00008 * THE PRESENT SOFTWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
00009 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE TIME.
00010 * AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY DIRECT,
00011 * INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING FROM THE
00012 * CONTENT OF SUCH SOFTWARE AND/OR THE USE MADE BY CUSTOMERS OF THE CODING
00013 * INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
00014 *******************************************************************************/
00015 
00016 /* Define to prevent recursive inclusion -------------------------------------*/
00017 #ifndef __OTG_DEV_H__
00018 #define __OTG_DEV_H__
00019 
00020 /* Includes ------------------------------------------------------------------*/
00021 #include <arch/cm3/stm/stm32xxxx.h>
00022 #include <dev/usb_stm32/usb_type.h>
00023 #include <stdint.h>
00024 
00025 /* Exported types ------------------------------------------------------------*/
00026 /* Exported constants --------------------------------------------------------*/
00027 
00028 /* Endpoint types */
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 /* Endpoint Addresses (w/direction) */
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 /*-*-*-*-*-*-*-*-*-* Replace the usb_regs.h defines -*-*-*-*-*-*-*-*-*-*-*-*-*/
00046 /* endpoints enumeration */
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 /* EP Transmit status defines */
00057 #define EP_TX_DIS              DEV_EP_TX_DIS)  /* EndPoint TX DISabled */
00058 #define EP_TX_STALL            DEV_EP_TX_STALL /* EndPoint TX STALLed */
00059 #define EP_TX_NAK              DEV_EP_TX_NAK   /* EndPoint TX NAKed */
00060 #define EP_TX_VALID            DEV_EP_TX_VALID /* EndPoint TX VALID */
00061 
00062 /* EP Transmit status defines */
00063 #define EP_RX_DIS              DEV_EP_RX_DIS   /* EndPoint RX DISabled */
00064 #define EP_RX_STALL            DEV_EP_RX_STALL /* EndPoint RX STALLed */
00065 #define EP_RX_NAK              DEV_EP_RX_NAK   /* EndPoint RX NAKed */
00066 #define EP_RX_VALID            DEV_EP_RX_VALID /* EndPoint RX VALID */
00067 /*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*/
00068 
00069 /* Exported macro ------------------------------------------------------------*/
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 /* Define the callbacks for updating the USB state machine */
00083 #define OTGD_FS_DEVICE_RESET              Device_Property.Reset()
00084 
00085 /* Exported define -----------------------------------------------------------*/
00086 /* Exported functions ------------------------------------------------------- */
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 /*-*-*-*-*-*-*-*-*-* Replace the usb_regs.h prototypes *-*-*-*-*-*-*-*-*-*-*-*/
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 /* __OTG_DEV_H__ */
00117 /******************* (C) COPYRIGHT 2010 STMicroelectronics *****END OF FILE****/
00118