Skip to content

Commit ee1cf8b

Browse files
other test stuff
1 parent dbd03a1 commit ee1cf8b

5 files changed

Lines changed: 27 additions & 5 deletions

File tree

Core/Src/u_bms.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
/* Globals. */
1313
static _Atomic float battbox_temp;
14-
static _Atomic bool precharge = false; // Default to false until BMS confirms precharge is complete
14+
static _Atomic bool precharge = true; // u_TODO - set this back to false once testing done!!! // Default to false until BMS confirms precharge is complete
1515

1616
static void _bms_fault_callback(ULONG args); // Forward declaration
1717

Core/Src/u_dti.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#include "c_utils.h"
2121
#include "u_bms.h"
2222
#include "u_can.h"
23+
#include "serial.h"
2324
#include "u_emrax.h"
2425
#include "u_queues.h"
2526
#include "u_mutexes.h"
@@ -122,9 +123,15 @@ void dti_set_regen(uint16_t current_target)
122123

123124
void dti_set_current(int16_t current)
124125
{
125-
if (!bms_getPrecharge()) {
126-
return;
127-
}
126+
static uint32_t count = 0;
127+
serial_monitor("dti_current", "current", "%d", current);
128+
serial_monitor("dti_current", "count", "%ld", count);
129+
count++;
130+
131+
// u_TODO - uncomment this when done testing
132+
// if (!bms_getPrecharge()) {
133+
// return;
134+
// }
128135
can_msg_t msg = { .id = 0x036, .len = 2, .data = { 0 } };
129136

130137
#ifdef TSMS_OVERRIDE

Core/Src/u_faults.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,8 @@ int faults_init(void) {
102102
/* Triggers a fault. */
103103
/* If the fault is already triggered, this just resets the fault's timer. */
104104
int trigger_fault(fault_t fault_id) {
105+
return U_SUCCESS; // u_TODO - remove this once testing done!!!
106+
105107
/* Set the relevant fault bit in the fault flags list. */
106108
atomic_fetch_or(&fault_flags, (uint32_t)(1 << fault_id)); // This is the _Atomic version of: fault_flags |= (uint32_t)(1 << fault_id);
107109

Core/Src/u_statemachine.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,11 @@ int init_statemachine(void) {
7272
return U_ERROR;
7373
}
7474

75+
// u_TODO - Remove this when done tesgin!! default the state to functional
76+
cerberus_state.functional = F_PERFORMANCE;
77+
cerberus_state.nero.home_mode = false;
78+
cerberus_state.nero.nero_index = PERFORMANCE;
79+
7580
PRINTLN_INFO("Ran init_statemachine().");
7681
return U_SUCCESS;
7782
}
@@ -96,6 +101,7 @@ nero_state_t get_nero_state()
96101

97102
static int transition_functional_state(func_state_t new_state)
98103
{
104+
99105
/* Special case: should be able to fault no matter what conditions */
100106
if (new_state == FAULTED) {
101107
/* Turn off high power peripherals */

Core/Src/u_threads.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,13 @@ void vCANOutgoing(ULONG thread_input) {
230230
queue_send(&faults, &(fault_t){CAN_OUTGOING_FAULT}, TX_NO_WAIT);
231231

232232
}
233+
234+
// u_TODO - when done testing, comment this out
235+
if(message.id == 0x036) {
236+
static uint32_t count = 0;
237+
serial_monitor("dti_current", "sent_count", "%ld", count);
238+
count++;
239+
}
233240
tx_thread_sleep(1); // This is needed, or else the queue will try to send messages too fast and outpace the HAL.
234241
}
235242
}
@@ -929,7 +936,7 @@ uint8_t threads_init(TX_BYTE_POOL *byte_pool) {
929936
CATCH_ERROR(create_thread(byte_pool, &faults_queue_thread), U_SUCCESS); // Create Faults Queue thread.
930937
CATCH_ERROR(create_thread(byte_pool, &faults_thread), U_SUCCESS); // Create Faults thread.
931938
CATCH_ERROR(create_thread(byte_pool, &shutdown_thread), U_SUCCESS); // Create Shutdown thread.
932-
CATCH_ERROR(create_thread(byte_pool, &statemachine_thread), U_SUCCESS); // Create State Machine thread.
939+
//CATCH_ERROR(create_thread(byte_pool, &statemachine_thread), U_SUCCESS); // Create State Machine thread.
933940
CATCH_ERROR(create_thread(byte_pool, &pedals_thread), U_SUCCESS); // Create Pedals thread.
934941
CATCH_ERROR(create_thread(byte_pool, &efuses_thread), U_SUCCESS); // Create eFuses thread.
935942
CATCH_ERROR(create_thread(byte_pool, &mux_thread), U_SUCCESS); // Create Mux thread.

0 commit comments

Comments
 (0)