Skip to content

Commit

Permalink
clang format manually
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Jun 18, 2024
1 parent 7d35aa9 commit a933c74
Show file tree
Hide file tree
Showing 11 changed files with 300 additions and 335 deletions.
6 changes: 3 additions & 3 deletions Core/Inc/can_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
#include "can.h"
#include "cmsis_os.h"

void can1_callback(CAN_HandleTypeDef *hcan);
void can1_callback(CAN_HandleTypeDef* hcan);

void vCanDispatch(void *pv_params);
void vCanDispatch(void* pv_params);
extern osThreadId_t can_dispatch_handle;
extern const osThreadAttr_t can_dispatch_attributes;

int8_t queue_can_msg(can_msg_t msg);
void init_can1(CAN_HandleTypeDef *hcan);
void init_can1(CAN_HandleTypeDef* hcan);

#endif
2 changes: 1 addition & 1 deletion Core/Inc/controller.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

#include "cmsis_os.h"

void vLedController(void *pv_params);
void vLedController(void* pv_params);
extern osThreadId_t led_controller_handle;
extern const osThreadAttr_t led_controller_attributes;

Expand Down
10 changes: 5 additions & 5 deletions Core/Inc/monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,24 +5,24 @@
#include "stm32f4xx_hal.h"

/* Defining Temperature Monitor Task */
void vTempMonitor(void *pv_params);
void vTempMonitor(void* pv_params);
extern osThreadId_t temp_monitor_handle;
extern const osThreadAttr_t temp_monitor_attributes;

/* Task for Monitoring the IMU */
void vIMUMonitor(void *pv_params);
void vIMUMonitor(void* pv_params);
extern osThreadId_t imu_monitor_handle;
extern const osThreadAttr_t imu_monitor_attributes;

void vTOFMonitor(void *pv_params);
void vTOFMonitor(void* pv_params);
extern osThreadId_t tof_monitor_handle;
extern const osThreadAttr_t tof_monitor_attributes;

void vShockpotMonitor(void *pv_params);
void vShockpotMonitor(void* pv_params);
extern osThreadId_t shockpot_monitor_handle;
extern const osThreadAttr_t shockpot_monitor_attributes;

void vStrainMonitor(void *pv_params);
void vStrainMonitor(void* pv_params);
extern osThreadId_t strain_monitor_handle;
extern const osThreadAttr_t strain_monitor_attributes;

Expand Down
61 changes: 30 additions & 31 deletions Core/Inc/msb.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,54 +2,53 @@
#ifndef MSB_CENTRAL_H
#define MSB_CENTRAL_H

#include "cmsis_os.h"
#include "lsm6dso.h"
#include "sht30.h"
#include "stm32f405xx.h"
#include "cmsis_os.h"
#include "vl6180x_api.h"

