-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
35 changed files
with
4,409 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"warnings_id": 303, | ||
"faults_id": 304, | ||
"warnings_counts_id": 305, | ||
"faults_counts_id": 306, | ||
"warnings": [ | ||
"WatchdogTimeout", | ||
"TxOverflow", | ||
"RxOverflow", | ||
"StackWaterMarkHighTask1Hz", | ||
"StackWaterMarkHighTask100Hz", | ||
"StackWaterMarkHighTask1kHz", | ||
"StackWaterMarkHighTaskCanRx", | ||
"StackWaterMarkHighTaskCanTx" | ||
], | ||
"faults": [ | ||
"DummyFault" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"FSMState": { | ||
"FSM_INIT_STATE": 0, | ||
"FSM_DRIVE_STATE": 1 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"messages": [ | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"Vitals": { | ||
"msg_id": 300, | ||
"cycle_time": 100, | ||
"description": "FSM vitals message.", | ||
"signals": { | ||
"Heartbeat": { | ||
"bits": 1 | ||
}, | ||
"State": { | ||
"enum": "FSMState" | ||
} | ||
} | ||
}, | ||
"AlertsContext": { | ||
"msg_id": 301, | ||
"cycle_time": 1000, | ||
"description": "Context info for FSM alerts", | ||
"signals": { | ||
"WatchdogTimeout": { | ||
"bits": 1 | ||
}, | ||
"WatchdogTimeoutTaskName": { | ||
"enum": "RtosTaskName" | ||
}, | ||
"TxOverflowCount": { | ||
"bits": 8 | ||
}, | ||
"RxOverflowCount": { | ||
"bits": 8 | ||
} | ||
} | ||
}, | ||
"CommitInfo": { | ||
"msg_id": 302, | ||
"cycle_time": 100, | ||
"description": "FSM Current Running Git Commit Info", | ||
"signals": { | ||
"Hash": { | ||
"bits": 32 | ||
}, | ||
"Clean": { | ||
"bits": 1 | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
# add_subdirectory(BMS) | ||
# add_subdirectory(FSM) | ||
add_subdirectory(FSM) | ||
add_subdirectory(VC) | ||
# add_subdirectory(DIM) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
set(ARM_CORE "cm4") | ||
set(IOC_PATH "${CMAKE_CURRENT_SOURCE_DIR}/src/cubemx/FSM.ioc") | ||
set(LINKER_SCRIPT "${LINKER_DIR}/stm32f412rgtx/stm32f412rgtx_app.ld") | ||
|
||
# app | ||
file(GLOB_RECURSE APP_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/app/*.c") | ||
list(APPEND APP_SRCS | ||
"${SHARED_APP_INCLUDE_DIR}/app_stateMachine.c" | ||
"${SHARED_APP_INCLUDE_DIR}/app_heartbeatMonitor.c" | ||
"${SHARED_APP_INCLUDE_DIR}/app_rangeCheck.c" | ||
"${SHARED_APP_INCLUDE_DIR}/app_signal.c" | ||
"${SHARED_APP_INCLUDE_DIR}/app_timer.c" | ||
) | ||
set(APP_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/app" "${SHARED_APP_INCLUDE_DIR}") | ||
|
||
# io | ||
file(GLOB_RECURSE IO_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/src/io/*.c") | ||
list(APPEND IO_SRCS | ||
"${SHARED_IO_INCLUDE_DIR}/io_can.c" | ||
"${SHARED_IO_INCLUDE_DIR}/io_jsoncan.c" | ||
"${SHARED_IO_INCLUDE_DIR}/io_time.c" | ||
) | ||
set(IO_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/io" "${SHARED_IO_INCLUDE_DIR}") | ||
|
||
# hw | ||
file(GLOB_RECURSE HW_SRCS | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/hw/*.c" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/*.c" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/cubemx/Src/*.c" | ||
) | ||
list(APPEND HW_SRCS | ||
"${SHARED_HW_INCLUDE_DIR}/hw_hardFaultHandler.c" | ||
"${SHARED_HW_INCLUDE_DIR}/hw_adcConversions.c" | ||
"${SHARED_HW_INCLUDE_DIR}/hw_can.c" | ||
"${SHARED_HW_INCLUDE_DIR}/hw_bootup.c" | ||
"${SHARED_HW_INCLUDE_DIR}/hw_pwmInputFreqOnly.c" | ||
"${SHARED_HW_INCLUDE_DIR}/hw_watchdog.c" | ||
"${SHARED_HW_INCLUDE_DIR}/hw_stackWaterMark.c" | ||
# "${SHARED_EMBEDDED_DIR}/hw/hw_uart.c" # TODO: add back when uart finalized | ||
) | ||
set(HW_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/src/hw" "${CMAKE_CURRENT_SOURCE_DIR}/src" "${SHARED_HW_INCLUDE_DIR}") | ||
|
||
# tests | ||
file(GLOB_RECURSE TEST_SRCS "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cpp") | ||
set(TEST_INCLUDE_DIRS "${CMAKE_CURRENT_SOURCE_DIR}/test") | ||
list(APPEND TEST_INCLUDE_DIRS "${SHARED_TEST_UTILS_INCLUDE_DIRS}") | ||
|
||
# commit info | ||
set(COMMIT_INFO_HEADER_PATH "${CMAKE_CURRENT_BINARY_DIR}/app/app_commitInfo.h") | ||
set(COMMIT_INFO_SRC_PATH "${CMAKE_CURRENT_BINARY_DIR}/app/app_commitInfo.c") | ||
|
||
if("${TARGET}" STREQUAL "deploy") | ||
jsoncan_library( | ||
"FSM_can" | ||
"FSM" | ||
"${CMAKE_CURRENT_BINARY_DIR}" | ||
TRUE | ||
"quadruna" | ||
) | ||
embedded_library( | ||
FSM_can | ||
"${CAN_SRCS}" | ||
"${CAN_INCLUDE_DIRS}" | ||
"${ARM_CORE}" | ||
TRUE | ||
) | ||
generate_stm32cube_code( | ||
"FSM" | ||
"${IOC_PATH}" | ||
) | ||
|
||
set(STM32_HAL_SRCS | ||
"stm32f4xx_hal_adc_ex.c" | ||
"stm32f4xx_hal_adc.c" | ||
"stm32f4xx_hal_cortex.c" | ||
"stm32f4xx_hal_dma_ex.c" | ||
"stm32f4xx_hal_dma.c" | ||
"stm32f4xx_hal_exti.c" | ||
"stm32f4xx_hal_can.c" | ||
"stm32f4xx_hal_gpio.c" | ||
"stm32f4xx_hal_iwdg.c" | ||
"stm32f4xx_hal_pwr_ex.c" | ||
"stm32f4xx_hal_rcc_ex.c" | ||
"stm32f4xx_hal_rcc.c" | ||
"stm32f4xx_hal_tim_ex.c" | ||
"stm32f4xx_hal_tim.c" | ||
# "stm32f4xx_hal_uart_ex.c" # TODO: add back when uart finalized | ||
"stm32f4xx_hal_uart.c" | ||
"stm32f4xx_hal.c" | ||
) | ||
|
||
# Pass syscalls to the cube library so we can build without warnings. | ||
set(SYSCALLS "${CMAKE_CURRENT_SOURCE_DIR}/src/cubemx/Src/syscalls.c") | ||
stm32f412rx_cube_library( | ||
"FSM_stm32cube" | ||
"${CMAKE_CURRENT_SOURCE_DIR}/src/cubemx/Inc" | ||
"${STM32_HAL_SRCS}" | ||
"${SYSCALLS}" | ||
"${IOC_PATH}.md5" | ||
) | ||
|
||
set(SRCS ${APP_SRCS} ${IO_SRCS} ${HW_SRCS} ${TASKS_SRCS}) | ||
set(INCLUDE_DIRS ${APP_INCLUDE_DIRS} ${IO_INCLUDE_DIRS} ${HW_INCLUDE_DIRS}) | ||
embedded_binary( | ||
"FSM" | ||
"${SRCS}" | ||
"${INCLUDE_DIRS}" | ||
"${LINKER_SCRIPT}" | ||
"${ARM_CORE}" | ||
) | ||
|
||
commit_info_library( | ||
"FSM.elf" | ||
"FSM_commit_info" | ||
"${COMMIT_INFO_HEADER_PATH}" | ||
"${COMMIT_INFO_SRC_PATH}" | ||
"${ARM_CORE}" | ||
) | ||
|
||
target_link_libraries("FSM_can" "FSM_stm32cube") | ||
target_link_libraries("FSM.elf" "FSM_stm32cube" "FSM_can" "FSM_commit_info") | ||
|
||
# TODO: embedded_image for boot | ||
|
||
elseif("${TARGET}" STREQUAL "test") | ||
jsoncan_library( | ||
"FSM_can" | ||
"FSM" | ||
"${CMAKE_CURRENT_BINARY_DIR}" | ||
FALSE | ||
"quadruna" | ||
) | ||
add_library(FSM_can STATIC "${CAN_SRCS}") | ||
target_include_directories(FSM_can PUBLIC "${CAN_INCLUDE_DIRS}") | ||
|
||
# TODO: fake libraries | ||
|
||
set(SRCS ${APP_SRCS} ${TEST_SRCS}) | ||
set(INCLUDE_DIRS ${APP_INCLUDE_DIRS} ${IO_INCLUDE_DIRS} ${TEST_INCLUDE_DIRS}) | ||
compile_gtest_executable( | ||
"FSM_test" | ||
"${SRCS}" | ||
"${INCLUDE_DIRS}" | ||
) | ||
target_link_libraries("FSM_test" "FSM_can" "shared_fakes") # TODO: add fakes here | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#include "app_globals.h" | ||
|
||
Globals fsm_globals; | ||
Globals *const globals = &fsm_globals; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#pragma once | ||
|
||
typedef struct | ||
{ | ||
int unused; | ||
} Globals; | ||
|
||
extern Globals *const globals; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
#include "states/app_driveState.h" | ||
#include "app_stateMachine.h" | ||
|
||
static void driveStateRunOnEntry(void) {} | ||
|
||
static void driveStateRunOnTick1Hz(void) {} | ||
|
||
static void driveStateRunOnTick100Hz(void) {} | ||
|
||
static void driveStateRunOnExit(void) {} | ||
|
||
const State *app_driveState_get() | ||
{ | ||
static State drive_state = { | ||
.name = "DRIVE", | ||
.run_on_entry = driveStateRunOnEntry, | ||
.run_on_tick_1Hz = driveStateRunOnTick1Hz, | ||
.run_on_tick_100Hz = driveStateRunOnTick100Hz, | ||
.run_on_exit = driveStateRunOnExit, | ||
}; | ||
|
||
return &drive_state; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#pragma once | ||
|
||
#include "app_stateMachine.h" | ||
|
||
/** | ||
* Get a pointer to the Drive State. | ||
* @return A pointer to the Drive State. THIS SHOULD NOT BE MODIFIED. | ||
*/ | ||
const State *app_driveState_get(void); |
Oops, something went wrong.