Skip to content
This repository was archived by the owner on Feb 18, 2026. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
89 commits
Select commit Hold shift + click to select a range
c73472c
Test Commit
krazykrayon Jan 25, 2025
8e51b42
added gpios to a pinout header file
krazykrayon Jan 25, 2025
ba0d304
Updated UART pins for display (hopefully correctly)
krazykrayon Feb 1, 2025
3224fc2
Updated CAN pins in BSP files (hopefully correctly)
krazykrayon Feb 1, 2025
b844371
Fixed alternate function for UART4
krazykrayon Feb 1, 2025
99ba1d4
Fix build error?
krazykrayon Feb 1, 2025
bdeb293
Fix build error (again)?
krazykrayon Feb 1, 2025
85f0638
Inserted correct pins for all BSP_GPIO_Init
krazykrayon Feb 1, 2025
2064b7b
GPIO pins done (I think)
krazykrayon Feb 1, 2025
6d4949a
Changed UART enum
krazykrayon Feb 1, 2025
57c7f46
Revert "GPIO pins done (I think)"
krazykrayon Feb 1, 2025
9dceea9
Revert "Changed UART enum"
krazykrayon Feb 1, 2025
489bc1c
Redid all GPIO functions pins
krazykrayon Feb 1, 2025
980227c
Changed Minions.h (i think this is causing build error?)
krazykrayon Feb 1, 2025
cd76208
Please build (changed contactors.h)
krazykrayon Feb 1, 2025
92919f3
Added in pinout header file to Tasks and ReadCarCan
krazykrayon Feb 1, 2025
a965754
All BSP function calls have the correct pins now (I think...)
krazykrayon Feb 1, 2025
868ae25
Changed BSP for new pins
krazykrayon Feb 1, 2025
217c6aa
made a #define oopsie
krazykrayon Feb 1, 2025
c79091e
USART3->UART4 (idk if I changed the BSP correctly)
krazykrayon Feb 1, 2025
12ae35f
Merge branch 'master' into feature/NewPinout
krazykrayon Feb 8, 2025
ba2378c
fixed the contactor pins
krazykrayon Feb 8, 2025
d4f190a
Removed pin definitions in contactors code + changed CAN prints to re…
krazykrayon Feb 8, 2025
e526294
Updated Minions.h
krazykrayon Feb 8, 2025
9991937
Used daybreak_pins.h for BSP_CAN
krazykrayon Feb 8, 2025
102a239
Fixed CommandLine.C with new defines
krazykrayon Feb 8, 2025
2008b19
fixed some bugs
krazykrayon Feb 8, 2025
f7f44e5
more build error fixes
krazykrayon Feb 8, 2025
c4c9684
even more build fixes
krazykrayon Feb 8, 2025
14b611d
used daybreak_pins.h for uart bsp
krazykrayon Feb 8, 2025
b261b2b
reordered pins in header
krazykrayon Feb 8, 2025
74d387e
used daybreak_pins.h for adc bsp
krazykrayon Feb 8, 2025
abfa918
Added in pins for extra ADCs and UART
krazykrayon Mar 1, 2025
34c54cd
didn't mean to change that file, oops
krazykrayon Mar 1, 2025
00bfd7b
Added init for extra ADC and UART... idk if it actually works, I gues…
krazykrayon Mar 1, 2025
09add9c
fixed some oopsies
krazykrayon Mar 1, 2025
80cfa47
Added Init for status leds
krazykrayon Mar 1, 2025
0aeb47c
StatusLED init definition
diyarajon Mar 1, 2025
b79ee75
Add LED and Ignition Driver (#440)
Lakshay983 Mar 26, 2025
91df2f5
Made the brake analog now :0
OscarPortillo37 Mar 28, 2025
71daffd
Testing edits
OscarPortillo37 Mar 29, 2025
3eed715
Debugging changes
OscarPortillo37 Mar 29, 2025
0b1ff95
Still testing & figuring out ADC failure. Changed the DMABufferSize, …
OscarPortillo37 Apr 2, 2025
d951778
akshay
Rav4s Apr 4, 2025
1a58d6f
Accel works with new pinout. Yay^_^
OscarPortillo37 Apr 5, 2025
1834596
Everything works :0. Might need to tune again in integration testing.
OscarPortillo37 Apr 5, 2025
e080a5c
Small Pedals test edits
OscarPortillo37 Apr 5, 2025
5f8811f
This is the working implementation of pedals & ADC/DMA for new Contro…
OscarPortillo37 Apr 5, 2025
4b5de2a
Merged
OscarPortillo37 Apr 5, 2025
0e6862d
Merge branch 'production/M2' into feature/NewPinout
guytonde Apr 6, 2025
e03e2c3
fixed adc; extra1 is acting up
guytonde Apr 6, 2025
a9d2f4b
Merge branch 'production/M2.5' into feature/NewPinout-Pedals
guytonde Apr 8, 2025
711943a
fixed error in resolving merge conflicts
guytonde Apr 9, 2025
ebb6741
small issue in indent
guytonde Apr 9, 2025
7a6c2b4
Merge branch 'production/M2.5' into feature/NewPinout
guytonde Apr 9, 2025
c95d7c7
Fix heartbeat (error in consistency)
guytonde Apr 9, 2025
cb7e102
Merge branch 'feature/NewPinout' into feature/NewPinout-Pedals
guytonde Apr 9, 2025
306cefa
Merge pull request #442 from lhr-solar/feature/NewPinout-Pedals
guytonde Apr 9, 2025
0c7f7c0
Feature/can fix (#441)
Lakshay983 Apr 12, 2025
8eac024
stupid
Lakshay983 Apr 18, 2025
aea0325
sharepoint workflow fix (#445)
Lakshay983 Apr 18, 2025
2584266
Dash driver (#446)
Mikail-Sadic-UT Apr 21, 2025
e4b5ae9
Display Info page redesign + Fault and Evac issues (#439)
guytonde May 12, 2025
e4f6dc6
IO State Rewrite (#449)
Lakshay983 May 17, 2025
be8c264
Contactor rewrite (#447)
Lakshay983 May 18, 2025
126b521
ReadCarCAN Rewrite for Daybreak 2025 (#448)
Lakshay983 May 24, 2025
c1d5000
Send tritium rework MVP (#451)
OscarPortillo37 Jun 7, 2025
dfb3a9b
Pedal Integration (#458)
Lakshay983 Jul 14, 2025
58d47ef
add nix file and add venv to gitignore
Lakshay983 Nov 3, 2025
7f13da1
add SWOC LIMIT define
Lakshay983 Nov 4, 2025
0cb899f
Theoretically works without faults
adiv06 Nov 8, 2025
f64a5b3
multiple swoc thresholds
ParthivS20 Nov 11, 2025
0e40b62
multiple swoc thresholds
ParthivS20 Nov 11, 2025
840a1b5
updated thresholds as of 11/10
ParthivS20 Nov 12, 2025
3ff7103
updated thresholds as of 11/10
ParthivS20 Nov 12, 2025
e957ed3
lakshay wrote this
ParthivS20 Nov 13, 2025
a50f126
lakshay wrote this
ParthivS20 Nov 13, 2025
3a6406b
max 29, starting tuning for max accell and speed
ParthivS20 Nov 14, 2025
388f942
updated power limits and turn brake light on in fault
ParthivS20 Nov 14, 2025
8e667b1
reset when swoc
ParthivS20 Nov 14, 2025
efc9a6b
reset when swoc
ParthivS20 Nov 14, 2025
d3ec9cd
swoc reset flag
ParthivS20 Nov 14, 2025
aa25cd6
display restart msg in display limit field
ParthivS20 Nov 14, 2025
2877c95
faults + FSM still need watchdogs
adiv06 Nov 19, 2025
b9b5201
Merge branch 'feature/NewPinout' of github.com:lhr-solar/Controls int…
adiv06 Nov 19, 2025
d8f611c
Revert "faults + FSM still need watchdogs"
adiv06 Dec 19, 2025
3314dc4
Revert "Theoretically works without faults"
adiv06 Dec 19, 2025
59a5615
ending revert
adiv06 Dec 19, 2025
f23933f
ending revert
adiv06 Dec 19, 2025
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
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
run: git submodule update --init --recursive
- name: Install tools
run: |
./Embedded-Sharepoint/Scripts/install.sh -i
sudo apt -y update
sudo apt -y install gcc-arm-none-eabi
- name: clean
run: make clean
- name: make leader
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ __pycache__

!.vscode/LHR.code-workspace
!.vscode/c_cpp_properties.json

.venv
28 changes: 28 additions & 0 deletions Apps/Inc/IOState.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#ifndef __IOSTATE_H
#define __IOSTATE_H

#include "common.h"
#include "os.h"
#include "Tasks.h"

// Macros for the SWITCH_BITMAP signal in the IO_STATE CAN message
#define SWITCH_BITMAP_BRAKELIGHT(value) ((value & 0x01) << 7) // Bit 7: BRAKELIGHT
#define SWITCH_BITMAP_CRUZ_ST(value) ((value & 0x01) << 6) // Bit 6: CRUZ_ST
#define SWITCH_BITMAP_CRUZ_EN(value) ((value & 0x01) << 5) // Bit 5: CRUZ_EN
#define SWITCH_BITMAP_REV_SW(value) ((value & 0x01) << 4) // Bit 4: REV_SW
#define SWITCH_BITMAP_FOR_SW(value) ((value & 0x01) << 3) // Bit 3: FOR_SW
#define SWITCH_BITMAP_REGEN_SW(value) ((value & 0x01) << 2) // Bit 2: REGEN_SW
#define SWITCH_BITMAP_IGN_2_MOTOR(value) ((value & 0x01) << 1) // Bit 1: IGN_2_Motor
#define SWITCH_BITMAP_IGN_1_ARRAY(value) ((value & 0x01) << 0) // Bit 0: IGN_1_Array

#define CANBUS_MOTOR_SAFE_TO_RUN 1
#define CANBUS_MOTOR_NOT_SAFE_TO_RUN (!CANBUS_MOTOR_SAFE_TO_RUN)

// typedef enum {
// IOSTATE_ERR_NONE = 0x0000, // No error
// IOSTATE_ERROR = 0xFFFF, // More than one state is high at a time
// } IOState_error_code_t;
Comment on lines +21 to +24
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This IOState_error_code_t enum is commented out. If it's no longer needed due to the new centralized error handling system, it should be removed to improve code clarity and reduce clutter.


void assertIOStateError(controls_error_e io_err);

#endif
34 changes: 17 additions & 17 deletions Apps/Inc/ReadCarCAN.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,25 @@
#include "os.h"
#include "common.h"
#include "Tasks.h"
#include "CANbus.h"

/**
* Error types
*/
typedef enum
{
READCARCAN_ERR_NONE,
READCARCAN_ERR_CHARGE_DISABLE, // Received a charge disable msg
READCARCAN_ERR_MISSED_MSG, // Didn't receive a BPS charge msg in time
READCARCAN_ERR_DISABLE_CONTACTORS_MSG, // Ignition is turned to neither (off due to LV) or both at the same time (impossible) are on at
READCARCAN_ERR_BPS_TRIP // Received a BPS trip msg (0 or 1)
} ReadCarCAN_error_code_t;
#define BPS_TRIP_MESSAGE 1

/**
* @brief Returns whether regen braking / charging is enabled or not
* @return Whether regen braking / charging is enabled or not
*/
bool ChargeEnable_Get(void);
// /**
// * Error types
// */
// typedef enum
// {
// READCARCAN_ERR_NONE = 0x0000,
// //READCARCAN_ERR_CHARGE_DISABLE = 0xAAAA, // Received a charge disable msg
// READCARCAN_ERR_BPS_MISSED_MSG = 0xBBBB, // Didn't receive a BPS charge msg in time
// READCARCAN_ERR_PCHG_MISSED_MSG = 0xCCCC, // Didn't receive a precharge msg in time
// //READCARCAN_ERR_DISABLE_CONTACTORS_MSG = 0xCCCC, // Ignition is turned to neither (off due to LV) or both at the same time (impossible) are on at
// READCARCAN_ERR_BPS_TRIP = 0xDDDD, // Received a BPS trip msg (0 or 1)
// READCARCAN_ERR_ACTIVE_PRECHARGE_FAULT = 0xEEEE, // Active precharge sent a fault message
// } ReadCarCAN_error_code_t;
Comment on lines +20 to +32
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The old ReadCarCAN_error_code_t enum is commented out. Since a new centralized error enum controls_error_e has been introduced, this old definition should be removed to avoid confusion and keep the codebase clean.



void assertReadCarCANError(controls_error_e rcc_err);

#endif

Expand Down
45 changes: 26 additions & 19 deletions Apps/Inc/ReadTritium.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/* Copyright (c) 2021 UT Longhorn Racing Solar
* @file ReadTritium.h
* @brief
*
* @brief
*
* @defgroup ReadTritium
* @addtogroup ReadTritium
* @{
Expand All @@ -14,30 +14,37 @@
#include "common.h"
#include "Tasks.h"


/**
* Motor Error States
* Read messages from motor in ReadTritium and trigger appropriate error messages as needed based on bits
*
* Read messages from motor in ReadTritium and trigger appropriate error messages as needed based on
* bits
*
*/
typedef enum{
T_HARDWARE_OVER_CURRENT_ERR = (1<<0),
T_SOFTWARE_OVER_CURRENT_ERR = (1<<1),
T_DC_BUS_OVERVOLT_ERR = (1<<2),
T_HALL_SENSOR_ERR = (1<<3),
T_WATCHDOG_LAST_RESET_ERR = (1<<4),
T_CONFIG_READ_ERR = (1<<5),
T_UNDER_VOLTAGE_LOCKOUT_ERR = (1<<6),
T_DESAT_FAULT_ERR = (1<<7),
T_MOTOR_OVER_SPEED_ERR = (1<<8),
T_INIT_FAIL = (1<<9), //motor controller fails to restart or initialize
T_MOTOR_WATCHDOG_TRIP = (1 << 15),
T_NONE = 0x00,
} tritium_error_code_t;
// typedef enum{
// T_HARDWARE_OVER_CURRENT_ERR = (1<<0),
// T_SOFTWARE_OVER_CURRENT_ERR = (1<<1),
// T_DC_BUS_OVERVOLT_ERR = (1<<2),
// T_HALL_SENSOR_ERR = (1<<3),
// T_WATCHDOG_LAST_RESET_ERR = (1<<4),
// T_CONFIG_READ_ERR = (1<<5),
// T_UNDER_VOLTAGE_LOCKOUT_ERR = (1<<6),
// T_DESAT_FAULT_ERR = (1<<7),
// T_MOTOR_OVER_SPEED_ERR = (1<<8),
// T_INIT_FAIL = (1<<9), //motor controller fails to restart or initialize
// T_MOTOR_WATCHDOG_TRIP = (1 << 15),
// T_NONE = 0x00,
// } tritium_error_code_t;
Comment on lines +24 to +37
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The tritium_error_code_t enum is commented out. With the new centralized error handling, this is likely obsolete and should be removed to improve code clarity.


// #define MOTOR_VELOCITY_SWOC_THRESHOLD 8.0f

float Motor_RPM_Get();
float Motor_Velocity_Get();
float Motor_Velocity_Get_Safe(); // Thread-safe version
uint16_t Motor_Error_Get();

#endif
void assertTritiumError(controls_error_e motor_err);

#endif

/* @} */
5 changes: 5 additions & 0 deletions Apps/Inc/SendCarCAN.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
#ifndef __SENDCARCAN_H
#define __SENDCARCAN_H

#include "common.h"
#include "os.h"
#include "CANbus.h"
#include "Tasks.h"



/**
* @brief Initialize SendCarCAN
Expand Down
107 changes: 41 additions & 66 deletions Apps/Inc/SendTritium.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,90 +11,65 @@
#define __SENDTRITIUM_H

#include "common.h"
#include "os.h"
#include "Dashboard.h"
#include "Tasks.h"


//#define SENDTRITIUM_PRINT_MES
#define CANBUS_MOTOR_SAFE_TO_RUN 1

#define MOTOR_MSG_PERIOD 100 // in ms
#define FSM_PERIOD 100 // in ms
#define DEBOUNCE_PERIOD 2 // in units of FSM_PERIOD
#define MOTOR_MSG_COUNTER_THRESHOLD (MOTOR_MSG_PERIOD)/(FSM_PERIOD)

#define FOREACH_Gear(GEAR) \
GEAR(FORWARD_GEAR), \
GEAR(NEUTRAL_GEAR), \
GEAR(REVERSE_GEAR), \

typedef enum GEAR_ENUM {
FOREACH_Gear(GENERATE_ENUM)
NUM_GEARS,
} Gear_t;

// State Names
typedef enum{
FORWARD_DRIVE,
NEUTRAL_DRIVE,
REVERSE_DRIVE,
RECORD_VELOCITY,
POWERED_CRUISE,
COASTING_CRUISE,
BRAKE_STATE,
ONEPEDAL,
ACCELERATE_CRUISE
} TritiumStateName_t;

// State Struct for FSM
typedef struct TritiumState{
TritiumStateName_t name;
void (*stateHandler)(void);
void (*stateDecider)(void);
} TritiumState_t;

#define MAX_VELOCITY 12000.0f // rpm (unobtainable value)

// Used to define accel & brake (hysteresis) thresholds for when to start/stop powering the motor, respectively
#define ACCEL_PEDAL_THRESHOLD 15 // percent
#define BRAKE_UNPRESSED_THRESHOLD 40 // percent
#define BRAKE_PRESSED_THRESHOLD 30 // percent

// Motor Controller current values. Current is in Amps (A)
#define MAX_MOCO_BATTERY_CURRENT 64.0f // NOTE: Provided only for reference. This 64A max for daybreak, anticipated to be 135 for next-gen
#define CONT_MOCO_BATTERY_CURRENT 30.0f // Continuous
#define MAX_MOCO_CURRENT 122.0f

#define PEDAL_MIN 0 // percent
#define PEDAL_MAX 100 // percent
#define CURRENT_SP_MIN 0 // percent
#define CURRENT_SP_MAX 100 // percent
#define SWOC_CURRENT_SP_MAX 60 // percent

#define GEAR_FAULT_THRESHOLD 3 // number of times gear fault can occur before it is considered a fault

#define ACCCEL_PEDAL_RESET_THRESHOLD 20
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in this macro name. It should be ACCEL_PEDAL_RESET_THRESHOLD.

Suggested change
#define ACCCEL_PEDAL_RESET_THRESHOLD 20
#define ACCEL_PEDAL_RESET_THRESHOLD 20

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

There is a typo in the macro name. It should be ACCEL_PEDAL_RESET_THRESHOLD.

Suggested change
#define ACCCEL_PEDAL_RESET_THRESHOLD 20
#define ACCEL_PEDAL_RESET_THRESHOLD 20


// /**
// * Error types
// *
// */
// typedef enum
// {
// SENDTRITIUM_ERR_NONE,
// SENDTRITIUM_ERR_GEAR_FAULT, // Received multiple or no gear inputs (e.g. FOR_SW, REV_SW)
// } SendTritium_error_code_t;
Comment on lines +48 to +56
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The SendTritium_error_code_t enum is commented out. This should be removed if it is no longer in use, to keep the code clean.


#ifdef SENDTRITIUM_EXPOSE_VARS
// Inputs
extern bool cruiseEnable;
extern bool cruiseSet;
extern bool onePedalEnable;
extern bool regenEnable;

extern uint8_t brakePedalPercent;
extern uint8_t accelPedalPercent;

extern Gear_t gear;

extern TritiumState_t state;
extern float velocityObserved;
extern float cruiseVelSetpoint;
extern gear_t gear;
extern bool isBrakeOn; // Used for updating display & brakelight
#endif

// Getter functions for local variables in SendTritium.c
EXPOSE_GETTER(bool, cruiseEnable)
EXPOSE_GETTER(bool, cruiseSet)
EXPOSE_GETTER(bool, onePedalEnable)
EXPOSE_GETTER(bool, regenEnable)
EXPOSE_GETTER(uint8_t, brakePedalPercent)
EXPOSE_GETTER(uint8_t, accelPedalPercent)
EXPOSE_GETTER(Gear_t, gear)
EXPOSE_GETTER(TritiumState_t, state)
EXPOSE_GETTER(float, velocityObserved)
EXPOSE_GETTER(float, cruiseVelSetpoint)
EXPOSE_GETTER(gear_t, gear)
EXPOSE_GETTER(float, currentSetpoint)
EXPOSE_GETTER(float, velocitySetpoint)

// Setter functions for local variables in SendTritium.c
#ifdef SENDTRITIUM_EXPOSE_VARS
EXPOSE_SETTER(bool, cruiseEnable)
EXPOSE_SETTER(bool, cruiseSet)
EXPOSE_SETTER(bool, onePedalEnable)
EXPOSE_SETTER(bool, regenEnable)
EXPOSE_SETTER(uint8_t, brakePedalPercent)
EXPOSE_SETTER(uint8_t, accelPedalPercent)
EXPOSE_SETTER(Gear_t, gear)
EXPOSE_SETTER(TritiumState_t, state)
EXPOSE_SETTER(float, velocityObserved)
EXPOSE_SETTER(float, cruiseVelSetpoint)
EXPOSE_SETTER(float, currentSetpoint)
EXPOSE_SETTER(float, velocitySetpoint)
#endif
EXPOSE_GETTER(bool, isBrakeOn)

/**
* @brief Linearly map range of integers to another range of integers, and provide the pecentage result.
Expand Down
Loading