diff --git a/.vscode/settings.json b/.vscode/settings.json index c5c2fbb..6a472e2 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,5 +5,15 @@ ], "cmake.preferredGenerators": [ "Ninja" - ] + ], + "stm32cube-ide-clangd.path": "cube", + "stm32cube-ide-clangd.arguments": [ + "starm-clangd", + "--query-driver=${env:CUBE_BUNDLE_PATH}/gnu-tools-for-stm32/14.3.1+st.2/bin/arm-none-eabi-gcc*", + "--query-driver=${env:CUBE_BUNDLE_PATH}/gnu-tools-for-stm32/14.3.1+st.2/bin/arm-none-eabi-g++*" + ], + "[c][cpp]": { + "editor.defaultFormatter": "stmicroelectronics.stm32cube-ide-clangd", + "editor.formatOnSave": true + } } \ No newline at end of file diff --git a/README.md b/README.md index 1a4aab9..996e361 100644 --- a/README.md +++ b/README.md @@ -11,11 +11,16 @@ cmake -B build cmake --build build ./build/motorcontroller_app ``` + +## Install + +Any VS Code user should install the STM32 Cube IDE extension + ## AI Policy -A.I. is both allowed and encouraged but -only responsibly. We do prefer handwritten -code for its educational value and suggest +A.I. is both allowed but only responsibly. +We do prefer handwritten code for its +educational value and suggest LLM's be used as sanity checkers. Either way, quality code is non-negotiable and every line of code merged must be understood. diff --git a/firmware/core/include/fault.hpp b/firmware/core/include/fault.hpp index 276e04d..2b339de 100644 --- a/firmware/core/include/fault.hpp +++ b/firmware/core/include/fault.hpp @@ -1,10 +1,10 @@ #pragma once #include "types.hpp" -struct FaultLimits { +typedef struct { float over_current_amps; float over_voltage_volts; float under_voltage_volts; -}; +} FaultLimits; FaultCode fault_check(const FaultLimits* limits); diff --git a/firmware/core/include/types.hpp b/firmware/core/include/types.hpp index 3429188..eed1ac8 100644 --- a/firmware/core/include/types.hpp +++ b/firmware/core/include/types.hpp @@ -1,43 +1,40 @@ #pragma once #include -typedef enum { -DIRECTION_FORWARD, -DIRECTION_REVERSE -} Direction; +typedef enum { DIRECTION_FORWARD, DIRECTION_REVERSE } Direction; typedef enum { - COMMUTATION_STEP_0, - COMMUTATION_STEP_1, - COMMUTATION_STEP_2, - COMMUTATION_STEP_3, - COMMUTATION_STEP_4, - COMMUTATION_STEP_5, - COMMUTATION_STEP_COUNT + COMMUTATION_STEP_0, + COMMUTATION_STEP_1, + COMMUTATION_STEP_2, + COMMUTATION_STEP_3, + COMMUTATION_STEP_4, + COMMUTATION_STEP_5, + COMMUTATION_STEP_COUNT } CommutationStep; typedef enum { - FAULT_NONE, - FAULT_OVER_CURRENT, - FAULT_OVER_VOLTAGE, - FAULT_UNDER_VOLTAGE, - FAULT_HALL_DESYNC, - FAULT_STALL + FAULT_NONE, + FAULT_OVER_CURRENT, + FAULT_OVER_VOLTAGE, + FAULT_UNDER_VOLTAGE, + FAULT_HALL_DESYNC, + FAULT_STALL } FaultCode; -typedef enum { -MOTOR_STATE_STOPPED, -MOTOR_STATE_RUNNING, -MOTOR_STATE_FAULTED +typedef enum { + MOTOR_STOPPED, + MOTOR_RUNNING, + MOTOR_FAULTED } MotorState; typedef struct { - bool high_side; - bool low_side; + bool high_side; + bool low_side; } PhaseDrive; typedef struct { - PhaseDrive phase_a; - PhaseDrive phase_b; - PhaseDrive phase_c; + PhaseDrive phase_a; + PhaseDrive phase_b; + PhaseDrive phase_c; } CommutationPattern;