Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
da4a67e
added id to CAN RX callback
ahoysal Jan 27, 2026
05214b4
Added enum as CAN identifier in RX
ahoysal Jan 27, 2026
9261965
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Jan 27, 2026
f26d44f
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jan 27, 2026
d36a3ba
Changed CAN_RX_Callback to take in ID, data, size
VihanJ Jan 27, 2026
9e1af22
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jan 27, 2026
499d15c
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Jan 27, 2026
4337a58
added formatting for uint32_t id in can_tests.c
VihanJ Jan 27, 2026
2b00473
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Jan 27, 2026
98923cf
cleand up can.c
VihanJ Jan 27, 2026
82e7709
added basepri masking, also tried to prevent spurious NVIC interrupts…
VihanJ Jan 29, 2026
6d6d9ff
added basepri masking, also tried to prevent spurious NVIC interrupts…
VihanJ Jan 29, 2026
18af90b
Refactored to use statically sized spsc buffer
VihanJ Jan 30, 2026
ebc37b8
passed human testing
VihanJ Feb 4, 2026
7245169
added notes in readme
VihanJ Feb 11, 2026
28b8e14
Merge remote-tracking branch 'origin/main' into CAN_ISR
VihanJ Feb 15, 2026
1b2adde
tried to fix CAN data baud rate in ECU/Core/Src/main.c
VihanJ Feb 19, 2026
622bf6c
Merge branch 'main' into CAN_ISR
VihanJ Feb 24, 2026
6afe33a
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Feb 24, 2026
837d821
Merge branch 'main' into CAN_ISR
dchansen06 Feb 24, 2026
7c779ca
Merge branch 'main' into CAN_ISR
dchansen06 Feb 24, 2026
f8c16e5
Merge branch 'main' into CAN_ISR
dchansen06 Feb 27, 2026
0442dec
Merge branch 'main' into CAN_ISR
dchansen06 Feb 27, 2026
fa981aa
Merge branch 'main' into CAN_ISR
dchansen06 Feb 27, 2026
7d90ef3
Merge branch 'main' into CAN_ISR
dchansen06 Feb 27, 2026
4125cc0
Merge branch 'main' into CAN_ISR
dchansen06 Feb 27, 2026
d60e880
Merge branch 'main' into CAN_ISR
dchansen06 Feb 27, 2026
c4c57b8
Merge branch 'main' into CAN_ISR
dchansen06 Mar 1, 2026
1bcc559
Merge branch 'main' into CAN_ISR
dchansen06 Mar 3, 2026
9581d92
Co-authored-by: Aagrim Hoysal <ahoysal@users.noreply.github.com>
VihanJ Mar 5, 2026
e91fba1
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 5, 2026
2e2b115
Merge branch 'main' into CAN_ISR
dchansen06 Mar 10, 2026
0017a46
Merge branch 'main' into CAN_ISR
dchansen06 Mar 10, 2026
a1b248a
Merge branch 'main' into CAN_ISR
dchansen06 Mar 10, 2026
5e91ea8
new tests
VihanJ Mar 10, 2026
42198b1
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Mar 10, 2026
5684d41
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 10, 2026
c02a207
Some working version of some testing maybe
dchansen06 Mar 10, 2026
2b60662
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Mar 10, 2026
e7c8328
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 10, 2026
e3dd937
Everything builds
dchansen06 Mar 10, 2026
00f4d3d
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 10, 2026
cbf4520
Merge branch 'main' into CAN_ISR
dchansen06 Mar 10, 2026
3b27e30
changed tests
VihanJ Mar 10, 2026
4700904
running through tests
VihanJ Mar 10, 2026
4a44cfd
tested can_external_test.c can_internal_test.c can_stress_test.c, can…
VihanJ Mar 12, 2026
9b2ebc3
deleted unused folders
VihanJ Mar 12, 2026
432295c
Automatic Json Format: Standardized formatting automatically
github-actions[bot] Mar 12, 2026
92d882e
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Mar 12, 2026
9b062ac
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 12, 2026
c823f4e
fixed for Release and Debug
VihanJ Mar 12, 2026
058270b
Merge branch 'main' into CAN_ISR
dchansen06 Mar 12, 2026
f2e9b20
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 12, 2026
c759e43
added documentation with my good friend chat gibidi
VihanJ Mar 12, 2026
39616ea
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Mar 12, 2026
65d0e3d
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 12, 2026
67e6887
Merge branch 'main' into CAN_ISR
dchansen06 Mar 12, 2026
5bbfa7a
Merge branch 'main' into CAN_ISR
dchansen06 Mar 12, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
126 changes: 125 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@
"target/stm32g4x.cfg"
],
"searchDir": [],
"preLaunchTask": "CMake: configure and build G4ADCTESTING",
"preLaunchTask": "CMake: configure and build G4CANTESTING",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
"preLaunchTask": "CMake: configure and build G4CANTESTING",
"preLaunchTask": "CMake: configure and build G4ADCTESTING",

I am not sure why this was changed, probably a merge issue. Right below is G4CANTESTING

