tested all the stm32f4 board, work great
This commit is contained in:
parent
8a2b228c3f
commit
de659be83e
|
@ -106,6 +106,7 @@ void board_init(void)
|
||||||
|
|
||||||
// USB Pins
|
// USB Pins
|
||||||
// Configure USB DM and DP pins. This is optional, and maintained only for user guidance.
|
// 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.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
|
|
@ -117,6 +117,7 @@ void board_init(void)
|
||||||
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
|
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* Configure USB DM and DP pins */
|
/* Configure USB DM and DP pins */
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
|
GPIO_InitStruct.Pin = (GPIO_PIN_11 | GPIO_PIN_12);
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
|
|
@ -106,14 +106,10 @@ void board_init(void)
|
||||||
// Notify runtime of frequency change.
|
// Notify runtime of frequency change.
|
||||||
SystemCoreClockUpdate();
|
SystemCoreClockUpdate();
|
||||||
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE(); // button, USB D+/D-
|
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE(); // LED
|
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
|
||||||
// LED
|
// LED
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE();
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = LED_PIN;
|
GPIO_InitStruct.Pin = LED_PIN;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
@ -123,20 +119,17 @@ void board_init(void)
|
||||||
board_led_write(false);
|
board_led_write(false);
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = BUTTON_PIN;
|
GPIO_InitStruct.Pin = BUTTON_PIN;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FAST;
|
||||||
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
|
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
|
||||||
|
|
||||||
// Enable USB OTG clock
|
|
||||||
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
|
|
||||||
|
|
||||||
// USB Pin Init
|
// USB Pin Init
|
||||||
// PA9- VUSB, PA10- ID, PA11- DM, PA12- DP
|
// PA9- VUSB, PA10- ID, PA11- DM, PA12- DP
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE();
|
|
||||||
|
|
||||||
/* Configure DM DP Pins */
|
/* Configure DM DP Pins */
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
|
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
@ -157,6 +150,9 @@ void board_init(void)
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
|
GPIO_InitStruct.Alternate = GPIO_AF10_OTG_FS;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
// Enable USB OTG clock
|
||||||
|
__HAL_RCC_USB_OTG_FS_CLK_ENABLE();
|
||||||
}
|
}
|
||||||
|
|
||||||
//--------------------------------------------------------------------+
|
//--------------------------------------------------------------------+
|
||||||
|
|
|
@ -106,12 +106,10 @@ void board_init(void)
|
||||||
// Notify runtime of frequency change.
|
// Notify runtime of frequency change.
|
||||||
SystemCoreClockUpdate();
|
SystemCoreClockUpdate();
|
||||||
|
|
||||||
__HAL_RCC_GPIOA_CLK_ENABLE(); // button, USB D+/D-
|
|
||||||
__HAL_RCC_GPIOD_CLK_ENABLE(); // LED
|
|
||||||
|
|
||||||
GPIO_InitTypeDef GPIO_InitStruct;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
|
||||||
// LED
|
// LED
|
||||||
|
__HAL_RCC_GPIOD_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = LED_PIN;
|
GPIO_InitStruct.Pin = LED_PIN;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
@ -121,6 +119,7 @@ void board_init(void)
|
||||||
board_led_write(false);
|
board_led_write(false);
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = BUTTON_PIN;
|
GPIO_InitStruct.Pin = BUTTON_PIN;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||||
|
@ -132,6 +131,7 @@ void board_init(void)
|
||||||
|
|
||||||
/* Configure USB FS GPIOs */
|
/* Configure USB FS GPIOs */
|
||||||
/* Configure USB D+ D- Pins */
|
/* Configure USB D+ D- Pins */
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
|
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
|
|
@ -126,13 +126,10 @@ void board_init(void)
|
||||||
//NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
//NVIC_SetPriority(USB0_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
|
||||||
#endif
|
#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;
|
GPIO_InitTypeDef GPIO_InitStruct;
|
||||||
|
|
||||||
// LED
|
// LED
|
||||||
|
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = LED_PIN;
|
GPIO_InitStruct.Pin = LED_PIN;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
GPIO_InitStruct.Pull = GPIO_PULLUP;
|
||||||
|
@ -142,6 +139,7 @@ void board_init(void)
|
||||||
board_led_write(false);
|
board_led_write(false);
|
||||||
|
|
||||||
// Button
|
// Button
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = BUTTON_PIN;
|
GPIO_InitStruct.Pin = BUTTON_PIN;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
GPIO_InitStruct.Pull = GPIO_PULLDOWN;
|
||||||
|
@ -150,6 +148,7 @@ void board_init(void)
|
||||||
|
|
||||||
/* Configure USB FS GPIOs */
|
/* Configure USB FS GPIOs */
|
||||||
/* Configure USB D+ D- Pins */
|
/* Configure USB D+ D- Pins */
|
||||||
|
__HAL_RCC_GPIOA_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
|
GPIO_InitStruct.Pin = GPIO_PIN_11 | GPIO_PIN_12;
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_HIGH;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
|
||||||
|
@ -172,6 +171,7 @@ void board_init(void)
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
/* Configure POWER_SWITCH IO pin */
|
/* Configure POWER_SWITCH IO pin */
|
||||||
|
__HAL_RCC_GPIOG_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
GPIO_InitStruct.Pin = GPIO_PIN_8;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD;
|
||||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||||
|
|
|
@ -39,3 +39,10 @@ INC += \
|
||||||
# For TinyUSB port source
|
# For TinyUSB port source
|
||||||
VENDOR = st
|
VENDOR = st
|
||||||
CHIP_FAMILY = synopsys
|
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
|
||||||
|
|
|
@ -158,6 +158,7 @@ void board_init(void)
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
|
GPIO_InitStruct.Alternate = GPIO_AF10_OTG2_HS;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
// LED
|
||||||
__HAL_RCC_GPIOB_CLK_ENABLE();
|
__HAL_RCC_GPIOB_CLK_ENABLE();
|
||||||
|
|
||||||
GPIO_InitStruct.Pin = LED_PIN;
|
GPIO_InitStruct.Pin = LED_PIN;
|
||||||
|
@ -166,6 +167,7 @@ void board_init(void)
|
||||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||||
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
|
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
// Button
|
||||||
__HAL_RCC_GPIOC_CLK_ENABLE();
|
__HAL_RCC_GPIOC_CLK_ENABLE();
|
||||||
GPIO_InitStruct.Pin = BUTTON_PIN;
|
GPIO_InitStruct.Pin = BUTTON_PIN;
|
||||||
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
|
||||||
|
|
Loading…
Reference in New Issue