Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
11 changes: 8 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
4 changes: 2 additions & 2 deletions firmware/core/include/fault.hpp
Original file line number Diff line number Diff line change
@@ -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);
49 changes: 23 additions & 26 deletions firmware/core/include/types.hpp
Original file line number Diff line number Diff line change
@@ -1,43 +1,40 @@
#pragma once
#include <cstdint>

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;
Loading