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 38 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: 2 additions & 0 deletions Apps/Inc/Tasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ typedef uint16_t error_code_t;
*/
void Task_Init(void* p_arg);

void Task_StatusLED_Init(void);

Comment on lines +220 to +221
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

do we need a task for the status LED? I say put the LED toggle into an important task (like ReadCarCAN or ReadTritium), so that way if the LED is toggling then we know those important tasks are actively running.

We want to avoid the situation where we see the status LED blinking and then assuming everything is fine but in reality we're stuck on the status LED task infinitely.

void Task_SendTritium(void* p_arg);

void Task_ReadCarCAN(void* p_arg);
Expand Down
220 changes: 220 additions & 0 deletions Apps/Inc/daybreak_pins.h
Comment thread
Rav4s marked this conversation as resolved.
Original file line number Diff line number Diff line change
@@ -0,0 +1,220 @@
/**
* @copyright Copyright (c) 2018-2023 UT Longhorn Racing Solar
* @file daybreak_pins.h
* @brief
*
* @defgroup daybreak_pins
* @addtogroup daybreak_pins
* @{
*/

#ifndef __DAYBREAK_PINS_H
#define __DAYBREAK_PINS_H

#include <stm32f4xx_gpio.h>

// GPIO

#define MOTOR_PRCHG_BYPASS_PORT PORTA
#define MOTOR_PRCHG_BYPASS GPIO_Pin_0

#define ARRAY_PRCHG_BYPASS_PORT PORTA
#define ARRAY_PRCHG_BYPASS GPIO_Pin_1

#define BRAKE_LIGHT_PORT PORTA
#define BRAKE_LIGHT GPIO_Pin_4

#define OS_FAULT_PORT PORTA
#define OS_FAULT GPIO_Pin_5

#define BPS_HAZARD_PORT PORTA
#define BPS_HAZARD GPIO_Pin_6

#define CRUISE_SET_PORT PORTA
#define CRUISE_SET GPIO_Pin_7

#define PA8_PORT PORTA
#define PA8 GPIO_Pin_8

#define MOTOR_C_SENSE_PORT PORTA
#define MOTOR_C_SENSE GPIO_Pin_9

#define MOTOR_CONTACTOR_PORT PORTA
#define MOTOR_CONTACTOR GPIO_Pin_10

#define PA15_PORT PORTA
#define PA15 GPIO_Pin_15

#define BPS_FAULT_PORT PORTB
#define BPS_FAULT GPIO_Pin_0

#define IG1_PORT PORTB
#define IG1 GPIO_Pin_1

#define FORWARD_PORT PORTB
#define FORWARD GPIO_Pin_2

#define PB7_PORT PORTB
#define PB7 GPIO_Pin_7

#define ARRAY_PBC_SENSE_PORT PORTB
#define ARRAY_PBC_SENSE GPIO_Pin_8

#define MOTOR_PBC_SENSE_PORT PORTB
#define MOTOR_PBC_SENSE GPIO_Pin_9

#define IG2_PORT PORTB
#define IG2 GPIO_Pin_10

#define MOTOR_CTRL_FAULT_PORT PORTB
#define MOTOR_CTRL_FAULT GPIO_Pin_14

#define REVERSE_PORT PORTB
#define REVERSE GPIO_Pin_15

#define CONTROLS_FAULT_PORT PORTC
#define CONTROLS_FAULT GPIO_Pin_4

#define CRUISE_ENABLE_PORT PORTC
#define CRUISE_ENABLE GPIO_Pin_5

#define TIMER_CLK_PORT PORTC
#define TIMER_CLK GPIO_Pin_6

#define HEARTBEAT_PORT PORTC
#define HEARTBEAT GPIO_Pin_7

#define CRUISE_IND_PORT PORTC
#define CRUISE_IND GPIO_Pin_8

#define PC9_PORT PORTC
#define PC9 GPIO_Pin_9

#define PC10_PORT PORTC
#define PC10 GPIO_Pin_10

