Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
e2d9043
Potentially might build but rough sketch start
dchansen06 Feb 27, 2026
eeb6143
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Feb 27, 2026
e79909a
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Feb 27, 2026
c4e0b60
Extra closing curly bracket
dchansen06 Feb 27, 2026
6c48271
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Feb 27, 2026
e86a33d
Send implementation should work now. Configuration very rough draft, …
kiranduriseti1 Mar 3, 2026
66a4d53
Merge branch 'main' into FancyCan
dchansen06 Mar 10, 2026
7e0f610
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 10, 2026
583d9d0
Merge branch 'main' into FancyCan
dchansen06 Mar 10, 2026
9b806b3
Merge branch 'main' into FancyCan
dchansen06 Mar 10, 2026
11ee2c8
Merge branch 'main' into FancyCan
dchansen06 Mar 10, 2026
6cbf1f2
Merge branch 'main' into FancyCan
dchansen06 Mar 12, 2026
8918c70
Merge branch 'main' into FancyCan
dchansen06 Mar 12, 2026
e5d9818
Merge branch 'main' into FancyCan
dchansen06 Mar 13, 2026
2093e55
Merge branch 'main' into FancyCan
dchansen06 Mar 13, 2026
1a2580c
Merge branch 'main' into FancyCan
dchansen06 Mar 13, 2026
276b820
Merge branch 'main' into FancyCan
dchansen06 Mar 13, 2026
1d1aa40
Merge branch 'main' into FancyCan
dchansen06 Mar 15, 2026
6a59760
Merge branch 'main' into FancyCan
dchansen06 Mar 17, 2026
9bb2cd7
Merge branch 'main' into FancyCan
dchansen06 Mar 18, 2026
71f72cc
Merge branch 'main' into FancyCan
dchansen06 Mar 19, 2026
0cc35a7
Merge branch 'main' into FancyCan
dchansen06 Mar 19, 2026
fdb3190
Merge branch 'main' into FancyCan
dchansen06 Mar 21, 2026
f04b4de
Merge branch 'main' into FancyCan
dchansen06 Mar 25, 2026
37e7d4e
updated utils and fancylayer: not working
kiranduriseti1 Mar 27, 2026
d3b9518
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Mar 27, 2026
75fbb01
Merge branch 'main' into FancyCan
dchansen06 Mar 28, 2026
37ec915
Merge branch 'main' into FancyCan
dchansen06 Mar 30, 2026
4b38aee
Merge branch 'main' into FancyCan
dchansen06 Mar 31, 2026
3f4ffd9
Merge branch 'main' into FancyCan
dchansen06 Mar 31, 2026
0dc0319
local FancyCan changes
kiranduriseti1 Apr 1, 2026
21bf399
Merge remote-tracking branch 'origin/FancyCan' into FancyCan
kiranduriseti1 Apr 1, 2026
dcd8ba6
merged forgot to pull
kiranduriseti1 Apr 1, 2026
29ad87c
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 1, 2026
d34d64a
Merge branch 'main' into FancyCan
dchansen06 Apr 3, 2026
aae2b65
layer builds, need to merge with new GRCAN migration
kiranduriseti1 Apr 3, 2026
88b0dae
layer builds, need to merge with new GRCAN migration
kiranduriseti1 Apr 3, 2026
44b920b
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
bb3acfd
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
9cc88b7
Updated to new GRCAN migration. Need to finish implementing build for…
kiranduriseti1 Apr 3, 2026
174c49a
CAN_LOOPBACK_TEST builds
kiranduriseti1 Apr 3, 2026
aa379c3
Automatic CMake Format: Standardized formatting automatically
github-actions[bot] Apr 3, 2026
3510caa
Automatic Clang-Format: Standardized formatting automatically
github-actions[bot] Apr 3, 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
9 changes: 9 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,15 @@
"CMake: configure"
],
"command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_STRESS_TEST"
},
{
"label": "CMake: configure and build CAN_LOOPBACK_TEST",
"type": "shell",
"dependsOrder": "sequence",
"dependsOn": [
"CMake: configure"
],
"command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CAN_LOOPBACK_TEST"
}
]
}
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ include("Autogen/CAN/CANfigurator.cmake")
# Peripherals
include("${lib_path}/Peripherals/USART/common.cmake")
include("${lib_path}/Peripherals/CAN/common.cmake")

include("${lib_path}/FancyLayers-RENAME/GRCAN/grcan_fancylayer.cmake")
include("${lib_path}/FancyLayers-RENAME/ADC/adc.cmake")
include("${lib_path}/FancyLayers-RENAME/NeoPixel/neopixel.cmake")