typedef enum
{
DEVICE_FRONT_LEFT,
DEVICE_FRONT_RIGHT,
DEVICE_BACK_RIGHT,
DEVICE_BACK_LEFT,
typedef enum {
DEVICE_FRONT_LEFT,
DEVICE_FRONT_RIGHT,
DEVICE_BACK_RIGHT,
DEVICE_BACK_LEFT,
} device_loc_t;

typedef struct
{
I2C_HandleTypeDef *hi2c;
sht30_t *temp_sensor;
lsm6dso_t *imu;
VL6180xDev_t tof;
ADC_HandleTypeDef *adc1;
uint32_t adc1_buf[3];
GPIO_TypeDef *debug_led1_gpio;
uint16_t *debug_led1_pin;
GPIO_TypeDef *debug_led2_gpio;
uint16_t *debug_led2_pin;
device_loc_t *device_loc;
osMutexId_t *i2c_mutex;
I2C_HandleTypeDef* hi2c;
sht30_t* temp_sensor;
lsm6dso_t* imu;
VL6180xDev_t tof;
ADC_HandleTypeDef* adc1;
uint32_t adc1_buf[3];
GPIO_TypeDef* debug_led1_gpio;
uint16_t* debug_led1_pin;
GPIO_TypeDef* debug_led2_gpio;
uint16_t* debug_led2_pin;
device_loc_t* device_loc;
osMutexId_t* i2c_mutex;
} msb_t;

msb_t *init_msb(I2C_HandleTypeDef *hi2c, ADC_HandleTypeDef *adc1, GPIO_TypeDef *debug_led1_gpio,
uint16_t *debug_led1_pin, GPIO_TypeDef *debug_led2_gpio, uint16_t *debug_led2_pin,
device_loc_t *device_loc);
msb_t* init_msb(I2C_HandleTypeDef* hi2c, ADC_HandleTypeDef* adc1, GPIO_TypeDef* debug_led1_gpio,
uint16_t* debug_led1_pin, GPIO_TypeDef* debug_led2_gpio, uint16_t* debug_led2_pin,
device_loc_t* device_loc);

int8_t measure_central_temp(msb_t *msb, uint16_t *temp, uint16_t *humidity);
int8_t measure_central_temp(msb_t* msb, uint16_t* temp, uint16_t* humidity);

int8_t read_accel(msb_t *msb, uint16_t accel[3]);
int8_t read_accel(msb_t* msb, uint16_t accel[3]);

int8_t read_gyro(msb_t *msb, uint16_t gyro[3]);
int8_t read_gyro(msb_t* msb, uint16_t gyro[3]);

int8_t read_distance(msb_t *msb, int32_t *range_mm);
int8_t read_distance(msb_t* msb, int32_t* range_mm);

int8_t write_debug1(msb_t *msb, bool status);
int8_t write_debug1(msb_t* msb, bool status);

int8_t write_debug2(msb_t *msb, bool status);
int8_t write_debug2(msb_t* msb, bool status);

void read_shockpot(msb_t *msb, uint32_t shockpot_sense);
void read_strain1(msb_t *msb, uint32_t strain1);
void read_strain2(msb_t *msb, uint32_t strain2);
void read_shockpot(msb_t* msb, uint32_t shockpot_sense);
void read_strain1(msb_t* msb, uint32_t strain1);
void read_strain2(msb_t* msb, uint32_t strain2);

#endif
24 changes: 12 additions & 12 deletions Core/Inc/msb_conf.h
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
/// All commonly changed settings and constants that could effect multiple factors, esp. in telemetry

// DELAYS
#define DELAY_CAN_DISPATCH 5
#define DELAY_CAN_DISPATCH 5
#define DELAY_TEMP_SENSOR_REFRESH 500
#define DELAY_IMU_REFRESH 500
#define DELAY_SHOCKPOT_REFRESH 500
#define DELAY_STRAIN_REFRESH 500
#define DELAY_TOF_REFRESH 500
#define DELAY_WHEEL_TEMP_REFRESH 500
#define DELAY_IMU_REFRESH 500
#define DELAY_SHOCKPOT_REFRESH 500
#define DELAY_STRAIN_REFRESH 500
#define DELAY_TOF_REFRESH 500
#define DELAY_WHEEL_TEMP_REFRESH 500

#define DELAY_DEBUG_LED_REFRESH 250

// CAN IDS
#define CANID_TEMP_SENSOR 0x602
#define CANID_IMU_ACCEL 0x603
#define CANID_IMU_GYRO 0x604
#define CANID_TEMP_SENSOR 0x602
#define CANID_IMU_ACCEL 0x603
#define CANID_IMU_GYRO 0x604
#define CANID_STRAIN_SENSE 0x605
#define CANID_SHOCK_SENSE 0x606
#define CANID_TOF 0x607
#define CANID_WHEEL_TEMP 0x608
#define CANID_SHOCK_SENSE 0x606
#define CANID_TOF 0x607
#define CANID_WHEEL_TEMP 0x608
4 changes: 2 additions & 2 deletions Core/Inc/serial_monitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
#include "cmsis_os.h"

/* Function to queue a message to be sent on the UART stream */
int serial_print(const char *format, ...);
int serial_print(const char* format, ...);

/* Defining Temperature Monitor Task */
void vSerialMonitor(void *pv_params);
void vSerialMonitor(void* pv_params);

extern osThreadId_t serial_monitor_handle;
extern const osThreadAttr_t serial_monitor_attributes;
Expand Down
24 changes: 9 additions & 15 deletions Core/Src/can_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@
#include "msb_conf.h"
#include "serial_monitor.h"

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

#define CAN_MSG_QUEUE_SIZE 25 /* messages */
static osMessageQueueId_t can_outbound_queue;

can_t *can1;
can_t* can1;

void init_can1(CAN_HandleTypeDef *hcan)
void init_can1(CAN_HandleTypeDef* hcan)
{
assert(hcan);

Expand All @@ -45,28 +45,22 @@ const osThreadAttr_t can_dispatch_attributes = {
.priority = (osPriority_t)osPriorityRealtime5,
};

void vCanDispatch(void *pv_params)
void vCanDispatch(void* pv_params)
{
can_msg_t msg_from_queue;
HAL_StatusTypeDef msg_status;

for (;;)
{
for (;;) {
/* Send CAN message */
if (osOK == osMessageQueueGet(can_outbound_queue, &msg_from_queue, NULL, osWaitForever))
{
if (osOK == osMessageQueueGet(can_outbound_queue, &msg_from_queue, NULL, osWaitForever)) {
msg_status = can_send_msg(can1, &msg_from_queue);
if (msg_status == HAL_ERROR)
{
if (msg_status == HAL_ERROR) {
serial_print("Failed to send CAN message");
}
else if (msg_status == HAL_BUSY)
{
} else if (msg_status == HAL_BUSY) {
serial_print("Outbound mailbox full!");
}
#ifdef LOG_VERBOSE
else
{
else {
printf("Message sent: %lX\r\n", msg_from_queue.id);
}
#endif
Expand Down
56 changes: 27 additions & 29 deletions Core/Src/controller.c
Original file line number Diff line number Diff line change
@@ -1,42 +1,40 @@
#include "controller.h"
#include "msb_conf.h"
#include "msb.h"
#include "msb_conf.h"

osThreadId_t led_controller_handle;
const osThreadAttr_t led_controller_attributes = {
.name = "LedController",
.stack_size = 32 * 8,
.priority = (osPriority_t)osPriorityBelowNormal1,
.name = "LedController",
.stack_size = 32 * 8,
.priority = (osPriority_t)osPriorityBelowNormal1,
};

void vLedController(void *pv_params)
void vLedController(void* pv_params)
{

msb_t *msb = (msb_t *)pv_params;
msb_t* msb = (msb_t*)pv_params;

switch (*msb->device_loc)
{
case DEVICE_FRONT_LEFT:
write_debug1(msb, true);
write_debug2(msb, true);
break;
case DEVICE_FRONT_RIGHT:
write_debug1(msb, true);
write_debug2(msb, false);
break;
case DEVICE_BACK_LEFT:
write_debug1(msb, false);
write_debug2(msb, true);
break;
case DEVICE_BACK_RIGHT:
write_debug1(msb, false);
write_debug2(msb, false);
break;
}
switch (*msb->device_loc) {
case DEVICE_FRONT_LEFT:
write_debug1(msb, true);
write_debug2(msb, true);
break;
case DEVICE_FRONT_RIGHT:
write_debug1(msb, true);
write_debug2(msb, false);
break;
case DEVICE_BACK_LEFT:
write_debug1(msb, false);
write_debug2(msb, true);
break;
case DEVICE_BACK_RIGHT:
write_debug1(msb, false);
write_debug2(msb, false);
break;
}

for (;;)
{
for (;;) {

osDelay(DELAY_DEBUG_LED_REFRESH);
}
osDelay(DELAY_DEBUG_LED_REFRESH);
}
}
Loading

0 comments on commit a933c74

Please sign in to comment.