#define PC11_PORT PORTC
#define PC11 GPIO_Pin_11

#define PC12_PORT PORTC
#define PC12 GPIO_Pin_12

#define PC13_PORT PORTC
#define PC13 GPIO_Pin_13

#define PC14_PORT PORTC
#define PC14 GPIO_Pin_14

#define BRAKE_SW_PORT PORTC
#define BRAKE_SW GPIO_Pin_15

#define PD2_PORT PORTD
#define PD2 GPIO_Pin_2

// UART/USART

// USB - USART2 - PA2_TX PA3_RX
Comment thread
krazykrayon marked this conversation as resolved.
#define USB_GPIO GPIOA
#define USB_UART USART2
#define USB_IRQ USART2_IRQn
#define USB_AF GPIO_AF_USART2
#define USB_APB1_UART RCC_APB1Periph_USART2
#define USB_AHB1_GPIO RCC_AHB1Periph_GPIOA
#define USB_TX_Pinsource GPIO_PinSource2
#define USB_TX GPIO_Pin_2
#define USB_RX_Pinsource GPIO_PinSource3
#define USB_RX GPIO_Pin_3

// DISPLAY UART4 - PA11_RX PA12_TX
Comment thread
krazykrayon marked this conversation as resolved.
#define DISPLAY_GPIO GPIOA
#define DISPLAY_UART UART4
#define DISPLAY_IRQ UART4_IRQn
#define DISPLAY_AF GPIO_AF11_UART4
#define DISPLAY_APB1_UART RCC_APB1Periph_UART4
#define DISPLAY_AHB1_GPIO RCC_AHB1Periph_GPIOA
#define DISPLAY_TX_Pinsource GPIO_PinSource12
#define DISPLAY_TX GPIO_Pin_12
#define DISPLAY_RX_Pinsource GPIO_PinSource11
#define DISPLAY_RX GPIO_Pin_11

// EXTRA_UART UART5 - PB12_RX PB13_TX
Comment thread
krazykrayon marked this conversation as resolved.
#define ExtraUART_GPIO GPIOB
#define ExtraUART_UART UART5
#define ExtraUART_IRQ UART5_IRQn
#define ExtraUART_AF GPIO_AF11_UART5
#define ExtraUART_APB1_UART RCC_APB1Periph_UART5
#define ExtraUART_AHB1_GPIO RCC_AHB1Periph_GPIOB
#define ExtraUART_TX_Pinsource GPIO_PinSource13
#define ExtraUART_TX GPIO_Pin_13
#define ExtraUART_RX_Pinsource GPIO_PinSource12
#define ExtraUART_RX GPIO_Pin_12


#define ExtraUART_PORT PORTB
#define ExtraUART_TX GPIO_Pin_13
#define ExtraUART_RX GPIO_Pin_12

// ADC

#define ADC1_APB1 RCC_APB2Periph_ADC1
#define ADC1_AHB1_GPIO RCC_AHB1Periph_GPIOC
#define ADC1_GPIO GPIOC

// ACCEL_POT PC0
#define ACCEL_POT_PORT PORTC
#define ACCEL_POT_CHANNEL ADC_Channel_10
#define ACCEL_POT GPIO_Pin_0

// BRAKE_POT PC1
#define BRAKE_POT_PORT PORTC
#define BRAKE_POT_CHANNEL ADC_Channel_11
#define BRAKE_POT GPIO_Pin_1

// EXTRA_ADC1 PC2
#define ExtraADC_1_PORT PORTC
#define ExtraADC_1_CHANNEL ADC_Channel_12
#define ExtraADC_1 GPIO_Pin_2

// EXTRA_ADC2 PC3
#define ExtraADC_2_PORT PORTC
#define ExtraADC_2_CHANNEL ADC_Channel_13
#define ExtraADC_2 GPIO_Pin_3

// CAN

// The pins have been changed in the BSP

