-
Notifications
You must be signed in to change notification settings - Fork 2
Daybreak 2025 Integration #436
base: production/M2.5
Are you sure you want to change the base?
Changes from 38 commits
c73472c
8e51b42
ba0d304
3224fc2
b844371
99ba1d4
bdeb293
85f0638
2064b7b
6d4949a
57c7f46
9dceea9
489bc1c
980227c
cd76208
92919f3
a965754
868ae25
217c6aa
c79091e
12ae35f
ba2378c
d4f190a
e526294
9991937
102a239
2008b19
f7f44e5
c4c9684
14b611d
b261b2b
74d387e
abfa918
34c54cd
00bfd7b
09add9c
80cfa47
0aeb47c
b79ee75
91df2f5
71daffd
3eed715
0b1ff95
d951778
1a58d6f
1834596
e080a5c
5f8811f
4b5de2a
0e6862d
e03e2c3
a9d2f4b
711943a
ebb6741
7a6c2b4
c95d7c7
cb7e102
306cefa
0c7f7c0
8eac024
aea0325
2584266
e4b5ae9
e4f6dc6
be8c264
126b521
c1d5000
dfb3a9b
58d47ef
7f13da1
0cb899f
f64a5b3
0e40b62
840a1b5
3ff7103
e957ed3
a50f126
3a6406b
388f942
8e667b1
efc9a6b
d3ec9cd
aa25cd6
2877c95
b9b5201
d8f611c
3314dc4
59a5615
f23933f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
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 | ||
|
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 | ||
|
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 | ||
|
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 | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,8 @@ | |
| * | ||
| */ | ||
|
|
||
| // (TODO) Status LEDs | ||
|
|
||
| #include "common.h" | ||
| #include "config.h" | ||
| #include "Tasks.h" | ||
|
|
@@ -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; | ||
|
|
@@ -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; | ||
| } | ||
| } | ||
|
|
@@ -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; | ||
| } | ||
|
|
||
|
|
@@ -58,6 +60,7 @@ int main(void) { | |
| OSInit(&err); | ||
| IdleInit(); | ||
| TaskSwHook_Init(); | ||
| Task_StatusLED_Init(); | ||
|
|
||
| assertOSError(err); | ||
|
|
||
|
|
@@ -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); | ||
|
Contributor
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. 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 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. 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. 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. @gemini-code-assist thought, big man? 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. Thanks for asking, @guytonde! I agree with @KnockbackNemo and @Lakshay983 that moving the initialization of However, I noticed a potential issue in 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
This is a Suggested change: --- 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; | ||
|
|
||
|
|
@@ -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(); | ||
|
|
||
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.
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.