Merge pull request #234 from hathach/stm32f4-blackpill
move VBUS sense out of dcd_synosys to bsp
This commit is contained in:
@@ -38,6 +38,14 @@
|
||||
#define BUTTON_STATE_ACTIVE 1
|
||||
|
||||
|
||||
// enable all LED, Button, Uart, USB clock
|
||||
static void all_rcc_clk_enable(void)
|
||||
{
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE(); // USB D+, D-
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE(); // LED
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE(); // Button
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief System Clock Configuration
|
||||
* The system Clock is configured as follow :
|
||||
@@ -91,21 +99,22 @@ void board_init(void)
|
||||
#endif
|
||||
|
||||
SystemClock_Config();
|
||||
|
||||
// Notify runtime of frequency change.
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
// LED
|
||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||
all_rcc_clk_enable();
|
||||
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
|
||||
// LED
|
||||
GPIO_InitStruct.Pin = LED_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
|
||||
|
||||
board_led_write(false);
|
||||
|
||||
// Button
|
||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||
GPIO_InitStruct.Pin = BUTTON_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||
@@ -113,7 +122,6 @@ void board_init(void)
|
||||
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
|
||||
|
||||
/* Configure DM DP Pins */
|
||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||
GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
@@ -136,6 +144,10 @@ void board_init(void)
|
||||
|
||||
/* Enable USB FS Clocks */
|
||||
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
|
||||
|
||||
// Enable VBUS sense (B device) via pin PA9
|
||||
USB_OTG_FS->GCCFG &= ~USB_OTG_GCCFG_NOVBUSSENS;
|
||||
USB_OTG_FS->GCCFG |= USB_OTG_GCCFG_VBUSBSEN;
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------+
|
||||
|
Reference in New Issue
Block a user