Skip to content

Commit

Permalink
use linux kernel format
Browse files Browse the repository at this point in the history
  • Loading branch information
jr1221 committed Jun 18, 2024
1 parent 97ed134 commit 96b6199
Show file tree
Hide file tree
Showing 12 changed files with 160 additions and 121 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
48 changes: 24 additions & 24 deletions Core/Inc/msb.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,40 @@ typedef enum {
DEVICE_BACK_LEFT,
} device_loc_t;

typedef struct
{
I2C_HandleTypeDef* hi2c;
sht30_t* temp_sensor;
lsm6dso_t* imu;
typedef struct {
I2C_HandleTypeDef *hi2c;
sht30_t *temp_sensor;
lsm6dso_t *imu;
VL6180xDev_t tof;
ADC_HandleTypeDef* adc1;
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;
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
16 changes: 10 additions & 6 deletions Core/Src/can_handler.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
#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 @@ -35,7 +35,8 @@ void init_can1(CAN_HandleTypeDef* hcan)

assert(!can_init(can1));

can_outbound_queue = osMessageQueueNew(CAN_MSG_QUEUE_SIZE, sizeof(can_msg_t), NULL);
can_outbound_queue =
osMessageQueueNew(CAN_MSG_QUEUE_SIZE, sizeof(can_msg_t), NULL);
}

osThreadId_t can_dispatch_handle;
Expand All @@ -45,14 +46,16 @@ 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 (;;) {
/* 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) {
serial_print("Failed to send CAN message");
Expand All @@ -61,7 +64,8 @@ void vCanDispatch(void* pv_params)
}
#ifdef LOG_VERBOSE
else {
printf("Message sent: %lX\r\n", msg_from_queue.id);
printf("Message sent: %lX\r\n",
msg_from_queue.id);
}
#endif
}
Expand Down
6 changes: 2 additions & 4 deletions Core/Src/controller.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ const osThreadAttr_t led_controller_attributes = {
.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:
Expand All @@ -34,7 +33,6 @@ void vLedController(void* pv_params)
}

for (;;) {

osDelay(DELAY_DEBUG_LED_REFRESH);
}
}
Loading

0 comments on commit 96b6199

Please sign in to comment.