Skip to content

Commit

Permalink
Bug/cleanup headers (#265)
Browse files Browse the repository at this point in the history
Co-authored-by: Caio <[email protected]>
  • Loading branch information
jr1221 and caiodasilva2005 authored Jan 21, 2025
1 parent 5a78287 commit 91fe776
Show file tree
Hide file tree
Showing 23 changed files with 60 additions and 141 deletions.
1 change: 0 additions & 1 deletion Core/Inc/bms.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

#ifndef BMS_H
#define BMS_H

Expand Down
14 changes: 0 additions & 14 deletions Core/Inc/can_handler.h
Original file line number Diff line number Diff line change
@@ -1,22 +1,8 @@
/**
* @file can_handler.h
* @author Hamza Iqbal
* @brief This CAN handler is meant to receive and properly route CAN messages
* and keep this task seperate the CAN driver. The purpose of this is
* specifically to have a better way of routing the different messages.
* @version 0.1
* @date 2023-09-22
*
* @copyright Copyright (c) 2023
*
*/

#ifndef CAN_HANDLER_H
#define CAN_HANDLER_H

#include "can.h"
#include "cmsis_os.h"
#include "dti.h"

/**
* @brief Callback to be called when a message is received on CAN line 1.
Expand Down
3 changes: 2 additions & 1 deletion Core/Inc/cerb_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@
#ifndef CERB_UTILS_H
#define CERB_UTILS_H

#include <stdbool.h>

#include "cmsis_os.h"
#include "stdbool.h"
#include "timer.h"

/**
Expand Down
2 changes: 0 additions & 2 deletions Core/Inc/dti.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
#define DTI_H

#include "can_handler.h"
#include <stdbool.h>
#include <stdint.h>

/* Message IDs from DTI CAN Datasheet */
#define DTI_CANID_ERPM 0x416 /* ERPM, Duty, Input Voltage */
Expand Down
1 change: 0 additions & 1 deletion Core/Inc/fault.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#ifndef CERBERUS_FAULT_H
#define CERBERUS_FAULT_H

#include "cerberus_conf.h"
#include "cmsis_os.h"

typedef enum {
Expand Down
5 changes: 2 additions & 3 deletions Core/Inc/monitor.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#ifndef CERBERUS_MONITOR_H
#define CERBERUS_MONITOR_H

#include <stdbool.h>

#include "cmsis_os.h"
#include "mpu.h"
#include "pdu.h"
#include "stdbool.h"
#include "steeringio.h"
#include "stm32f4xx_hal.h"

/**
* @brief Get the debounced TSMS reading.
Expand Down
6 changes: 3 additions & 3 deletions Core/Inc/mpu.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef MPU_H
#define MPU_H

#include "cmsis_os2.h"
#include "stm32f4xx_hal.h"
#include <stdbool.h>
#include <stdint.h>

#include "cmsis_os.h"
#include "stm32f4xx_hal.h"

typedef struct {
I2C_HandleTypeDef *hi2c;
Expand Down
4 changes: 2 additions & 2 deletions Core/Inc/pdu.h
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
#ifndef PDU_H
#define PDU_H

#include <stdbool.h>

#include "cmsis_os.h"
#include "pca9539.h"
#include <stdbool.h>
#include <stdint.h>

#define SOUND_RTDS_FLAG 1U

Expand Down
2 changes: 0 additions & 2 deletions Core/Inc/pedals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@
#ifndef PROCESSING_H
#define PROCESSING_H

#include "cmsis_os.h"
#include "stdbool.h"
#include "dti.h"
#include "pdu.h"
#include "mpu.h"
Expand Down
21 changes: 0 additions & 21 deletions Core/Inc/queues.h

This file was deleted.

2 changes: 0 additions & 2 deletions Core/Inc/state_machine.h
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#ifndef STATE_MACHINE_H
#define STATE_MACHINE_H

#include "cmsis_os.h"
#include "fault.h"
#include "pdu.h"
#include "dti.h"
#include "mpu.h"
Expand Down
5 changes: 0 additions & 5 deletions Core/Inc/steeringio.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@
#define STEERING_H

#include "can.h"
#include "cmsis_os.h"
#include "ringbuffer.h"
#include "timer.h"
#include <stdbool.h>
#include <stdint.h>

#define STEERING_CANID_IO 0x680

Expand Down
9 changes: 4 additions & 5 deletions Core/Src/bms.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
#include "bms.h"
#include "timer.h"
#include "fault.h"
#include "can.h"
#include "cerberus_conf.h"

#include <assert.h>
#include <stdlib.h>
#include "stdio.h"

#include "cerberus_conf.h"
#include "fault.h"

bms_t *bms;

Expand Down
22 changes: 6 additions & 16 deletions Core/Src/can_handler.c
Original file line number Diff line number Diff line change
@@ -1,24 +1,14 @@
/**
* @file can_handler.c
* @author Hamza Iqbal and Nick DePatie
* @brief Source file for CAN handler
* @version 0.1
* @date 2023-09-22
*
* @copyright Copyright (c) 2023
*
*/

#include "can_handler.h"

#include <assert.h>
#include <stdlib.h>
#include <string.h>

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

#define CAN_MSG_QUEUE_SIZE 50 /* messages */

Expand Down
11 changes: 4 additions & 7 deletions Core/Src/dti.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,14 @@
* @copyright Copyright (c) 2023
*
*/

#include "dti.h"
#include "can.h"
#include "emrax.h"
#include "fault.h"
#include "c_utils.h"
#include <math.h>

#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>

#include "emrax.h"
#include "bms.h"

#define CAN_QUEUE_SIZE 5 /* messages */
Expand Down
11 changes: 4 additions & 7 deletions Core/Src/fault.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
#include "fault.h"
#include "task.h"
#include <assert.h>

#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "state_machine.h"
#include "can_handler.h"
#include <string.h>
#include "c_utils.h"
#include "cerb_utils.h"

#include "cerberus_conf.h"
#include "state_machine.h"

#define FAULT_HANDLE_QUEUE_SIZE 16
Expand Down
12 changes: 6 additions & 6 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "sht30.h"
#include "lsm6dso.h"
#include "monitor.h"
#include "queues.h"
#include <string.h>

#include "bms.h"
#include "fault.h"
#include "can_handler.h"
#include "state_machine.h"
Expand All @@ -38,7 +37,8 @@
#include "dti.h"
#include "steeringio.h"
#include "pedals.h"
#include "string.h"
#include "monitor.h"
#include "state_machine.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
Expand Down
24 changes: 6 additions & 18 deletions Core/Src/monitor.c
Original file line number Diff line number Diff line change
@@ -1,26 +1,14 @@
#include "monitor.h"
#include "c_utils.h"
#include "can_handler.h"

#include <assert.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

#include "cerb_utils.h"
#include "cerberus_conf.h"
#include "fault.h"
// #include "lsm6dso.h"
#include "mpu.h"
#include "pdu.h"
#include "pedals.h"
#include "queues.h"
#include "sht30.h"
#include "state_machine.h"
#include "steeringio.h"
#include "stm32f405xx.h"
#include "task.h"
#include "timer.h"
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <assert.h>

#define TSMS_DEBOUNCE_PERIOD 500 /* ms */

Expand Down
5 changes: 3 additions & 2 deletions Core/Src/mpu.c
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
#include "mpu.h"
#include "stm32f405xx.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "c_utils.h"
#include <stdio.h>

#define YLED_PIN GPIO_PIN_8
#define RLED_PIN GPIO_PIN_9
Expand Down
4 changes: 3 additions & 1 deletion Core/Src/pdu.c
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
#include "pdu.h"
#include "fault.h"

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>

#include "fault.h"

#define PUMP_CTRL 0
#define RADFAN_CTRL 1
#define BRKLIGHT_CTRL 2
Expand Down
11 changes: 6 additions & 5 deletions Core/Src/pedals.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@
* @copyright Copyright (c) 2024
*
*/

#include "pedals.h"
#include "state_machine.h"
#include "queues.h"
#include "cerb_utils.h"
#include "can_handler.h"
#include "cerberus_conf.h"
#include "dti.h"
#include "queues.h"
#include "bms.h"
#include "emrax.h"
#include "monitor.h"
#include <assert.h>
#include <string.h>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <string.h>

#include "cerb_utils.h"
#include "cerberus_conf.h"
#include "fault.h"
#include "state_machine.h"

/* DO NOT ATTEMPT TO SEND TORQUE COMMANDS LOWER THAN THIS VALUE */
#define MIN_COMMAND_FREQ 60 /* Hz */
Expand Down
15 changes: 6 additions & 9 deletions Core/Src/state_machine.c
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
#include "state_machine.h"
#include "can_handler.h"
#include "fault.h"
#include "queues.h"
#include "monitor.h"
#include "queues.h"
#include "pedals.h"
#include <stdbool.h>

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "cerb_utils.h"
#include <assert.h>
#include <string.h>

#include "cerb_utils.h"
#include "monitor.h"
#include "pedals.h"

#define STATE_TRANS_QUEUE_SIZE 4

#define SEND_NERO_TIMEOUT 500 /*in millis*/
Expand Down
11 changes: 3 additions & 8 deletions Core/Src/steeringio.c
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
#include "steeringio.h"
#include "can.h"
#include "cerb_utils.h"
#include "cerberus_conf.h"
#include "cmsis_os.h"

#include <stdio.h>

#include "pedals.h"
#include "state_machine.h"
#include "stdio.h"
#include <assert.h>
#include <stdlib.h>
#include <string.h>

#define CAN_QUEUE_SIZE 5 /* messages */

Expand Down

0 comments on commit 91fe776

Please sign in to comment.