// CarCan - CAN3 PB3_RX PB4_TX
#define CarCAN_PORT PORTB
#define CarCAN_GPIO GPIOB
#define CarCAN CAN3
#define CarCAN_AHB1_GPIO RCC_AHB1Periph_GPIOB
#define CarCAN_APB1_CAN RCC_APB1Periph_CAN3
#define CarCAN_AF GPIO_AF11_CAN3
#define CarCAN_TX_Pinsource GPIO_PinSource4
#define CarCAN_TX GPIO_Pin_4
#define CarCAN_TX_IRQ CAN3_TX_IRQn
#define CarCAN_RX_Pinsource GPIO_PinSource3
#define CarCAN_RX GPIO_Pin_3
#define CarCAN_RX_IRQ CAN3_RX0_IRQn

// MotorCan - CAN2 PB5_RX PB6_TX
#define MotorCAN_PORT PORTB
#define MotorCAN_GPIO GPIOB
#define MotorCAN CAN2
#define MotorCAN_AHB1_GPIO RCC_AHB1Periph_GPIOB
#define MotorCAN_APB1_CAN RCC_APB1Periph_CAN2
#define MotorCAN_AF GPIO_AF_CAN2
#define MotorCAN_TX_Pinsource GPIO_PinSource6
#define MotorCAN_TX GPIO_Pin_6
#define MotorCAN_TX_IRQ CAN2_TX_IRQn
#define MotorCAN_RX_Pinsource GPIO_PinSource5
#define MotorCAN_RX GPIO_Pin_5
#define MotorCAN_RX_IRQ CAN2_RX0_IRQn






