Skip to content

Commit

Permalink
Simple main and CAN task
Browse files Browse the repository at this point in the history
  • Loading branch information
evanlombardo committed Feb 9, 2024
1 parent d757bbe commit 7354804
Show file tree
Hide file tree
Showing 10 changed files with 170 additions and 56 deletions.
7 changes: 2 additions & 5 deletions Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */

#include "../../MSB/api/msb_main.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
Expand Down Expand Up @@ -440,10 +440,7 @@ void StartDefaultTask(void *argument)
{
/* USER CODE BEGIN 5 */
/* Infinite loop */
for(;;)
{
osDelay(1);
}
start_msb();
/* USER CODE END 5 */
}

Expand Down
11 changes: 11 additions & 0 deletions MSB/api/msb_can.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#ifndef MSB_CAN_H
#define MSB_CAN_H

void loop_publish_can();

void start_can_publisher();

void stop_can_publisher();

#endif
15 changes: 15 additions & 0 deletions MSB/api/msb_central.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@

#ifndef MSB_CENTRAL_H
#define MSB_CENTRAL_H

#include "api/msb_common.h"

typedef struct msb_central {
const short id;
} msb_central_t;

void monitor_strain_gauge(msb_central_t* msb);
void monitor_potentiometer(msb_central_t* msb);
void monitor_tof(msb_central_t* msb);

#endif
7 changes: 7 additions & 0 deletions MSB/api/msb_common.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#ifndef MSB_COMMON_H
#define MSB_COMMON_H

void push_can_queue(string message);

#endif
13 changes: 13 additions & 0 deletions MSB/api/msb_knuckle.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#ifndef MSB_KNUCKLE_H
#define MSB_KNUCKLE_H

#include "api/msb_common.h"

typedef struct msb_knuckle {
const short id;
} msb_knuckle_t;

void monitor_imu(msb_knuckle_t* msb);

#endif
7 changes: 7 additions & 0 deletions MSB/api/msb_main.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

#ifndef MSB_MAIN_H
#define MSB_MAIN_H

void start_msb();

#endif
13 changes: 13 additions & 0 deletions MSB/api/msb_temp.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

#ifndef MSB_TEMP_H
#define MSB_TEMP_H

#include "api/msb_common.h"

typedef struct msb_temp {
const short id;
} msb_temp_t;

void monitor_temp(msb_temp_t* msb);

#endif
27 changes: 27 additions & 0 deletions MSB/msb_can.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

#include "api/msb_common.h"
#include "api/msb_can.h"

char* queue[25];
int queue_index;
int running = 0;

void loop_publish_can() {
while (running) {
// every x amount of time, output queue to can
// for now just print each string
}
}

void start_can_publisher() {
running = 1;
loop_publish_can();
}

void stop_can_publisher() {
running = 0;
}

void push_can_queue(string message) {
queue[queue_index++] = message;
}
22 changes: 22 additions & 0 deletions MSB/msb_main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

#include "api/msb_main.h"
#include "api/msb_can.h"

osThreadId_t canTaskHandle;

void init_msb() {
// spawn CAN output thread
// canTaskHandle = osThreadNew(start_can_publisher, NULL, NULL);
start_can_publisher();
}

void start_msb() {

init_msb();

while (1) {
// loop query tasks
}

}

104 changes: 53 additions & 51 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,50 @@ BUILD_DIR = build
# source
######################################
# C sources
C_SOURCES = \
Core/Src/main.c \
Core/Src/app_freertos.c \
Core/Src/stm32g4xx_it.c \
Core/Src/stm32g4xx_hal_msp.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_adc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c \
Core/Src/system_stm32g4xx.c \
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
Middlewares/Third_Party/FreeRTOS/Source/list.c \
Middlewares/Third_Party/FreeRTOS/Source/queue.c \
Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \
Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
Middlewares/Third_Party/FreeRTOS/Source/timers.c \
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c
C_SOURCES = \
Core/Src/main.c \
Core/Src/app_freertos.c \
Core/Src/stm32g4xx_it.c \
Core/Src/stm32g4xx_hal_msp.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_adc_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_ll_adc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_rcc_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_flash_ramfunc.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_gpio.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_exti.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_dma_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_pwr_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_cortex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_fdcan.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_i2c_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_tim_ex.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart.c \
Drivers/STM32G4xx_HAL_Driver/Src/stm32g4xx_hal_uart_ex.c \
Core/Src/system_stm32g4xx.c \
Middlewares/Third_Party/FreeRTOS/Source/croutine.c \
Middlewares/Third_Party/FreeRTOS/Source/event_groups.c \
Middlewares/Third_Party/FreeRTOS/Source/list.c \
Middlewares/Third_Party/FreeRTOS/Source/queue.c \
Middlewares/Third_Party/FreeRTOS/Source/stream_buffer.c \
Middlewares/Third_Party/FreeRTOS/Source/tasks.c \
Middlewares/Third_Party/FreeRTOS/Source/timers.c \
Middlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2/cmsis_os2.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/MemMang/heap_4.c \
Middlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F/port.c \
MSB/msb_main.c \
MSB/msb_can.c

# ASM sources
ASM_SOURCES = \
ASM_SOURCES = \
startup_stm32g431xx.s

# ASM sources
Expand Down Expand Up @@ -123,24 +125,24 @@ MCU = $(CPU) -mthumb $(FPU) $(FLOAT-ABI)
AS_DEFS =

# C defines
C_DEFS = \
-DUSE_HAL_DRIVER \
C_DEFS = \
-DUSE_HAL_DRIVER \
-DSTM32G431xx


# AS includes
AS_INCLUDES = \
AS_INCLUDES = \
-ICore/Inc

# C includes
C_INCLUDES = \
-ICore/Inc \
-IDrivers/STM32G4xx_HAL_Driver/Inc \
-IDrivers/STM32G4xx_HAL_Driver/Inc/Legacy \
-IMiddlewares/Third_Party/FreeRTOS/Source/include \
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
-IDrivers/CMSIS/Device/ST/STM32G4xx/Include \
C_INCLUDES = \
-ICore/Inc \
-IDrivers/STM32G4xx_HAL_Driver/Inc \
-IDrivers/STM32G4xx_HAL_Driver/Inc/Legacy \
-IMiddlewares/Third_Party/FreeRTOS/Source/include \
-IMiddlewares/Third_Party/FreeRTOS/Source/CMSIS_RTOS_V2 \
-IMiddlewares/Third_Party/FreeRTOS/Source/portable/GCC/ARM_CM4F \
-IDrivers/CMSIS/Device/ST/STM32G4xx/Include \
-IDrivers/CMSIS/Include


Expand Down

0 comments on commit 7354804

Please sign in to comment.