From b21e6dd3f9e0dddc14baaa429f6c5b7e88c21567 Mon Sep 17 00:00:00 2001 From: Simon Hailes Date: Fri, 31 Aug 2018 16:02:55 +0100 Subject: [PATCH 1/2] Add platformio.ini file, update README.md, and .gitignore --- .gitignore | 5 +++++ README.md | 10 +++++++++- platformio.ini | 17 +++++++++++++++++ 3 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 platformio.ini diff --git a/.gitignore b/.gitignore index eb48f105..72db3d9a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,7 @@ build/* !build/hover.hex +.pioenvs +.piolibdeps +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json diff --git a/README.md b/README.md index 0ba12488..7e89ec90 100644 --- a/README.md +++ b/README.md @@ -21,8 +21,16 @@ http://vocke.tv/lib/exe/fetch.php?media=20150722_hoverboard_sch.pdf --- +## Building +To build the firmware, just type "make". Make sure you have specified your gcc-arm-none-eabi binary (version 7 works, there is a version that does not!) location in the Makefile ("PREFIX = ..."). + +The firmware will also build (and flash) very easily from platform.io, plaformio.ini file included. Simply open the folder in the IDE of choice (vscode or Atom), and press the 'PlatformIO:Build' or the 'PlatformIO:Upload' button (bottom left in vscode). + +(Note: if you have no buttons, use Debug/Add Configuration, and select 'PlatformIO Debugger'; seems to kick it into life). + + ## Flashing -To build the firmware, just type "make". Make sure you have specified your gcc-arm-none-eabi binary (version 7 works, there is a version that does not!) location in the Makefile ("PREFIX = ..."). Right to the STM32, there is a debugging header with GND, 3V3, SWDIO and SWCLK. Connect GND, SWDIO and SWCLK to your SWD programmer, like the ST-Link found on many STM devboards. +Right to the STM32, there is a debugging header with GND, 3V3, SWDIO and SWCLK. Connect GND, SWDIO and SWCLK to your SWD programmer, like the ST-Link found on many STM devboards. Make sure you hold the powerbutton or connect a jumper to the power button pins while flashing the firmware, as the STM might release the power latch and switches itself off during flashing. Battery > 36V have to be connected while flashing. diff --git a/platformio.ini b/platformio.ini new file mode 100644 index 00000000..a554459e --- /dev/null +++ b/platformio.ini @@ -0,0 +1,17 @@ +; PlatformIO Project Configuration File2 +; http://docs.platformio.org/page/projectconf.html + +[platformio] +include_dir = inc + +[env:genericSTM32F103RC] +platform = ststm32 +framework = stm32cube +board = genericSTM32F103RC +build_flags = + -DUSE_HAL_DRIVER + -DSTM32F103xE + -Wl,-T${PROJECT_DIR}/STM32F103RCTx_FLASH.ld + -Wl,-lc + -Wl,-lm + -Wl,-lnosys \ No newline at end of file From 765f890eaadea45adf9afcfc119be1720095e8fc Mon Sep 17 00:00:00 2001 From: phail Date: Mon, 3 Sep 2018 22:51:47 +0200 Subject: [PATCH 2/2] case sensitive Folder names, small changes --- .gitignore | 3 +++ Makefile | 22 +++++++++++----------- {Inc => inc}/config.h | 0 {Inc => inc}/defines.h | 0 {Inc => inc}/setup.h | 0 {Inc => inc}/stm32f1xx_hal_conf.h | 0 {Inc => inc}/stm32f1xx_it.h | 0 {Src => src}/bldc.c | 4 ++-- {Src => src}/comms.c | 0 {Src => src}/control.c | 0 {Src => src}/main.c | 0 {Src => src}/setup.c | 0 {Src => src}/stm32f1xx_it.c | 0 {Src => src}/system_stm32f1xx.c | 0 14 files changed, 16 insertions(+), 13 deletions(-) rename {Inc => inc}/config.h (100%) rename {Inc => inc}/defines.h (100%) rename {Inc => inc}/setup.h (100%) rename {Inc => inc}/stm32f1xx_hal_conf.h (100%) rename {Inc => inc}/stm32f1xx_it.h (100%) rename {Src => src}/bldc.c (97%) rename {Src => src}/comms.c (100%) rename {Src => src}/control.c (100%) rename {Src => src}/main.c (100%) rename {Src => src}/setup.c (100%) rename {Src => src}/stm32f1xx_it.c (100%) rename {Src => src}/system_stm32f1xx.c (100%) diff --git a/.gitignore b/.gitignore index 72db3d9a..dbfd7177 100644 --- a/.gitignore +++ b/.gitignore @@ -5,3 +5,6 @@ build/* .vscode/.browse.c_cpp.db* .vscode/c_cpp_properties.json .vscode/launch.json +.travis.yml +.vscode/extensions.json +lib/readme.txt diff --git a/Makefile b/Makefile index 832aab58..b8fd746f 100644 --- a/Makefile +++ b/Makefile @@ -35,13 +35,13 @@ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_adc.c \ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_uart.c \ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_i2c.c \ Drivers/STM32F1xx_HAL_Driver/Src/stm32f1xx_hal_dma.c \ -Src/system_stm32f1xx.c \ -Src/setup.c \ -Src/control.c \ -Src/main.c \ -Src/bldc.c \ -Src/comms.c \ -Src/stm32f1xx_it.c \ +src/system_stm32f1xx.c \ +src/setup.c \ +src/control.c \ +src/main.c \ +src/bldc.c \ +src/comms.c \ +src/stm32f1xx_it.c \ # ASM sources ASM_SOURCES = \ @@ -89,7 +89,7 @@ AS_INCLUDES = # C includes C_INCLUDES = \ --IInc \ +-Iinc \ -IDrivers/STM32F1xx_HAL_Driver/Inc \ -IDrivers/STM32F1xx_HAL_Driver/Inc/Legacy \ -IDrivers/CMSIS/Device/ST/STM32F1xx/Include \ @@ -135,10 +135,10 @@ vpath %.c $(sort $(dir $(C_SOURCES))) OBJECTS += $(addprefix $(BUILD_DIR)/,$(notdir $(ASM_SOURCES:.s=.o))) vpath %.s $(sort $(dir $(ASM_SOURCES))) -$(BUILD_DIR)/%.o: %.c Inc/config.h Makefile | $(BUILD_DIR) +$(BUILD_DIR)/%.o: %.c inc/config.h Makefile | $(BUILD_DIR) $(CC) -c $(CFLAGS) -Wa,-a,-ad,-alms=$(BUILD_DIR)/$(notdir $(<:.c=.lst)) $< -o $@ -$(BUILD_DIR)/%.o: %.s Inc/config.h Makefile | $(BUILD_DIR) +$(BUILD_DIR)/%.o: %.s inc/config.h Makefile | $(BUILD_DIR) $(AS) -c $(CFLAGS) $< -o $@ $(BUILD_DIR)/$(TARGET).elf: $(OBJECTS) Makefile @@ -155,7 +155,7 @@ $(BUILD_DIR): mkdir -p $@ format: - find Src/ Inc/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i + find src/ inc/ -iname '*.h' -o -iname '*.c' | xargs clang-format -i ####################################### # clean up ####################################### diff --git a/Inc/config.h b/inc/config.h similarity index 100% rename from Inc/config.h rename to inc/config.h diff --git a/Inc/defines.h b/inc/defines.h similarity index 100% rename from Inc/defines.h rename to inc/defines.h diff --git a/Inc/setup.h b/inc/setup.h similarity index 100% rename from Inc/setup.h rename to inc/setup.h diff --git a/Inc/stm32f1xx_hal_conf.h b/inc/stm32f1xx_hal_conf.h similarity index 100% rename from Inc/stm32f1xx_hal_conf.h rename to inc/stm32f1xx_hal_conf.h diff --git a/Inc/stm32f1xx_it.h b/inc/stm32f1xx_it.h similarity index 100% rename from Inc/stm32f1xx_it.h rename to inc/stm32f1xx_it.h diff --git a/Src/bldc.c b/src/bldc.c similarity index 97% rename from Src/bldc.c rename to src/bldc.c index e5c609cd..d023c288 100644 --- a/Src/bldc.c +++ b/src/bldc.c @@ -36,7 +36,7 @@ const uint8_t hall_to_pos[8] = { 0, }; -inline void blockPWM(int pwm, int pos, int *u, int *v, int *w) { +static inline void blockPWM(int pwm, int pos, int *u, int *v, int *w) { switch(pos) { case 0: *u = 0; @@ -75,7 +75,7 @@ inline void blockPWM(int pwm, int pos, int *u, int *v, int *w) { } } -inline void blockPhaseCurrent(int pos, int u, int v, int *q) { +static inline void blockPhaseCurrent(int pos, int u, int v, int *q) { switch(pos) { case 0: *q = u - v; diff --git a/Src/comms.c b/src/comms.c similarity index 100% rename from Src/comms.c rename to src/comms.c diff --git a/Src/control.c b/src/control.c similarity index 100% rename from Src/control.c rename to src/control.c diff --git a/Src/main.c b/src/main.c similarity index 100% rename from Src/main.c rename to src/main.c diff --git a/Src/setup.c b/src/setup.c similarity index 100% rename from Src/setup.c rename to src/setup.c diff --git a/Src/stm32f1xx_it.c b/src/stm32f1xx_it.c similarity index 100% rename from Src/stm32f1xx_it.c rename to src/stm32f1xx_it.c diff --git a/Src/system_stm32f1xx.c b/src/system_stm32f1xx.c similarity index 100% rename from Src/system_stm32f1xx.c rename to src/system_stm32f1xx.c