#endif
12 changes: 6 additions & 6 deletions Apps/Src/CommandLine.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ void Task_CommandLine(void* p_arg) {

while(1){
printf("> ");
BSP_UART_Read(UART_2, input);
BSP_UART_Read(USB, input);
printf("\n\r");

if (!executeCommand(input)) { // If command failed, error
Expand Down Expand Up @@ -151,10 +151,10 @@ static bool cmd_CANbus_Send(void){
char *busInput = strtok_r(NULL, " ", &save);
CAN_t bus;
if(strcmp(busInput, "motor") == 0){
bus = CAN_1;
bus = motor;
}
else if(strcmp(busInput, "car") == 0){
bus = CAN_3;
bus = car;
}
else{
return false;
Expand Down Expand Up @@ -186,10 +186,10 @@ static bool cmd_CANbus_Read(void){
char *busInput = strtok_r(NULL, " ", &save);
CAN_t bus;
if(strcmp(busInput, "motor") == 0){
bus = CAN_1;
bus = motor;
}
else if(strcmp(busInput, "car") == 0){
bus = CAN_3;
bus = car;
}
else{
return false;
Expand Down Expand Up @@ -279,7 +279,7 @@ static bool cmd_Minions_Read(void){
pin = IGN_2;
}
else if(strcmp(pinInput, "regen_sw") == 0){
pin = REGEN_SW;
pin = BPS_HAZ;
}
else if(strcmp(pinInput, "for_sw") == 0){
pin = FOR_SW;
Expand Down
7 changes: 4 additions & 3 deletions Apps/Src/ReadCarCAN.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "os.h"
#include "os_cfg_app.h"
#include "Display.h"
#include "daybreak_pins.h"

// Length of the array and motor PBC saturation buffers
#define SAT_BUF_LENGTH 5
Expand Down Expand Up @@ -336,7 +337,7 @@ static void handler_ReadCarCAN_chargeDisable(void)
updateHVArraySaturation(DISABLE_SATURATION_MSG);

// Kill contactor using a direct write to avoid blocking calls when the scheduler is locked
BSP_GPIO_Write_Pin(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN, false);
BSP_GPIO_Write_Pin(ARRAY_PRCHG_BYPASS_PORT, ARRAY_PRCHG_BYPASS, false);

// Check that the contactor was successfully turned off
bool ret = (bool)Contactors_Get(ARRAY_PRECHARGE_BYPASS_CONTACTOR);
Expand Down Expand Up @@ -365,8 +366,8 @@ static void handler_ReadCarCAN_contactorsDisable(void)
updateHVPlusMinusSaturation(DISABLE_SATURATION_MSG);

// Kill contactor using a direct write to avoid blocking calls when the scheduler is locked
BSP_GPIO_Write_Pin(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN, false);
BSP_GPIO_Write_Pin(CONTACTORS_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, false);
BSP_GPIO_Write_Pin(ARRAY_PRCHG_BYPASS_PORT, ARRAY_PRCHG_BYPASS, false);
BSP_GPIO_Write_Pin(MOTOR_PRCHG_BYPASS_PORT, MOTOR_PRCHG_BYPASS, false);

// Fills buffers with disable messages
memset(HVArrayChargeMsgBuffer, DISABLE_SATURATION_MSG, sizeof(HVArrayChargeMsgBuffer));
Expand Down
5 changes: 3 additions & 2 deletions Apps/Src/Tasks.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include "ReadTritium.h"
#include "ReadCarCAN.h"
#include "UpdateDisplay.h"
#include "daybreak_pins.h"


/**
Expand Down Expand Up @@ -136,8 +137,8 @@ void throwTaskError(error_code_t errorCode, callback_t errorCallback, error_sche
*/
void EmergencyContactorOpen() {
// Array motor kill
BSP_GPIO_Write_Pin(CONTACTORS_PORT, MOTOR_CONTROLLER_PRECHARGE_BYPASS_PIN, OFF);
BSP_GPIO_Write_Pin(CONTACTORS_PORT, ARRAY_PRECHARGE_BYPASS_PIN, OFF);
BSP_GPIO_Write_Pin(MOTOR_PRCHG_BYPASS_PORT, MOTOR_PRCHG_BYPASS, OFF);
BSP_GPIO_Write_Pin(ARRAY_PRCHG_BYPASS_PORT, ARRAY_PRCHG_BYPASS, OFF);

// Turn additional brakelight on to indicate critical error
BSP_GPIO_Write_Pin(PININFO_LUT[BRAKELIGHT].port, PININFO_LUT[BRAKELIGHT].pinMask, true);
Expand Down
24 changes: 20 additions & 4 deletions Apps/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
*
*/

// (TODO) Status LEDs

#include "common.h"
#include "config.h"
#include "Tasks.h"
Expand All @@ -17,7 +19,7 @@
#include "Pedals.h"
#include "UpdateDisplay.h"
#include "SendCarCAN.h"

#include "daybreak_pins.h"
#include "BSP_GPIO.h"

int idle_time_ctr = 0;
Expand All @@ -36,7 +38,7 @@ void IdleTaskHook(void)
last_tick_cnt = current_tick_cnt;

if(current_tick_cnt % 50 == 0){
BSP_GPIO_Write_Pin(PORTB, GPIO_Pin_6, toggle);
BSP_GPIO_Write_Pin(HEARTBEAT_PORT, HEARTBEAT, toggle);
toggle = !toggle;
}
}
Expand All @@ -45,7 +47,7 @@ void IdleTaskHook(void)

void IdleInit(void)
{
BSP_GPIO_Init(PORTB, GPIO_Pin_6, OUTPUT, false);
BSP_GPIO_Init(HEARTBEAT_PORT, HEARTBEAT, OUTPUT, false);
OS_AppIdleTaskHookPtr = &IdleTaskHook;
}

Expand All @@ -58,6 +60,7 @@ int main(void) {
OSInit(&err);
IdleInit();
TaskSwHook_Init();
Task_StatusLED_Init();

assertOSError(err);

Expand Down Expand Up @@ -89,6 +92,19 @@ int main(void) {
while(1);
}

void Task_StatusLED_Init(void) {
BSP_GPIO_Init(OS_FAULT_PORT, OS_FAULT, OUTPUT, false);
BSP_GPIO_Init(IG1_PORT, IG1, OUTPUT, false);
BSP_GPIO_Init(IG2_PORT, IG2, OUTPUT, false);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

IG_1 and IG_2 are primarily dashboard inputs, so we probably want to initialize them in a separate function. Motor contactor can technically be initialized here but might make more sense being initialized elsewhere too

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Yeah, there should be like a Contactor.c and Ignition.c file in drivers and those pins can be init'd there. It'll be nicer for when you're running standalone tests like a Test_IgnitionSequence.c so you can just run Ignition_Init() and it'll work.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

@gemini-code-assist thought, big man?

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Thanks for asking, @guytonde!

I agree with @KnockbackNemo and @Lakshay983 that moving the initialization of IG1 and IG2 to a dedicated driver like Ignition.c (as inputs, which they are) and MOTOR_CONTACTOR to Contactors.c is a good architectural improvement. This enhances modularity and makes the code easier to test and maintain, as @Lakshay983 pointed out.

However, I noticed a potential issue in Apps/Src/main.c within the lines highlighted by this comment:

95:void Task_StatusLED_Init(void) {
96:    BSP_GPIO_Init(OS_FAULT_PORT, OS_FAULT, OUTPUT, false);
97:    BSP_GPIO_Init(IG1_PORT, IG1, OUTPUT, false);
98:    BSP_GPIO_Init(IG2_PORT, IG2, OUTPUT, false);

This Task_StatusLED_Init function initializes IG1 and IG2 as OUTPUT pins. Based on the changes in Apps/Src/Ignition.c (where IG1 and IG2 are correctly initialized as INPUT pins via Ignition_Init), this function in main.c appears to be:

  1. Incorrect: It sets IG1 and IG2 as OUTPUT when they are INPUTs.
  2. Unused: This Task_StatusLED_Init function is not called anywhere in the new main.c or Tasks.c files.

This is a critical issue as it introduces confusing and misleading code that could lead to future bugs or maintenance headaches. I recommend removing this Task_StatusLED_Init function from main.c entirely, as its purpose seems to be superseded by the new driver structure.

Suggested change:
Remove lines 95-98 from Apps/Src/main.c.

--- a/Apps/Src/main.c
+++ b/Apps/Src/main.c
@@ -92,7 +92,3 @@
     while(1);
 }
 
-void Task_StatusLED_Init(void) {
-    BSP_GPIO_Init(OS_FAULT_PORT, OS_FAULT, OUTPUT, false);
-    BSP_GPIO_Init(IG1_PORT, IG1, OUTPUT, false);
-    BSP_GPIO_Init(IG2_PORT, IG2, OUTPUT, false);

BSP_GPIO_Init(MOTOR_CONTACTOR_PORT, MOTOR_CONTACTOR, OUTPUT, false);
BSP_GPIO_Init(MOTOR_PRCHG_BYPASS_PORT, MOTOR_PRCHG_BYPASS, OUTPUT, false);
BSP_GPIO_Init(ARRAY_PRCHG_BYPASS_PORT, ARRAY_PRCHG_BYPASS, OUTPUT, false);
BSP_GPIO_Init(MOTOR_CTRL_FAULT_PORT, MOTOR_CTRL_FAULT, OUTPUT, false);
BSP_GPIO_Init(BPS_FAULT_PORT, BPS_FAULT, OUTPUT, false);
BSP_GPIO_Init(CONTROLS_FAULT_PORT, CONTROLS_FAULT, OUTPUT, false);
BSP_GPIO_Init(CRUISE_IND_PORT, CRUISE_IND, OUTPUT, false);
}

void Task_Init(void *p_arg){
OS_ERR err;

Expand All @@ -97,7 +113,7 @@ void Task_Init(void *p_arg){

// Initialize drivers
Pedals_Init();
BSP_UART_Init(UART_2);
BSP_UART_Init(USB);
CANbus_Init(CARCAN, carCANFilterList, NUM_CARCAN_FILTERS);
CANbus_Init(MOTORCAN, NULL, NUM_MOTORCAN_FILTERS);
Contactors_Init();
Expand Down
Loading