2 ******************************************************************************
4 * @author MCD Application Team
6 * @date 19-September-2011
7 * @brief This file is responsible to offer board support package and is
8 * configurable by user.
9 ******************************************************************************
12 * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
13 * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
14 * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
15 * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
16 * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
17 * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
19 * <h2><center>© COPYRIGHT 2011 STMicroelectronics</center></h2>
20 ******************************************************************************
23 /* Includes ------------------------------------------------------------------*/
25 #include "usbd_conf.h"
26 #include "stm32f4xx_conf.h"
27 #include "../drivers/nvic.h"
28 #include "../drivers/io.h"
30 void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE
*pdev
) {
34 void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE
*pdev
,uint8_t state
) {
41 * @brief USB_OTG_BSP_Init
42 * Initilizes BSP configurations
47 void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE
*pdev
)
50 GPIO_InitTypeDef GPIO_InitStructure
;
54 NVIC_SetPriority(OTG_HS_IRQn
, NVIC_PRIO_USB
);
55 NVIC_DisableIRQ(OTG_HS_IRQn
);
57 NVIC_SetPriority(OTG_FS_IRQn
, NVIC_PRIO_USB
);
58 NVIC_DisableIRQ(OTG_FS_IRQn
);
61 RCC_AHB1PeriphClockCmd( RCC_AHB1Periph_GPIOA
, ENABLE
);
63 /* Configure SOF VBUS ID DM DP Pins */
64 GPIO_InitStructure
.GPIO_Pin
= GPIO_Pin_11
| GPIO_Pin_12
;
65 GPIO_InitStructure
.GPIO_Speed
= GPIO_Speed_100MHz
;
66 GPIO_InitStructure
.GPIO_Mode
= GPIO_Mode_AF
;
67 GPIO_InitStructure
.GPIO_OType
= GPIO_OType_PP
;
68 GPIO_InitStructure
.GPIO_PuPd
= GPIO_PuPd_NOPULL
;
69 GPIO_Init(GPIOA
, &GPIO_InitStructure
);
71 GPIO_PinAFConfig(GPIOA
,GPIO_PinSource11
,GPIO_AF_OTG1_FS
) ;
72 GPIO_PinAFConfig(GPIOA
,GPIO_PinSource12
,GPIO_AF_OTG1_FS
) ;
74 #ifdef VBUS_SENSING_ENABLED
75 IOConfigGPIO(IOGetByTag(IO_TAG(VBUS_SENSING_PIN
)), IOCFG_IN_FLOATING
);
78 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG
, ENABLE
);
79 RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS
, ENABLE
) ;
81 EXTI_ClearITPendingBit(EXTI_Line0
);
84 * @brief USB_OTG_BSP_EnableInterrupt
85 * Enabele USB Global interrupt
89 void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE
*pdev
)
94 NVIC_SetPriority(OTG_HS_IRQn
, NVIC_PRIO_USB
);
95 NVIC_EnableIRQ(OTG_HS_IRQn
);
97 NVIC_SetPriority(OTG_FS_IRQn
, NVIC_PRIO_USB
);
98 NVIC_EnableIRQ(OTG_FS_IRQn
);
102 * @brief USB_OTG_BSP_uDelay
103 * This function provides delay time in micro sec
104 * @param usec : Value of delay required in micro sec
107 #pragma GCC diagnostic push
108 #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
109 void USB_OTG_BSP_uDelay (const uint32_t usec
)
112 const uint32_t utime
= (120 * usec
/ 7);
115 if ( ++count
> utime
)
122 #pragma GCC diagnostic pop
125 * @brief USB_OTG_BSP_mDelay
126 * This function provides delay time in milli sec
127 * @param msec : Value of delay required in milli sec
130 void USB_OTG_BSP_mDelay (const uint32_t msec
)
132 USB_OTG_BSP_uDelay(msec
* 1000);
146 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/