mirror of
https://github.com/hathach/tinyusb.git
synced 2025-02-14 18:40:37 +00:00
switch stm32f3 to use st_driver
This commit is contained in:
parent
c4b384d22f
commit
1d2223a116
@ -1,32 +1,35 @@
|
||||
CFLAGS += \
|
||||
-DHSE_VALUE=8000000 \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_STM32F3 \
|
||||
-DSTM32F303xC \
|
||||
-mthumb \
|
||||
-mabi=aapcs-linux \
|
||||
-mcpu=cortex-m4 \
|
||||
-mfloat-abi=hard \
|
||||
-mfpu=fpv4-sp-d16 \
|
||||
-nostdlib -nostartfiles
|
||||
-nostdlib -nostartfiles \
|
||||
-DCFG_TUSB_MCU=OPT_MCU_STM32F3
|
||||
|
||||
ST_HAL_DRIVER = hw/mcu/st/st_driver/STM32F3xx_HAL_Driver
|
||||
ST_CMSIS = hw/mcu/st/st_driver/CMSIS/Device/ST/STM32F3xx
|
||||
|
||||
# All source paths should be relative to the top level.
|
||||
LD_FILE = hw/bsp/stm32f303disco/STM32F303VCTx_FLASH.ld
|
||||
|
||||
SRC_C += \
|
||||
hw/mcu/st/system-init/system_stm32f3xx.c \
|
||||
hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal.c \
|
||||
hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_cortex.c \
|
||||
hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_rcc.c \
|
||||
hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_gpio.c
|
||||
$(ST_CMSIS)/Source/Templates/system_stm32f3xx.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_cortex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_rcc.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f3xx_hal_gpio.c
|
||||
|
||||
SRC_S += \
|
||||
hw/mcu/st/startup/stm32f3/startup_stm32f303xc.s
|
||||
|
||||
INC += \
|
||||
$(TOP)/hw/bsp/stm32f303disco \
|
||||
$(TOP)/hw/mcu/st/cmsis \
|
||||
$(TOP)/hw/mcu/st/stm32lib/CMSIS/STM32F3xx/Include \
|
||||
$(TOP)/hw/mcu/st/stm32lib/STM32F3xx_HAL_Driver/Inc
|
||||
$(TOP)/hw/mcu/st/st_driver/CMSIS/Include \
|
||||
$(TOP)/$(ST_CMSIS)/Include \
|
||||
$(TOP)/$(ST_HAL_DRIVER)/Inc \
|
||||
$(TOP)/hw/bsp/$(BOARD)
|
||||
|
||||
# For TinyUSB port source
|
||||
VENDOR = st
|
||||
|
@ -29,8 +29,13 @@
|
||||
#include "stm32f3xx.h"
|
||||
#include "stm32f3xx_hal_conf.h"
|
||||
|
||||
#define LED_PORT GPIOE
|
||||
#define LED_PIN GPIO_PIN_9
|
||||
#define LED_PORT GPIOE
|
||||
#define LED_PIN GPIO_PIN_9
|
||||
#define LED_STATE_ON 1
|
||||
|
||||
#define BUTTON_PORT GPIOA
|
||||
#define BUTTON_PIN GPIO_PIN_0
|
||||
#define BUTTON_STATE_ACTIVE 1
|
||||
|
||||
void board_init(void)
|
||||
{
|
||||
@ -64,10 +69,8 @@ void board_init(void)
|
||||
// Notify runtime of frequency change.
|
||||
SystemCoreClockUpdate();
|
||||
|
||||
/* -1- Enable GPIO Clock (to be able to program the configuration registers) */
|
||||
// LED
|
||||
__HAL_RCC_GPIOE_CLK_ENABLE();
|
||||
|
||||
/* -2- Configure PE.8 to PE.15 IOs in output push-pull mode to drive external LEDs */
|
||||
GPIO_InitTypeDef GPIO_InitStruct;
|
||||
GPIO_InitStruct.Pin = LED_PIN;
|
||||
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
|
||||
@ -75,7 +78,13 @@ void board_init(void)
|
||||
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_HIGH;
|
||||
HAL_GPIO_Init(LED_PORT, &GPIO_InitStruct);
|
||||
|
||||
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_FREQ_HIGH;
|
||||
HAL_GPIO_Init(BUTTON_PORT, &GPIO_InitStruct);
|
||||
|
||||
#if 0
|
||||
RCC->AHB2ENR |= RCC_AHB2ENR_OTGFSEN;
|
||||
@ -102,18 +111,16 @@ void board_init(void)
|
||||
|
||||
void board_led_write(bool state)
|
||||
{
|
||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state);
|
||||
HAL_GPIO_WritePin(LED_PORT, LED_PIN, state ? LED_STATE_ON : (1-LED_STATE_ON));
|
||||
}
|
||||
|
||||
uint32_t board_button_read(void)
|
||||
{
|
||||
// TODO implement
|
||||
return 0;
|
||||
return BUTTON_STATE_ACTIVE == HAL_GPIO_ReadPin(BUTTON_PORT, BUTTON_PIN);
|
||||
}
|
||||
|
||||
#if CFG_TUSB_OS == OPT_OS_NONE
|
||||
volatile uint32_t system_ticks = 0;
|
||||
|
||||
void SysTick_Handler (void)
|
||||
{
|
||||
system_ticks++;
|
||||
|
@ -20,7 +20,7 @@ SRC_C += \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f4xx_hal.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f4xx_hal_cortex.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f4xx_hal_rcc.c \
|
||||
$(ST_HAL_DRIVER)/Src/stm32f4xx_hal_gpio.c
|
||||
$(ST_HAL_DRIVER)/Src/stm32f4xx_hal_gpio.c
|
||||
|
||||
SRC_S += \
|
||||
$(ST_CMSIS)/Source/Templates/gcc/startup_stm32f407xx.s
|
||||
|
@ -1 +1 @@
|
||||
Subproject commit acc346e98e646ba16b7c495ef3e9363d289b8ea1
|
||||
Subproject commit fd4cb843d79efa2ad41bc8ff0b2bd0f8c2c55297
|
Loading…
x
Reference in New Issue
Block a user