Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/clang #193

Closed
wants to merge 14 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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
18 changes: 0 additions & 18 deletions .clang-format

This file was deleted.

5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# https://github.com/github/gitignore/blob/master/C.gitignore

# nix
*.nix

# VSCode files
.vs/
.vscode/
Expand Down Expand Up @@ -71,4 +74,4 @@ types_c.taghl
ctrlp.root

#html
*.html
*.html
10 changes: 10 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
repos:
- repo: local
hooks:
- id: clang_restage
name: Restage formatted files
entry: clang_restage
language: system
pass_filenames: false
always_run: true
stages: [pre-commit]
17 changes: 9 additions & 8 deletions Core/Src/bms.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "bms.h"
#include "timer.h"
#include "fault.h"
#include "can.h"
#include "serial_monitor.h"
#include "cerberus_conf.h"
#include "fault.h"
#include "serial_monitor.h"
#include "stdio.h"
#include "timer.h"
#include <assert.h>
#include <stdlib.h>
#include "stdio.h"

#define CAN_QUEUE_SIZE 5

Expand All @@ -25,9 +25,10 @@ const osThreadAttr_t bms_monitor_attributes = {

void bms_fault_callback()
{
fault_data_t fault_data = {
.id = BMS_CAN_MONITOR_FAULT, .severity = DEFCON1
}; /*TO-DO: update severity*/
fault_data_t fault_data

= { .id = BMS_CAN_MONITOR_FAULT,
.severity = DEFCON1 }; /*TO-DO: update severity*/
fault_data.diag = "Failing To Receive CAN Messages from Shepherd";
osTimerStart(bms->bms_monitor_timer, BMS_CAN_MONITOR_DELAY);
queue_fault(&fault_data);
Expand Down Expand Up @@ -61,7 +62,7 @@ void vBMSCANMonitor(void *pv_params)
BMS_CAN_MONITOR_DELAY);
bms->dcl = (uint16_t)((msg_from_queue.data[1] << 8) &
msg_from_queue.data[0]);
//serial_print("BMS DCL %d", bms->dcl);
// serial_print("BMS DCL %d", bms->dcl);
}
}
}
11 changes: 5 additions & 6 deletions Core/Src/can_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,17 @@
*/

#include "can_handler.h"
#include "bms.h"
#include "can.h"
#include "cerberus_conf.h"
#include "dti.h"
#include "fault.h"
#include "steeringio.h"
#include "serial_monitor.h"
#include "bms.h"
#include "stdio.h"
#include "steeringio.h"
#include <assert.h>
#include <stdlib.h>
#include "stdio.h"
#include <string.h>
#include "dti.h"

#define CAN_MSG_QUEUE_SIZE 50 /* messages */
static osMessageQueueId_t can_outbound_queue;
Expand Down Expand Up @@ -84,7 +83,7 @@ void can1_callback(CAN_HandleTypeDef *hcan)
osMessageQueuePut(dti_router_queue, &new_msg, 0U, 0U);
break;
case BMS_DCL_MSG:
//printf("Recieved dcl");
// printf("Recieved dcl");
osMessageQueuePut(bms_monitor_queue, &new_msg, 0U, 0U);
break;
default:
Expand Down Expand Up @@ -120,7 +119,7 @@ void vCanDispatch(void *pv_params)
fault_data.diag = "Outbound mailbox full!";
queue_fault(&fault_data);
} else {
//printf("Message sent: %lX\r\n", msg_from_queue.id);
// printf("Message sent: %lX\r\n", msg_from_queue.id);
}
}

Expand Down
6 changes: 3 additions & 3 deletions Core/Src/fault.c
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#include "fault.h"
#include "c_utils.h"
#include "can_handler.h"
#include "serial_monitor.h"
#include "state_machine.h"
#include "task.h"
#include <assert.h>
#include <stdio.h>
#include "state_machine.h"
#include "can_handler.h"
#include <string.h>
#include "c_utils.h"

#define FAULT_HANDLE_QUEUE_SIZE 16

Expand Down
7 changes: 5 additions & 2 deletions Core/Src/monitor.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,8 @@ void vPedalsMonitor(void *pv_params)
eval_pedal_fault(adc_data[ACCELPIN_1], adc_data[ACCELPIN_2],
&diff_timer_accelerator, &sc_timer_accelerator,
&oc_timer_accelerator, &fault_data);
// eval_pedal_fault(adc_data[BRAKEPIN_1], adc_data[BRAKEPIN_1], &diff_timer_brake, &sc_timer_brake, &oc_timer_brake, &fault_data);
// eval_pedal_fault(adc_data[BRAKEPIN_1], adc_data[BRAKEPIN_1], &diff_timer_brake,
// &sc_timer_brake, &oc_timer_brake, &fault_data);

/* Offset adjusted per pedal sensor, clamp to be above 0 */
uint16_t accel_val1 =
Expand Down Expand Up @@ -308,7 +309,9 @@ void vPedalsMonitor(void *pv_params)

/* Send CAN messages with raw pedal readings, we do not care if it fails*/
counter += 1;
if (counter >= 5) {
if (counter >=

5) {
counter = 0;
endian_swap(&adc_data[ACCELPIN_1],
sizeof(adc_data[ACCELPIN_1]));
Expand Down
15 changes: 5 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,11 @@
# Cerberus
FreeRTOS Application that runs on MPU22A

## Setting up Docker Environment
> For initial installation and more info, visit here: https://nerdocs.atlassian.net/wiki/spaces/NER/pages/108888108/Setting+Up+STM32+Dev+Env
## Setting up Environment
> For initial installation and more info, visit here : https: // nerdocs.atlassian.net/wiki/spaces/NER/pages/524451844/2024+Firmware+Onboarding+Master

```
# TLDR:
# Pull Container:
docker compose pull
After entering the ner-venv but before making your first commit, run:

# Run Container
docker compose run --rm ner-gcc-arm
```


pre-commit install
```