Expand Down Expand Up @@ -89,6 +91,7 @@ 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 G4CANTESTING CAN_FILTER_TEST)
add_gr_project(STM32G474xE G4FANCYCANTESTING CAN_LOOPBACK_TEST)

add_gr_project(STM32G474xE G4NEOTESTING)

Expand Down
60 changes: 60 additions & 0 deletions G4FANCYCANTESTING/CAN_LOOPBACK_TEST/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
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 GRCAN_FANCYLAYER)

target_include_directories(
${PROJECT_NAME}_USER_CODE
INTERFACE
../Core/Inc
.
)
10 changes: 10 additions & 0 deletions G4FANCYCANTESTING/CAN_LOOPBACK_TEST/can_cfg.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#ifndef CAN_CFG_H
#define CAN_CFG_H

#define USECAN1
#define TX_BUFFER_1_SIZE 10

#define USECAN2
#define TX_BUFFER_2_SIZE 10

#endif
274 changes: 274 additions & 0 deletions G4FANCYCANTESTING/CAN_LOOPBACK_TEST/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,274 @@
/* USER CODE BEGIN Header */
/**
******************************************************************************
* @file : main.c
* @brief : Main program body
******************************************************************************
* @attention
*
* Copyright (c) 2024 STMicroelectronics.
* All rights reserved.
*
* This software is licensed under terms that can be found in the LICENSE file
* in the root directory of this software component.
* If no LICENSE file comes with this software, it is provided AS-IS.
*
******************************************************************************
*/
/* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/
#include "main.h"

#include "adc.h"
#include "can.h" // Assume this works
#include "can_tests.h"
#include "dma.h"
#include "fdcan.h"
#include "gpio.h"
#include "i2c.h"
#include "spi.h"
#include "tim.h"
#include "usart.h"

/* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */
#include "Logomatic.h"
/* USER CODE END Includes */

/* Private typedef -----------------------------------------------------------*/
/* USER CODE BEGIN PTD */

/* USER CODE END PTD */

/* Private define ------------------------------------------------------------*/
/* USER CODE BEGIN PD */

/* USER CODE END PD */

/* Private macro -------------------------------------------------------------*/
/* USER CODE BEGIN PM */

/* USER CODE END PM */

/* Private variables ---------------------------------------------------------*/

/* USER CODE BEGIN PV */
/* USER CODE END PV */

/* Private function prototypes -----------------------------------------------*/
void SystemClock_Config(void);
/* USER CODE BEGIN PFP */

/* USER CODE END PFP */

/* Private user code ---------------------------------------------------------*/
/* USER CODE BEGIN 0 */
/* Enable ITM for SWO output */
static void ITM_Enable(void)
{
LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOB);
LL_GPIO_InitTypeDef GPIO_InitStruct = {0};
GPIO_InitStruct.Pin = LL_GPIO_PIN_3;
GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE;
GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL;
GPIO_InitStruct.Pull = LL_GPIO_PULL_NO;
GPIO_InitStruct.Alternate = LL_GPIO_AF_0;
LL_GPIO_Init(GPIOB, &GPIO_InitStruct);

DBGMCU->CR |= DBGMCU_CR_TRACE_IOEN;

/* Enable TRC (Trace) */
CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk;

/* Configure TPI for SWO output (set prescaler for 2MHz SWO clock) */
TPI->SPPR = 2U; /* 2 = Manchester/async UART mode */
TPI->ACPR = 84U; /* Prescaler: (170 MHz / (84+1) / 2) ≈ 1MHz SWO */

ITM->TER |= (1UL << 0);
ITM->TCR |= (ITM_TCR_ITMENA_Msk | ITM_TCR_SWOENA_Msk);
}
// static int toggleze = 0;
/* USER CODE END 0 */

