tested all the stm32f4 board, work great

This commit is contained in:
hathach 2019-09-11 17:37:23 +07:00
parent 8a2b228c3f
commit de659be83e
7 changed files with 24 additions and 17 deletions

View File

@ -106,6 +106,7 @@ void board_init(void)
// USB Pins
// Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL;

View File

@ -83,7 +83,7 @@ static void SystemClock_Config(void)
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2);
/* Enable Power Clock */
/* Enable Power Clock */
__HAL_RCC_PWR_CLK_ENABLE();
}
@ -117,6 +117,7 @@ void board_init(void)
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
/* Configure USB DM and 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;

View File

@ -106,14 +106,10 @@ void board_init(void)
// Notify runtime of frequency change.
SystemCoreClockUpdate();
__HAL_RCC_GPIOA_CLK_ENABLE(); // button, USB D+/D-
__HAL_RCC_GPIOD_CLK_ENABLE(); // LED
GPIO_InitTypeDef GPIO_InitStruct;
// LED
__HAL_RCC_GPIOD_CLK_ENABLE();
GPIO_InitStruct.Pin = LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
@ -123,20 +119,17 @@ void board_init(void)
board_led_write(false);
// Button
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = BUTTON_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
// Enable USB OTG clock
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
// USB Pin Init
// PA9- VUSB, PA10- ID, PA11- DM, PA12- DP
__HAL_RCC_GPIOA_CLK_ENABLE();
/* Configure DM DP Pins */
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
@ -157,6 +150,9 @@ void board_init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// Enable USB OTG clock
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
}
//--------------------------------------------------------------------+

View File

@ -106,12 +106,10 @@ void board_init(void)
// Notify runtime of frequency change.
SystemCoreClockUpdate();
__HAL_RCC_GPIOA_CLK_ENABLE(); // button, USB D+/D-
__HAL_RCC_GPIOD_CLK_ENABLE(); // LED
GPIO_InitTypeDef GPIO_InitStruct;
// LED
__HAL_RCC_GPIOD_CLK_ENABLE();
GPIO_InitStruct.Pin = LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
@ -121,6 +119,7 @@ void board_init(void)
board_led_write(false);
// Button
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = BUTTON_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
@ -132,6 +131,7 @@ void board_init(void)
/* Configure USB FS GPIOs */
/* Configure USB D+ D- Pins */
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;

View File

@ -126,13 +126,10 @@ void board_init(void)
//NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
#endif
__HAL_RCC_GPIOA_CLK_ENABLE(); // button, USB D+/D-
__HAL_RCC_GPIOE_CLK_ENABLE(); // LED
__HAL_RCC_GPIOG_CLK_ENABLE(); // USB power switch IO pin
GPIO_InitTypeDef GPIO_InitStruct;
// LED
__HAL_RCC_GPIOE_CLK_ENABLE();
GPIO_InitStruct.Pin = LED_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_PULLUP;
@ -142,6 +139,7 @@ void board_init(void)
board_led_write(false);
// Button
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = BUTTON_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
@ -150,6 +148,7 @@ void board_init(void)
/* Configure USB FS GPIOs */
/* Configure USB D+ D- Pins */
__HAL_RCC_GPIOA_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
@ -172,6 +171,7 @@ void board_init(void)
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
/* Configure POWER_SWITCH IO pin */
__HAL_RCC_GPIOG_CLK_ENABLE();
GPIO_InitStruct.Pin = GPIO_PIN_8;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
GPIO_InitStruct.Pull = GPIO_NOPULL;

View File

@ -39,3 +39,10 @@ INC += \
# For TinyUSB port source
VENDOR = st
CHIP_FAMILY = synopsys
# Path to STM32 Cube Programmer CLI, should be added into system path
STM32Prog = STM32_Programmer_CLI
# flash target using on-board stlink
flash: $(BUILD)/$(BOARD)-firmware.elf
$(STM32Prog) --connect port=swd --write $< --go

View File

@ -158,6 +158,7 @@ void board_init(void)
GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
// LED
__HAL_RCC_GPIOB_CLK_ENABLE();
GPIO_InitStruct.Pin = LED_PIN;
@ -166,6 +167,7 @@ void board_init(void)
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
// Button
__HAL_RCC_GPIOC_CLK_ENABLE();
GPIO_InitStruct.Pin = BUTTON_PIN;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;