Code restructuring
This commit is contained in:
parent
93388152fa
commit
75dda2e6eb
2
.gitignore
vendored
2
.gitignore
vendored
@ -1 +1 @@
|
||||
build/
|
||||
_build/
|
||||
|
3
.vscode/c_cpp_properties.json
vendored
3
.vscode/c_cpp_properties.json
vendored
@ -3,7 +3,8 @@
|
||||
{
|
||||
"name": "Linux",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
"${workspaceFolder}/**",
|
||||
"${workspaceFolder}/base"
|
||||
],
|
||||
"defines": [],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
|
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
@ -8,7 +8,7 @@
|
||||
"name": "gdb Launch Debug",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/build/firmware.elf",
|
||||
"program": "${workspaceFolder}/_build/firmware.elf",
|
||||
"args": [
|
||||
"-d","${workspaceFolder}/Core/Src",
|
||||
"-d","${workspaceFolder}/Core/Startup",
|
||||
@ -53,7 +53,7 @@
|
||||
},
|
||||
{
|
||||
"description": "Load executable into debugger.",
|
||||
"text": "file ${workspaceFolder}/build/firmware.elf",
|
||||
"text": "file ${workspaceFolder}/_build/firmware.elf",
|
||||
"ignoreFailures": false
|
||||
},
|
||||
{
|
||||
|
@ -5,13 +5,15 @@
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#include "platform/stm32g0xx/Gpio.h"
|
||||
|
||||
IWDG_HandleTypeDef hiwdg;
|
||||
UART_HandleTypeDef huart2;
|
||||
|
||||
static void SystemClock_Config(void);
|
||||
static void MX_GPIO_Init(void);
|
||||
static void MX_USART2_UART_Init(void);
|
||||
static void MX_IWDG_Init(void);
|
||||
// static void MX_IWDG_Init(void);
|
||||
|
||||
#define SYS_TICK_PRIO 0
|
||||
|
||||
@ -64,7 +66,11 @@ int main(void)
|
||||
j = 800;
|
||||
}
|
||||
printf("%u: Hello World\r\n", i++);
|
||||
<<<<<<< HEAD
|
||||
HAL_GPIO_TogglePin(LED_GREEN_GPIO_Port, LED_GREEN_Pin);
|
||||
=======
|
||||
green_led.toggle();
|
||||
>>>>>>> 133286e (fix: format)
|
||||
HAL_Delay(j);
|
||||
// HAL_IWDG_Refresh(&hiwdg);
|
||||
}
|
||||
@ -137,16 +143,16 @@ void SystemClock_Config(void)
|
||||
MODIFY_REG(RCC->CCIPR, RCC_CCIPR_USART2SEL, RCC_USART2CLKSOURCE_PCLK1);
|
||||
}
|
||||
|
||||
static void MX_IWDG_Init(void)
|
||||
{
|
||||
hiwdg.Instance = IWDG;
|
||||
hiwdg.Init.Prescaler = IWDG_PRESCALER_4;
|
||||
hiwdg.Init.Window = 4095;
|
||||
hiwdg.Init.Reload = 4095;
|
||||
if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
|
||||
Error_Handler();
|
||||
}
|
||||
}
|
||||
// static void MX_IWDG_Init(void)
|
||||
// {
|
||||
// hiwdg.Instance = IWDG;
|
||||
// hiwdg.Init.Prescaler = IWDG_PRESCALER_4;
|
||||
// hiwdg.Init.Window = 4095;
|
||||
// hiwdg.Init.Reload = 4095;
|
||||
// if (HAL_IWDG_Init(&hiwdg) != HAL_OK) {
|
||||
// Error_Handler();
|
||||
// }
|
||||
// }
|
||||
|
||||
static void MX_USART2_UART_Init(void)
|
||||
{
|
69
Makefile
69
Makefile
@ -3,40 +3,32 @@ TARGET = firmware
|
||||
DEBUG = 1
|
||||
OPT = -O0
|
||||
|
||||
BUILD_DIR = build
|
||||
BUILD_DIR = _build
|
||||
|
||||
CC_SOURCES = \
|
||||
Core/Src/main.cc \
|
||||
Core/main.cc \
|
||||
platform/stm32g0xx/Gpio.cc \
|
||||
|
||||
C_SOURCES = \
|
||||
Core/Src/stm32g0xx_it.c \
|
||||
Core/Src/stm32g0xx_hal_msp.c \
|
||||
Core/Src/system_stm32g0xx.c \
|
||||
Core/Src/syscalls.c \
|
||||
Core/Src/sysmem.c \
|
||||
Core/Src/print.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_iwdg.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c \
|
||||
Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim.c \
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_tim_ex.c \
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_ll_rcc.c \
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash.c \
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_flash_ex.c \
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma.c \
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_dma_ex.c \
|
||||
|
||||
# Drivers/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_exti.c
|
||||
platform/stm32g0xx/stm32g0xx_it.c \
|
||||
platform/stm32g0xx/stm32g0xx_hal_msp.c \
|
||||
platform/stm32g0xx/system_stm32g0xx.c \
|
||||
platform/stm32g0xx/syscalls.c \
|
||||
platform/stm32g0xx/sysmem.c \
|
||||
Core/print.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_cortex.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_rcc_ex.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_pwr_ex.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_iwdg.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart_ex.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_uart.c \
|
||||
Legacy/STM32G0xx_HAL_Driver/Src/stm32g0xx_hal_gpio.c
|
||||
|
||||
ASM_SOURCES = \
|
||||
Core/Startup/startup_stm32g071rbtx.s
|
||||
platform/stm32g0xx/startup_stm32g071rbtx.s
|
||||
|
||||
PREFIX = arm-none-eabi-
|
||||
CC = $(PREFIX)gcc
|
||||
@ -51,22 +43,18 @@ BIN = $(CP) -O binary -S
|
||||
CPU = -mcpu=cortex-m0plus
|
||||
MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
|
||||
|
||||
AS_DEFS =
|
||||
|
||||
C_DEFS = \
|
||||
-DUSE_HAL_DRIVER \
|
||||
-DSTM32G071xx
|
||||
|
||||
|
||||
AS_INCLUDES =
|
||||
|
||||
C_INCLUDES = \
|
||||
-ICore/Inc \
|
||||
-IDrivers/STM32G0xx_HAL_Driver/Inc \
|
||||
-IDrivers/STM32G0xx_HAL_Driver/Inc/Legacy \
|
||||
-IDrivers/CMSIS/Device/ST/STM32G0xx/Include \
|
||||
-IDrivers/CMSIS/Include
|
||||
|
||||
-I. \
|
||||
-ICore \
|
||||
-ILegacy/STM32G0xx_HAL_Driver/Inc \
|
||||
-ILegacy/STM32G0xx_HAL_Driver/Inc/Legacy \
|
||||
-Iarch/CMSIS/Device/ST/STM32G0xx/Include \
|
||||
-Iarch/CMSIS/Include \
|
||||
-Iplatform/stm32g0xx
|
||||
|
||||
ASFLAGS = $(MCU) $(AS_DEFS) $(AS_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
||||
CFLAGS = $(MCU) $(C_DEFS) $(C_INCLUDES) $(OPT) -Wall -fdata-sections -ffunction-sections
|
||||
@ -77,7 +65,7 @@ endif
|
||||
|
||||
CFLAGS += -MMD -MP -MF"$(@:%.o=%.d)"
|
||||
|
||||
LDSCRIPT = STM32G071RBTX_FLASH.ld
|
||||
LDSCRIPT = platform/stm32g0xx/STM32G071RBTX_FLASH.ld
|
||||
|
||||
LIBS = -lc -lm -lnosys
|
||||
LIBDIR =
|
||||
@ -105,7 +93,6 @@ $(BUILD_DIR)/%.o: %.s Makefile | $(BUILD_DIR)
|
||||
|
||||
$(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile
|
||||
$(CXX) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
# $(CC) $(OBJECTS) $(LDFLAGS) -o $@
|
||||
$(SZ) $@
|
||||
|
||||
$(BUILD_DIR)/%.hex: $(BUILD_DIR)/%.elf | $(BUILD_DIR)
|
||||
|
Loading…
Reference in New Issue
Block a user