This repository was archived by the owner on Feb 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Daybreak 2025 Integration #436
Open
krazykrayon
wants to merge
89
commits into
production/M2.5
Choose a base branch
from
feature/NewPinout
base: production/M2.5
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
c73472c
Test Commit
krazykrayon 8e51b42
added gpios to a pinout header file
krazykrayon ba0d304
Updated UART pins for display (hopefully correctly)
krazykrayon 3224fc2
Updated CAN pins in BSP files (hopefully correctly)
krazykrayon b844371
Fixed alternate function for UART4
krazykrayon 99ba1d4
Fix build error?
krazykrayon bdeb293
Fix build error (again)?
krazykrayon 85f0638
Inserted correct pins for all BSP_GPIO_Init
krazykrayon 2064b7b
GPIO pins done (I think)
krazykrayon 6d4949a
Changed UART enum
krazykrayon 57c7f46
Revert "GPIO pins done (I think)"
krazykrayon 9dceea9
Revert "Changed UART enum"
krazykrayon 489bc1c
Redid all GPIO functions pins
krazykrayon 980227c
Changed Minions.h (i think this is causing build error?)
krazykrayon cd76208
Please build (changed contactors.h)
krazykrayon 92919f3
Added in pinout header file to Tasks and ReadCarCan
krazykrayon a965754
All BSP function calls have the correct pins now (I think...)
krazykrayon 868ae25
Changed BSP for new pins
krazykrayon 217c6aa
made a #define oopsie
krazykrayon c79091e
USART3->UART4 (idk if I changed the BSP correctly)
krazykrayon 12ae35f
Merge branch 'master' into feature/NewPinout
krazykrayon ba2378c
fixed the contactor pins
krazykrayon d4f190a
Removed pin definitions in contactors code + changed CAN prints to re…
krazykrayon e526294
Updated Minions.h
krazykrayon 9991937
Used daybreak_pins.h for BSP_CAN
krazykrayon 102a239
Fixed CommandLine.C with new defines
krazykrayon 2008b19
fixed some bugs
krazykrayon f7f44e5
more build error fixes
krazykrayon c4c9684
even more build fixes
krazykrayon 14b611d
used daybreak_pins.h for uart bsp
krazykrayon b261b2b
reordered pins in header
krazykrayon 74d387e
used daybreak_pins.h for adc bsp
krazykrayon abfa918
Added in pins for extra ADCs and UART
krazykrayon 34c54cd
didn't mean to change that file, oops
krazykrayon 00bfd7b
Added init for extra ADC and UART... idk if it actually works, I gues…
krazykrayon 09add9c
fixed some oopsies
krazykrayon 80cfa47
Added Init for status leds
krazykrayon 0aeb47c
StatusLED init definition
diyarajon b79ee75
Add LED and Ignition Driver (#440)
Lakshay983 91df2f5
Made the brake analog now :0
OscarPortillo37 71daffd
Testing edits
OscarPortillo37 3eed715
Debugging changes
OscarPortillo37 0b1ff95
Still testing & figuring out ADC failure. Changed the DMABufferSize, …
OscarPortillo37 d951778
akshay
Rav4s 1a58d6f
Accel works with new pinout. Yay^_^
OscarPortillo37 1834596
Everything works :0. Might need to tune again in integration testing.
OscarPortillo37 e080a5c
Small Pedals test edits
OscarPortillo37 5f8811f
This is the working implementation of pedals & ADC/DMA for new Contro…
OscarPortillo37 4b5de2a
Merged
OscarPortillo37 0e6862d
Merge branch 'production/M2' into feature/NewPinout
guytonde e03e2c3
fixed adc; extra1 is acting up
guytonde a9d2f4b
Merge branch 'production/M2.5' into feature/NewPinout-Pedals
guytonde 711943a
fixed error in resolving merge conflicts
guytonde ebb6741
small issue in indent
guytonde 7a6c2b4
Merge branch 'production/M2.5' into feature/NewPinout
guytonde c95d7c7
Fix heartbeat (error in consistency)
guytonde cb7e102
Merge branch 'feature/NewPinout' into feature/NewPinout-Pedals
guytonde 306cefa
Merge pull request #442 from lhr-solar/feature/NewPinout-Pedals
guytonde 0c7f7c0
Feature/can fix (#441)
Lakshay983 8eac024
stupid
Lakshay983 aea0325
sharepoint workflow fix (#445)
Lakshay983 2584266
Dash driver (#446)
Mikail-Sadic-UT e4b5ae9
Display Info page redesign + Fault and Evac issues (#439)
guytonde e4f6dc6
IO State Rewrite (#449)
Lakshay983 be8c264
Contactor rewrite (#447)
Lakshay983 126b521
ReadCarCAN Rewrite for Daybreak 2025 (#448)
Lakshay983 c1d5000
Send tritium rework MVP (#451)
OscarPortillo37 dfb3a9b
Pedal Integration (#458)
Lakshay983 58d47ef
add nix file and add venv to gitignore
Lakshay983 7f13da1
add SWOC LIMIT define
Lakshay983 0cb899f
Theoretically works without faults
adiv06 f64a5b3
multiple swoc thresholds
ParthivS20 0e40b62
multiple swoc thresholds
ParthivS20 840a1b5
updated thresholds as of 11/10
ParthivS20 3ff7103
updated thresholds as of 11/10
ParthivS20 e957ed3
lakshay wrote this
ParthivS20 a50f126
lakshay wrote this
ParthivS20 3a6406b
max 29, starting tuning for max accell and speed
ParthivS20 388f942
updated power limits and turn brake light on in fault
ParthivS20 8e667b1
reset when swoc
ParthivS20 efc9a6b
reset when swoc
ParthivS20 d3ec9cd
swoc reset flag
ParthivS20 aa25cd6
display restart msg in display limit field
ParthivS20 2877c95
faults + FSM still need watchdogs
adiv06 b9b5201
Merge branch 'feature/NewPinout' of github.com:lhr-solar/Controls int…
adiv06 d8f611c
Revert "faults + FSM still need watchdogs"
adiv06 3314dc4
Revert "Theoretically works without faults"
adiv06 59a5615
ending revert
adiv06 f23933f
ending revert
adiv06 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,3 +7,5 @@ __pycache__ | |
|
|
||
| !.vscode/LHR.code-workspace | ||
| !.vscode/c_cpp_properties.json | ||
|
|
||
| .venv | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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; | ||
|
|
||
| void assertIOStateError(controls_error_e io_err); | ||
|
|
||
| #endif | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
|
|
||
| void assertReadCarCANError(controls_error_e rcc_err); | ||
|
|
||
| #endif | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| * @{ | ||
|
|
@@ -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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // #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 | ||
|
|
||
| /* @} */ | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| // /** | ||
| // * 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
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
|
||
| #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. | ||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This
IOState_error_code_tenum 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.