"showDevDebugOutput": "raw",
"svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd",
"swoConfig": {
Expand Down Expand Up @@ -498,6 +498,130 @@
}
]
}
},
{
"cwd": "${workspaceFolder}",
"executable": "${command:cmake.buildDirectory}/CAN_EXTERNAL_TEST.elf",
"name": "CAN_EXTERNAL_TEST",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"configFiles": [
"interface/stlink.cfg",
"target/stm32g4x.cfg"
],
"searchDir": [],
"preLaunchTask": "CMake: configure and build CAN_EXTERNAL_TEST",
"showDevDebugOutput": "raw",
"svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd",
"swoConfig": {
"enabled": true,
"cpuFrequency": 170000000,
"swoFrequency": 2000000,
"source": "probe",
"decoders": [
{
"type": "console",
"label": "ITM",
"showOnStartup": true,
"port": 0,
"encoding": "ascii"
}
]
}
},
{
"cwd": "${workspaceFolder}",
"executable": "${command:cmake.buildDirectory}/CAN_INTERNAL_TEST.elf",
"name": "CAN_INTERNAL_TEST",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"configFiles": [
"interface/stlink.cfg",
"target/stm32g4x.cfg"
],
"searchDir": [],
"preLaunchTask": "CMake: configure and build CAN_INTERNAL_TEST",
"showDevDebugOutput": "raw",
"svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd",
"swoConfig": {
"enabled": true,
"cpuFrequency": 170000000,
"swoFrequency": 2000000,
"source": "probe",
"decoders": [
{
"type": "console",
"label": "ITM",
"showOnStartup": true,
"port": 0,
"encoding": "ascii"
}
]
}
},
{
"cwd": "${workspaceFolder}",
"executable": "${command:cmake.buildDirectory}/CAN_STRESS_TEST.elf",
"name": "CAN_STRESS_TEST",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"configFiles": [
"interface/stlink.cfg",
"target/stm32g4x.cfg"
],
"searchDir": [],
"preLaunchTask": "CMake: configure and build CAN_STRESS_TEST",
"showDevDebugOutput": "raw",
"svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd",
"swoConfig": {
"enabled": true,
"cpuFrequency": 170000000,
"swoFrequency": 2000000,
"source": "probe",
"decoders": [
{
"type": "console",
"label": "ITM",
"showOnStartup": true,
"port": 0,
"encoding": "ascii"
}
]
}
},
{
"cwd": "${workspaceFolder}",
"executable": "${command:cmake.buildDirectory}/CAN_RELEASE_TEST.elf",
"name": "CAN_RELEASE_TEST",
"request": "launch",
"type": "cortex-debug",
"servertype": "openocd",
"configFiles": [
"interface/stlink.cfg",
"target/stm32g4x.cfg"
],
"searchDir": [],
"preLaunchTask": "CMake: configure and build CAN_RELEASE_TEST",
"showDevDebugOutput": "raw",
"svdPath": "${workspaceFolder}/Lib/Vendor/CMSIS_5/SVD/STM32G474.svd",
"swoConfig": {
"enabled": true,
"cpuFrequency": 170000000,
"swoFrequency": 2000000,
"source": "probe",
"decoders": [
{
"type": "console",
"label": "ITM",
"showOnStartup": true,
"port": 0,
"encoding": "ascii"
}
]
}
}
]
}
36 changes: 36 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,42 @@
"CMake: configure"
],
"command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target W3_G4SPI_Receive"
},
{
"label": "CMake: configure and build CAN_EXTERNAL_TEST",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"CMake: configure"
],
"command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_EXTERNAL_TEST"
},
{
"label": "CMake: configure and build CAN_INTERNAL_TEST",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"CMake: configure"
],
"command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_INTERNAL_TEST"
},
{
"label": "CMake: configure and build CAN_RELEASE_TEST",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"CMake: configure"
],
"command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_RELEASE_TEST"
},
{
"label": "CMake: configure and build CAN_STRESS_TEST",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"CMake: configure"
],
"command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_STRESS_TEST"
}
]
}
2 changes: 1 addition & 1 deletion CCU/Application/Src/CANDler.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void CAN_Configure(void)
canCfg.rx_callback = Read_CAN;
canCfg.rx_interrupt_priority = 15; // TODO: Maybe make these not hardcoded
canCfg.tx_interrupt_priority = 15;
canCfg.tx_buffer_length = 5;
// canCfg.tx_buffer_length = 5;

// RX shared settings
canCfg.init_rx_gpio.Mode = GPIO_MODE_AF_PP;
Expand Down
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,18 @@ add_gr_project(STM32G474xE TireTemp)
# Development
add_gr_project(STM32G474xE G4ADCTESTING)
add_gr_project(STM32G474xE G4PERTESTING)
add_gr_project(STM32G474xE G4CANTESTING)
#add_gr_project(STM32G474xE G4CANTESTING)

#CAN Peripheral Testing
#add_gr_project(STM32G474xE G4CANTESTING FILTER_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_EXTERNAL_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_INTERNAL_TEST)
#add_gr_project(STM32G474xE G4CANTESTING INIT_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_RELEASE_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_STRESS_TEST)

