Skip to content

Commit

Permalink
Still trying to get this working
Browse files Browse the repository at this point in the history
  • Loading branch information
nwdepatie committed Dec 14, 2023
1 parent 896b57a commit ca24f33
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 31 deletions.
2 changes: 1 addition & 1 deletion Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ int main(void)
serial_monitor_handle = osThreadNew(vSerialMonitor, NULL, &serial_monitor_attributes);
fault_handle = osThreadNew(vFaultHandler, NULL, &fault_handle_attributes);
pedals_monitor_handle = osThreadNew(vPedalsMonitor, &pedal_params, &pedals_monitor_attributes);
route_can_incoming_handle = osThreadNew(vRouteCanIncoming, &hcan1, &route_can_incoming_attributes);
//route_can_incoming_handle = osThreadNew(vRouteCanIncoming, &hcan1, &route_can_incoming_attributes);
can_dispatch_handle = osThreadNew(vCanDispatch, &hcan1, &can_dispatch_attributes);

/* USER CODE END RTOS_THREADS */
Expand Down
60 changes: 30 additions & 30 deletions Core/Src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void vWatchdogMonitor(void* pv_params)
osThreadId_t pedals_monitor_handle;
const osThreadAttr_t pedals_monitor_attributes = {
.name = "PedalMonitor",
.stack_size = 128 * 8,
.stack_size = 128 * 12,
.priority = (osPriority_t)osPriorityHigh,
};

Expand All @@ -116,48 +116,48 @@ void vPedalsMonitor(void* pv_params)

uint16_t adc_data[4];

HAL_ADC_Start(params->accel_adc1);
HAL_ADC_Start(params->accel_adc2);
HAL_ADC_Start(params->brake_adc);
//HAL_ADC_Start(params->accel_adc1);
//HAL_ADC_Start(params->accel_adc2);
//HAL_ADC_Start(params->brake_adc);

for (;;) {
serial_print("Pedals Task\r\n");
/*
* Get the value from the adc at the brake and accelerator
* pin addresses and average them to the sensor data value
*/
adc_data[ACCELPIN_1] = HAL_ADC_PollForConversion(params->accel_adc1, HAL_MAX_DELAY);
adc_data[ACCELPIN_2] = HAL_ADC_PollForConversion(params->accel_adc2, HAL_MAX_DELAY);
adc_data[BRAKEPIN_1] = HAL_ADC_PollForConversion(params->brake_adc, HAL_MAX_DELAY);
adc_data[BRAKEPIN_2] = HAL_ADC_PollForConversion(params->brake_adc, HAL_MAX_DELAY);
//adc_data[ACCELPIN_1] = HAL_ADC_PollForConversion(params->accel_adc1, HAL_MAX_DELAY);
//adc_data[ACCELPIN_2] = HAL_ADC_PollForConversion(params->accel_adc2, HAL_MAX_DELAY);
//adc_data[BRAKEPIN_1] = HAL_ADC_PollForConversion(params->brake_adc, HAL_MAX_DELAY);
//adc_data[BRAKEPIN_2] = HAL_ADC_PollForConversion(params->brake_adc, HAL_MAX_DELAY);

/* Evaluate accelerator faults */
if (is_timer_expired(&oc_timer))
//if (is_timer_expired(&oc_timer))
//todo queue fault
continue;
else if ((adc_data[ACCELPIN_1] == MAX_ADC_VAL_12B || adc_data[ACCELPIN_2] == MAX_ADC_VAL_12B) &&
!is_timer_active(&oc_timer))
start_timer(&oc_timer, PEDAL_FAULT_TIME);
else
cancel_timer(&oc_timer);
// continue;
//else if ((adc_data[ACCELPIN_1] == MAX_ADC_VAL_12B || adc_data[ACCELPIN_2] == MAX_ADC_VAL_12B) &&
// !is_timer_active(&oc_timer))
// start_timer(&oc_timer, PEDAL_FAULT_TIME);
//else
// cancel_timer(&oc_timer);

if (is_timer_expired(&sc_timer))
//if (is_timer_expired(&sc_timer))
//todo queue fault
continue;
else if ((adc_data[ACCELPIN_1] == 0 || adc_data[ACCELPIN_2] == 0) &&
!is_timer_active(&sc_timer))
start_timer(&sc_timer, PEDAL_FAULT_TIME);
else
cancel_timer(&sc_timer);

if (is_timer_expired(&diff_timer))
// continue;
//else if ((adc_data[ACCELPIN_1] == 0 || adc_data[ACCELPIN_2] == 0) &&
// !is_timer_active(&sc_timer))
// start_timer(&sc_timer, PEDAL_FAULT_TIME);
//else
// cancel_timer(&sc_timer);

//if (is_timer_expired(&diff_timer))
//todo queue fault
continue;
else if ((adc_data[ACCELPIN_1] - adc_data[ACCELPIN_2] > PEDAL_DIFF_THRESH * MAX_ADC_VAL_12B) &&
!is_timer_active(&diff_timer))
start_timer(&diff_timer, PEDAL_FAULT_TIME);
else
cancel_timer(&diff_timer);
// continue;
//else if ((adc_data[ACCELPIN_1] - adc_data[ACCELPIN_2] > PEDAL_DIFF_THRESH * MAX_ADC_VAL_12B) &&
// !is_timer_active(&diff_timer))
// start_timer(&diff_timer, PEDAL_FAULT_TIME);
//else
// cancel_timer(&diff_timer);

//sensor_data.acceleratorValue
// = (sensor_data.acceleratorValue + (adc_data[ACCELPIN_1] + adc_data[ACCELPIN_2]) / 2)
Expand Down

0 comments on commit ca24f33

Please sign in to comment.