/**
* @brief The application entry point.
* @retval int
*/
int main(void)
{
/* USER CODE BEGIN 1 */

/* USER CODE END 1 */

/* MCU
* Configuration--------------------------------------------------------*/

/* Reset of all peripherals, Initializes the Flash interface and the
* Systick. */
HAL_Init();
/* USER CODE BEGIN Init */
ITM_Enable();
/* USER CODE END Init */

/* Configure the system clock */
SystemClock_Config();

/* USER CODE BEGIN SysInit */

/* USER CODE END SysInit */

/* Initialize all configured peripherals */
MX_GPIO_Init();
MX_DMA_Init();
// MX_FDCAN2_Init();
MX_ADC1_Init();
MX_LPUART1_UART_Init();
MX_I2C2_Init();
MX_USART1_UART_Init();
MX_SPI3_Init();
MX_TIM2_Init();

/* USER CODE BEGIN 2 */

LOGOMATIC("Booted!\n");

// LOGOMATIC("running can_external_test:\n");
can_external_test();

/* Infinite loop */
/* USER CODE BEGIN WHILE */
while (1) {
/* USER CODE END WHILE */
LOGOMATIC("Main Loop\n");
LL_mDelay(1000);

// Receive on GPIOs
// HAL_GPIO_WritePin(GPIOA, GPIO_PIN_5, toggleze ? GPIO_PIN_SET
// : GPIO_PIN_RESET); HAL_Delay(1000); msg.data[0] = toggleze ?
// 0x00 : 0x80; can_send(data_can, &msg);

// RCC->CFGR |= RCC_CFGR_SW;
/* USER CODE BEGIN 3 */
}
}

/**
* @brief System Clock Configuration
* @retval None
*/

// void SystemClock_Config(void)
// {
// LL_FLASH_SetLatency(LL_FLASH_LATENCY_4);
// while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {
// }
// LL_PWR_EnableRange1BoostMode();
// LL_RCC_HSE_Enable();

// /* Wait till HSE is ready */
// while (LL_RCC_HSE_IsReady() != 1) {
// }

// LL_RCC_HSE_EnableCSS();
// LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSE, LL_RCC_PLLM_DIV_1, 20,
// LL_RCC_PLLR_DIV_2);
// //LL_RCC_PLL_ConfigDomain_48M(LL_RCC_PLLSOURCE_HSE, );
// LL_RCC_PLL_EnableDomain_SYS();
// LL_RCC_PLL_Enable();
// /* Wait till PLL is ready */
// while (LL_RCC_PLL_IsReady() != 1) {
// }

// LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_2);
// /* Wait till System clock is ready */
// while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {
// }

// /* Insure 1us transition state at intermediate medium speed clock*/
// for (__IO uint32_t i = (170 >> 1); i != 0; i--)
// ;

// /* Set AHB prescaler*/
// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
// LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
// LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
// LL_SetSystemCoreClock(160000000);

// /* Update the time base */
// if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) {
// Error_Handler();
// }
// }*/
void SystemClock_Config(void)
{
LL_FLASH_SetLatency(LL_FLASH_LATENCY_4);
while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_4) {}
LL_PWR_EnableRange1BoostMode();
LL_RCC_HSI_Enable();
/* Wait till HSI is ready */
while (LL_RCC_HSI_IsReady() != 1) {}

LL_RCC_HSI_SetCalibTrimming(64);
LL_RCC_PLL_ConfigDomain_SYS(LL_RCC_PLLSOURCE_HSI, LL_RCC_PLLM_DIV_4, 85, LL_RCC_PLLR_DIV_2);
LL_RCC_PLL_EnableDomain_SYS();
LL_RCC_PLL_Enable();
/* Wait till PLL is ready */
while (LL_RCC_PLL_IsReady() != 1) {}

LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_PLL);
// LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
/* Wait till System clock is ready */
while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_PLL) {}

/* Insure 1us transition state at intermediate medium speed clock*/
for (__IO uint32_t i = (170 >> 1); i != 0; i--)
;

/* Set AHB prescaler*/
LL_RCC_SetAHBPrescaler(LL_RCC_SYSCLK_DIV_1);
LL_RCC_SetAPB1Prescaler(LL_RCC_APB1_DIV_1);
LL_RCC_SetAPB2Prescaler(LL_RCC_APB2_DIV_1);
LL_SetSystemCoreClock(170000000);

/* Update the time base */
if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) {
Error_Handler();
}
}

/* USER CODE BEGIN 4 */

/* USER CODE END 4 */

/**
* @brief This function is executed in case of error occurrence.
* @retval None
*/
void Error_Handler(void)
{
/* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return
* state */
__disable_irq();
while (1) {}
/* USER CODE END Error_Handler_Debug */
}
#ifdef USE_FULL_ASSERT
/**
* @brief Reports the name of the source file and the source line number
* where the assert_param error has occurred.
* @param file: pointer to the source file name
* @param line: assert_param error line source number
* @retval None
*/
void assert_failed(uint8_t *file, uint32_t line)
{
/* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line
number, ex: printf("Wrong parameters value: file %s on line %d\r\n",
file, line) */
/* USER CODE END 6 */
}
#endif /* USE_FULL_ASSERT */
Loading
Loading