#add_gr_project(STM32G474xE G4CANTESTING)

Comment on lines +84 to +95
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
#add_gr_project(STM32G474xE G4CANTESTING)
#CAN Peripheral Testing
#add_gr_project(STM32G474xE G4CANTESTING FILTER_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_EXTERNAL_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_INTERNAL_TEST)
#add_gr_project(STM32G474xE G4CANTESTING INIT_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_RELEASE_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_STRESS_TEST)
#add_gr_project(STM32G474xE G4CANTESTING)
# CAN Peripheral Testing
add_gr_project(STM32G474xE G4CANTESTING CAN_EXTERNAL_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_INTERNAL_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_RELEASE_TEST)
add_gr_project(STM32G474xE G4CANTESTING CAN_STRESS_TEST)

add_gr_project(STM32G474xE G4NEOTESTING)

# BLINKY Demos
Expand Down
2 changes: 1 addition & 1 deletion DashPanel/Application/Src/CANdler.c
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void CANInitialize()
canCfg.rx_callback = CAN_callback;
canCfg.rx_interrupt_priority = 15;
canCfg.tx_interrupt_priority = 15;
canCfg.tx_buffer_length = 3;
// canCfg.tx_buffer_length = 3;

canCfg.fdcan_instance = FDCAN1;
canCfg.rx_gpio = GPIOA;
Expand Down
8 changes: 4 additions & 4 deletions ECU/Core/Src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,17 +271,17 @@ void CAN_Configure()
canCfg.hal_fdcan_init.NominalSyncJumpWidth = 16;
canCfg.hal_fdcan_init.NominalTimeSeg1 = 127; // Updated for 170MHz: (1+127+42)*1 = 170 ticks -> 1 Mbps
canCfg.hal_fdcan_init.NominalTimeSeg2 = 42;
canCfg.hal_fdcan_init.DataPrescaler = 8;
canCfg.hal_fdcan_init.DataPrescaler = 2;
canCfg.hal_fdcan_init.DataSyncJumpWidth = 16;
canCfg.hal_fdcan_init.DataTimeSeg1 = 15; // Updated for 170MHz: (1+15+5)*8 = 168 ticks -> ~5 Mbps
canCfg.hal_fdcan_init.DataTimeSeg2 = 5;
canCfg.hal_fdcan_init.DataTimeSeg1 = 12; // Updated for 170MHz: 170 MHz/((1+12+4)*2) = 5 Mbps
canCfg.hal_fdcan_init.DataTimeSeg2 = 4;
canCfg.hal_fdcan_init.StdFiltersNbr = 1;
canCfg.hal_fdcan_init.ExtFiltersNbr = 0;

canCfg.rx_callback = NULL;
canCfg.rx_interrupt_priority = 15; // TODO: Maybe make these not hardcoded
canCfg.tx_interrupt_priority = 15;
canCfg.tx_buffer_length = CAN_TX_BUFFER_LENGTH;
// canCfg.tx_buffer_length = CAN_TX_BUFFER_LENGTH;

// RX shared settings
canCfg.init_rx_gpio.Mode = GPIO_MODE_AF_PP;
Expand Down
55 changes: 55 additions & 0 deletions G4CANTESTING/CAN_EXTERNAL_TEST/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
cmake_minimum_required(VERSION 3.25)

# Setup compiler settings
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)

# Define the build type
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Debug")
endif()

# Enable compile command to ease indexing with e.g. clangd
set(CMAKE_EXPORT_COMPILE_COMMANDS TRUE)

# Enable CMake support for ASM and C languages
enable_language(
C
ASM
)

# Core project settings
project(${CMAKE_PROJECT_NAME})

# what, does in fact not get the filename of somthing but rather the name of the project from the path
get_filename_component(PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME)

add_library(${PROJECT_NAME}_USER_CODE INTERFACE)

target_sources(
${PROJECT_NAME}_USER_CODE
INTERFACE
../Core/Src/adc.c
../Core/Src/crc.c
../Core/Src/dma.c
../Core/Src/gpio.c
../Core/Src/i2c.c
main.c
../Core/Src/spi.c
../Core/Src/stm32g4xx_hal_msp.c
../Core/Src/stm32g4xx_it.c
../Core/Src/tim.c
../Core/Src/usart.c
)

set_target_properties(
${NAME}
PROPERTIES
OUTPUT_NAME
"CAN_${NAME}"
)

target_link_libraries(${PROJECT_NAME}_USER_CODE INTERFACE PERIPHERAL_CAN_LIB)

target_include_directories(${PROJECT_NAME}_USER_CODE INTERFACE ../Core/Inc)
11 changes: 11 additions & 0 deletions G4CANTESTING/CAN_EXTERNAL_TEST/can_conf.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@

#ifndef CAN_CONF_H
#define CAN_CONF_H

#define USECAN1
#define TX_BUFFER_1_SIZE 10

#define USECAN2
#define TX_BUFFER_2_SIZE 10

#endif
Loading
Loading