Skip to content

Commit

Permalink
190 no more nero monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
Sabramz committed Aug 10, 2024
1 parent 2bb96b1 commit 49439a7
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 35 deletions.
11 changes: 1 addition & 10 deletions Core/Inc/nero.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
#include "cmsis_os.h"
#include "stm32f4xx_hal.h"

#define NERO_UPDATE_FLAG 1U

/*
* Tells NERO the current MPH
*/
Expand All @@ -16,13 +14,6 @@ void set_mph(int8_t new_mph);
* @brief Send NERO information over CAN.
*
*/
void send_mode_status();

/*
* Emits the state of NERO
*/
void vNeroMonitor(void *pv_params);
extern osThreadId_t nero_monitor_handle;
extern const osThreadAttr_t nero_monitor_attributes;
void send_nero_msg();

#endif // NERO_H
3 changes: 1 addition & 2 deletions Core/Src/fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,7 @@ int queue_fault(fault_data_t *fault_data)
if (!fault_handle_queue)
return -1;

return queue_and_set_flag(fault_handle_queue, fault_data,
fault_handle,
return queue_and_set_flag(fault_handle_queue, fault_data, fault_handle,
NEW_FAULT_FLAG);
}

Expand Down
4 changes: 1 addition & 3 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,6 @@ int main(void)
assert(can_receive_thread);
serial_monitor_handle = osThreadNew(vSerialMonitor, NULL, &serial_monitor_attributes);
assert(serial_monitor_handle);
nero_monitor_handle = osThreadNew(vNeroMonitor, NULL, &nero_monitor_attributes);
assert(nero_monitor_handle);

/* Control Logic */
process_pedals_args_t *proc_pedal_args = malloc(sizeof(process_pedals_args_t));
Expand Down Expand Up @@ -727,7 +725,7 @@ void StartDefaultTask(void *argument)
HAL_GPIO_TogglePin(GPIOC, GPIO_PIN_8);

/* Send NERO state data continuously */
send_mode_status();
send_nero_msg();
osDelay(500);
//osDelay(YELLOW_LED_BLINK_DELAY);
}
Expand Down
20 changes: 2 additions & 18 deletions Core/Src/nero.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

static int8_t mph = 0;

void send_mode_status()
void send_nero_msg()
{
can_msg_t msg = { .id = 0x501,
.len = 4,
Expand All @@ -28,21 +28,5 @@ void send_mode_status()
void set_mph(int8_t new_mph)
{
mph = new_mph;
osThreadFlagsSet(nero_monitor_handle, NERO_UPDATE_FLAG);
}

osThreadId_t nero_monitor_handle;
const osThreadAttr_t nero_monitor_attributes = {
.name = "NeroMonitor",
.stack_size = 32 * 32,
.priority = (osPriority_t)osPriorityRealtime2,
};

void vNeroMonitor(void *pv_params)
{
for (;;) {
osThreadFlagsWait(NERO_UPDATE_FLAG, osFlagsWaitAny,
osWaitForever);
send_mode_status();
}
send_nero_msg();
}
2 changes: 1 addition & 1 deletion Core/Src/processing.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ void tsms_debounce_cb(void *arg)
tsms = *((bool *)arg);
osMutexRelease(tsms_mutex);
/* Tell NERO allaboutit */
osThreadFlagsSet(nero_monitor_handle, NERO_UPDATE_FLAG);
send_nero_msg();
}

osThreadId_t process_tsms_thread_id;
Expand Down
3 changes: 2 additions & 1 deletion Core/Src/state_machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ static int transition_nero_state(nero_state_t new_state, pdu_t *pdu, dti_t *mc)

cerberus_state.nero = new_state;
/* Notify NERO */
osThreadFlagsSet(nero_monitor_handle, NERO_UPDATE_FLAG);
send_nero_msg();

return 0;
}
Expand All @@ -178,6 +178,7 @@ static int queue_state_transition(state_req_t new_state)
if (!state_trans_queue) {
return 1;
}

return queue_and_set_flag(state_trans_queue, &new_state,
sm_director_handle, STATE_TRANSITION_FLAG);
}
Expand Down

0 comments on commit 49439a7

Please sign in to comment.