Fix WS2812 led definition
[inav.git] / src / main / vcpf4 / usb_bsp.c
blobe322ec8931c42c6acae4edf0204d8e367d5d6956
1 /**
2 ******************************************************************************
3 * @file usb_bsp.c
4 * @author MCD Application Team
5 * @version V1.0.0
6 * @date 19-September-2011
7 * @brief This file is responsible to offer board support package and is
8 * configurable by user.
9 ******************************************************************************
10 * @attention
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>&copy; COPYRIGHT 2011 STMicroelectronics</center></h2>
20 ******************************************************************************
23 /* Includes ------------------------------------------------------------------*/
24 #include "usb_bsp.h"
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) {
31 (void)pdev;
34 void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state) {
35 (void)pdev;
36 (void)state;
40 /**
41 * @brief USB_OTG_BSP_Init
42 * Initilizes BSP configurations
43 * @param None
44 * @retval None
47 void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
49 (void)pdev;
50 GPIO_InitTypeDef GPIO_InitStructure;
53 #ifdef USE_USB_OTG_HS
54 NVIC_SetPriority(OTG_HS_IRQn, NVIC_PRIO_USB);
55 NVIC_DisableIRQ(OTG_HS_IRQn);
56 #else
57 NVIC_SetPriority(OTG_FS_IRQn, NVIC_PRIO_USB);
58 NVIC_DisableIRQ(OTG_FS_IRQn);
59 #endif
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);
76 #endif
78 RCC_APB2PeriphClockCmd(RCC_APB2Periph_SYSCFG, ENABLE);
79 RCC_AHB2PeriphClockCmd(RCC_AHB2Periph_OTG_FS, ENABLE) ;
81 EXTI_ClearITPendingBit(EXTI_Line0);
83 /**
84 * @brief USB_OTG_BSP_EnableInterrupt
85 * Enabele USB Global interrupt
86 * @param None
87 * @retval None
89 void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)
91 (void)pdev;
93 #ifdef USE_USB_OTG_HS
94 NVIC_SetPriority(OTG_HS_IRQn, NVIC_PRIO_USB);
95 NVIC_EnableIRQ(OTG_HS_IRQn);
96 #else
97 NVIC_SetPriority(OTG_FS_IRQn, NVIC_PRIO_USB);
98 NVIC_EnableIRQ(OTG_FS_IRQn);
99 #endif
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
105 * @retval None
107 #pragma GCC diagnostic push
108 #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
109 void USB_OTG_BSP_uDelay (const uint32_t usec)
111 uint32_t count = 0;
112 const uint32_t utime = (120 * usec / 7);
115 if ( ++count > utime )
117 return ;
120 while (1);
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
128 * @retval None
130 void USB_OTG_BSP_mDelay (const uint32_t msec)
132 USB_OTG_BSP_uDelay(msec * 1000);
135 * @}
139 * @}
143 * @}
146 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/