diff --git a/.gitignore b/.gitignore index e4961bac..69ac0052 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,16 @@ .DS_Store *.hex +.vscode/settings.json + LCM/Project/MDK5/Objects/ LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.uvguix.* LCM/Project/MDK5/Listings/ + +LCM/Project/MDK5/out/ +LCM/Project/MDK5/tmp/ + +LCM/Project/MDK5/.clangd +LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cbuild-idx.yml +LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cbuild-set.yml +LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New*.cbuild.yml diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 00000000..e5bfed02 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,3 @@ +{ + "recommendations": ["arm.keil-studio-pack"] +} diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..9542210c --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,18 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Arm Debugger", + "type": "arm-debugger", + "request": "launch", + "serialNumber": "${command:device-manager.getSerialNumber}", + "programs": "${command:cmsis-csolution.getBinaryFiles}", + "cmsisPack": "${command:cmsis-csolution.getTargetPack}", + "deviceName": "${command:cmsis-csolution.getDeviceName}", + "processorName": "${command:cmsis-csolution.getProcessorName}" + } + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index b4a68e18..00000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "C_Cpp.clang_format_fallbackStyle": "Google" -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..8b67ca23 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,15 @@ +{ + "version": "2.0.0", + "tasks": [ + { + "type": "arm-debugger.flash", + "serialNumber": "${command:device-manager.getSerialNumber}", + "programs": "${command:cmsis-csolution.getBinaryFiles}", + "cmsisPack": "${command:cmsis-csolution.getTargetPack}", + "deviceName": "${command:cmsis-csolution.getDeviceName}", + "processorName": "${command:cmsis-csolution.getProcessorName}", + "problemMatcher": [], + "label": "Flash Device" + } + ] +} diff --git a/Docs/lcm-arm-cmsis-vscode.jpg b/Docs/lcm-arm-cmsis-vscode.jpg new file mode 100644 index 00000000..23d40299 Binary files /dev/null and b/Docs/lcm-arm-cmsis-vscode.jpg differ diff --git a/LCM/Code/App/task.h b/LCM/Code/App/task.h index cb1f4efe..0a1c9d55 100644 --- a/LCM/Code/App/task.h +++ b/LCM/Code/App/task.h @@ -14,7 +14,7 @@ typedef enum } CELL_TYPE; //#define PINTV -#define XRV +//#define XRV //#define GTV //#define ADV diff --git a/LCM/Code/App/vesc_uasrt.c b/LCM/Code/App/vesc_uasrt.c index 25860869..59d391ad 100644 --- a/LCM/Code/App/vesc_uasrt.c +++ b/LCM/Code/App/vesc_uasrt.c @@ -6,18 +6,18 @@ uint8_t VESC_RX_Buff[80]; uint8_t VESC_RX_Flag = 0; -#ifdef GTV -#define FIRMWARE_ID "GTV_2_1_5" -#endif -#ifdef XRV -#define FIRMWARE_ID "XRV_2_1_5" -#endif -#ifdef PINTV -#define FIRMWARE_ID "PintV_2_1_5" -#endif -#ifdef ADV -#define FIRMWARE_ID "ADV_2_1_5" -#endif +// #ifdef GTV +// #define FIRMWARE_ID "GTV_2_1_5" +// #endif +// #ifdef XRV +// #define FIRMWARE_ID "XRV_2_1_5" +// #endif +// #ifdef PINTV +// #define FIRMWARE_ID "PintV_2_1_5" +// #endif +// #ifdef ADV +// #define FIRMWARE_ID "ADV_2_1_5" +// #endif // Access ADC values here to determine riding state extern float ADC1_Val, ADC2_Val; diff --git a/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cbuild-pack.yml b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cbuild-pack.yml new file mode 100644 index 00000000..72318b33 --- /dev/null +++ b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cbuild-pack.yml @@ -0,0 +1,5 @@ +cbuild-pack: + resolved-packs: + - resolved-pack: HKMicroChip::HK32F030xMxx_DFP@1.0.17 + selected-by-pack: + - HKMicroChip::HK32F030xMxx_DFP diff --git a/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cproject.yml b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cproject.yml new file mode 100644 index 00000000..0560ac74 --- /dev/null +++ b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.cproject.yml @@ -0,0 +1,104 @@ +project: + output: + base-name: v$VERSION$_$TargetType$ + type: hex + packs: + - pack: HKMicroChip::HK32F030xMxx_DFP + setups: + - setup: Options for LCMLightControlIOWS2812New + add-path: + - ../../Code/App + - ../../Code/Drive + - ../../Code/User + - ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/inc + - ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/CMSIS/CM0/Core + - ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/CMSIS/HK32F030M/Include + define: + - HK32F030M + - HK32F030MF4P6 + misc: + - C: + - -std=c99 + C-CPP: + - -fno-rtti + - -funsigned-char + - -fshort-enums + - -fshort-wchar + - -ffunction-sections + - -Wno-packed + - -Wno-missing-variable-declarations + - -Wno-missing-prototypes + - -Wno-missing-noreturn + - -Wno-sign-conversion + - -Wno-nonportable-include-path + - -Wno-reserved-id-macro + - -Wno-unused-macros + - -Wno-documentation-unknown-command + - -Wno-documentation + - -Wno-license-management + - -Wno-parentheses-equality + CPP: + - -xc++ + - -std=c++03 + ASM: + - -masm=auto + Link: + - --map + - --load_addr_map_info + - --xref + - --callgraph + - --symbols + - --info sizes + - --info totals + - --info unused + - --info veneers + - --strict + - --summary_stderr + - --info summarysizes + linker: + - script: LCM_Light_Control_IO_WS2812_New_LCMLightControlIOWS2812New.sct + groups: + - group: Startup + files: + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/CMSIS/HK32F030M/Source/ARM/KEIL_Startup_hk32f030m.s + - group: User + files: + - file: ../../Code/User/main.c + - file: ../../Code/User/hk32f030m_it.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/CMSIS/HK32F030M/Source/system_hk32f030m.c + - group: App + files: + - file: ../../Code/App/ws2812.c + - file: ../../Code/App/crc.c + - file: ../../Code/App/vesc_uasrt.c + - file: ../../Code/App/test.c + - file: ../../Code/App/task.c + - file: ../../Code/App/flag_bit.c + - group: Drive + files: + - file: ../../Code/Drive/led.c + - file: ../../Code/Drive/time.c + - file: ../../Code/Drive/spi.c + - file: ../../Code/Drive/power.c + - file: ../../Code/Drive/led_pwm.c + - file: ../../Code/Drive/key.c + - file: ../../Code/Drive/buzzer.c + - file: ../../Code/Drive/usart.c + - file: ../../Code/Drive/adc.c + - file: ../../Code/Drive/io_ws2812.c + - file: ../../Code/Drive/eeprom.c + - group: Library + files: + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_adc.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_gpio.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_iwdg.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_misc.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_rcc.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_spi.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_syscfg.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_tim.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_usart.c + - file: ../../Library/HK32F030Mxx_Library_V1.1.6/HK32F030M/HK32F030M_Lib/src/hk32f030m_flash.c + - group: Readme + files: + - file: ../../Readme/Readme.txt diff --git a/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml new file mode 100644 index 00000000..d5680726 --- /dev/null +++ b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml @@ -0,0 +1,37 @@ +solution: + created-by: uv2csolution@1.5.0 + created-for: CMSIS-Toolbox@2.4.0 + compiler: AC6@6.22.0 + variables: + - VERSION: 2_1_5 + + target-types: + - type: ADV + define: + - ADV + - FIRMWARE_ID: '"ADV_$VERSION$"' + device: HK_MicroChip::HK32F030MF4P6 + - type: GTV + define: + - GTV + - FIRMWARE_ID: '"GTV_$VERSION$"' + device: HK_MicroChip::HK32F030MF4P6 + - type: PINTV + define: + - PINTV + - FIRMWARE_ID: '"PINTV_$VERSION$"' + device: HK_MicroChip::HK32F030MF4P6 + - type: XRV + define: + - XRV + - FIRMWARE_ID: '"XRV_$VERSION$"' + device: HK_MicroChip::HK32F030MF4P6 + build-types: + - type: Debug + optimize: debug + debug: on + - type: Release + optimize: size + debug: off + projects: + - project: LCM_Light_Control_IO_WS2812_New.cproject.yml diff --git a/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New_LCMLightControlIOWS2812New.sct b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New_LCMLightControlIOWS2812New.sct new file mode 100644 index 00000000..f94c68ca --- /dev/null +++ b/LCM/Project/MDK5/LCM_Light_Control_IO_WS2812_New_LCMLightControlIOWS2812New.sct @@ -0,0 +1,16 @@ +; *********************************************************************** +; *** Scatter-Loading Description File generated by uv2csolution *** +; *********************************************************************** + +LR_IROM1 0x08000000 0x00004000 { ; load region size_region + ER_IROM1 0x08000000 0x00004000 { ; load address = execution address + *.o (RESET, +First) + *(InRoot$$Sections) + .ANY (+RO) + .ANY (+XO) + } + RW_IRAM1 0x20000000 0x00000800 { ; RW data + .ANY (+RW +ZI) + } +} + diff --git a/LCM/build.bat b/LCM/build.bat new file mode 100644 index 00000000..193bddd9 --- /dev/null +++ b/LCM/build.bat @@ -0,0 +1,19 @@ +@REM ADV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+ADV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+ADV +copy Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/ADV/Release/*.hex . + +@REM GTV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+GTV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+GTV +copy Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/GTV/Release/*.hex . + +@REM PINTV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+PINTV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+PINTV +cp Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/PINTV/Release/*.hex . + +@REM XRV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+XRV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+XRV +copy Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/XRV/Release/*.hex . diff --git a/LCM/build.sh b/LCM/build.sh new file mode 100755 index 00000000..f9a9ba09 --- /dev/null +++ b/LCM/build.sh @@ -0,0 +1,19 @@ +# ADV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+ADV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+ADV +cp Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/ADV/Release/*.hex ./ + +# GTV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+GTV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+GTV +cp Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/GTV/Release/*.hex ./ + +# PINTV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+PINTV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+PINTV +cp Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/PINTV/Release/*.hex ./ + +# XRV +cbuild setup Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+XRV --packs +cbuild Project/MDK5/LCM_Light_Control_IO_WS2812_New.csolution.yml --context-set --context LCM_Light_Control_IO_WS2812_New.Release+XRV +cp Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/XRV/Release/*.hex ./ diff --git a/README.md b/README.md new file mode 100644 index 00000000..3724307a --- /dev/null +++ b/README.md @@ -0,0 +1,28 @@ +# Floatwheel LCM Firmware + +#### Linux Prerequisites + +1. Install `curl` and `libncurses5` via your package manager of choice + +## Setting up the project + +1. Install [Visual Studio Code](https://code.visualstudio.com) +1. Open `floatwheel` folder in Visual Studio Code +1. Install [Keil Studio Pack](https://marketplace.visualstudio.com/items?itemName=Arm.keil-studio-pack) extension [^1] +1. Wait for Arm Tools to finish downloading / installing [^2][^3] +1. Activate Keil MDK Community license when prompted +1. Open a terminal in Visual Studio Code +1. Input `cpackget add LCM/HKMicroChip.HK32F030xMxx_DFP.1.0.17.pack` and press Enter/Return [^4] +1. Use CMSIS tab to select target device and build / debug[^5] + +![Example build environment](./Docs/lcm-arm-cmsis-vscode.jpg "Example build environment") + +Build scripts are also included: `LCM/build.sh` (Linux / Mac OS) `LCM/build.bat` (Windows) + +They build firmware for all 4 configurations, then copy the created `_.hex` files into the `LCM` directory. The intention is to use them when releasing new versions until a future solution is reached. + +[^1]: This should be suggested automatically +[^2]: Located on the bottom bar, will show either Arm Tools: x or Installing...(xx%) +[^3]: This process takes quite some time. Check `Output -> Arm Tools` for details +[^4]: Try adding `~/.vcpkg/artifacts/2139c4c6/tools.open.cmsis.pack.cmsis.toolbox/2.6.1/bin/` to $PATH if you're having issues running cpackget +[^5]: .hex file located at `LCM/Project/MDK5/out/LCM_Light_Control_IO_WS2812_New/` in Debug / Release folder diff --git a/vcpkg-configuration.json b/vcpkg-configuration.json new file mode 100644 index 00000000..50383936 --- /dev/null +++ b/vcpkg-configuration.json @@ -0,0 +1,16 @@ +{ + "registries": [ + { + "name": "arm", + "kind": "artifact", + "location": "https://artifacts.tools.arm.com/vcpkg-registry" + } + ], + "requires": { + "arm:tools/open-cmsis-pack/cmsis-toolbox": "2.6.1", + "arm:compilers/arm/armclang": "6.22.0", + "arm:tools/kitware/cmake": "3.28.4", + "arm:compilers/arm/llvm-embedded": "19.1.1", + "arm:tools/ninja-build/ninja": "1.12.0" + } +}