usb_bsp.c
Go to the documentation of this file.
1 
23 /* Includes ------------------------------------------------------------------*/
24 #include "usb_bsp.h"
25 #include "usbd_conf.h"
26 #include "stm32f4xx_conf.h"
27 
28 
30  (void)pdev;
31 }
32 
33 void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev,uint8_t state) {
34  (void)pdev;
35  (void)state;
36 }
37 
38 
47 {
48  (void)pdev;
49  GPIO_InitTypeDef GPIO_InitStructure;
50 
51 #ifndef USE_ULPI_PHY
52 #ifdef USB_OTG_FS_LOW_PWR_MGMT_SUPPORT
53  EXTI_InitTypeDef EXTI_InitStructure;
54  NVIC_InitTypeDef NVIC_InitStructure;
55 #endif
56 #endif
57 
58  NVIC_InitTypeDef NVIC_InitStructure;
59 #ifdef USE_USB_OTG_HS
60  NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_IRQn;
61 #else
62  NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
63 #endif
64  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
65  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
66  NVIC_InitStructure.NVIC_IRQChannelCmd = DISABLE;
67  NVIC_Init(&NVIC_InitStructure);
68 
70 
71  /* Configure SOF VBUS ID DM DP Pins */
72  GPIO_InitStructure.GPIO_Pin = GPIO_Pin_11 | GPIO_Pin_12;
73  GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz;
74  GPIO_InitStructure.GPIO_Mode = GPIO_Mode_AF;
75  GPIO_InitStructure.GPIO_OType = GPIO_OType_PP;
76  GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL ;
77  GPIO_Init(GPIOA, &GPIO_InitStructure);
78 
81 
84 
85  /* enable the PWR clock */
87 
89 }
97 {
98  (void)pdev;
99  NVIC_InitTypeDef NVIC_InitStructure;
100 
101 #ifdef USE_USB_OTG_HS
102  NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_IRQn;
103 #else
104  NVIC_InitStructure.NVIC_IRQChannel = OTG_FS_IRQn;
105 #endif
106  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
107  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
108  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
109  NVIC_Init(&NVIC_InitStructure);
110 #ifdef USB_OTG_HS_DEDICATED_EP1_ENABLED
112  NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_OUT_IRQn;
113  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
114  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 2;
115  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
116  NVIC_Init(&NVIC_InitStructure);
117 
119  NVIC_InitStructure.NVIC_IRQChannel = OTG_HS_EP1_IN_IRQn;
120  NVIC_InitStructure.NVIC_IRQChannelPreemptionPriority = 1;
121  NVIC_InitStructure.NVIC_IRQChannelSubPriority = 1;
122  NVIC_InitStructure.NVIC_IRQChannelCmd = ENABLE;
123  NVIC_Init(&NVIC_InitStructure);
124 #endif
125 }
132 #pragma GCC diagnostic push
133 #pragma GCC diagnostic ignored "-Wunsafe-loop-optimizations"
134 void USB_OTG_BSP_uDelay (const uint32_t usec)
135 {
136  uint32_t count = 0;
137  const uint32_t utime = (120 * usec / 7);
138  do
139  {
140  if ( ++count > utime )
141  {
142  return ;
143  }
144  }
145  while (1);
146 }
147 #pragma GCC diagnostic pop
148 
155 void USB_OTG_BSP_mDelay (const uint32_t msec)
156 {
157  USB_OTG_BSP_uDelay(msec * 1000);
158 }
171 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
void USB_OTG_BSP_DriveVBUS(USB_OTG_CORE_HANDLE *pdev, uint8_t state)
Definition: usb_bsp.c:33
Specific api's relative to the used hardware platform.
void GPIO_PinAFConfig(GPIO_TypeDef *GPIOx, uint16_t GPIO_PinSource, uint8_t GPIO_AF)
Changes the mapping of the specified pin.
void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct)
Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.
void NVIC_PriorityGroupConfig(uint32_t NVIC_PriorityGroup)
Configures the priority grouping: pre-emption priority and subpriority.
EXTI Init Structure definition.
#define GPIOA
Definition: stm32f4xx.h:2110
void USB_OTG_BSP_Init(USB_OTG_CORE_HANDLE *pdev)
USB_OTG_BSP_Init Initilizes BSP configurations.
Definition: usb_bsp.c:46
void USB_OTG_BSP_uDelay(const uint32_t usec)
USB_OTG_BSP_uDelay This function provides delay time in micro sec.
Definition: usb_bsp.c:134
void RCC_AHB1PeriphClockCmd(uint32_t RCC_AHB1Periph, FunctionalState NewState)
Enables or disables the AHB1 peripheral clock.
void RCC_APB2PeriphClockCmd(uint32_t RCC_APB2Periph, FunctionalState NewState)
Enables or disables the High Speed APB (APB2) peripheral clock.
void GPIO_Init(GPIO_TypeDef *GPIOx, GPIO_InitTypeDef *GPIO_InitStruct)
Initializes the GPIOx peripheral according to the specified parameters in the GPIO_InitStruct.
void RCC_APB1PeriphResetCmd(uint32_t RCC_APB1Periph, FunctionalState NewState)
Forces or releases Low Speed APB (APB1) peripheral reset.
void RCC_AHB2PeriphClockCmd(uint32_t RCC_AHB2Periph, FunctionalState NewState)
Enables or disables the AHB2 peripheral clock.
#define EXTI_Line0
void USB_OTG_BSP_mDelay(const uint32_t msec)
USB_OTG_BSP_mDelay This function provides delay time in milli sec.
Definition: usb_bsp.c:155
void USB_OTG_BSP_EnableInterrupt(USB_OTG_CORE_HANDLE *pdev)
USB_OTG_BSP_EnableInterrupt Enabele USB Global interrupt.
Definition: usb_bsp.c:96
void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
Clears the EXTI's line pending bits.
USB Device configuration file.
void USB_OTG_BSP_ConfigVBUS(USB_OTG_CORE_HANDLE *pdev)
Definition: usb_bsp.c:29


rosflight_firmware
Author(s): Daniel Koch , James Jackson
autogenerated on Wed Jul 3 2019 19:59:26