From 16dbc4f0e13f096208997e771177f41445e4303d Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Tue, 3 Feb 2026 12:52:38 -0800 Subject: [PATCH 01/95] Setup DashPanel base project with basic things -- currently untested physically --- .vscode/launch.json | 31 ++ .vscode/tasks.json | 9 + CMakeLists.txt | 1 + DashPanel/Application/Inc/empty.txt | 0 DashPanel/Application/Src/empty.txt | 0 DashPanel/CMakeLists.txt | 51 ++++ DashPanel/Core/Inc/main.h | 99 ++++++ DashPanel/Core/Inc/stm32_assert.h | 53 ++++ DashPanel/Core/Inc/stm32g4xx_hal_conf.h | 390 ++++++++++++++++++++++++ DashPanel/Core/Inc/stm32g4xx_it.h | 66 ++++ DashPanel/Core/Src/main.c | 346 +++++++++++++++++++++ DashPanel/Core/Src/stm32g4xx_it.c | 203 ++++++++++++ DashPanel/Core/Src/syscalls.c | 244 +++++++++++++++ DashPanel/Core/Src/sysmem.c | 87 ++++++ DashPanel/Core/Src/system_stm32g4xx.c | 285 +++++++++++++++++ DashPanel/README.md | 0 16 files changed, 1865 insertions(+) create mode 100644 DashPanel/Application/Inc/empty.txt create mode 100644 DashPanel/Application/Src/empty.txt create mode 100644 DashPanel/CMakeLists.txt create mode 100644 DashPanel/Core/Inc/main.h create mode 100644 DashPanel/Core/Inc/stm32_assert.h create mode 100644 DashPanel/Core/Inc/stm32g4xx_hal_conf.h create mode 100644 DashPanel/Core/Inc/stm32g4xx_it.h create mode 100644 DashPanel/Core/Src/main.c create mode 100644 DashPanel/Core/Src/stm32g4xx_it.c create mode 100644 DashPanel/Core/Src/syscalls.c create mode 100644 DashPanel/Core/Src/sysmem.c create mode 100644 DashPanel/Core/Src/system_stm32g4xx.c create mode 100644 DashPanel/README.md diff --git a/.vscode/launch.json b/.vscode/launch.json index d2c158491..13a32d88d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -94,6 +94,37 @@ ] } }, + { + "cwd": "${workspaceFolder}", + "executable": "${command:cmake.buildDirectory}/DashPanel.elf", + "name": "DashPanel", + "request": "launch", + "type": "cortex-debug", + "servertype": "openocd", + "configFiles": [ + "interface/stlink.cfg", + "target/stm32g4x.cfg" + ], + "searchDir": [], + "preLaunchTask": "CMake: configure and build DashPanel", + "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}/G4HELLO.elf", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index da3d7ad1d..29b177bbe 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -27,6 +27,15 @@ ], "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CCU" }, + { + "label": "CMake: configure and build DashPanel", + "type": "shell", + "dependsOrder": "sequence", + "dependsOn": [ + "CMake: configure" + ], + "command": "cmake --build build/${command:cmake.activeBuildPresetName} --target DashPanel" + }, { "label": "CMake: configure and build G4HELLO", "type": "shell", diff --git a/CMakeLists.txt b/CMakeLists.txt index ef62927ea..c0bcbfc74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ message( add_gr_project(STM32G474xE ECU) add_gr_project(STM32G474xE CCU) add_gr_project(STM32G474xE AnalogCalibration) +add_gr_project(STM32G474xE DashPanel) # Development add_gr_project(STM32G474xE G4ADCTESTING) diff --git a/DashPanel/Application/Inc/empty.txt b/DashPanel/Application/Inc/empty.txt new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/Application/Src/empty.txt b/DashPanel/Application/Src/empty.txt new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt new file mode 100644 index 000000000..1c4b7412e --- /dev/null +++ b/DashPanel/CMakeLists.txt @@ -0,0 +1,51 @@ +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() + +# what, does in fact not get the filename of somthing but rather the name of the project from the path +get_filename_component(GR_PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# Enable CMake support for ASM and C languages +enable_language( + C + ASM +) + +# Core project settings +project(${CMAKE_PROJECT_NAME}) + +add_library(${GR_PROJECT_NAME}_USER_CODE INTERFACE) +target_sources( + ${GR_PROJECT_NAME}_USER_CODE + INTERFACE + # Core + Core/Src/main.c + Core/Src/stm32g4xx_it.c + Core/Src/syscalls.c + Core/Src/sysmem.c + Core/Src/system_stm32g4xx.c + # Application + # TODO +) + +target_link_libraries( + ${GR_PROJECT_NAME}_USER_CODE + INTERFACE + GR_OLD_CAN_MESSAGES + PERIPHERAL_CAN_LIB +) + +target_include_directories( + ${GR_PROJECT_NAME}_USER_CODE + INTERFACE + Application/Inc + Core/Inc +) diff --git a/DashPanel/Core/Inc/main.h b/DashPanel/Core/Inc/main.h new file mode 100644 index 000000000..9a79f3367 --- /dev/null +++ b/DashPanel/Core/Inc/main.h @@ -0,0 +1,99 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32g4xx_ll_lpuart.h" +#include "stm32g4xx_ll_rcc.h" +#include "stm32g4xx_ll_bus.h" +#include "stm32g4xx_ll_crs.h" +#include "stm32g4xx_ll_system.h" +#include "stm32g4xx_ll_exti.h" +#include "stm32g4xx_ll_cortex.h" +#include "stm32g4xx_ll_utils.h" +#include "stm32g4xx_ll_pwr.h" +#include "stm32g4xx_ll_dma.h" +#include "stm32g4xx_ll_gpio.h" + +#if defined(USE_FULL_ASSERT) +#include "stm32_assert.h" +#endif /* USE_FULL_ASSERT */ + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define TS_ACTIVE_BTN_Pin LL_GPIO_PIN_3 +#define TS_ACTIVE_BTN_GPIO_Port GPIOA +#define RTD_BTN_Pin LL_GPIO_PIN_4 +#define RTD_BTN_GPIO_Port GPIOA +#ifndef NVIC_PRIORITYGROUP_0 +#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, + 4 bits for subpriority */ +#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, + 3 bits for subpriority */ +#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, + 2 bits for subpriority */ +#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, + 1 bit for subpriority */ +#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, + 0 bit for subpriority */ +#endif + +/* USER CODE BEGIN Private defines */ + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ diff --git a/DashPanel/Core/Inc/stm32_assert.h b/DashPanel/Core/Inc/stm32_assert.h new file mode 100644 index 000000000..61631c41e --- /dev/null +++ b/DashPanel/Core/Inc/stm32_assert.h @@ -0,0 +1,53 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32_assert.h + * @author MCD Application Team + * @brief STM32 assert file. + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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 */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32_ASSERT_H +#define __STM32_ASSERT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Includes ------------------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32_ASSERT_H */ + diff --git a/DashPanel/Core/Inc/stm32g4xx_hal_conf.h b/DashPanel/Core/Inc/stm32g4xx_hal_conf.h new file mode 100644 index 000000000..51f16ecdd --- /dev/null +++ b/DashPanel/Core/Inc/stm32g4xx_hal_conf.h @@ -0,0 +1,390 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32g4xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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 */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32G4xx_HAL_CONF_H +#define STM32G4xx_HAL_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ + +#define HAL_MODULE_ENABLED + +/*#define HAL_ADC_MODULE_ENABLED */ +/*#define HAL_COMP_MODULE_ENABLED */ +/*#define HAL_CORDIC_MODULE_ENABLED */ +/*#define HAL_CRC_MODULE_ENABLED */ +/*#define HAL_CRYP_MODULE_ENABLED */ +/*#define HAL_DAC_MODULE_ENABLED */ +#define HAL_FDCAN_MODULE_ENABLED +/*#define HAL_FMAC_MODULE_ENABLED */ +/*#define HAL_HRTIM_MODULE_ENABLED */ +/*#define HAL_IRDA_MODULE_ENABLED */ +/*#define HAL_IWDG_MODULE_ENABLED */ +/*#define HAL_I2C_MODULE_ENABLED */ +/*#define HAL_I2S_MODULE_ENABLED */ +/*#define HAL_LPTIM_MODULE_ENABLED */ +/*#define HAL_NAND_MODULE_ENABLED */ +/*#define HAL_NOR_MODULE_ENABLED */ +/*#define HAL_OPAMP_MODULE_ENABLED */ +/*#define HAL_PCD_MODULE_ENABLED */ +/*#define HAL_QSPI_MODULE_ENABLED */ +/*#define HAL_RNG_MODULE_ENABLED */ +/*#define HAL_RTC_MODULE_ENABLED */ +/*#define HAL_SAI_MODULE_ENABLED */ +/*#define HAL_SMARTCARD_MODULE_ENABLED */ +/*#define HAL_SMBUS_MODULE_ENABLED */ +/*#define HAL_SPI_MODULE_ENABLED */ +/*#define HAL_SRAM_MODULE_ENABLED */ +/*#define HAL_TIM_MODULE_ENABLED */ +/*#define HAL_UART_MODULE_ENABLED */ +/*#define HAL_USART_MODULE_ENABLED */ +/*#define HAL_WWDG_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +/*#define HAL_EXTI_MODULE_ENABLED */ +/*#define HAL_DMA_MODULE_ENABLED */ +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## Register Callbacks selection + * ############################## */ +/** + * @brief This is the list of modules where register callback can be used + */ +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U +#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U +#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U +#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U +#define USE_HAL_UART_REGISTER_CALLBACKS 0U +#define USE_HAL_USART_REGISTER_CALLBACKS 0U +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U + +/* ########################## Oscillator Values adaptation + * ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your + * application. This value is used by the RCC HAL module to compute the system + * frequency (when HSE is used as system clock source, directly or through the + * PLL). + */ +#if !defined(HSE_VALUE) +#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined(HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system + * frequency (when HSI is used as system clock source, directly or through the + * PLL). + */ +#if !defined(HSI_VALUE) +#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. + * This internal oscillator is mainly dedicated to provide a high + * precision clock to the USB peripheral by means of a special Clock Recovery + * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator + * runs on it default frequency which is subject to manufacturing process + * variations. + */ +#if !defined(HSI48_VALUE) +#define HSI48_VALUE \ + (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ + FS/RNG in Hz. The real value my vary depending on \ + manufacturing process variations.*/ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined(LSI_VALUE) +/*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations in voltage and +temperature.*/ +#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system + * frequency + */ +#if !defined(LSE_VALUE) +#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined(LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S and SAI peripherals + * This value is used by the I2S and SAI HAL modules to compute the I2S + * and SAI clock source frequency, this source is inserted directly through + * I2S_CKIN pad. + */ +#if !defined(EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ + +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 0U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32g4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32g4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32g4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32g4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32g4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED +#include "stm32g4xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CORDIC_MODULE_ENABLED +#include "stm32g4xx_hal_cordic.h" +#endif /* HAL_CORDIC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32g4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32g4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32g4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32g4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED +#include "stm32g4xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32g4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_FMAC_MODULE_ENABLED +#include "stm32g4xx_hal_fmac.h" +#endif /* HAL_FMAC_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED +#include "stm32g4xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32g4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32g4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32g4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32g4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32g4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32g4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32g4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32g4xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32g4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32g4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32g4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32g4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32g4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32g4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32g4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32g4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32g4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32g4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32g4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32g4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32g4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32g4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/DashPanel/Core/Inc/stm32g4xx_it.h b/DashPanel/Core/Inc/stm32g4xx_it.h new file mode 100644 index 000000000..1a144ad22 --- /dev/null +++ b/DashPanel/Core/Inc/stm32g4xx_it.h @@ -0,0 +1,66 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32g4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32G4xx_IT_H +#define __STM32G4xx_IT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32G4xx_IT_H */ diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c new file mode 100644 index 000000000..b3f940679 --- /dev/null +++ b/DashPanel/Core/Src/main.c @@ -0,0 +1,346 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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" + +/* 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); +static void MX_GPIO_Init(void); +static void MX_LPUART1_UART_Init(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) +{ + /* Enable TRC (Trace) */ + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + + /* Enable stimulus port 0 */ + ITM->TER |= (1UL << 0); + + /* Set trace control register */ + ITM->TCR |= ITM_TCR_ITMENA_Msk; +} +/* 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. */ + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); + + /* System interrupt init*/ + NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); + + /* SysTick_IRQn interrupt configuration */ + NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),15, 0)); + + /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral + */ + LL_PWR_DisableUCPDDeadBattery(); + + /* USER CODE BEGIN Init */ + + /* 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_LPUART1_UART_Init(); + /* USER CODE BEGIN 2 */ + + /* USER CODE END 2 */ + + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + LOGOMATIC("Hello from DashPanel!\n"); + LL_mDelay(1000); + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); + while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) + { + } + LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); + LL_RCC_HSI_Enable(); + /* Wait till HSI is ready */ + while(LL_RCC_HSI_IsReady() != 1) + { + } + + LL_RCC_HSI_SetCalibTrimming(64); + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); + /* Wait till System clock is ready */ + while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) + { + } + + /* 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_Init1msTick(16000000); + + LL_SetSystemCoreClock(16000000); +} + +/** + * @brief LPUART1 Initialization Function + * @param None + * @retval None + */ +static void MX_LPUART1_UART_Init(void) +{ + + /* USER CODE BEGIN LPUART1_Init 0 */ + + /* USER CODE END LPUART1_Init 0 */ + + LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; + + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + + LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); + + /* Peripheral clock enable */ + LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); + + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + /**LPUART1 GPIO Configuration + PC0 ------> LPUART1_RX + PC1 ------> LPUART1_TX + */ + GPIO_InitStruct.Pin = LL_GPIO_PIN_0; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = LL_GPIO_PIN_1; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN LPUART1_Init 1 */ + + /* USER CODE END LPUART1_Init 1 */ + LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; + LPUART_InitStruct.BaudRate = 115200; + LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; + LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; + LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; + LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; + LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; + LL_LPUART_Init(LPUART1, &LPUART_InitStruct); + LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_DisableFIFO(LPUART1); + + /* USER CODE BEGIN WKUPType LPUART1 */ + + /* USER CODE END WKUPType LPUART1 */ + + LL_LPUART_Enable(LPUART1); + + /* Polling LPUART1 initialisation */ + while((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) + { + } + /* USER CODE BEGIN LPUART1_Init 2 */ + + /* USER CODE END LPUART1_Init 2 */ + +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + /* USER CODE BEGIN MX_GPIO_Init_1 */ + + /* USER CODE END MX_GPIO_Init_1 */ + + /* GPIO Ports Clock Enable */ + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_6); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7); + + /**/ + LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_4); + + /**/ + GPIO_InitStruct.Pin = TS_ACTIVE_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(TS_ACTIVE_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = RTD_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(RTD_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_5; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_6; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_7; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_4; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN MX_GPIO_Init_2 */ + + /* USER CODE END MX_GPIO_Init_2 */ +} + +/* 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 */ diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c new file mode 100644 index 000000000..2f115be65 --- /dev/null +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -0,0 +1,203 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32g4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 "stm32g4xx_it.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* 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 -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ + +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + while (1) + { + } + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Memory management fault. + */ +void MemManage_Handler(void) +{ + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } +} + +/** + * @brief This function handles Prefetch fault, memory access fault. + */ +void BusFault_Handler(void) +{ + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Undefined instruction or illegal state. + */ +void UsageFault_Handler(void) +{ + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } +} + +/** + * @brief This function handles System service call via SWI instruction. + */ +void SVC_Handler(void) +{ + /* USER CODE BEGIN SVCall_IRQn 0 */ + + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ + + /* USER CODE END SVCall_IRQn 1 */ +} + +/** + * @brief This function handles Debug monitor. + */ +void DebugMon_Handler(void) +{ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + + /* USER CODE END DebugMonitor_IRQn 1 */ +} + +/** + * @brief This function handles Pendable request for system service. + */ +void PendSV_Handler(void) +{ + /* USER CODE BEGIN PendSV_IRQn 0 */ + + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ + + /* USER CODE END PendSV_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32G4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32g4xx.s). */ +/******************************************************************************/ + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ diff --git a/DashPanel/Core/Src/syscalls.c b/DashPanel/Core/Src/syscalls.c new file mode 100644 index 000000000..e10d76fa2 --- /dev/null +++ b/DashPanel/Core/Src/syscalls.c @@ -0,0 +1,244 @@ +/** + ****************************************************************************** + * @file syscalls.c + * @author Auto-generated by STM32CubeMX + * @brief Minimal System calls file + * + * For more information about which c-functions + * need which of these lowlevel functions + * please consult the Newlib or Picolibc libc-manual + ****************************************************************************** + * @attention + * + * Copyright (c) 2020-2025 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. + * + ****************************************************************************** + */ + +/* Includes */ +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Variables */ +extern int __io_putchar(int ch) __attribute__((weak)); +extern int __io_getchar(void) __attribute__((weak)); + + +char *__env[1] = { 0 }; +char **environ = __env; + + +/* Functions */ +void initialise_monitor_handles() +{ +} + +int _getpid(void) +{ + return 1; +} + +int _kill(int pid, int sig) +{ + (void)pid; + (void)sig; + errno = EINVAL; + return -1; +} + +void _exit (int status) +{ + _kill(status, -1); + while (1) {} /* Make sure we hang here */ +} + +__attribute__((weak)) int _read(int file, char *ptr, int len) +{ + (void)file; + int DataIdx; + + for (DataIdx = 0; DataIdx < len; DataIdx++) + { + *ptr++ = __io_getchar(); + } + + return len; +} + +__attribute__((weak)) int _write(int file, char *ptr, int len) +{ + (void)file; + int DataIdx; + + for (DataIdx = 0; DataIdx < len; DataIdx++) + { + __io_putchar(*ptr++); + } + return len; +} + +int _close(int file) +{ + (void)file; + return -1; +} + + +int _fstat(int file, struct stat *st) +{ + (void)file; + st->st_mode = S_IFCHR; + return 0; +} + +int _isatty(int file) +{ + (void)file; + return 1; +} + +int _lseek(int file, int ptr, int dir) +{ + (void)file; + (void)ptr; + (void)dir; + return 0; +} + +int _open(char *path, int flags, ...) +{ + (void)path; + (void)flags; + /* Pretend like we always fail */ + return -1; +} + +int _wait(int *status) +{ + (void)status; + errno = ECHILD; + return -1; +} + +int _unlink(char *name) +{ + (void)name; + errno = ENOENT; + return -1; +} + +clock_t _times(struct tms *buf) +{ + (void)buf; + return -1; +} + +int _stat(const char *file, struct stat *st) +{ + (void)file; + st->st_mode = S_IFCHR; + return 0; +} + +int _link(char *old, char *new) +{ + (void)old; + (void)new; + errno = EMLINK; + return -1; +} + +int _fork(void) +{ + errno = EAGAIN; + return -1; +} + +int _execve(char *name, char **argv, char **env) +{ + (void)name; + (void)argv; + (void)env; + errno = ENOMEM; + return -1; +} + +// --- Picolibc Specific Section --- +#if defined(__PICOLIBC__) + +/** + * @brief Picolibc helper function to output a character to a FILE stream. + * This redirects the output to the low-level __io_putchar function. + * @param c Character to write. + * @param file FILE stream pointer (ignored). + * @retval int The character written. + */ +static int starm_putc(char c, FILE *file) +{ + (void) file; + __io_putchar(c); + return c; +} + +/** + * @brief Picolibc helper function to input a character from a FILE stream. + * This redirects the input from the low-level __io_getchar function. + * @param file FILE stream pointer (ignored). + * @retval int The character read, cast to an unsigned char then int. + */ +static int starm_getc(FILE *file) +{ + unsigned char c; + (void) file; + c = __io_getchar(); + return c; +} + +// Define and initialize the standard I/O streams for Picolibc. +// FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to a FILE structure. +// _FDEV_SETUP_RW indicates the stream is for reading and writing. +static FILE __stdio = FDEV_SETUP_STREAM(starm_putc, + starm_getc, + NULL, + _FDEV_SETUP_RW); + +// Assign the standard stream pointers (stdin, stdout, stderr) to the initialized stream. +// Picolibc uses these pointers for standard I/O operations (printf, scanf, etc.). +FILE *const stdin = &__stdio; +__strong_reference(stdin, stdout); +__strong_reference(stdin, stderr); + +// Create strong aliases mapping standard C library function names (without underscore) +// to the implemented system call stubs (with underscore). Picolibc uses these +// standard names internally, so this linking is required. +__strong_reference(_read, read); +__strong_reference(_write, write); +__strong_reference(_times, times); +__strong_reference(_execve, execve); +__strong_reference(_fork, fork); +__strong_reference(_link, link); +__strong_reference(_unlink, unlink); +__strong_reference(_stat, stat); +__strong_reference(_wait, wait); +__strong_reference(_open, open); +__strong_reference(_close, close); +__strong_reference(_lseek, lseek); +__strong_reference(_isatty, isatty); +__strong_reference(_fstat, fstat); +__strong_reference(_exit, exit); +__strong_reference(_kill, kill); +__strong_reference(_getpid, getpid); + +#endif //__PICOLIBC__ diff --git a/DashPanel/Core/Src/sysmem.c b/DashPanel/Core/Src/sysmem.c new file mode 100644 index 000000000..a875d42c0 --- /dev/null +++ b/DashPanel/Core/Src/sysmem.c @@ -0,0 +1,87 @@ +/** + ****************************************************************************** + * @file sysmem.c + * @author Generated by STM32CubeMX + * @brief System Memory calls file + * + * For more information about which C functions + * need which of these lowlevel functions + * please consult the Newlib or Picolibc libc manual + ****************************************************************************** + * @attention + * + * Copyright (c) 2025 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. + * + ****************************************************************************** + */ + +/* Includes */ +#include +#include +#include + +/** + * Pointer to the current high watermark of the heap usage + */ +static uint8_t *__sbrk_heap_end = NULL; + +/** + * @brief _sbrk() allocates memory to the newlib heap and is used by malloc + * and others from the C library + * + * @verbatim + * ############################################################################ + * # .data # .bss # newlib heap # MSP stack # + * # # # # Reserved by _Min_Stack_Size # + * ############################################################################ + * ^-- RAM start ^-- _end _estack, RAM end --^ + * @endverbatim + * + * This implementation starts allocating at the '_end' linker symbol + * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack + * The implementation considers '_estack' linker symbol to be RAM end + * NOTE: If the MSP stack, at any point during execution, grows larger than the + * reserved size, please increase the '_Min_Stack_Size'. + * + * @param incr Memory size + * @return Pointer to allocated memory + */ +void *_sbrk(ptrdiff_t incr) +{ + extern uint8_t _end; /* Symbol defined in the linker script */ + extern uint8_t _estack; /* Symbol defined in the linker script */ + extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ + const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; + const uint8_t *max_heap = (uint8_t *)stack_limit; + uint8_t *prev_heap_end; + + /* Initialize heap end at first call */ + if (NULL == __sbrk_heap_end) + { + __sbrk_heap_end = &_end; + } + + /* Protect heap from growing into the reserved MSP stack */ + if (__sbrk_heap_end + incr > max_heap) + { + errno = ENOMEM; + return (void *)-1; + } + + prev_heap_end = __sbrk_heap_end; + __sbrk_heap_end += incr; + + return (void *)prev_heap_end; +} + +#if defined(__PICOLIBC__) + // Picolibc expects syscalls without the leading underscore. + // This creates a strong alias so that + // calls to `sbrk()` are resolved to our `_sbrk()` implementation. + __strong_reference(_sbrk, sbrk); +#endif diff --git a/DashPanel/Core/Src/system_stm32g4xx.c b/DashPanel/Core/Src/system_stm32g4xx.c new file mode 100644 index 000000000..922e57abc --- /dev/null +++ b/DashPanel/Core/Src/system_stm32g4xx.c @@ -0,0 +1,285 @@ +/** + ****************************************************************************** + * @file system_stm32g4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32g4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the HSI (16 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | HSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * PLL_M | 1 + *----------------------------------------------------------------------------- + * PLL_N | 16 + *----------------------------------------------------------------------------- + * PLL_P | 7 + *----------------------------------------------------------------------------- + * PLL_Q | 2 + *----------------------------------------------------------------------------- + * PLL_R | 2 + *----------------------------------------------------------------------------- + * Require 48MHz for RNG | Disabled + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32g4xx_system + * @{ + */ + +/** @addtogroup STM32G4xx_System_Private_Includes + * @{ + */ + +#include "stm32g4xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/* Note: Following vector table addresses must be defined in line with linker + configuration. */ +/*!< Uncomment the following line if you need to relocate the vector table + anywhere in Flash or Sram, else the vector table is kept at the automatic + remap of boot address selected */ +/* #define USER_VECT_TAB_ADDRESS */ + +#if defined(USER_VECT_TAB_ADDRESS) +/*!< Uncomment the following line if you need to relocate your vector Table + in Sram else user remap will be done in Flash. */ +/* #define VECT_TAB_SRAM */ +#if defined(VECT_TAB_SRAM) +#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +#else +#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +#endif /* VECT_TAB_SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ +/******************************************************************************/ +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Variables + * @{ + */ + /* The SystemCoreClock variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = HSI_VALUE; + + const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; + const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * @param None + * @retval None + */ + +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ + #endif + + /* Configure the Vector Table location add offset address ------------------*/ +#if defined(USER_VECT_TAB_ADDRESS) + SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 24 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp, pllvco, pllr, pllsource, pllm; + + /* Get SYSCLK source -------------------------------------------------------*/ + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case 0x04: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + + case 0x08: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + + case 0x0C: /* PLL used as system clock source */ + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); + pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U ; + if (pllsource == 0x02UL) /* HSI used as PLL clock source */ + { + pllvco = (HSI_VALUE / pllm); + } + else /* HSE used as PLL clock source */ + { + pllvco = (HSE_VALUE / pllm); + } + pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); + pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; + SystemCoreClock = pllvco/pllr; + break; + + default: + break; + } + /* Compute HCLK clock frequency --------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + diff --git a/DashPanel/README.md b/DashPanel/README.md new file mode 100644 index 000000000..e69de29bb From a4be817f20a655a7133c98b6a42ff5c4c67404c0 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 20:55:25 +0000 Subject: [PATCH 02/95] Automatic CMake Format: Standardized formatting automatically --- DashPanel/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index 1c4b7412e..927279519 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -32,8 +32,8 @@ target_sources( Core/Src/syscalls.c Core/Src/sysmem.c Core/Src/system_stm32g4xx.c - # Application - # TODO + # Application + # TODO ) target_link_libraries( From c5e9b65742cfd1edeabcc2aed118ac61390acc17 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 20:56:44 +0000 Subject: [PATCH 03/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Inc/main.h | 71 +++-- DashPanel/Core/Inc/stm32_assert.h | 49 ++- DashPanel/Core/Inc/stm32g4xx_it.h | 30 +- DashPanel/Core/Src/main.c | 440 +++++++++++++------------- DashPanel/Core/Src/stm32g4xx_it.c | 175 +++++----- DashPanel/Core/Src/syscalls.c | 150 ++++----- DashPanel/Core/Src/sysmem.c | 48 ++- DashPanel/Core/Src/system_stm32g4xx.c | 437 +++++++++++++------------ 8 files changed, 685 insertions(+), 715 deletions(-) diff --git a/DashPanel/Core/Inc/main.h b/DashPanel/Core/Inc/main.h index 9a79f3367..5ee9090c2 100644 --- a/DashPanel/Core/Inc/main.h +++ b/DashPanel/Core/Inc/main.h @@ -1,21 +1,21 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ /* Define to prevent recursive inclusion -------------------------------------*/ @@ -27,17 +27,17 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_ll_lpuart.h" -#include "stm32g4xx_ll_rcc.h" #include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_exti.h" #include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_utils.h" -#include "stm32g4xx_ll_pwr.h" +#include "stm32g4xx_ll_crs.h" #include "stm32g4xx_ll_dma.h" +#include "stm32g4xx_ll_exti.h" #include "stm32g4xx_ll_gpio.h" +#include "stm32g4xx_ll_lpuart.h" +#include "stm32g4xx_ll_pwr.h" +#include "stm32g4xx_ll_rcc.h" +#include "stm32g4xx_ll_system.h" +#include "stm32g4xx_ll_utils.h" #if defined(USE_FULL_ASSERT) #include "stm32_assert.h" @@ -76,16 +76,21 @@ void Error_Handler(void); #define RTD_BTN_Pin LL_GPIO_PIN_4 #define RTD_BTN_GPIO_Port GPIOA #ifndef NVIC_PRIORITYGROUP_0 -#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, - 4 bits for subpriority */ -#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, - 3 bits for subpriority */ -#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, - 2 bits for subpriority */ -#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, - 1 bit for subpriority */ -#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, - 0 bit for subpriority */ +#define NVIC_PRIORITYGROUP_0 \ + ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, \ + 4 bits for subpriority */ +#define NVIC_PRIORITYGROUP_1 \ + ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, \ + 3 bits for subpriority */ +#define NVIC_PRIORITYGROUP_2 \ + ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, \ + 2 bits for subpriority */ +#define NVIC_PRIORITYGROUP_3 \ + ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, \ + 1 bit for subpriority */ +#define NVIC_PRIORITYGROUP_4 \ + ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, \ + 0 bit for subpriority */ #endif /* USER CODE BEGIN Private defines */ diff --git a/DashPanel/Core/Inc/stm32_assert.h b/DashPanel/Core/Inc/stm32_assert.h index 61631c41e..92460620f 100644 --- a/DashPanel/Core/Inc/stm32_assert.h +++ b/DashPanel/Core/Inc/stm32_assert.h @@ -1,21 +1,21 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file stm32_assert.h - * @author MCD Application Team - * @brief STM32 assert file. - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file stm32_assert.h + * @author MCD Application Team + * @brief STM32 assert file. + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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 */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32_ASSERT_H @@ -29,15 +29,15 @@ extern "C" { /* Exported constants --------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT +#ifdef USE_FULL_ASSERT /** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t *file, uint32_t line); @@ -50,4 +50,3 @@ void assert_failed(uint8_t *file, uint32_t line); #endif #endif /* __STM32_ASSERT_H */ - diff --git a/DashPanel/Core/Inc/stm32g4xx_it.h b/DashPanel/Core/Inc/stm32g4xx_it.h index 1a144ad22..3cfc1aa5a 100644 --- a/DashPanel/Core/Inc/stm32g4xx_it.h +++ b/DashPanel/Core/Inc/stm32g4xx_it.h @@ -1,20 +1,20 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file stm32g4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ /* Define to prevent recursive inclusion -------------------------------------*/ diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index b3f940679..6f3dc53e5 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -1,20 +1,20 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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" @@ -70,244 +70,234 @@ static void ITM_Enable(void) /* USER CODE END 0 */ /** - * @brief The application entry point. - * @retval int - */ + * @brief The application entry point. + * @retval int + */ int main(void) { - /* USER CODE BEGIN 1 */ + /* USER CODE BEGIN 1 */ - /* USER CODE END 1 */ + /* USER CODE END 1 */ - /* MCU Configuration--------------------------------------------------------*/ + /* MCU Configuration--------------------------------------------------------*/ - /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); - /* System interrupt init*/ - NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); + /* System interrupt init*/ + NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); - /* SysTick_IRQn interrupt configuration */ - NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),15, 0)); + /* SysTick_IRQn interrupt configuration */ + NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0)); - /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral - */ - LL_PWR_DisableUCPDDeadBattery(); + /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral + */ + LL_PWR_DisableUCPDDeadBattery(); - /* USER CODE BEGIN Init */ + /* USER CODE BEGIN Init */ - /* USER CODE END Init */ + /* USER CODE END Init */ - /* Configure the system clock */ - SystemClock_Config(); + /* Configure the system clock */ + SystemClock_Config(); - /* USER CODE BEGIN SysInit */ + /* USER CODE BEGIN SysInit */ - /* USER CODE END SysInit */ + /* USER CODE END SysInit */ - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_LPUART1_UART_Init(); - /* USER CODE BEGIN 2 */ + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_LPUART1_UART_Init(); + /* USER CODE BEGIN 2 */ - /* USER CODE END 2 */ + /* USER CODE END 2 */ - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { - /* USER CODE END WHILE */ - LOGOMATIC("Hello from DashPanel!\n"); - LL_mDelay(1000); - /* USER CODE BEGIN 3 */ - } - /* USER CODE END 3 */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) { + /* USER CODE END WHILE */ + LOGOMATIC("Hello from DashPanel!\n"); + LL_mDelay(1000); + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ } /** - * @brief System Clock Configuration - * @retval None - */ + * @brief System Clock Configuration + * @retval None + */ void SystemClock_Config(void) { - LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); - while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) - { - } - LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while(LL_RCC_HSI_IsReady() != 1) - { - } - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); - /* Wait till System clock is ready */ - while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) - { - } - - /* 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_Init1msTick(16000000); - - LL_SetSystemCoreClock(16000000); + LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); + while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) {} + LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); + LL_RCC_HSI_Enable(); + /* Wait till HSI is ready */ + while (LL_RCC_HSI_IsReady() != 1) {} + + LL_RCC_HSI_SetCalibTrimming(64); + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); + /* Wait till System clock is ready */ + while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {} + + /* 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_Init1msTick(16000000); + + LL_SetSystemCoreClock(16000000); } /** - * @brief LPUART1 Initialization Function - * @param None - * @retval None - */ + * @brief LPUART1 Initialization Function + * @param None + * @retval None + */ static void MX_LPUART1_UART_Init(void) { - /* USER CODE BEGIN LPUART1_Init 0 */ + /* USER CODE BEGIN LPUART1_Init 0 */ - /* USER CODE END LPUART1_Init 0 */ + /* USER CODE END LPUART1_Init 0 */ - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; + LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); + LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); + /* Peripheral clock enable */ + LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**LPUART1 GPIO Configuration - PC0 ------> LPUART1_RX - PC1 ------> LPUART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + /**LPUART1 GPIO Configuration + PC0 ------> LPUART1_RX + PC1 ------> LPUART1_TX + */ + GPIO_InitStruct.Pin = LL_GPIO_PIN_0; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + GPIO_InitStruct.Pin = LL_GPIO_PIN_1; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /* USER CODE BEGIN LPUART1_Init 1 */ + /* USER CODE BEGIN LPUART1_Init 1 */ - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); + /* USER CODE END LPUART1_Init 1 */ + LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; + LPUART_InitStruct.BaudRate = 115200; + LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; + LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; + LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; + LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; + LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; + LL_LPUART_Init(LPUART1, &LPUART_InitStruct); + LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_DisableFIFO(LPUART1); - /* USER CODE BEGIN WKUPType LPUART1 */ + /* USER CODE BEGIN WKUPType LPUART1 */ - /* USER CODE END WKUPType LPUART1 */ + /* USER CODE END WKUPType LPUART1 */ - LL_LPUART_Enable(LPUART1); + LL_LPUART_Enable(LPUART1); - /* Polling LPUART1 initialisation */ - while((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) - { - } - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ + /* Polling LPUART1 initialisation */ + while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} + /* USER CODE BEGIN LPUART1_Init 2 */ + /* USER CODE END LPUART1_Init 2 */ } /** - * @brief GPIO Initialization Function - * @param None - * @retval None - */ + * @brief GPIO Initialization Function + * @param None + * @retval None + */ static void MX_GPIO_Init(void) { - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* USER CODE BEGIN MX_GPIO_Init_1 */ - - /* USER CODE END MX_GPIO_Init_1 */ - - /* GPIO Ports Clock Enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - - /**/ - LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5); - - /**/ - LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_6); - - /**/ - LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7); - - /**/ - LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_4); - - /**/ - GPIO_InitStruct.Pin = TS_ACTIVE_BTN_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(TS_ACTIVE_BTN_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = RTD_BTN_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(RTD_BTN_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN MX_GPIO_Init_2 */ - - /* USER CODE END MX_GPIO_Init_2 */ + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + /* USER CODE BEGIN MX_GPIO_Init_1 */ + + /* USER CODE END MX_GPIO_Init_1 */ + + /* GPIO Ports Clock Enable */ + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_6); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7); + + /**/ + LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_4); + + /**/ + GPIO_InitStruct.Pin = TS_ACTIVE_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(TS_ACTIVE_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = RTD_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(RTD_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_5; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_6; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_7; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_4; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN MX_GPIO_Init_2 */ + + /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ @@ -315,32 +305,30 @@ static void MX_GPIO_Init(void) /* USER CODE END 4 */ /** - * @brief This function is executed in case of error occurrence. - * @retval None - */ + * @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 */ + /* 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 - */ + * @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 */ + /* 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 */ diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c index 2f115be65..ccc490cc1 100644 --- a/DashPanel/Core/Src/stm32g4xx_it.c +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -1,25 +1,26 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file stm32g4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 "stm32g4xx_it.h" + +#include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ @@ -64,131 +65,125 @@ /* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** - * @brief This function handles Non maskable interrupt. - */ + * @brief This function handles Non maskable interrupt. + */ void NMI_Handler(void) { - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) - { - } - /* USER CODE END NonMaskableInt_IRQn 1 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + while (1) {} + /* USER CODE END NonMaskableInt_IRQn 1 */ } /** - * @brief This function handles Hard fault interrupt. - */ + * @brief This function handles Hard fault interrupt. + */ void HardFault_Handler(void) { - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } } /** - * @brief This function handles Memory management fault. - */ + * @brief This function handles Memory management fault. + */ void MemManage_Handler(void) { - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } } /** - * @brief This function handles Prefetch fault, memory access fault. - */ + * @brief This function handles Prefetch fault, memory access fault. + */ void BusFault_Handler(void) { - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } } /** - * @brief This function handles Undefined instruction or illegal state. - */ + * @brief This function handles Undefined instruction or illegal state. + */ void UsageFault_Handler(void) { - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } } /** - * @brief This function handles System service call via SWI instruction. - */ + * @brief This function handles System service call via SWI instruction. + */ void SVC_Handler(void) { - /* USER CODE BEGIN SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 0 */ - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ - /* USER CODE END SVCall_IRQn 1 */ + /* USER CODE END SVCall_IRQn 1 */ } /** - * @brief This function handles Debug monitor. - */ + * @brief This function handles Debug monitor. + */ void DebugMon_Handler(void) { - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - /* USER CODE END DebugMonitor_IRQn 1 */ + /* USER CODE END DebugMonitor_IRQn 1 */ } /** - * @brief This function handles Pendable request for system service. - */ + * @brief This function handles Pendable request for system service. + */ void PendSV_Handler(void) { - /* USER CODE BEGIN PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 0 */ - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ - /* USER CODE END PendSV_IRQn 1 */ + /* USER CODE END PendSV_IRQn 1 */ } /** - * @brief This function handles System tick timer. - */ + * @brief This function handles System tick timer. + */ void SysTick_Handler(void) { - /* USER CODE BEGIN SysTick_IRQn 0 */ + /* USER CODE BEGIN SysTick_IRQn 0 */ - /* USER CODE END SysTick_IRQn 0 */ + /* USER CODE END SysTick_IRQn 0 */ - /* USER CODE BEGIN SysTick_IRQn 1 */ + /* USER CODE BEGIN SysTick_IRQn 1 */ - /* USER CODE END SysTick_IRQn 1 */ + /* USER CODE END SysTick_IRQn 1 */ } /******************************************************************************/ diff --git a/DashPanel/Core/Src/syscalls.c b/DashPanel/Core/Src/syscalls.c index e10d76fa2..6abf331cb 100644 --- a/DashPanel/Core/Src/syscalls.c +++ b/DashPanel/Core/Src/syscalls.c @@ -21,158 +21,147 @@ */ /* Includes */ -#include -#include #include -#include #include -#include +#include +#include +#include #include #include - +#include /* Variables */ extern int __io_putchar(int ch) __attribute__((weak)); extern int __io_getchar(void) __attribute__((weak)); - -char *__env[1] = { 0 }; +char *__env[1] = {0}; char **environ = __env; - /* Functions */ -void initialise_monitor_handles() -{ -} +void initialise_monitor_handles() {} -int _getpid(void) -{ - return 1; -} +int _getpid(void) { return 1; } int _kill(int pid, int sig) { - (void)pid; - (void)sig; - errno = EINVAL; - return -1; + (void)pid; + (void)sig; + errno = EINVAL; + return -1; } -void _exit (int status) +void _exit(int status) { - _kill(status, -1); - while (1) {} /* Make sure we hang here */ + _kill(status, -1); + while (1) {} /* Make sure we hang here */ } __attribute__((weak)) int _read(int file, char *ptr, int len) { - (void)file; - int DataIdx; + (void)file; + int DataIdx; - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - *ptr++ = __io_getchar(); - } + for (DataIdx = 0; DataIdx < len; DataIdx++) { + *ptr++ = __io_getchar(); + } - return len; + return len; } __attribute__((weak)) int _write(int file, char *ptr, int len) { - (void)file; - int DataIdx; + (void)file; + int DataIdx; - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - __io_putchar(*ptr++); - } - return len; + for (DataIdx = 0; DataIdx < len; DataIdx++) { + __io_putchar(*ptr++); + } + return len; } int _close(int file) { - (void)file; - return -1; + (void)file; + return -1; } - int _fstat(int file, struct stat *st) { - (void)file; - st->st_mode = S_IFCHR; - return 0; + (void)file; + st->st_mode = S_IFCHR; + return 0; } int _isatty(int file) { - (void)file; - return 1; + (void)file; + return 1; } int _lseek(int file, int ptr, int dir) { - (void)file; - (void)ptr; - (void)dir; - return 0; + (void)file; + (void)ptr; + (void)dir; + return 0; } int _open(char *path, int flags, ...) { - (void)path; - (void)flags; - /* Pretend like we always fail */ - return -1; + (void)path; + (void)flags; + /* Pretend like we always fail */ + return -1; } int _wait(int *status) { - (void)status; - errno = ECHILD; - return -1; + (void)status; + errno = ECHILD; + return -1; } int _unlink(char *name) { - (void)name; - errno = ENOENT; - return -1; + (void)name; + errno = ENOENT; + return -1; } clock_t _times(struct tms *buf) { - (void)buf; - return -1; + (void)buf; + return -1; } int _stat(const char *file, struct stat *st) { - (void)file; - st->st_mode = S_IFCHR; - return 0; + (void)file; + st->st_mode = S_IFCHR; + return 0; } int _link(char *old, char *new) { - (void)old; - (void)new; - errno = EMLINK; - return -1; + (void)old; + (void)new; + errno = EMLINK; + return -1; } int _fork(void) { - errno = EAGAIN; - return -1; + errno = EAGAIN; + return -1; } int _execve(char *name, char **argv, char **env) { - (void)name; - (void)argv; - (void)env; - errno = ENOMEM; - return -1; + (void)name; + (void)argv; + (void)env; + errno = ENOMEM; + return -1; } // --- Picolibc Specific Section --- @@ -187,8 +176,8 @@ int _execve(char *name, char **argv, char **env) */ static int starm_putc(char c, FILE *file) { - (void) file; - __io_putchar(c); + (void)file; + __io_putchar(c); return c; } @@ -201,18 +190,15 @@ static int starm_putc(char c, FILE *file) static int starm_getc(FILE *file) { unsigned char c; - (void) file; - c = __io_getchar(); + (void)file; + c = __io_getchar(); return c; } // Define and initialize the standard I/O streams for Picolibc. // FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to a FILE structure. // _FDEV_SETUP_RW indicates the stream is for reading and writing. -static FILE __stdio = FDEV_SETUP_STREAM(starm_putc, - starm_getc, - NULL, - _FDEV_SETUP_RW); +static FILE __stdio = FDEV_SETUP_STREAM(starm_putc, starm_getc, NULL, _FDEV_SETUP_RW); // Assign the standard stream pointers (stdin, stdout, stderr) to the initialized stream. // Picolibc uses these pointers for standard I/O operations (printf, scanf, etc.). diff --git a/DashPanel/Core/Src/sysmem.c b/DashPanel/Core/Src/sysmem.c index a875d42c0..3a092d114 100644 --- a/DashPanel/Core/Src/sysmem.c +++ b/DashPanel/Core/Src/sysmem.c @@ -22,8 +22,8 @@ /* Includes */ #include -#include #include +#include /** * Pointer to the current high watermark of the heap usage @@ -53,35 +53,33 @@ static uint8_t *__sbrk_heap_end = NULL; */ void *_sbrk(ptrdiff_t incr) { - extern uint8_t _end; /* Symbol defined in the linker script */ - extern uint8_t _estack; /* Symbol defined in the linker script */ - extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ - const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; - const uint8_t *max_heap = (uint8_t *)stack_limit; - uint8_t *prev_heap_end; + extern uint8_t _end; /* Symbol defined in the linker script */ + extern uint8_t _estack; /* Symbol defined in the linker script */ + extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ + const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; + const uint8_t *max_heap = (uint8_t *)stack_limit; + uint8_t *prev_heap_end; - /* Initialize heap end at first call */ - if (NULL == __sbrk_heap_end) - { - __sbrk_heap_end = &_end; - } + /* Initialize heap end at first call */ + if (NULL == __sbrk_heap_end) { + __sbrk_heap_end = &_end; + } - /* Protect heap from growing into the reserved MSP stack */ - if (__sbrk_heap_end + incr > max_heap) - { - errno = ENOMEM; - return (void *)-1; - } + /* Protect heap from growing into the reserved MSP stack */ + if (__sbrk_heap_end + incr > max_heap) { + errno = ENOMEM; + return (void *)-1; + } - prev_heap_end = __sbrk_heap_end; - __sbrk_heap_end += incr; + prev_heap_end = __sbrk_heap_end; + __sbrk_heap_end += incr; - return (void *)prev_heap_end; + return (void *)prev_heap_end; } #if defined(__PICOLIBC__) - // Picolibc expects syscalls without the leading underscore. - // This creates a strong alias so that - // calls to `sbrk()` are resolved to our `_sbrk()` implementation. - __strong_reference(_sbrk, sbrk); +// Picolibc expects syscalls without the leading underscore. +// This creates a strong alias so that +// calls to `sbrk()` are resolved to our `_sbrk()` implementation. +__strong_reference(_sbrk, sbrk); #endif diff --git a/DashPanel/Core/Src/system_stm32g4xx.c b/DashPanel/Core/Src/system_stm32g4xx.c index 922e57abc..4eec0cb3c 100644 --- a/DashPanel/Core/Src/system_stm32g4xx.c +++ b/DashPanel/Core/Src/system_stm32g4xx.c @@ -1,109 +1,109 @@ /** - ****************************************************************************** - * @file system_stm32g4xx.c - * @author MCD Application Team - * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32g4xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * After each device reset the HSI (16 MHz) is used as system clock source. - * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to - * configure the system clock before to branch to main program. - * - * This file configures the system clock as follows: - *============================================================================= - *----------------------------------------------------------------------------- - * System Clock source | HSI - *----------------------------------------------------------------------------- - * SYSCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * HCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * AHB Prescaler | 1 - *----------------------------------------------------------------------------- - * APB1 Prescaler | 1 - *----------------------------------------------------------------------------- - * APB2 Prescaler | 1 - *----------------------------------------------------------------------------- - * PLL_M | 1 - *----------------------------------------------------------------------------- - * PLL_N | 16 - *----------------------------------------------------------------------------- - * PLL_P | 7 - *----------------------------------------------------------------------------- - * PLL_Q | 2 - *----------------------------------------------------------------------------- - * PLL_R | 2 - *----------------------------------------------------------------------------- - * Require 48MHz for RNG | Disabled - *----------------------------------------------------------------------------- - *============================================================================= - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file system_stm32g4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32g4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the HSI (16 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | HSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * PLL_M | 1 + *----------------------------------------------------------------------------- + * PLL_N | 16 + *----------------------------------------------------------------------------- + * PLL_P | 7 + *----------------------------------------------------------------------------- + * PLL_Q | 2 + *----------------------------------------------------------------------------- + * PLL_R | 2 + *----------------------------------------------------------------------------- + * Require 48MHz for RNG | Disabled + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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. + * + ****************************************************************************** + */ /** @addtogroup CMSIS - * @{ - */ + * @{ + */ /** @addtogroup stm32g4xx_system - * @{ - */ + * @{ + */ /** @addtogroup STM32G4xx_System_Private_Includes - * @{ - */ + * @{ + */ #include "stm32g4xx.h" -#if !defined (HSE_VALUE) - #define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ +#if !defined(HSE_VALUE) +#define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ -#if !defined (HSI_VALUE) - #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ +#if !defined(HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_TypesDefinitions - * @{ - */ + * @{ + */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_Defines - * @{ - */ + * @{ + */ /************************* Miscellaneous Configuration ************************/ /* Note: Following vector table addresses must be defined in line with linker - configuration. */ + configuration. */ /*!< Uncomment the following line if you need to relocate the vector table anywhere in Flash or Sram, else the vector table is kept at the automatic remap of boot address selected */ @@ -114,172 +114,171 @@ in Sram else user remap will be done in Flash. */ /* #define VECT_TAB_SRAM */ #if defined(VECT_TAB_SRAM) -#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ +#define VECT_TAB_BASE_ADDRESS \ + SRAM_BASE /*!< Vector Table base address field. \ + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET \ + 0x00000000U /*!< Vector Table base offset field. \ + This value must be a multiple of 0x200. */ #else -#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#endif /* VECT_TAB_SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -/******************************************************************************/ -/** - * @} - */ +#define VECT_TAB_BASE_ADDRESS \ + FLASH_BASE /*!< Vector Table base address field. \ + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET \ + 0x00000000U /*!< Vector Table base offset field. \ + This value must be a multiple of 0x200. */ +#endif /* VECT_TAB_SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ + /******************************************************************************/ + /** + * @} + */ /** @addtogroup STM32G4xx_System_Private_Macros - * @{ - */ + * @{ + */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_Variables - * @{ - */ - /* The SystemCoreClock variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. - */ - uint32_t SystemCoreClock = HSI_VALUE; - - const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; - const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; + * @{ + */ +/* The SystemCoreClock variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. +*/ +uint32_t SystemCoreClock = HSI_VALUE; + +const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; +const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_FunctionPrototypes - * @{ - */ + * @{ + */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_Functions - * @{ - */ + * @{ + */ /** - * @brief Setup the microcontroller system. - * @param None - * @retval None - */ + * @brief Setup the microcontroller system. + * @param None + * @retval None + */ void SystemInit(void) { - /* FPU settings ------------------------------------------------------------*/ - #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ - #endif +/* FPU settings ------------------------------------------------------------*/ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10 * 2)) | (3UL << (11 * 2))); /* set CP10 and CP11 Full Access */ +#endif - /* Configure the Vector Table location add offset address ------------------*/ + /* Configure the Vector Table location add offset address ------------------*/ #if defined(USER_VECT_TAB_ADDRESS) - SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ + SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ } /** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 24 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 24 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ void SystemCoreClockUpdate(void) { - uint32_t tmp, pllvco, pllr, pllsource, pllm; - - /* Get SYSCLK source -------------------------------------------------------*/ - switch (RCC->CFGR & RCC_CFGR_SWS) - { - case 0x04: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - - case 0x08: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - - case 0x0C: /* PLL used as system clock source */ - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN - SYSCLK = PLL_VCO / PLLR - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); - pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U ; - if (pllsource == 0x02UL) /* HSI used as PLL clock source */ - { - pllvco = (HSI_VALUE / pllm); - } - else /* HSE used as PLL clock source */ - { - pllvco = (HSE_VALUE / pllm); - } - pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); - pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; - SystemCoreClock = pllvco/pllr; - break; - - default: - break; - } - /* Compute HCLK clock frequency --------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK clock frequency */ - SystemCoreClock >>= tmp; + uint32_t tmp, pllvco, pllr, pllsource, pllm; + + /* Get SYSCLK source -------------------------------------------------------*/ + switch (RCC->CFGR & RCC_CFGR_SWS) { + case 0x04: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + + case 0x08: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + + case 0x0C: /* PLL used as system clock source */ + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); + pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U; + if (pllsource == 0x02UL) /* HSI used as PLL clock source */ + { + pllvco = (HSI_VALUE / pllm); + } else /* HSE used as PLL clock source */ + { + pllvco = (HSE_VALUE / pllm); + } + pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); + pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; + SystemCoreClock = pllvco / pllr; + break; + + default: + break; + } + /* Compute HCLK clock frequency --------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; } - /** - * @} - */ + * @} + */ /** - * @} - */ + * @} + */ /** - * @} - */ - - + * @} + */ From c55c3697dc9da77f8d6f062863f2187875a6fae6 Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 3 Feb 2026 13:18:13 -0800 Subject: [PATCH 04/95] Enable ITM in main function Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Core/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 6f3dc53e5..30d753128 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -111,7 +111,7 @@ int main(void) MX_GPIO_Init(); MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ - + ITM_Enable() /* USER CODE END 2 */ /* Infinite loop */ From a703e99e1cfcf7f5338798aab00fd9519def29a0 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:19:18 +0000 Subject: [PATCH 05/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 30d753128..a3f8cac06 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -112,11 +112,12 @@ int main(void) MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ ITM_Enable() - /* USER CODE END 2 */ + /* USER CODE END 2 */ - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { /* USER CODE END WHILE */ LOGOMATIC("Hello from DashPanel!\n"); LL_mDelay(1000); From 90aebe562e9022245adbfd4eba746025b448843b Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 3 Feb 2026 13:20:53 -0800 Subject: [PATCH 06/95] Missing semicolon for enabling ITM Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Core/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index a3f8cac06..e11e1194d 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -111,7 +111,7 @@ int main(void) MX_GPIO_Init(); MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ - ITM_Enable() + ITM_Enable(); /* USER CODE END 2 */ /* Infinite loop */ From 8bffa4458b6c092a40da3adb438349b4f75e9713 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:21:56 +0000 Subject: [PATCH 07/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index e11e1194d..78601e35f 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -112,12 +112,11 @@ int main(void) MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ ITM_Enable(); - /* USER CODE END 2 */ + /* USER CODE END 2 */ - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) { /* USER CODE END WHILE */ LOGOMATIC("Hello from DashPanel!\n"); LL_mDelay(1000); From 6b174f4abd74dfd39fcea750fbba5e9514f558c9 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 5 Feb 2026 21:02:56 -0800 Subject: [PATCH 08/95] initialize dash panel can stuff Co-authored-by: David Uzunov Co-authored-by: Anthony Ma Co-authored-by: Aagrim Hoysal --- DashPanel/Application/Inc/CANdler.h | 7 +++ DashPanel/Application/Inc/main2.h | 0 DashPanel/Application/Src/CANdler.c | 75 +++++++++++++++++++++++++++++ DashPanel/Application/Src/main2.c | 0 DashPanel/Core/Src/main.c | 32 +++++++++--- DashPanel/DASHPLANEL.md | 23 +++++++++ G4PERTESTING/Core/Inc/main.h | 1 + G4PERTESTING/Core/Src/main.c | 3 ++ 8 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 DashPanel/Application/Inc/CANdler.h create mode 100644 DashPanel/Application/Inc/main2.h create mode 100644 DashPanel/Application/Src/CANdler.c create mode 100644 DashPanel/Application/Src/main2.c create mode 100644 DashPanel/DASHPLANEL.md diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h new file mode 100644 index 000000000..5056eb4c7 --- /dev/null +++ b/DashPanel/Application/Inc/CANdler.h @@ -0,0 +1,7 @@ +#ifndef CANDLER_H +#define CANDLER_H + +void CANInitialize(); +void CAN_callback(uint32_t ID, void *data, uint32_t size); + +#endif diff --git a/DashPanel/Application/Inc/main2.h b/DashPanel/Application/Inc/main2.h new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c new file mode 100644 index 000000000..9f1f1d2ae --- /dev/null +++ b/DashPanel/Application/Src/CANdler.c @@ -0,0 +1,75 @@ +#include "can.h" +#include "stm32g4xx_hal_fdcan.h" +#include "CANdler.h" + +#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID +#define PING_ID 2 // ID of ping message - TODO: change with correct ID + +void CANInitialize() { + CANConfig canCfg; + + canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; + canCfg.hal_fdcan_init.FrameFormat = FDCAN_FRAME_FD_NO_BRS; + canCfg.hal_fdcan_init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; + canCfg.hal_fdcan_init.Mode = FDCAN_MODE_NORMAL; + canCfg.hal_fdcan_init.AutoRetransmission = ENABLE; + canCfg.hal_fdcan_init.TransmitPause = DISABLE; + canCfg.hal_fdcan_init.ProtocolException = ENABLE; + canCfg.hal_fdcan_init.NominalPrescaler = 1; + 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.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.StdFiltersNbr = 1; + canCfg.hal_fdcan_init.ExtFiltersNbr = 0; + + canCfg.rx_callback = CAN_callback; // PLEASE SET + canCfg.rx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_buffer_length = 3; // PLEASE SET + + // canCfg.rx_gpio = GPIOB; + // canCfg.init_rx_gpio.Pin = GPIO_PIN_12; + canCfg.init_rx_gpio.Mode = GPIO_MODE_AF_PP; + canCfg.init_rx_gpio.Pull = GPIO_PULLUP; + canCfg.init_rx_gpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + // canCfg.init_rx_gpio.Alternate = GPIO_AF9_FDCAN2; + + // canCfg.tx_gpio = GPIOB; + // canCfg.init_tx_gpio.Pin = GPIO_PIN_13; + canCfg.init_tx_gpio.Mode = GPIO_MODE_AF_PP; + canCfg.init_tx_gpio.Pull = GPIO_NOPULL; + canCfg.init_tx_gpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + // canCfg.init_tx_gpio.Alternate = GPIO_AF9_FDCAN2; + + // FDCAN_FilterTypeDef filter; + // can_add_filter(can2Handle, &filter); + /* USER CODE END 2 */ + + + // FDCAN_TxHeaderTypeDef TxHeader = { + // .Identifier = 1, + + // .IdType = FDCAN_STANDARD_ID, + // .TxFrameType = FDCAN_DATA_FRAME, + // .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node + // // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors + // .DataLength = 1, + // .BitRateSwitch = FDCAN_BRS_OFF, + // .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages + // .MessageMarker = 0 // also change this to a real address if you change fifo control + // }; + CANHandle *can_handler = can_init(&canCfg); + can_start(can_handler); +} + +void CAN_callback(uint32_t ID, void *data, uint32_t size){ + if (ID == ECU_ID) { + // process data + } else if (ID == PING_ID) { + // process ping + } +} diff --git a/DashPanel/Application/Src/main2.c b/DashPanel/Application/Src/main2.c new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 78601e35f..d003f171b 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -18,6 +18,7 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" +#include "CANdler.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -97,6 +98,7 @@ int main(void) LL_PWR_DisableUCPDDeadBattery(); /* USER CODE BEGIN Init */ + CANInitialize(); /* USER CODE END Init */ @@ -129,28 +131,42 @@ int main(void) * @brief System Clock Configuration * @retval None */ + void SystemClock_Config(void) { - LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) {} - LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); + 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_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); + 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_2); /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {} + 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); - LL_Init1msTick(16000000); - - LL_SetSystemCoreClock(16000000); + /* Update the time base */ + if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { + Error_Handler(); + } } /** diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md new file mode 100644 index 000000000..73994e311 --- /dev/null +++ b/DashPanel/DASHPLANEL.md @@ -0,0 +1,23 @@ +# DASH PLANel + +## CAN + +1. Set up CANdler with help of CAN team +2. Export button inputs +3. Import ECU CAN messages + + + +## Buttons + +1. Process button inputs (THE BUTTONS DO NOT LATCH) +2. Implement debouncing + +## LED + +1. Integrate NeoPixel +2. Set up lights + +## Testing + +1. Implement LP-UART for async & LOGOMATIC diff --git a/G4PERTESTING/Core/Inc/main.h b/G4PERTESTING/Core/Inc/main.h index 23d7ffce4..edc4c0b10 100644 --- a/G4PERTESTING/Core/Inc/main.h +++ b/G4PERTESTING/Core/Inc/main.h @@ -105,6 +105,7 @@ void Error_Handler(void); #define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ +extern CANHandle /* USER CODE END Private defines */ diff --git a/G4PERTESTING/Core/Src/main.c b/G4PERTESTING/Core/Src/main.c index ba6196726..48f7bbafe 100644 --- a/G4PERTESTING/Core/Src/main.c +++ b/G4PERTESTING/Core/Src/main.c @@ -105,6 +105,9 @@ int main(void) MX_TIM2_Init(); /* USER CODE BEGIN 2 */ + /* Initialize CAN interface */ + + /* USER CODE END 2 */ /* Infinite loop */ From a77a2b2155363774713587ec23bd76e7f2edfe1d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 05:04:00 +0000 Subject: [PATCH 09/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 32 +++++++++++++++-------------- DashPanel/Core/Src/main.c | 1 + G4PERTESTING/Core/Src/main.c | 1 - 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 9f1f1d2ae..215a8dfcd 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,12 +1,14 @@ +#include "CANdler.h" + #include "can.h" #include "stm32g4xx_hal_fdcan.h" -#include "CANdler.h" -#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID +#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID #define PING_ID 2 // ID of ping message - TODO: change with correct ID -void CANInitialize() { - CANConfig canCfg; +void CANInitialize() +{ + CANConfig canCfg; canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; canCfg.hal_fdcan_init.FrameFormat = FDCAN_FRAME_FD_NO_BRS; @@ -26,10 +28,10 @@ void CANInitialize() { canCfg.hal_fdcan_init.StdFiltersNbr = 1; canCfg.hal_fdcan_init.ExtFiltersNbr = 0; - canCfg.rx_callback = CAN_callback; // PLEASE SET - canCfg.rx_interrupt_priority = 0; // PLEASE SET - canCfg.tx_interrupt_priority = 0; // PLEASE SET - canCfg.tx_buffer_length = 3; // PLEASE SET + canCfg.rx_callback = CAN_callback; // PLEASE SET + canCfg.rx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_buffer_length = 3; // PLEASE SET // canCfg.rx_gpio = GPIOB; // canCfg.init_rx_gpio.Pin = GPIO_PIN_12; @@ -49,7 +51,6 @@ void CANInitialize() { // can_add_filter(can2Handle, &filter); /* USER CODE END 2 */ - // FDCAN_TxHeaderTypeDef TxHeader = { // .Identifier = 1, @@ -66,10 +67,11 @@ void CANInitialize() { can_start(can_handler); } -void CAN_callback(uint32_t ID, void *data, uint32_t size){ - if (ID == ECU_ID) { - // process data - } else if (ID == PING_ID) { - // process ping - } +void CAN_callback(uint32_t ID, void *data, uint32_t size) +{ + if (ID == ECU_ID) { + // process data + } else if (ID == PING_ID) { + // process ping + } } diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index d003f171b..0da50c7de 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -18,6 +18,7 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" + #include "CANdler.h" /* Private includes ----------------------------------------------------------*/ diff --git a/G4PERTESTING/Core/Src/main.c b/G4PERTESTING/Core/Src/main.c index 48f7bbafe..ee28d20d0 100644 --- a/G4PERTESTING/Core/Src/main.c +++ b/G4PERTESTING/Core/Src/main.c @@ -107,7 +107,6 @@ int main(void) /* Initialize CAN interface */ - /* USER CODE END 2 */ /* Infinite loop */ From 497a26a47fdd031db6f488cd7458e20b682a5474 Mon Sep 17 00:00:00 2001 From: DavidUzunov Date: Thu, 5 Feb 2026 22:00:29 -0800 Subject: [PATCH 10/95] Did some things Co-authored-by: Bailey Say Co-authored-by: Anthony Ma Co-authored-by: Aagrim Hoysal --- DashPanel/Application/Inc/CANdler.h | 15 ++++++++++++ DashPanel/Application/Src/CANdler.c | 38 +++++++++++++++++++---------- DashPanel/DASHPLANEL.md | 5 +++- DashPanel/README.md | 27 ++++++++++++++++++++ 4 files changed, 71 insertions(+), 14 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 5056eb4c7..110d4059f 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,6 +1,21 @@ #ifndef CANDLER_H #define CANDLER_H +typedef struct { + uint16_t vehicleSpeed; + uint8_t ECUState; +} DashStatus; +typedef struct { + uint16_t vehicleSpeed; + uint8_t ECUState; +} CAN_MSG_ECU; + +typedef struct { + +} CAN_MSG_PING; + +extern DashStatus dashStatus; + void CANInitialize(); void CAN_callback(uint32_t ID, void *data, uint32_t size); diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 215a8dfcd..56fe28a45 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -6,8 +6,12 @@ #define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID #define PING_ID 2 // ID of ping message - TODO: change with correct ID +DashStatus dashStatus; + void CANInitialize() { + dashStatus = {0}; + CANConfig canCfg; canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; @@ -51,27 +55,35 @@ void CANInitialize() // can_add_filter(can2Handle, &filter); /* USER CODE END 2 */ - // FDCAN_TxHeaderTypeDef TxHeader = { - // .Identifier = 1, - - // .IdType = FDCAN_STANDARD_ID, - // .TxFrameType = FDCAN_DATA_FRAME, - // .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node - // // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors - // .DataLength = 1, - // .BitRateSwitch = FDCAN_BRS_OFF, - // .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages - // .MessageMarker = 0 // also change this to a real address if you change fifo control - // }; CANHandle *can_handler = can_init(&canCfg); can_start(can_handler); } +void CAN_sendPing() { + FDCAN_TxHeaderTypeDef PingTxHeader = { + .Identifier = GR_DASH_PANEL | , + + .IdType = FDCAN_STANDARD_ID, + .TxFrameType = FDCAN_DATA_FRAME, + .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node + // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors + .DataLength = 4, + .BitRateSwitch = FDCAN_BRS_OFF, + .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages + .MessageMarker = 0 // also change this to a real address if you change fifo control + }; +} + void CAN_callback(uint32_t ID, void *data, uint32_t size) { + // Process data if (ID == ECU_ID) { - // process data + CAN_MSG_ECU* ecu_data = (CAN_MSG_ECU*) data; + dashStatus->vehicleSpeed = ecu_data->vehicleSpeed; + dashStatus->ECUState = ecu_data->ECUState; + // Process data } else if (ID == PING_ID) { // process ping + CAN_sendPing(); } } diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index 73994e311..2cda667fa 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -6,7 +6,10 @@ 2. Export button inputs 3. Import ECU CAN messages - +- Torque, Current, Speed, or put battery before drive +- Probably need to figure out what we're putting on the board for now +- We should set up the ECU send too... +- Also update the README ## Buttons diff --git a/DashPanel/README.md b/DashPanel/README.md index e69de29bb..372b72035 100644 --- a/DashPanel/README.md +++ b/DashPanel/README.md @@ -0,0 +1,27 @@ +# Button mappings + +## Butt1 + +TS-Active +Connected to PA3 + +## Butt2 + +RTD(Ready to Drive) +Connected to PA4 + +## D1 + +idk + +## D2 + +idk + +## D3 + +idk + +## D4 + +idk From d9003fc0c7e6858b809f696cb4a9a472f8079090 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 06:01:34 +0000 Subject: [PATCH 11/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 8 ++++---- DashPanel/Application/Src/CANdler.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 110d4059f..079780564 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -2,12 +2,12 @@ #define CANDLER_H typedef struct { - uint16_t vehicleSpeed; - uint8_t ECUState; + uint16_t vehicleSpeed; + uint8_t ECUState; } DashStatus; typedef struct { - uint16_t vehicleSpeed; - uint8_t ECUState; + uint16_t vehicleSpeed; + uint8_t ECUState; } CAN_MSG_ECU; typedef struct { diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 56fe28a45..9c5e3926e 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -59,9 +59,10 @@ void CANInitialize() can_start(can_handler); } -void CAN_sendPing() { +void CAN_sendPing() +{ FDCAN_TxHeaderTypeDef PingTxHeader = { - .Identifier = GR_DASH_PANEL | , + .Identifier = GR_DASH_PANEL |, .IdType = FDCAN_STANDARD_ID, .TxFrameType = FDCAN_DATA_FRAME, @@ -78,10 +79,10 @@ void CAN_callback(uint32_t ID, void *data, uint32_t size) { // Process data if (ID == ECU_ID) { - CAN_MSG_ECU* ecu_data = (CAN_MSG_ECU*) data; + CAN_MSG_ECU *ecu_data = (CAN_MSG_ECU *)data; dashStatus->vehicleSpeed = ecu_data->vehicleSpeed; dashStatus->ECUState = ecu_data->ECUState; - // Process data + // Process data } else if (ID == PING_ID) { // process ping CAN_sendPing(); From e69574a220ac6d7b837da4c491338ea7da495a5a Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Mon, 9 Feb 2026 19:55:37 -0800 Subject: [PATCH 12/95] delete placeholder files --- DashPanel/Application/Inc/empty.txt | 0 DashPanel/Application/Inc/main2.h | 0 DashPanel/Application/Src/empty.txt | 0 DashPanel/Application/Src/main2.c | 0 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 DashPanel/Application/Inc/empty.txt delete mode 100644 DashPanel/Application/Inc/main2.h delete mode 100644 DashPanel/Application/Src/empty.txt delete mode 100644 DashPanel/Application/Src/main2.c diff --git a/DashPanel/Application/Inc/empty.txt b/DashPanel/Application/Inc/empty.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/DashPanel/Application/Inc/main2.h b/DashPanel/Application/Inc/main2.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/DashPanel/Application/Src/empty.txt b/DashPanel/Application/Src/empty.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/DashPanel/Application/Src/main2.c b/DashPanel/Application/Src/main2.c deleted file mode 100644 index e69de29bb..000000000 From 77ce64c6e94f81478e1bf1f1ca039c58f9b3e37d Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Mon, 9 Feb 2026 21:10:14 -0800 Subject: [PATCH 13/95] basic gpio interrupt handler setup --- DashPanel/Core/Src/main.c | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 0da50c7de..4f1ccf253 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -51,6 +51,7 @@ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_LPUART1_UART_Init(void); +static void GPIO_Interrupt_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ @@ -100,6 +101,7 @@ int main(void) /* USER CODE BEGIN Init */ CANInitialize(); + GPIO_Interrupt_Init(); /* USER CODE END Init */ @@ -319,6 +321,59 @@ static void MX_GPIO_Init(void) /* USER CODE BEGIN 4 */ +/** + * @brief GPIO Interrupt Handler Setup Function + * @param None + * @retval None + */ +static void GPIO_Interrupt_Init(void) { + + // Map PA3 and PA4 to EXTI lines 3 and 4 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE4); + + LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE3); + LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE4); + LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_0); + LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_0); + + NVIC_SetPriority(EXTI3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); + NVIC_SetPriority(EXTI4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); + + // Enable interrupts + NVIC_EnableIRQ(EXTI3_IRQn); + NVIC_EnableIRQ(EXTI4_IRQn); + +} + +/** + * @brief EXTI Line 3 Interrupt Handler (for TS Active button) + * @param None + * @retval None + */ +void EXTI3_IRQHandler(void) { + + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { + + LOGOMATIC("TS Active Pressed!"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); + } + +} + +/** + * @brief EXTI Line 4 Interrupt Handler (for RTD button) + * @param None + * @retval None + */ +void EXTI4_IRQHandler(void) { + + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { + + LOGOMATIC("RTD Pressed!"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); + } +} /* USER CODE END 4 */ /** From e97c8deb6ff1721e7c90389d1e00c206afd8cab5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 05:11:14 +0000 Subject: [PATCH 14/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 4f1ccf253..cb98fe56e 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -326,7 +326,8 @@ static void MX_GPIO_Init(void) * @param None * @retval None */ -static void GPIO_Interrupt_Init(void) { +static void GPIO_Interrupt_Init(void) +{ // Map PA3 and PA4 to EXTI lines 3 and 4 LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); @@ -343,7 +344,6 @@ static void GPIO_Interrupt_Init(void) { // Enable interrupts NVIC_EnableIRQ(EXTI3_IRQn); NVIC_EnableIRQ(EXTI4_IRQn); - } /** @@ -351,14 +351,14 @@ static void GPIO_Interrupt_Init(void) { * @param None * @retval None */ -void EXTI3_IRQHandler(void) { +void EXTI3_IRQHandler(void) +{ if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { LOGOMATIC("TS Active Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); } - } /** @@ -366,7 +366,8 @@ void EXTI3_IRQHandler(void) { * @param None * @retval None */ -void EXTI4_IRQHandler(void) { +void EXTI4_IRQHandler(void) +{ if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { From 5d9ca76d724597026fa6d794c5470a6263e1cd36 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Tue, 10 Feb 2026 12:47:05 -0800 Subject: [PATCH 15/95] more candler stuff --- DashPanel/Application/Inc/CANdler.h | 10 +++++-- DashPanel/Application/Inc/dashutils.h | 6 ++++ DashPanel/Application/Src/CANdler.c | 40 +++++++++++++++++---------- DashPanel/Application/Src/dashutils.c | 10 +++++++ DashPanel/Core/Src/main.c | 25 +++++++++-------- DashPanel/DASHPLANEL.md | 4 +-- 6 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 DashPanel/Application/Inc/dashutils.h create mode 100644 DashPanel/Application/Src/dashutils.c diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 079780564..391b25832 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,5 +1,6 @@ #ifndef CANDLER_H #define CANDLER_H +#include "can.h" typedef struct { uint16_t vehicleSpeed; @@ -8,15 +9,18 @@ typedef struct { typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; -} CAN_MSG_ECU; +} CAN_RECEIVE_ECU; typedef struct { - -} CAN_MSG_PING; + uint8_t TSActiveButton; + uint8_t RTDButton; +} CAN_SEND_ECU; extern DashStatus dashStatus; +extern CANHandle * can_handler; void CANInitialize(); +void CAN_sendPing(GR_OLD_NODE_ID to); void CAN_callback(uint32_t ID, void *data, uint32_t size); #endif diff --git a/DashPanel/Application/Inc/dashutils.h b/DashPanel/Application/Inc/dashutils.h new file mode 100644 index 000000000..e19e47ae4 --- /dev/null +++ b/DashPanel/Application/Inc/dashutils.h @@ -0,0 +1,6 @@ +#ifdef DASHPANEL_UTILS_H +#define DASHPANEL_UTILS_H + +uint32_t MillisecondsSinceBoot(void); + +#endif // DASHPANEL_UTILS_H diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 9c5e3926e..4e50c8987 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,11 +1,13 @@ #include "CANdler.h" #include "can.h" +#include "dashutils.h" #include "stm32g4xx_hal_fdcan.h" #define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID #define PING_ID 2 // ID of ping message - TODO: change with correct ID +CANHandle *can_handler; DashStatus dashStatus; void CANInitialize() @@ -55,24 +57,34 @@ void CANInitialize() // can_add_filter(can2Handle, &filter); /* USER CODE END 2 */ - CANHandle *can_handler = can_init(&canCfg); + can_handler = can_init(&canCfg); can_start(can_handler); } -void CAN_sendPing() +void CAN_sendPing(GR_OLD_NODE_ID to) { - FDCAN_TxHeaderTypeDef PingTxHeader = { - .Identifier = GR_DASH_PANEL |, - - .IdType = FDCAN_STANDARD_ID, - .TxFrameType = FDCAN_DATA_FRAME, - .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node - // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors - .DataLength = 4, - .BitRateSwitch = FDCAN_BRS_OFF, - .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages - .MessageMarker = 0 // also change this to a real address if you change fifo control - }; + FDCANTxMessage pingMsg; + pingMsg.tx_header.Identifier = (GR_DASH_PANEL<<20) | (MSG_PING<<8) | to; + pingMsg.tx_header.IdType = FDCAN_STANDARD_ID; + pingMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME; + pingMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; + pingMsg.tx_header.DataLength = 4; + pingMsg.tx_header.BitRateSwitch = FDCAN_BRS_OFF; + pingMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; + pingMsg.tx_header.MessageMarker = 0; + + ((uint32_t*) (pingMsg.data))[0] = MillisecondsSinceBoot(); + can_send(can_handler, &pingMsg); +} + +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU* msg) { + + FDCANTxMessage sendECUMsg; + + // TODO: set up the message + + can_send(c, &sendECUMsg); + } void CAN_callback(uint32_t ID, void *data, uint32_t size) diff --git a/DashPanel/Application/Src/dashutils.c b/DashPanel/Application/Src/dashutils.c new file mode 100644 index 000000000..16d979019 --- /dev/null +++ b/DashPanel/Application/Src/dashutils.c @@ -0,0 +1,10 @@ +#include "dashutils.h" +#include "main.h" + +// from ECU +uint32_t MillisecondsSinceBoot(void) +{ + // For some reason, GetTickFreq returns period in millisecon instead of frequency + // See https://community.st.com/t5/stm32-mcus-embedded-software/name-amp-description-of-hal-gettickfreq-misleading/td-p/242457 + return HAL_GetTick() * HAL_GetTickFreq(); +} diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index cb98fe56e..681f42b4c 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -284,33 +284,25 @@ static void MX_GPIO_Init(void) /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOC, &GPIO_InitStruct); @@ -356,6 +348,8 @@ void EXTI3_IRQHandler(void) if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { + // Blame Electronics if hardware debounce doesn't work + LOGOMATIC("TS Active Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); } @@ -371,6 +365,13 @@ void EXTI4_IRQHandler(void) if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { + // Blame Electronics if hardware debounce doesn't work + + CAN_SEND_ECU msg_struct; + msg_struct.TSActiveButton = 0; + msg_struct.RTDButton = 1; + + CAN_sendECU(can_handler, &msg_struct); LOGOMATIC("RTD Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); } diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index 2cda667fa..dd0a13a07 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -13,8 +13,8 @@ ## Buttons -1. Process button inputs (THE BUTTONS DO NOT LATCH) -2. Implement debouncing +1. Test button interrupts +2. Move the CAN messages to grand loop + make global status + create CAN send flag ## LED From a32990261cf50c292045b58c1acd85e226b735d2 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:48:17 +0000 Subject: [PATCH 16/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 2 +- DashPanel/Application/Src/CANdler.c | 8 ++++---- DashPanel/Application/Src/dashutils.c | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 391b25832..70512f011 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -17,7 +17,7 @@ typedef struct { } CAN_SEND_ECU; extern DashStatus dashStatus; -extern CANHandle * can_handler; +extern CANHandle *can_handler; void CANInitialize(); void CAN_sendPing(GR_OLD_NODE_ID to); diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 4e50c8987..cee848a4f 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -64,7 +64,7 @@ void CANInitialize() void CAN_sendPing(GR_OLD_NODE_ID to) { FDCANTxMessage pingMsg; - pingMsg.tx_header.Identifier = (GR_DASH_PANEL<<20) | (MSG_PING<<8) | to; + pingMsg.tx_header.Identifier = (GR_DASH_PANEL << 20) | (MSG_PING << 8) | to; pingMsg.tx_header.IdType = FDCAN_STANDARD_ID; pingMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME; pingMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; @@ -73,18 +73,18 @@ void CAN_sendPing(GR_OLD_NODE_ID to) pingMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; pingMsg.tx_header.MessageMarker = 0; - ((uint32_t*) (pingMsg.data))[0] = MillisecondsSinceBoot(); + ((uint32_t *)(pingMsg.data))[0] = MillisecondsSinceBoot(); can_send(can_handler, &pingMsg); } -void CAN_sendECU(CANHandle *c, CAN_SEND_ECU* msg) { +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) +{ FDCANTxMessage sendECUMsg; // TODO: set up the message can_send(c, &sendECUMsg); - } void CAN_callback(uint32_t ID, void *data, uint32_t size) diff --git a/DashPanel/Application/Src/dashutils.c b/DashPanel/Application/Src/dashutils.c index 16d979019..4178d408a 100644 --- a/DashPanel/Application/Src/dashutils.c +++ b/DashPanel/Application/Src/dashutils.c @@ -1,4 +1,5 @@ #include "dashutils.h" + #include "main.h" // from ECU From 79c4bcb96062ecdc37c573687141f0618f4ec31e Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 21:33:37 -0800 Subject: [PATCH 17/95] move CAN send to main loop --- DashPanel/Application/Inc/CANdler.h | 4 ++++ DashPanel/Application/Src/CANdler.c | 3 +++ DashPanel/Core/Src/main.c | 29 ++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 70512f011..2b43e58fd 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -5,6 +5,8 @@ typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; + uint8_t TSActiveButton; + uint8_t RTDButton; } DashStatus; typedef struct { uint16_t vehicleSpeed; @@ -18,9 +20,11 @@ typedef struct { extern DashStatus dashStatus; extern CANHandle *can_handler; +extern bool canReadyToSend; void CANInitialize(); void CAN_sendPing(GR_OLD_NODE_ID to); void CAN_callback(uint32_t ID, void *data, uint32_t size); +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg); #endif diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index cee848a4f..406a55c1f 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -9,10 +9,13 @@ CANHandle *can_handler; DashStatus dashStatus; +bool canReadyToSend; + void CANInitialize() { dashStatus = {0}; + canReadyToSend = false; CANConfig canCfg; diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 681f42b4c..21e4067db 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -123,8 +123,24 @@ int main(void) /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ - LOGOMATIC("Hello from DashPanel!\n"); - LL_mDelay(1000); + // LOGOMATIC("Hello from DashPanel!\n"); + // LL_mDelay(1000); + + if (canReadyToSend) { + + CAN_SEND_ECU msg_struct; + msg_struct.TSActiveButton = dashStatus.TSActiveButton; + msg_struct.RTDButton = dashStatus.RTDButton; + + // Kinda weird ngl but it doesn't matter + if (dashStatus.TSActiveButton) dashStatus.TSActiveButton = 0; + if (dashStatus.RTDButton) dashStatus.RTDButton = 0; + + CAN_sendECU(can_handler, &msg_struct); + + canReadyToSend = false; + + } /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ @@ -350,6 +366,8 @@ void EXTI3_IRQHandler(void) // Blame Electronics if hardware debounce doesn't work + dashStatus.TSActiveButton = 1; + canReadyToSend = true; LOGOMATIC("TS Active Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); } @@ -367,11 +385,8 @@ void EXTI4_IRQHandler(void) // Blame Electronics if hardware debounce doesn't work - CAN_SEND_ECU msg_struct; - msg_struct.TSActiveButton = 0; - msg_struct.RTDButton = 1; - - CAN_sendECU(can_handler, &msg_struct); + dashStatus.RTDButton = 1; + canReadyToSend = true; LOGOMATIC("RTD Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); } From 1b7f2e7f21f8f14853b4fb65a8bbdd1b3c690e54 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:34:39 +0000 Subject: [PATCH 18/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 1 - DashPanel/Core/Src/main.c | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 406a55c1f..4a39da2fa 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -11,7 +11,6 @@ CANHandle *can_handler; DashStatus dashStatus; bool canReadyToSend; - void CANInitialize() { dashStatus = {0}; diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 21e4067db..36a75f03a 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -133,13 +133,16 @@ int main(void) msg_struct.RTDButton = dashStatus.RTDButton; // Kinda weird ngl but it doesn't matter - if (dashStatus.TSActiveButton) dashStatus.TSActiveButton = 0; - if (dashStatus.RTDButton) dashStatus.RTDButton = 0; + if (dashStatus.TSActiveButton) { + dashStatus.TSActiveButton = 0; + } + if (dashStatus.RTDButton) { + dashStatus.RTDButton = 0; + } CAN_sendECU(can_handler, &msg_struct); canReadyToSend = false; - } /* USER CODE BEGIN 3 */ } From 9858b60db8084322dbc751438da42e759267debd Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 21:45:05 -0800 Subject: [PATCH 19/95] include gr old node --- DashPanel/Application/Inc/CANdler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 2b43e58fd..e5f92a400 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,6 +1,7 @@ #ifndef CANDLER_H #define CANDLER_H #include "can.h" +#include "GR_OLD_NODE_ID.h" typedef struct { uint16_t vehicleSpeed; From 6f38b01475507b46f3782c754e73122d2dfc7780 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:46:09 +0000 Subject: [PATCH 20/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index e5f92a400..f02156000 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,7 +1,7 @@ #ifndef CANDLER_H #define CANDLER_H -#include "can.h" #include "GR_OLD_NODE_ID.h" +#include "can.h" typedef struct { uint16_t vehicleSpeed; From 5b06c357d3bdd5872d46f7b82843b383a292f01c Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 21:49:45 -0800 Subject: [PATCH 21/95] including stuff --- DashPanel/Application/Inc/CANdler.h | 4 ++++ DashPanel/CMakeLists.txt | 2 ++ 2 files changed, 6 insertions(+) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index f02156000..014416174 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,7 +1,11 @@ #ifndef CANDLER_H #define CANDLER_H #include "GR_OLD_NODE_ID.h" +<<<<<<< Updated upstream #include "can.h" +======= +#include "GR_OLD_MSG_ID.h" +>>>>>>> Stashed changes typedef struct { uint16_t vehicleSpeed; diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index 927279519..b52f34c7b 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -33,6 +33,8 @@ target_sources( Core/Src/sysmem.c Core/Src/system_stm32g4xx.c # Application + Application/Src/CANdler.c + Application/Src/dashutils.c # TODO ) From 33cb3a6704077e3da79eca62da47cb0541feceba Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:50:26 +0000 Subject: [PATCH 22/95] Automatic CMake Format: Standardized formatting automatically --- DashPanel/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index b52f34c7b..1c8b6621f 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -32,7 +32,7 @@ target_sources( Core/Src/syscalls.c Core/Src/sysmem.c Core/Src/system_stm32g4xx.c - # Application + # Application Application/Src/CANdler.c Application/Src/dashutils.c # TODO From 4a626a59f58d570876f9738408731860b31ae86e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:51:28 +0000 Subject: [PATCH 23/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 014416174..396b4add7 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -3,11 +3,11 @@ #include "GR_OLD_NODE_ID.h" <<<<<<< Updated upstream #include "can.h" -======= + ======= #include "GR_OLD_MSG_ID.h" ->>>>>>> Stashed changes + >>>>>>> Stashed changes -typedef struct { + typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; uint8_t TSActiveButton; From 06f232bb956c48704e10eddccda51075ee1136d4 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:52:32 +0000 Subject: [PATCH 24/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 396b4add7..d14152099 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -3,11 +3,12 @@ #include "GR_OLD_NODE_ID.h" <<<<<<< Updated upstream #include "can.h" - ======= + == == == + = #include "GR_OLD_MSG_ID.h" - >>>>>>> Stashed changes + >>>>>>> Stashed changes - typedef struct { + typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; uint8_t TSActiveButton; From 1c286cdd7856ff129233a94206f444564c09a5bb Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 23:09:23 -0800 Subject: [PATCH 25/95] yeah --- DashPanel/Application/Inc/CANdler.h | 4 +++- DashPanel/Application/Src/CANdler.c | 19 +++++++++++-------- DashPanel/CMakeLists.txt | 1 + DashPanel/DASHPLANEL.md | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index d14152099..db972946c 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,12 +1,14 @@ #ifndef CANDLER_H #define CANDLER_H #include "GR_OLD_NODE_ID.h" -<<<<<<< Updated upstream #include "can.h" +<<<<<<< Updated upstream == == == = #include "GR_OLD_MSG_ID.h" >>>>>>> Stashed changes +======= +>>>>>>> Stashed changes typedef struct { uint16_t vehicleSpeed; diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 4a39da2fa..1e33adc2f 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,19 +1,21 @@ #include "CANdler.h" +#include "main.h" #include "can.h" #include "dashutils.h" #include "stm32g4xx_hal_fdcan.h" +#include "GR_OLD_MSG_ID.h" +#include "GR_OLD_NODE_ID.h" -#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID -#define PING_ID 2 // ID of ping message - TODO: change with correct ID +#define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID +#define PING_ID MSG_PING // ID of ping message - TODO: change with correct ID CANHandle *can_handler; -DashStatus dashStatus; +DashStatus dashStatus = {0}; bool canReadyToSend; void CANInitialize() { - dashStatus = {0}; canReadyToSend = false; CANConfig canCfg; @@ -93,12 +95,13 @@ void CAN_callback(uint32_t ID, void *data, uint32_t size) { // Process data if (ID == ECU_ID) { - CAN_MSG_ECU *ecu_data = (CAN_MSG_ECU *)data; - dashStatus->vehicleSpeed = ecu_data->vehicleSpeed; - dashStatus->ECUState = ecu_data->ECUState; + CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; + dashStatus.vehicleSpeed = ecu_data->vehicleSpeed; + dashStatus.ECUState = ecu_data->ECUState; // Process data } else if (ID == PING_ID) { // process ping - CAN_sendPing(); + // TODO: fix ping + // CAN_sendPing(); } } diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index 1c8b6621f..98db91f73 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -43,6 +43,7 @@ target_link_libraries( INTERFACE GR_OLD_CAN_MESSAGES PERIPHERAL_CAN_LIB + CircularBuffer_Lib ) target_include_directories( diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index dd0a13a07..b1d942c16 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -14,7 +14,7 @@ ## Buttons 1. Test button interrupts -2. Move the CAN messages to grand loop + make global status + create CAN send flag +2. Actually set up CAN send and ping ## LED From 8ac5bdf27a8382d6d92d27552eb18328dd8f340c Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 23:12:00 -0800 Subject: [PATCH 26/95] get rid of git merge stuff --- DashPanel/Application/Inc/CANdler.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index db972946c..ab03d8d2b 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -2,13 +2,7 @@ #define CANDLER_H #include "GR_OLD_NODE_ID.h" #include "can.h" -<<<<<<< Updated upstream - == == == - = #include "GR_OLD_MSG_ID.h" - >>>>>>> Stashed changes -======= ->>>>>>> Stashed changes typedef struct { uint16_t vehicleSpeed; From ebcfe99173cc08041c99db11df0413db07989904 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 07:13:03 +0000 Subject: [PATCH 27/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 4 ++-- DashPanel/Application/Src/CANdler.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index ab03d8d2b..7b5b3e3c1 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,10 +1,10 @@ #ifndef CANDLER_H #define CANDLER_H +#include "GR_OLD_MSG_ID.h" #include "GR_OLD_NODE_ID.h" #include "can.h" -#include "GR_OLD_MSG_ID.h" - typedef struct { +typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; uint8_t TSActiveButton; diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 1e33adc2f..f8b6052af 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,13 +1,13 @@ #include "CANdler.h" -#include "main.h" +#include "GR_OLD_MSG_ID.h" +#include "GR_OLD_NODE_ID.h" #include "can.h" #include "dashutils.h" +#include "main.h" #include "stm32g4xx_hal_fdcan.h" -#include "GR_OLD_MSG_ID.h" -#include "GR_OLD_NODE_ID.h" -#define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID +#define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID #define PING_ID MSG_PING // ID of ping message - TODO: change with correct ID CANHandle *can_handler; From 8b68ad863ccd97ff86490ef597e6ea17b697c958 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Sat, 14 Feb 2026 02:16:49 -0800 Subject: [PATCH 28/95] Setup logomatic --- DashPanel/Core/Src/main.c | 104 +++++++------------------------------- 1 file changed, 17 insertions(+), 87 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 36a75f03a..0d08b22f9 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -19,6 +19,7 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" +#include "dashutils.h" #include "CANdler.h" /* Private includes ----------------------------------------------------------*/ @@ -44,13 +45,24 @@ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ - +LogomaticConfig logomaticConfig = {.clock_source = LOGOMATIC_PCLK1, + .bus = LOGOMATIC_BUS, + .gpio_port = LOGOMATIC_GPIOA, + .gpio_pin_rx_tx_mask = LL_GPIO_PIN_2 | LL_GPIO_PIN_3, + .baud_rate = 115200, + .data_width = LOGOMATIC_DATAWIDTH_8B, + .stop_bits = LOGOMATIC_STOPBITS_1, + .parity = LOGOMATIC_PARITY_NONE, + .transfer_direction = LOGOMATIC_DIRECTION_TX, + .hardware_flow_control = LOGOMATIC_HWCONTROL_NONE, + .prescaler = LOGOMATIC_PRESCALER_DIV1, + .tx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, + .rx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8}; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); -static void MX_LPUART1_UART_Init(void); static void GPIO_Interrupt_Init(void); /* USER CODE BEGIN PFP */ @@ -58,18 +70,7 @@ static void GPIO_Interrupt_Init(void); /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Enable stimulus port 0 */ - ITM->TER |= (1UL << 0); - /* Set trace control register */ - ITM->TCR |= ITM_TCR_ITMENA_Msk; -} /* USER CODE END 0 */ /** @@ -102,21 +103,20 @@ int main(void) /* USER CODE BEGIN Init */ CANInitialize(); GPIO_Interrupt_Init(); - + Setup_Logomatic(&logomaticConfig); /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ - + LOGOMATIC("Boot completed at %lu ms\n", MillisecondsSinceBoot()); /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); - MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ - ITM_Enable(); + /* USER CODE END 2 */ /* Infinite loop */ @@ -191,76 +191,6 @@ void SystemClock_Config(void) } } -/** - * @brief LPUART1 Initialization Function - * @param None - * @retval None - */ -static void MX_LPUART1_UART_Init(void) -{ - - /* USER CODE BEGIN LPUART1_Init 0 */ - - /* USER CODE END LPUART1_Init 0 */ - - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); - - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**LPUART1 GPIO Configuration - PC0 ------> LPUART1_RX - PC1 ------> LPUART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN LPUART1_Init 1 */ - - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); - - /* USER CODE BEGIN WKUPType LPUART1 */ - - /* USER CODE END WKUPType LPUART1 */ - - LL_LPUART_Enable(LPUART1); - - /* Polling LPUART1 initialisation */ - while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ -} - /** * @brief GPIO Initialization Function * @param None From 667505663c31c5e7e2f4903e836565744963743a Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Sat, 14 Feb 2026 02:17:17 -0800 Subject: [PATCH 29/95] Correct `#ifdef` to `#ifndef` for header guard for dash utils --- DashPanel/Application/Inc/dashutils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DashPanel/Application/Inc/dashutils.h b/DashPanel/Application/Inc/dashutils.h index e19e47ae4..c2df97745 100644 --- a/DashPanel/Application/Inc/dashutils.h +++ b/DashPanel/Application/Inc/dashutils.h @@ -1,4 +1,6 @@ -#ifdef DASHPANEL_UTILS_H +#include + +#ifndef DASHPANEL_UTILS_H #define DASHPANEL_UTILS_H uint32_t MillisecondsSinceBoot(void); From 16812514846c2a971fe6d7d816cea565ad1ed688 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Sat, 14 Feb 2026 02:21:34 -0800 Subject: [PATCH 30/95] Reset arbitrary changes to `G4PERTESTING` that should not be on this branch --- G4PERTESTING/Core/Inc/main.h | 1 - G4PERTESTING/Core/Src/main.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/G4PERTESTING/Core/Inc/main.h b/G4PERTESTING/Core/Inc/main.h index edc4c0b10..23d7ffce4 100644 --- a/G4PERTESTING/Core/Inc/main.h +++ b/G4PERTESTING/Core/Inc/main.h @@ -105,7 +105,6 @@ void Error_Handler(void); #define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ -extern CANHandle /* USER CODE END Private defines */ diff --git a/G4PERTESTING/Core/Src/main.c b/G4PERTESTING/Core/Src/main.c index ee28d20d0..ba6196726 100644 --- a/G4PERTESTING/Core/Src/main.c +++ b/G4PERTESTING/Core/Src/main.c @@ -105,8 +105,6 @@ int main(void) MX_TIM2_Init(); /* USER CODE BEGIN 2 */ - /* Initialize CAN interface */ - /* USER CODE END 2 */ /* Infinite loop */ From b529c0b55f06c7d82096c4bf2007c1cc0123235e Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 07:08:29 +0000 Subject: [PATCH 31/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 0d08b22f9..6d03b9284 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -19,8 +19,8 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" -#include "dashutils.h" #include "CANdler.h" +#include "dashutils.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ From d72a726a340d90423836bafdccb71b3440009c2a Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 12:15:19 +0000 Subject: [PATCH 32/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/syscalls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/syscalls.c b/DashPanel/Core/Src/syscalls.c index 6abf331cb..d2b217993 100644 --- a/DashPanel/Core/Src/syscalls.c +++ b/DashPanel/Core/Src/syscalls.c @@ -40,7 +40,10 @@ char **environ = __env; /* Functions */ void initialise_monitor_handles() {} -int _getpid(void) { return 1; } +int _getpid(void) +{ + return 1; +} int _kill(int pid, int sig) { From e22ae1d5ef4a9572ba30760ccb06bb46d6c8490a Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:43:58 -0800 Subject: [PATCH 33/95] Update build command in tasks.json to use presets Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- .vscode/tasks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 29b177bbe..2d4727490 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -34,7 +34,7 @@ "dependsOn": [ "CMake: configure" ], - "command": "cmake --build build/${command:cmake.activeBuildPresetName} --target DashPanel" + "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target DashPanel" }, { "label": "CMake: configure and build G4HELLO", From d6caf7c88f2adb8993560d68c1f364022d752b3e Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 17 Feb 2026 23:40:21 -0800 Subject: [PATCH 34/95] Mark size parameter in CAN callback as unused with a FIXME comment Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Application/Src/CANdler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index f8b6052af..c7bf3390e 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -5,6 +5,7 @@ #include "can.h" #include "dashutils.h" #include "main.h" +#include "Unused.h" #include "stm32g4xx_hal_fdcan.h" #define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID @@ -93,6 +94,8 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { + UNUSED(size) # FIXME Validate actual size versus expected size for different messages! + // Process data if (ID == ECU_ID) { CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; From 13f11190d5a68e89e84d904ad638aed45fd554e1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 07:41:22 +0000 Subject: [PATCH 35/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index c7bf3390e..4d170b8c5 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -2,10 +2,10 @@ #include "GR_OLD_MSG_ID.h" #include "GR_OLD_NODE_ID.h" +#include "Unused.h" #include "can.h" #include "dashutils.h" #include "main.h" -#include "Unused.h" #include "stm32g4xx_hal_fdcan.h" #define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID @@ -97,12 +97,15 @@ void CAN_callback(uint32_t ID, void *data, uint32_t size) UNUSED(size) # FIXME Validate actual size versus expected size for different messages! // Process data - if (ID == ECU_ID) { + if (ID == ECU_ID) + { CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; dashStatus.vehicleSpeed = ecu_data->vehicleSpeed; dashStatus.ECUState = ecu_data->ECUState; // Process data - } else if (ID == PING_ID) { + } + else if (ID == PING_ID) + { // process ping // TODO: fix ping // CAN_sendPing(); From a075d0631ca1ed1e3ff04a442fd80096ae61fda9 Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 17 Feb 2026 23:41:55 -0800 Subject: [PATCH 36/95] Fix comment Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 4d170b8c5..5d07381ec 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,7 +94,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size) # FIXME Validate actual size versus expected size for different messages! + UNUSED(size) // FIXME Validate actual size versus expected size for different messages! // Process data if (ID == ECU_ID) From 369dc2fa8ee43051c247395e304b59e2d59eda94 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 07:42:56 +0000 Subject: [PATCH 37/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 5d07381ec..32f5e7b70 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,18 +94,15 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size) // FIXME Validate actual size versus expected size for different messages! - + UNUSED(size) // FIXME Validate actual size versus expected size for different messages! + // Process data - if (ID == ECU_ID) - { + if (ID == ECU_ID) { CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; dashStatus.vehicleSpeed = ecu_data->vehicleSpeed; dashStatus.ECUState = ecu_data->ECUState; // Process data - } - else if (ID == PING_ID) - { + } else if (ID == PING_ID) { // process ping // TODO: fix ping // CAN_sendPing(); From bc7b02cac00ba4fa538c27e1e269ce5eb80e6dd5 Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 17 Feb 2026 23:44:23 -0800 Subject: [PATCH 38/95] Need sleep before committing tiny changes Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 32f5e7b70..e0114a238 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,7 +94,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size) // FIXME Validate actual size versus expected size for different messages! + UNUSED(size); // FIXME Validate actual size versus expected size for different messages! // Process data if (ID == ECU_ID) { From 7f0124ee0c2e072f8c9b00d9052a28ccb2cd0d38 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 07:45:25 +0000 Subject: [PATCH 39/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index e0114a238..92d96cdb1 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,7 +94,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size); // FIXME Validate actual size versus expected size for different messages! + UNUSED(size); // FIXME Validate actual size versus expected size for different messages! // Process data if (ID == ECU_ID) { From 121c66652ed107569944677f6cd336f69d37f00b Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Tue, 3 Feb 2026 12:52:38 -0800 Subject: [PATCH 40/95] Setup DashPanel base project with basic things -- currently untested physically --- .vscode/launch.json | 31 ++ .vscode/tasks.json | 9 + CMakeLists.txt | 1 + DashPanel/Application/Inc/empty.txt | 0 DashPanel/Application/Src/empty.txt | 0 DashPanel/CMakeLists.txt | 51 ++++ DashPanel/Core/Inc/main.h | 99 ++++++ DashPanel/Core/Inc/stm32_assert.h | 53 ++++ DashPanel/Core/Inc/stm32g4xx_hal_conf.h | 390 ++++++++++++++++++++++++ DashPanel/Core/Inc/stm32g4xx_it.h | 66 ++++ DashPanel/Core/Src/main.c | 346 +++++++++++++++++++++ DashPanel/Core/Src/stm32g4xx_it.c | 203 ++++++++++++ DashPanel/Core/Src/syscalls.c | 244 +++++++++++++++ DashPanel/Core/Src/sysmem.c | 87 ++++++ DashPanel/Core/Src/system_stm32g4xx.c | 285 +++++++++++++++++ DashPanel/README.md | 0 16 files changed, 1865 insertions(+) create mode 100644 DashPanel/Application/Inc/empty.txt create mode 100644 DashPanel/Application/Src/empty.txt create mode 100644 DashPanel/CMakeLists.txt create mode 100644 DashPanel/Core/Inc/main.h create mode 100644 DashPanel/Core/Inc/stm32_assert.h create mode 100644 DashPanel/Core/Inc/stm32g4xx_hal_conf.h create mode 100644 DashPanel/Core/Inc/stm32g4xx_it.h create mode 100644 DashPanel/Core/Src/main.c create mode 100644 DashPanel/Core/Src/stm32g4xx_it.c create mode 100644 DashPanel/Core/Src/syscalls.c create mode 100644 DashPanel/Core/Src/sysmem.c create mode 100644 DashPanel/Core/Src/system_stm32g4xx.c create mode 100644 DashPanel/README.md diff --git a/.vscode/launch.json b/.vscode/launch.json index d2c158491..13a32d88d 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -94,6 +94,37 @@ ] } }, + { + "cwd": "${workspaceFolder}", + "executable": "${command:cmake.buildDirectory}/DashPanel.elf", + "name": "DashPanel", + "request": "launch", + "type": "cortex-debug", + "servertype": "openocd", + "configFiles": [ + "interface/stlink.cfg", + "target/stm32g4x.cfg" + ], + "searchDir": [], + "preLaunchTask": "CMake: configure and build DashPanel", + "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}/G4HELLO.elf", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index da3d7ad1d..29b177bbe 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -27,6 +27,15 @@ ], "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target CCU" }, + { + "label": "CMake: configure and build DashPanel", + "type": "shell", + "dependsOrder": "sequence", + "dependsOn": [ + "CMake: configure" + ], + "command": "cmake --build build/${command:cmake.activeBuildPresetName} --target DashPanel" + }, { "label": "CMake: configure and build G4HELLO", "type": "shell", diff --git a/CMakeLists.txt b/CMakeLists.txt index ef62927ea..c0bcbfc74 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -66,6 +66,7 @@ message( add_gr_project(STM32G474xE ECU) add_gr_project(STM32G474xE CCU) add_gr_project(STM32G474xE AnalogCalibration) +add_gr_project(STM32G474xE DashPanel) # Development add_gr_project(STM32G474xE G4ADCTESTING) diff --git a/DashPanel/Application/Inc/empty.txt b/DashPanel/Application/Inc/empty.txt new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/Application/Src/empty.txt b/DashPanel/Application/Src/empty.txt new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt new file mode 100644 index 000000000..1c4b7412e --- /dev/null +++ b/DashPanel/CMakeLists.txt @@ -0,0 +1,51 @@ +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() + +# what, does in fact not get the filename of somthing but rather the name of the project from the path +get_filename_component(GR_PROJECT_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME) + +# Enable CMake support for ASM and C languages +enable_language( + C + ASM +) + +# Core project settings +project(${CMAKE_PROJECT_NAME}) + +add_library(${GR_PROJECT_NAME}_USER_CODE INTERFACE) +target_sources( + ${GR_PROJECT_NAME}_USER_CODE + INTERFACE + # Core + Core/Src/main.c + Core/Src/stm32g4xx_it.c + Core/Src/syscalls.c + Core/Src/sysmem.c + Core/Src/system_stm32g4xx.c + # Application + # TODO +) + +target_link_libraries( + ${GR_PROJECT_NAME}_USER_CODE + INTERFACE + GR_OLD_CAN_MESSAGES + PERIPHERAL_CAN_LIB +) + +target_include_directories( + ${GR_PROJECT_NAME}_USER_CODE + INTERFACE + Application/Inc + Core/Inc +) diff --git a/DashPanel/Core/Inc/main.h b/DashPanel/Core/Inc/main.h new file mode 100644 index 000000000..9a79f3367 --- /dev/null +++ b/DashPanel/Core/Inc/main.h @@ -0,0 +1,99 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __MAIN_H +#define __MAIN_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Includes ------------------------------------------------------------------*/ +#include "stm32g4xx_ll_lpuart.h" +#include "stm32g4xx_ll_rcc.h" +#include "stm32g4xx_ll_bus.h" +#include "stm32g4xx_ll_crs.h" +#include "stm32g4xx_ll_system.h" +#include "stm32g4xx_ll_exti.h" +#include "stm32g4xx_ll_cortex.h" +#include "stm32g4xx_ll_utils.h" +#include "stm32g4xx_ll_pwr.h" +#include "stm32g4xx_ll_dma.h" +#include "stm32g4xx_ll_gpio.h" + +#if defined(USE_FULL_ASSERT) +#include "stm32_assert.h" +#endif /* USE_FULL_ASSERT */ + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void Error_Handler(void); + +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +/* Private defines -----------------------------------------------------------*/ +#define TS_ACTIVE_BTN_Pin LL_GPIO_PIN_3 +#define TS_ACTIVE_BTN_GPIO_Port GPIOA +#define RTD_BTN_Pin LL_GPIO_PIN_4 +#define RTD_BTN_GPIO_Port GPIOA +#ifndef NVIC_PRIORITYGROUP_0 +#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, + 4 bits for subpriority */ +#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, + 3 bits for subpriority */ +#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, + 2 bits for subpriority */ +#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, + 1 bit for subpriority */ +#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, + 0 bit for subpriority */ +#endif + +/* USER CODE BEGIN Private defines */ + +/* USER CODE END Private defines */ + +#ifdef __cplusplus +} +#endif + +#endif /* __MAIN_H */ diff --git a/DashPanel/Core/Inc/stm32_assert.h b/DashPanel/Core/Inc/stm32_assert.h new file mode 100644 index 000000000..61631c41e --- /dev/null +++ b/DashPanel/Core/Inc/stm32_assert.h @@ -0,0 +1,53 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32_assert.h + * @author MCD Application Team + * @brief STM32 assert file. + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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 */ +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32_ASSERT_H +#define __STM32_ASSERT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ +/* Includes ------------------------------------------------------------------*/ +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32_ASSERT_H */ + diff --git a/DashPanel/Core/Inc/stm32g4xx_hal_conf.h b/DashPanel/Core/Inc/stm32g4xx_hal_conf.h new file mode 100644 index 000000000..51f16ecdd --- /dev/null +++ b/DashPanel/Core/Inc/stm32g4xx_hal_conf.h @@ -0,0 +1,390 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32g4xx_hal_conf.h + * @author MCD Application Team + * @brief HAL configuration file + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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 */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef STM32G4xx_HAL_CONF_H +#define STM32G4xx_HAL_CONF_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Exported types ------------------------------------------------------------*/ +/* Exported constants --------------------------------------------------------*/ + +/* ########################## Module Selection ############################## */ +/** + * @brief This is the list of modules to be used in the HAL driver + */ + +#define HAL_MODULE_ENABLED + +/*#define HAL_ADC_MODULE_ENABLED */ +/*#define HAL_COMP_MODULE_ENABLED */ +/*#define HAL_CORDIC_MODULE_ENABLED */ +/*#define HAL_CRC_MODULE_ENABLED */ +/*#define HAL_CRYP_MODULE_ENABLED */ +/*#define HAL_DAC_MODULE_ENABLED */ +#define HAL_FDCAN_MODULE_ENABLED +/*#define HAL_FMAC_MODULE_ENABLED */ +/*#define HAL_HRTIM_MODULE_ENABLED */ +/*#define HAL_IRDA_MODULE_ENABLED */ +/*#define HAL_IWDG_MODULE_ENABLED */ +/*#define HAL_I2C_MODULE_ENABLED */ +/*#define HAL_I2S_MODULE_ENABLED */ +/*#define HAL_LPTIM_MODULE_ENABLED */ +/*#define HAL_NAND_MODULE_ENABLED */ +/*#define HAL_NOR_MODULE_ENABLED */ +/*#define HAL_OPAMP_MODULE_ENABLED */ +/*#define HAL_PCD_MODULE_ENABLED */ +/*#define HAL_QSPI_MODULE_ENABLED */ +/*#define HAL_RNG_MODULE_ENABLED */ +/*#define HAL_RTC_MODULE_ENABLED */ +/*#define HAL_SAI_MODULE_ENABLED */ +/*#define HAL_SMARTCARD_MODULE_ENABLED */ +/*#define HAL_SMBUS_MODULE_ENABLED */ +/*#define HAL_SPI_MODULE_ENABLED */ +/*#define HAL_SRAM_MODULE_ENABLED */ +/*#define HAL_TIM_MODULE_ENABLED */ +/*#define HAL_UART_MODULE_ENABLED */ +/*#define HAL_USART_MODULE_ENABLED */ +/*#define HAL_WWDG_MODULE_ENABLED */ +#define HAL_GPIO_MODULE_ENABLED +/*#define HAL_EXTI_MODULE_ENABLED */ +/*#define HAL_DMA_MODULE_ENABLED */ +#define HAL_RCC_MODULE_ENABLED +#define HAL_FLASH_MODULE_ENABLED +#define HAL_PWR_MODULE_ENABLED +#define HAL_CORTEX_MODULE_ENABLED + +/* ########################## Register Callbacks selection + * ############################## */ +/** + * @brief This is the list of modules where register callback can be used + */ +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U +#define USE_HAL_COMP_REGISTER_CALLBACKS 0U +#define USE_HAL_CORDIC_REGISTER_CALLBACKS 0U +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U +#define USE_HAL_EXTI_REGISTER_CALLBACKS 0U +#define USE_HAL_FDCAN_REGISTER_CALLBACKS 0U +#define USE_HAL_FMAC_REGISTER_CALLBACKS 0U +#define USE_HAL_HRTIM_REGISTER_CALLBACKS 0U +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U +#define USE_HAL_OPAMP_REGISTER_CALLBACKS 0U +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U +#define USE_HAL_UART_REGISTER_CALLBACKS 0U +#define USE_HAL_USART_REGISTER_CALLBACKS 0U +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U + +/* ########################## Oscillator Values adaptation + * ####################*/ +/** + * @brief Adjust the value of External High Speed oscillator (HSE) used in your + * application. This value is used by the RCC HAL module to compute the system + * frequency (when HSE is used as system clock source, directly or through the + * PLL). + */ +#if !defined(HSE_VALUE) +#define HSE_VALUE (16000000UL) /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined(HSE_STARTUP_TIMEOUT) +#define HSE_STARTUP_TIMEOUT (100UL) /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ + +/** + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system + * frequency (when HSI is used as system clock source, directly or through the + * PLL). + */ +#if !defined(HSI_VALUE) +#define HSI_VALUE (16000000UL) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @brief Internal High Speed oscillator (HSI48) value for USB FS and RNG. + * This internal oscillator is mainly dedicated to provide a high + * precision clock to the USB peripheral by means of a special Clock Recovery + * System (CRS) circuitry. When the CRS is not used, the HSI48 RC oscillator + * runs on it default frequency which is subject to manufacturing process + * variations. + */ +#if !defined(HSI48_VALUE) +#define HSI48_VALUE \ + (48000000UL) /*!< Value of the Internal High Speed oscillator for USB \ + FS/RNG in Hz. The real value my vary depending on \ + manufacturing process variations.*/ +#endif /* HSI48_VALUE */ + +/** + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined(LSI_VALUE) +/*!< Value of the Internal Low Speed oscillator in Hz +The real value may vary depending on the variations in voltage and +temperature.*/ +#define LSI_VALUE (32000UL) /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ +/** + * @brief External Low Speed oscillator (LSE) value. + * This value is used by the UART, RTC HAL module to compute the system + * frequency + */ +#if !defined(LSE_VALUE) +#define LSE_VALUE (32768UL) /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ + +#if !defined(LSE_STARTUP_TIMEOUT) +#define LSE_STARTUP_TIMEOUT (5000UL) /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ + +/** + * @brief External clock source for I2S and SAI peripherals + * This value is used by the I2S and SAI HAL modules to compute the I2S + * and SAI clock source frequency, this source is inserted directly through + * I2S_CKIN pad. + */ +#if !defined(EXTERNAL_CLOCK_VALUE) +#define EXTERNAL_CLOCK_VALUE (12288000UL) /*!< Value of the External oscillator in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ + +/* Tip: To avoid modifying this file each time you need to use different HSE, + === you can define the HSE value in your toolchain compiler preprocessor. */ + +/* ########################### System Configuration ######################### */ +/** + * @brief This is the HAL system configuration section + */ + +#define VDD_VALUE (3300UL) /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY (15UL) /*!< tick interrupt priority (lowest by default) */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 0U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +/* ########################## Assert Selection ############################## */ +/** + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ +/* #define USE_FULL_ASSERT 1U */ + +/* ################## SPI peripheral configuration ########################## */ + +/* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver + * Activated: CRC code is present inside driver + * Deactivated: CRC code cleaned from driver + */ + +#define USE_SPI_CRC 0U + +/* Includes ------------------------------------------------------------------*/ +/** + * @brief Include module's header file + */ + +#ifdef HAL_RCC_MODULE_ENABLED +#include "stm32g4xx_hal_rcc.h" +#endif /* HAL_RCC_MODULE_ENABLED */ + +#ifdef HAL_GPIO_MODULE_ENABLED +#include "stm32g4xx_hal_gpio.h" +#endif /* HAL_GPIO_MODULE_ENABLED */ + +#ifdef HAL_DMA_MODULE_ENABLED +#include "stm32g4xx_hal_dma.h" +#endif /* HAL_DMA_MODULE_ENABLED */ + +#ifdef HAL_CORTEX_MODULE_ENABLED +#include "stm32g4xx_hal_cortex.h" +#endif /* HAL_CORTEX_MODULE_ENABLED */ + +#ifdef HAL_ADC_MODULE_ENABLED +#include "stm32g4xx_hal_adc.h" +#endif /* HAL_ADC_MODULE_ENABLED */ + +#ifdef HAL_COMP_MODULE_ENABLED +#include "stm32g4xx_hal_comp.h" +#endif /* HAL_COMP_MODULE_ENABLED */ + +#ifdef HAL_CORDIC_MODULE_ENABLED +#include "stm32g4xx_hal_cordic.h" +#endif /* HAL_CORDIC_MODULE_ENABLED */ + +#ifdef HAL_CRC_MODULE_ENABLED +#include "stm32g4xx_hal_crc.h" +#endif /* HAL_CRC_MODULE_ENABLED */ + +#ifdef HAL_CRYP_MODULE_ENABLED +#include "stm32g4xx_hal_cryp.h" +#endif /* HAL_CRYP_MODULE_ENABLED */ + +#ifdef HAL_DAC_MODULE_ENABLED +#include "stm32g4xx_hal_dac.h" +#endif /* HAL_DAC_MODULE_ENABLED */ + +#ifdef HAL_EXTI_MODULE_ENABLED +#include "stm32g4xx_hal_exti.h" +#endif /* HAL_EXTI_MODULE_ENABLED */ + +#ifdef HAL_FDCAN_MODULE_ENABLED +#include "stm32g4xx_hal_fdcan.h" +#endif /* HAL_FDCAN_MODULE_ENABLED */ + +#ifdef HAL_FLASH_MODULE_ENABLED +#include "stm32g4xx_hal_flash.h" +#endif /* HAL_FLASH_MODULE_ENABLED */ + +#ifdef HAL_FMAC_MODULE_ENABLED +#include "stm32g4xx_hal_fmac.h" +#endif /* HAL_FMAC_MODULE_ENABLED */ + +#ifdef HAL_HRTIM_MODULE_ENABLED +#include "stm32g4xx_hal_hrtim.h" +#endif /* HAL_HRTIM_MODULE_ENABLED */ + +#ifdef HAL_IRDA_MODULE_ENABLED +#include "stm32g4xx_hal_irda.h" +#endif /* HAL_IRDA_MODULE_ENABLED */ + +#ifdef HAL_IWDG_MODULE_ENABLED +#include "stm32g4xx_hal_iwdg.h" +#endif /* HAL_IWDG_MODULE_ENABLED */ + +#ifdef HAL_I2C_MODULE_ENABLED +#include "stm32g4xx_hal_i2c.h" +#endif /* HAL_I2C_MODULE_ENABLED */ + +#ifdef HAL_I2S_MODULE_ENABLED +#include "stm32g4xx_hal_i2s.h" +#endif /* HAL_I2S_MODULE_ENABLED */ + +#ifdef HAL_LPTIM_MODULE_ENABLED +#include "stm32g4xx_hal_lptim.h" +#endif /* HAL_LPTIM_MODULE_ENABLED */ + +#ifdef HAL_NAND_MODULE_ENABLED +#include "stm32g4xx_hal_nand.h" +#endif /* HAL_NAND_MODULE_ENABLED */ + +#ifdef HAL_NOR_MODULE_ENABLED +#include "stm32g4xx_hal_nor.h" +#endif /* HAL_NOR_MODULE_ENABLED */ + +#ifdef HAL_OPAMP_MODULE_ENABLED +#include "stm32g4xx_hal_opamp.h" +#endif /* HAL_OPAMP_MODULE_ENABLED */ + +#ifdef HAL_PCD_MODULE_ENABLED +#include "stm32g4xx_hal_pcd.h" +#endif /* HAL_PCD_MODULE_ENABLED */ + +#ifdef HAL_PWR_MODULE_ENABLED +#include "stm32g4xx_hal_pwr.h" +#endif /* HAL_PWR_MODULE_ENABLED */ + +#ifdef HAL_QSPI_MODULE_ENABLED +#include "stm32g4xx_hal_qspi.h" +#endif /* HAL_QSPI_MODULE_ENABLED */ + +#ifdef HAL_RNG_MODULE_ENABLED +#include "stm32g4xx_hal_rng.h" +#endif /* HAL_RNG_MODULE_ENABLED */ + +#ifdef HAL_RTC_MODULE_ENABLED +#include "stm32g4xx_hal_rtc.h" +#endif /* HAL_RTC_MODULE_ENABLED */ + +#ifdef HAL_SAI_MODULE_ENABLED +#include "stm32g4xx_hal_sai.h" +#endif /* HAL_SAI_MODULE_ENABLED */ + +#ifdef HAL_SMARTCARD_MODULE_ENABLED +#include "stm32g4xx_hal_smartcard.h" +#endif /* HAL_SMARTCARD_MODULE_ENABLED */ + +#ifdef HAL_SMBUS_MODULE_ENABLED +#include "stm32g4xx_hal_smbus.h" +#endif /* HAL_SMBUS_MODULE_ENABLED */ + +#ifdef HAL_SPI_MODULE_ENABLED +#include "stm32g4xx_hal_spi.h" +#endif /* HAL_SPI_MODULE_ENABLED */ + +#ifdef HAL_SRAM_MODULE_ENABLED +#include "stm32g4xx_hal_sram.h" +#endif /* HAL_SRAM_MODULE_ENABLED */ + +#ifdef HAL_TIM_MODULE_ENABLED +#include "stm32g4xx_hal_tim.h" +#endif /* HAL_TIM_MODULE_ENABLED */ + +#ifdef HAL_UART_MODULE_ENABLED +#include "stm32g4xx_hal_uart.h" +#endif /* HAL_UART_MODULE_ENABLED */ + +#ifdef HAL_USART_MODULE_ENABLED +#include "stm32g4xx_hal_usart.h" +#endif /* HAL_USART_MODULE_ENABLED */ + +#ifdef HAL_WWDG_MODULE_ENABLED +#include "stm32g4xx_hal_wwdg.h" +#endif /* HAL_WWDG_MODULE_ENABLED */ + +/* Exported macro ------------------------------------------------------------*/ +#ifdef USE_FULL_ASSERT +/** + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ +#define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) +/* Exported functions ------------------------------------------------------- */ +void assert_failed(uint8_t *file, uint32_t line); +#else +#define assert_param(expr) ((void)0U) +#endif /* USE_FULL_ASSERT */ + +#ifdef __cplusplus +} +#endif + +#endif /* STM32G4xx_HAL_CONF_H */ diff --git a/DashPanel/Core/Inc/stm32g4xx_it.h b/DashPanel/Core/Inc/stm32g4xx_it.h new file mode 100644 index 000000000..1a144ad22 --- /dev/null +++ b/DashPanel/Core/Inc/stm32g4xx_it.h @@ -0,0 +1,66 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32g4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ + +/* Define to prevent recursive inclusion -------------------------------------*/ +#ifndef __STM32G4xx_IT_H +#define __STM32G4xx_IT_H + +#ifdef __cplusplus +extern "C" { +#endif + +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ + +/* USER CODE END Includes */ + +/* Exported types ------------------------------------------------------------*/ +/* USER CODE BEGIN ET */ + +/* USER CODE END ET */ + +/* Exported constants --------------------------------------------------------*/ +/* USER CODE BEGIN EC */ + +/* USER CODE END EC */ + +/* Exported macro ------------------------------------------------------------*/ +/* USER CODE BEGIN EM */ + +/* USER CODE END EM */ + +/* Exported functions prototypes ---------------------------------------------*/ +void NMI_Handler(void); +void HardFault_Handler(void); +void MemManage_Handler(void); +void BusFault_Handler(void); +void UsageFault_Handler(void); +void SVC_Handler(void); +void DebugMon_Handler(void); +void PendSV_Handler(void); +void SysTick_Handler(void); +/* USER CODE BEGIN EFP */ + +/* USER CODE END EFP */ + +#ifdef __cplusplus +} +#endif + +#endif /* __STM32G4xx_IT_H */ diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c new file mode 100644 index 000000000..b3f940679 --- /dev/null +++ b/DashPanel/Core/Src/main.c @@ -0,0 +1,346 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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" + +/* 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); +static void MX_GPIO_Init(void); +static void MX_LPUART1_UART_Init(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) +{ + /* Enable TRC (Trace) */ + CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; + + /* Enable stimulus port 0 */ + ITM->TER |= (1UL << 0); + + /* Set trace control register */ + ITM->TCR |= ITM_TCR_ITMENA_Msk; +} +/* 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. */ + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); + + /* System interrupt init*/ + NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); + + /* SysTick_IRQn interrupt configuration */ + NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),15, 0)); + + /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral + */ + LL_PWR_DisableUCPDDeadBattery(); + + /* USER CODE BEGIN Init */ + + /* 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_LPUART1_UART_Init(); + /* USER CODE BEGIN 2 */ + + /* USER CODE END 2 */ + + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { + /* USER CODE END WHILE */ + LOGOMATIC("Hello from DashPanel!\n"); + LL_mDelay(1000); + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ +} + +/** + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); + while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) + { + } + LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); + LL_RCC_HSI_Enable(); + /* Wait till HSI is ready */ + while(LL_RCC_HSI_IsReady() != 1) + { + } + + LL_RCC_HSI_SetCalibTrimming(64); + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); + /* Wait till System clock is ready */ + while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) + { + } + + /* 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_Init1msTick(16000000); + + LL_SetSystemCoreClock(16000000); +} + +/** + * @brief LPUART1 Initialization Function + * @param None + * @retval None + */ +static void MX_LPUART1_UART_Init(void) +{ + + /* USER CODE BEGIN LPUART1_Init 0 */ + + /* USER CODE END LPUART1_Init 0 */ + + LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; + + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + + LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); + + /* Peripheral clock enable */ + LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); + + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + /**LPUART1 GPIO Configuration + PC0 ------> LPUART1_RX + PC1 ------> LPUART1_TX + */ + GPIO_InitStruct.Pin = LL_GPIO_PIN_0; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + GPIO_InitStruct.Pin = LL_GPIO_PIN_1; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN LPUART1_Init 1 */ + + /* USER CODE END LPUART1_Init 1 */ + LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; + LPUART_InitStruct.BaudRate = 115200; + LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; + LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; + LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; + LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; + LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; + LL_LPUART_Init(LPUART1, &LPUART_InitStruct); + LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_DisableFIFO(LPUART1); + + /* USER CODE BEGIN WKUPType LPUART1 */ + + /* USER CODE END WKUPType LPUART1 */ + + LL_LPUART_Enable(LPUART1); + + /* Polling LPUART1 initialisation */ + while((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) + { + } + /* USER CODE BEGIN LPUART1_Init 2 */ + + /* USER CODE END LPUART1_Init 2 */ + +} + +/** + * @brief GPIO Initialization Function + * @param None + * @retval None + */ +static void MX_GPIO_Init(void) +{ + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + /* USER CODE BEGIN MX_GPIO_Init_1 */ + + /* USER CODE END MX_GPIO_Init_1 */ + + /* GPIO Ports Clock Enable */ + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_6); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7); + + /**/ + LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_4); + + /**/ + GPIO_InitStruct.Pin = TS_ACTIVE_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(TS_ACTIVE_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = RTD_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(RTD_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_5; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_6; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_7; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_4; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN MX_GPIO_Init_2 */ + + /* USER CODE END MX_GPIO_Init_2 */ +} + +/* 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 */ diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c new file mode 100644 index 000000000..2f115be65 --- /dev/null +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -0,0 +1,203 @@ +/* USER CODE BEGIN Header */ +/** + ****************************************************************************** + * @file stm32g4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 "stm32g4xx_it.h" +/* Private includes ----------------------------------------------------------*/ +/* USER CODE BEGIN Includes */ +/* USER CODE END Includes */ + +/* Private typedef -----------------------------------------------------------*/ +/* USER CODE BEGIN TD */ + +/* USER CODE END TD */ + +/* 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 -----------------------------------------------*/ +/* USER CODE BEGIN PFP */ + +/* USER CODE END PFP */ + +/* Private user code ---------------------------------------------------------*/ +/* USER CODE BEGIN 0 */ + +/* USER CODE END 0 */ + +/* External variables --------------------------------------------------------*/ + +/* USER CODE BEGIN EV */ + +/* USER CODE END EV */ + +/******************************************************************************/ +/* Cortex-M4 Processor Interruption and Exception Handlers */ +/******************************************************************************/ +/** + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + while (1) + { + } + /* USER CODE END NonMaskableInt_IRQn 1 */ +} + +/** + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Memory management fault. + */ +void MemManage_Handler(void) +{ + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } +} + +/** + * @brief This function handles Prefetch fault, memory access fault. + */ +void BusFault_Handler(void) +{ + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } +} + +/** + * @brief This function handles Undefined instruction or illegal state. + */ +void UsageFault_Handler(void) +{ + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } +} + +/** + * @brief This function handles System service call via SWI instruction. + */ +void SVC_Handler(void) +{ + /* USER CODE BEGIN SVCall_IRQn 0 */ + + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ + + /* USER CODE END SVCall_IRQn 1 */ +} + +/** + * @brief This function handles Debug monitor. + */ +void DebugMon_Handler(void) +{ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + + /* USER CODE END DebugMonitor_IRQn 1 */ +} + +/** + * @brief This function handles Pendable request for system service. + */ +void PendSV_Handler(void) +{ + /* USER CODE BEGIN PendSV_IRQn 0 */ + + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ + + /* USER CODE END PendSV_IRQn 1 */ +} + +/** + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + + /* USER CODE BEGIN SysTick_IRQn 1 */ + + /* USER CODE END SysTick_IRQn 1 */ +} + +/******************************************************************************/ +/* STM32G4xx Peripheral Interrupt Handlers */ +/* Add here the Interrupt Handlers for the used peripherals. */ +/* For the available peripheral interrupt handler names, */ +/* please refer to the startup file (startup_stm32g4xx.s). */ +/******************************************************************************/ + +/* USER CODE BEGIN 1 */ + +/* USER CODE END 1 */ diff --git a/DashPanel/Core/Src/syscalls.c b/DashPanel/Core/Src/syscalls.c new file mode 100644 index 000000000..e10d76fa2 --- /dev/null +++ b/DashPanel/Core/Src/syscalls.c @@ -0,0 +1,244 @@ +/** + ****************************************************************************** + * @file syscalls.c + * @author Auto-generated by STM32CubeMX + * @brief Minimal System calls file + * + * For more information about which c-functions + * need which of these lowlevel functions + * please consult the Newlib or Picolibc libc-manual + ****************************************************************************** + * @attention + * + * Copyright (c) 2020-2025 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. + * + ****************************************************************************** + */ + +/* Includes */ +#include +#include +#include +#include +#include +#include +#include +#include + + +/* Variables */ +extern int __io_putchar(int ch) __attribute__((weak)); +extern int __io_getchar(void) __attribute__((weak)); + + +char *__env[1] = { 0 }; +char **environ = __env; + + +/* Functions */ +void initialise_monitor_handles() +{ +} + +int _getpid(void) +{ + return 1; +} + +int _kill(int pid, int sig) +{ + (void)pid; + (void)sig; + errno = EINVAL; + return -1; +} + +void _exit (int status) +{ + _kill(status, -1); + while (1) {} /* Make sure we hang here */ +} + +__attribute__((weak)) int _read(int file, char *ptr, int len) +{ + (void)file; + int DataIdx; + + for (DataIdx = 0; DataIdx < len; DataIdx++) + { + *ptr++ = __io_getchar(); + } + + return len; +} + +__attribute__((weak)) int _write(int file, char *ptr, int len) +{ + (void)file; + int DataIdx; + + for (DataIdx = 0; DataIdx < len; DataIdx++) + { + __io_putchar(*ptr++); + } + return len; +} + +int _close(int file) +{ + (void)file; + return -1; +} + + +int _fstat(int file, struct stat *st) +{ + (void)file; + st->st_mode = S_IFCHR; + return 0; +} + +int _isatty(int file) +{ + (void)file; + return 1; +} + +int _lseek(int file, int ptr, int dir) +{ + (void)file; + (void)ptr; + (void)dir; + return 0; +} + +int _open(char *path, int flags, ...) +{ + (void)path; + (void)flags; + /* Pretend like we always fail */ + return -1; +} + +int _wait(int *status) +{ + (void)status; + errno = ECHILD; + return -1; +} + +int _unlink(char *name) +{ + (void)name; + errno = ENOENT; + return -1; +} + +clock_t _times(struct tms *buf) +{ + (void)buf; + return -1; +} + +int _stat(const char *file, struct stat *st) +{ + (void)file; + st->st_mode = S_IFCHR; + return 0; +} + +int _link(char *old, char *new) +{ + (void)old; + (void)new; + errno = EMLINK; + return -1; +} + +int _fork(void) +{ + errno = EAGAIN; + return -1; +} + +int _execve(char *name, char **argv, char **env) +{ + (void)name; + (void)argv; + (void)env; + errno = ENOMEM; + return -1; +} + +// --- Picolibc Specific Section --- +#if defined(__PICOLIBC__) + +/** + * @brief Picolibc helper function to output a character to a FILE stream. + * This redirects the output to the low-level __io_putchar function. + * @param c Character to write. + * @param file FILE stream pointer (ignored). + * @retval int The character written. + */ +static int starm_putc(char c, FILE *file) +{ + (void) file; + __io_putchar(c); + return c; +} + +/** + * @brief Picolibc helper function to input a character from a FILE stream. + * This redirects the input from the low-level __io_getchar function. + * @param file FILE stream pointer (ignored). + * @retval int The character read, cast to an unsigned char then int. + */ +static int starm_getc(FILE *file) +{ + unsigned char c; + (void) file; + c = __io_getchar(); + return c; +} + +// Define and initialize the standard I/O streams for Picolibc. +// FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to a FILE structure. +// _FDEV_SETUP_RW indicates the stream is for reading and writing. +static FILE __stdio = FDEV_SETUP_STREAM(starm_putc, + starm_getc, + NULL, + _FDEV_SETUP_RW); + +// Assign the standard stream pointers (stdin, stdout, stderr) to the initialized stream. +// Picolibc uses these pointers for standard I/O operations (printf, scanf, etc.). +FILE *const stdin = &__stdio; +__strong_reference(stdin, stdout); +__strong_reference(stdin, stderr); + +// Create strong aliases mapping standard C library function names (without underscore) +// to the implemented system call stubs (with underscore). Picolibc uses these +// standard names internally, so this linking is required. +__strong_reference(_read, read); +__strong_reference(_write, write); +__strong_reference(_times, times); +__strong_reference(_execve, execve); +__strong_reference(_fork, fork); +__strong_reference(_link, link); +__strong_reference(_unlink, unlink); +__strong_reference(_stat, stat); +__strong_reference(_wait, wait); +__strong_reference(_open, open); +__strong_reference(_close, close); +__strong_reference(_lseek, lseek); +__strong_reference(_isatty, isatty); +__strong_reference(_fstat, fstat); +__strong_reference(_exit, exit); +__strong_reference(_kill, kill); +__strong_reference(_getpid, getpid); + +#endif //__PICOLIBC__ diff --git a/DashPanel/Core/Src/sysmem.c b/DashPanel/Core/Src/sysmem.c new file mode 100644 index 000000000..a875d42c0 --- /dev/null +++ b/DashPanel/Core/Src/sysmem.c @@ -0,0 +1,87 @@ +/** + ****************************************************************************** + * @file sysmem.c + * @author Generated by STM32CubeMX + * @brief System Memory calls file + * + * For more information about which C functions + * need which of these lowlevel functions + * please consult the Newlib or Picolibc libc manual + ****************************************************************************** + * @attention + * + * Copyright (c) 2025 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. + * + ****************************************************************************** + */ + +/* Includes */ +#include +#include +#include + +/** + * Pointer to the current high watermark of the heap usage + */ +static uint8_t *__sbrk_heap_end = NULL; + +/** + * @brief _sbrk() allocates memory to the newlib heap and is used by malloc + * and others from the C library + * + * @verbatim + * ############################################################################ + * # .data # .bss # newlib heap # MSP stack # + * # # # # Reserved by _Min_Stack_Size # + * ############################################################################ + * ^-- RAM start ^-- _end _estack, RAM end --^ + * @endverbatim + * + * This implementation starts allocating at the '_end' linker symbol + * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack + * The implementation considers '_estack' linker symbol to be RAM end + * NOTE: If the MSP stack, at any point during execution, grows larger than the + * reserved size, please increase the '_Min_Stack_Size'. + * + * @param incr Memory size + * @return Pointer to allocated memory + */ +void *_sbrk(ptrdiff_t incr) +{ + extern uint8_t _end; /* Symbol defined in the linker script */ + extern uint8_t _estack; /* Symbol defined in the linker script */ + extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ + const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; + const uint8_t *max_heap = (uint8_t *)stack_limit; + uint8_t *prev_heap_end; + + /* Initialize heap end at first call */ + if (NULL == __sbrk_heap_end) + { + __sbrk_heap_end = &_end; + } + + /* Protect heap from growing into the reserved MSP stack */ + if (__sbrk_heap_end + incr > max_heap) + { + errno = ENOMEM; + return (void *)-1; + } + + prev_heap_end = __sbrk_heap_end; + __sbrk_heap_end += incr; + + return (void *)prev_heap_end; +} + +#if defined(__PICOLIBC__) + // Picolibc expects syscalls without the leading underscore. + // This creates a strong alias so that + // calls to `sbrk()` are resolved to our `_sbrk()` implementation. + __strong_reference(_sbrk, sbrk); +#endif diff --git a/DashPanel/Core/Src/system_stm32g4xx.c b/DashPanel/Core/Src/system_stm32g4xx.c new file mode 100644 index 000000000..922e57abc --- /dev/null +++ b/DashPanel/Core/Src/system_stm32g4xx.c @@ -0,0 +1,285 @@ +/** + ****************************************************************************** + * @file system_stm32g4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32g4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the HSI (16 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | HSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * PLL_M | 1 + *----------------------------------------------------------------------------- + * PLL_N | 16 + *----------------------------------------------------------------------------- + * PLL_P | 7 + *----------------------------------------------------------------------------- + * PLL_Q | 2 + *----------------------------------------------------------------------------- + * PLL_R | 2 + *----------------------------------------------------------------------------- + * Require 48MHz for RNG | Disabled + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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. + * + ****************************************************************************** + */ + +/** @addtogroup CMSIS + * @{ + */ + +/** @addtogroup stm32g4xx_system + * @{ + */ + +/** @addtogroup STM32G4xx_System_Private_Includes + * @{ + */ + +#include "stm32g4xx.h" + +#if !defined (HSE_VALUE) + #define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSI_VALUE) + #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_TypesDefinitions + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Defines + * @{ + */ + +/************************* Miscellaneous Configuration ************************/ +/* Note: Following vector table addresses must be defined in line with linker + configuration. */ +/*!< Uncomment the following line if you need to relocate the vector table + anywhere in Flash or Sram, else the vector table is kept at the automatic + remap of boot address selected */ +/* #define USER_VECT_TAB_ADDRESS */ + +#if defined(USER_VECT_TAB_ADDRESS) +/*!< Uncomment the following line if you need to relocate your vector Table + in Sram else user remap will be done in Flash. */ +/* #define VECT_TAB_SRAM */ +#if defined(VECT_TAB_SRAM) +#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +#else +#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. + This value must be a multiple of 0x200. */ +#endif /* VECT_TAB_SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ +/******************************************************************************/ +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Macros + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Variables + * @{ + */ + /* The SystemCoreClock variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. + */ + uint32_t SystemCoreClock = HSI_VALUE; + + const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; + const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_FunctionPrototypes + * @{ + */ + +/** + * @} + */ + +/** @addtogroup STM32G4xx_System_Private_Functions + * @{ + */ + +/** + * @brief Setup the microcontroller system. + * @param None + * @retval None + */ + +void SystemInit(void) +{ + /* FPU settings ------------------------------------------------------------*/ + #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ + #endif + + /* Configure the Vector Table location add offset address ------------------*/ +#if defined(USER_VECT_TAB_ADDRESS) + SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ +} + +/** + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 24 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ +void SystemCoreClockUpdate(void) +{ + uint32_t tmp, pllvco, pllr, pllsource, pllm; + + /* Get SYSCLK source -------------------------------------------------------*/ + switch (RCC->CFGR & RCC_CFGR_SWS) + { + case 0x04: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + + case 0x08: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + + case 0x0C: /* PLL used as system clock source */ + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); + pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U ; + if (pllsource == 0x02UL) /* HSI used as PLL clock source */ + { + pllvco = (HSI_VALUE / pllm); + } + else /* HSE used as PLL clock source */ + { + pllvco = (HSE_VALUE / pllm); + } + pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); + pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; + SystemCoreClock = pllvco/pllr; + break; + + default: + break; + } + /* Compute HCLK clock frequency --------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; +} + + +/** + * @} + */ + +/** + * @} + */ + +/** + * @} + */ + + diff --git a/DashPanel/README.md b/DashPanel/README.md new file mode 100644 index 000000000..e69de29bb From 16d6ec7692c7d2a2081adee9a7bd1a4d66e116e7 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 20:55:25 +0000 Subject: [PATCH 41/95] Automatic CMake Format: Standardized formatting automatically --- DashPanel/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index 1c4b7412e..927279519 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -32,8 +32,8 @@ target_sources( Core/Src/syscalls.c Core/Src/sysmem.c Core/Src/system_stm32g4xx.c - # Application - # TODO + # Application + # TODO ) target_link_libraries( From 3f9304ec58fd98e14bd8ced6adc3b5105749e920 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 20:56:44 +0000 Subject: [PATCH 42/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Inc/main.h | 71 +++-- DashPanel/Core/Inc/stm32_assert.h | 49 ++- DashPanel/Core/Inc/stm32g4xx_it.h | 30 +- DashPanel/Core/Src/main.c | 440 +++++++++++++------------- DashPanel/Core/Src/stm32g4xx_it.c | 175 +++++----- DashPanel/Core/Src/syscalls.c | 150 ++++----- DashPanel/Core/Src/sysmem.c | 48 ++- DashPanel/Core/Src/system_stm32g4xx.c | 437 +++++++++++++------------ 8 files changed, 685 insertions(+), 715 deletions(-) diff --git a/DashPanel/Core/Inc/main.h b/DashPanel/Core/Inc/main.h index 9a79f3367..5ee9090c2 100644 --- a/DashPanel/Core/Inc/main.h +++ b/DashPanel/Core/Inc/main.h @@ -1,21 +1,21 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file : main.h - * @brief : Header for main.c file. - * This file contains the common defines of the application. - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file : main.h + * @brief : Header for main.c file. + * This file contains the common defines of the application. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ /* Define to prevent recursive inclusion -------------------------------------*/ @@ -27,17 +27,17 @@ extern "C" { #endif /* Includes ------------------------------------------------------------------*/ -#include "stm32g4xx_ll_lpuart.h" -#include "stm32g4xx_ll_rcc.h" #include "stm32g4xx_ll_bus.h" -#include "stm32g4xx_ll_crs.h" -#include "stm32g4xx_ll_system.h" -#include "stm32g4xx_ll_exti.h" #include "stm32g4xx_ll_cortex.h" -#include "stm32g4xx_ll_utils.h" -#include "stm32g4xx_ll_pwr.h" +#include "stm32g4xx_ll_crs.h" #include "stm32g4xx_ll_dma.h" +#include "stm32g4xx_ll_exti.h" #include "stm32g4xx_ll_gpio.h" +#include "stm32g4xx_ll_lpuart.h" +#include "stm32g4xx_ll_pwr.h" +#include "stm32g4xx_ll_rcc.h" +#include "stm32g4xx_ll_system.h" +#include "stm32g4xx_ll_utils.h" #if defined(USE_FULL_ASSERT) #include "stm32_assert.h" @@ -76,16 +76,21 @@ void Error_Handler(void); #define RTD_BTN_Pin LL_GPIO_PIN_4 #define RTD_BTN_GPIO_Port GPIOA #ifndef NVIC_PRIORITYGROUP_0 -#define NVIC_PRIORITYGROUP_0 ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, - 4 bits for subpriority */ -#define NVIC_PRIORITYGROUP_1 ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, - 3 bits for subpriority */ -#define NVIC_PRIORITYGROUP_2 ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, - 2 bits for subpriority */ -#define NVIC_PRIORITYGROUP_3 ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, - 1 bit for subpriority */ -#define NVIC_PRIORITYGROUP_4 ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, - 0 bit for subpriority */ +#define NVIC_PRIORITYGROUP_0 \ + ((uint32_t)0x00000007) /*!< 0 bit for pre-emption priority, \ + 4 bits for subpriority */ +#define NVIC_PRIORITYGROUP_1 \ + ((uint32_t)0x00000006) /*!< 1 bit for pre-emption priority, \ + 3 bits for subpriority */ +#define NVIC_PRIORITYGROUP_2 \ + ((uint32_t)0x00000005) /*!< 2 bits for pre-emption priority, \ + 2 bits for subpriority */ +#define NVIC_PRIORITYGROUP_3 \ + ((uint32_t)0x00000004) /*!< 3 bits for pre-emption priority, \ + 1 bit for subpriority */ +#define NVIC_PRIORITYGROUP_4 \ + ((uint32_t)0x00000003) /*!< 4 bits for pre-emption priority, \ + 0 bit for subpriority */ #endif /* USER CODE BEGIN Private defines */ diff --git a/DashPanel/Core/Inc/stm32_assert.h b/DashPanel/Core/Inc/stm32_assert.h index 61631c41e..92460620f 100644 --- a/DashPanel/Core/Inc/stm32_assert.h +++ b/DashPanel/Core/Inc/stm32_assert.h @@ -1,21 +1,21 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file stm32_assert.h - * @author MCD Application Team - * @brief STM32 assert file. - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file stm32_assert.h + * @author MCD Application Team + * @brief STM32 assert file. + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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 */ /* Define to prevent recursive inclusion -------------------------------------*/ #ifndef __STM32_ASSERT_H @@ -29,15 +29,15 @@ extern "C" { /* Exported constants --------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/ /* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT +#ifdef USE_FULL_ASSERT /** - * @brief The assert_param macro is used for function's parameters check. - * @param expr: If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ + * @brief The assert_param macro is used for function's parameters check. + * @param expr: If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ void assert_failed(uint8_t *file, uint32_t line); @@ -50,4 +50,3 @@ void assert_failed(uint8_t *file, uint32_t line); #endif #endif /* __STM32_ASSERT_H */ - diff --git a/DashPanel/Core/Inc/stm32g4xx_it.h b/DashPanel/Core/Inc/stm32g4xx_it.h index 1a144ad22..3cfc1aa5a 100644 --- a/DashPanel/Core/Inc/stm32g4xx_it.h +++ b/DashPanel/Core/Inc/stm32g4xx_it.h @@ -1,20 +1,20 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file stm32g4xx_it.h - * @brief This file contains the headers of the interrupt handlers. - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file stm32g4xx_it.h + * @brief This file contains the headers of the interrupt handlers. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 */ /* Define to prevent recursive inclusion -------------------------------------*/ diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index b3f940679..6f3dc53e5 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -1,20 +1,20 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file : main.c - * @brief : Main program body - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file : main.c + * @brief : Main program body + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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" @@ -70,244 +70,234 @@ static void ITM_Enable(void) /* USER CODE END 0 */ /** - * @brief The application entry point. - * @retval int - */ + * @brief The application entry point. + * @retval int + */ int main(void) { - /* USER CODE BEGIN 1 */ + /* USER CODE BEGIN 1 */ - /* USER CODE END 1 */ + /* USER CODE END 1 */ - /* MCU Configuration--------------------------------------------------------*/ + /* MCU Configuration--------------------------------------------------------*/ - /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ - LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); - LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); + /* Reset of all peripherals, Initializes the Flash interface and the Systick. */ + LL_APB2_GRP1_EnableClock(LL_APB2_GRP1_PERIPH_SYSCFG); + LL_APB1_GRP1_EnableClock(LL_APB1_GRP1_PERIPH_PWR); - /* System interrupt init*/ - NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); + /* System interrupt init*/ + NVIC_SetPriorityGrouping(NVIC_PRIORITYGROUP_4); - /* SysTick_IRQn interrupt configuration */ - NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(),15, 0)); + /* SysTick_IRQn interrupt configuration */ + NVIC_SetPriority(SysTick_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 15, 0)); - /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral - */ - LL_PWR_DisableUCPDDeadBattery(); + /** Disable the internal Pull-Up in Dead Battery pins of UCPD peripheral + */ + LL_PWR_DisableUCPDDeadBattery(); - /* USER CODE BEGIN Init */ + /* USER CODE BEGIN Init */ - /* USER CODE END Init */ + /* USER CODE END Init */ - /* Configure the system clock */ - SystemClock_Config(); + /* Configure the system clock */ + SystemClock_Config(); - /* USER CODE BEGIN SysInit */ + /* USER CODE BEGIN SysInit */ - /* USER CODE END SysInit */ + /* USER CODE END SysInit */ - /* Initialize all configured peripherals */ - MX_GPIO_Init(); - MX_LPUART1_UART_Init(); - /* USER CODE BEGIN 2 */ + /* Initialize all configured peripherals */ + MX_GPIO_Init(); + MX_LPUART1_UART_Init(); + /* USER CODE BEGIN 2 */ - /* USER CODE END 2 */ + /* USER CODE END 2 */ - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { - /* USER CODE END WHILE */ - LOGOMATIC("Hello from DashPanel!\n"); - LL_mDelay(1000); - /* USER CODE BEGIN 3 */ - } - /* USER CODE END 3 */ + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) { + /* USER CODE END WHILE */ + LOGOMATIC("Hello from DashPanel!\n"); + LL_mDelay(1000); + /* USER CODE BEGIN 3 */ + } + /* USER CODE END 3 */ } /** - * @brief System Clock Configuration - * @retval None - */ + * @brief System Clock Configuration + * @retval None + */ void SystemClock_Config(void) { - LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); - while(LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) - { - } - LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); - LL_RCC_HSI_Enable(); - /* Wait till HSI is ready */ - while(LL_RCC_HSI_IsReady() != 1) - { - } - - LL_RCC_HSI_SetCalibTrimming(64); - LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); - /* Wait till System clock is ready */ - while(LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) - { - } - - /* 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_Init1msTick(16000000); - - LL_SetSystemCoreClock(16000000); + LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); + while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) {} + LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); + LL_RCC_HSI_Enable(); + /* Wait till HSI is ready */ + while (LL_RCC_HSI_IsReady() != 1) {} + + LL_RCC_HSI_SetCalibTrimming(64); + LL_RCC_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); + /* Wait till System clock is ready */ + while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {} + + /* 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_Init1msTick(16000000); + + LL_SetSystemCoreClock(16000000); } /** - * @brief LPUART1 Initialization Function - * @param None - * @retval None - */ + * @brief LPUART1 Initialization Function + * @param None + * @retval None + */ static void MX_LPUART1_UART_Init(void) { - /* USER CODE BEGIN LPUART1_Init 0 */ + /* USER CODE BEGIN LPUART1_Init 0 */ - /* USER CODE END LPUART1_Init 0 */ + /* USER CODE END LPUART1_Init 0 */ - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; + LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); + LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); + /* Peripheral clock enable */ + LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**LPUART1 GPIO Configuration - PC0 ------> LPUART1_RX - PC1 ------> LPUART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + /**LPUART1 GPIO Configuration + PC0 ------> LPUART1_RX + PC1 ------> LPUART1_TX + */ + GPIO_InitStruct.Pin = LL_GPIO_PIN_0; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + GPIO_InitStruct.Pin = LL_GPIO_PIN_1; + GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + GPIO_InitStruct.Alternate = LL_GPIO_AF_8; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - /* USER CODE BEGIN LPUART1_Init 1 */ + /* USER CODE BEGIN LPUART1_Init 1 */ - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); + /* USER CODE END LPUART1_Init 1 */ + LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; + LPUART_InitStruct.BaudRate = 115200; + LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; + LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; + LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; + LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; + LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; + LL_LPUART_Init(LPUART1, &LPUART_InitStruct); + LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); + LL_LPUART_DisableFIFO(LPUART1); - /* USER CODE BEGIN WKUPType LPUART1 */ + /* USER CODE BEGIN WKUPType LPUART1 */ - /* USER CODE END WKUPType LPUART1 */ + /* USER CODE END WKUPType LPUART1 */ - LL_LPUART_Enable(LPUART1); + LL_LPUART_Enable(LPUART1); - /* Polling LPUART1 initialisation */ - while((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) - { - } - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ + /* Polling LPUART1 initialisation */ + while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} + /* USER CODE BEGIN LPUART1_Init 2 */ + /* USER CODE END LPUART1_Init 2 */ } /** - * @brief GPIO Initialization Function - * @param None - * @retval None - */ + * @brief GPIO Initialization Function + * @param None + * @retval None + */ static void MX_GPIO_Init(void) { - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - /* USER CODE BEGIN MX_GPIO_Init_1 */ - - /* USER CODE END MX_GPIO_Init_1 */ - - /* GPIO Ports Clock Enable */ - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); - - /**/ - LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5); - - /**/ - LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_6); - - /**/ - LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7); - - /**/ - LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_4); - - /**/ - GPIO_InitStruct.Pin = TS_ACTIVE_BTN_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(TS_ACTIVE_BTN_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = RTD_BTN_Pin; - GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(RTD_BTN_GPIO_Port, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /**/ - GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN MX_GPIO_Init_2 */ - - /* USER CODE END MX_GPIO_Init_2 */ + LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; + /* USER CODE BEGIN MX_GPIO_Init_1 */ + + /* USER CODE END MX_GPIO_Init_1 */ + + /* GPIO Ports Clock Enable */ + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); + LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOA); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_5); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_6); + + /**/ + LL_GPIO_ResetOutputPin(GPIOA, LL_GPIO_PIN_7); + + /**/ + LL_GPIO_ResetOutputPin(GPIOC, LL_GPIO_PIN_4); + + /**/ + GPIO_InitStruct.Pin = TS_ACTIVE_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(TS_ACTIVE_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = RTD_BTN_Pin; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(RTD_BTN_GPIO_Port, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_5; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_6; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_7; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /**/ + GPIO_InitStruct.Pin = LL_GPIO_PIN_4; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /* USER CODE BEGIN MX_GPIO_Init_2 */ + + /* USER CODE END MX_GPIO_Init_2 */ } /* USER CODE BEGIN 4 */ @@ -315,32 +305,30 @@ static void MX_GPIO_Init(void) /* USER CODE END 4 */ /** - * @brief This function is executed in case of error occurrence. - * @retval None - */ + * @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 */ + /* 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 - */ + * @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 */ + /* 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 */ diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c index 2f115be65..ccc490cc1 100644 --- a/DashPanel/Core/Src/stm32g4xx_it.c +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -1,25 +1,26 @@ /* USER CODE BEGIN Header */ /** - ****************************************************************************** - * @file stm32g4xx_it.c - * @brief Interrupt Service Routines. - ****************************************************************************** - * @attention - * - * Copyright (c) 2026 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file stm32g4xx_it.c + * @brief Interrupt Service Routines. + ****************************************************************************** + * @attention + * + * Copyright (c) 2026 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 "stm32g4xx_it.h" + +#include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ @@ -64,131 +65,125 @@ /* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** - * @brief This function handles Non maskable interrupt. - */ + * @brief This function handles Non maskable interrupt. + */ void NMI_Handler(void) { - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ - while (1) - { - } - /* USER CODE END NonMaskableInt_IRQn 1 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + while (1) {} + /* USER CODE END NonMaskableInt_IRQn 1 */ } /** - * @brief This function handles Hard fault interrupt. - */ + * @brief This function handles Hard fault interrupt. + */ void HardFault_Handler(void) { - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ - } + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } } /** - * @brief This function handles Memory management fault. - */ + * @brief This function handles Memory management fault. + */ void MemManage_Handler(void) { - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } } /** - * @brief This function handles Prefetch fault, memory access fault. - */ + * @brief This function handles Prefetch fault, memory access fault. + */ void BusFault_Handler(void) { - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } } /** - * @brief This function handles Undefined instruction or illegal state. - */ + * @brief This function handles Undefined instruction or illegal state. + */ void UsageFault_Handler(void) { - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) - { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } } /** - * @brief This function handles System service call via SWI instruction. - */ + * @brief This function handles System service call via SWI instruction. + */ void SVC_Handler(void) { - /* USER CODE BEGIN SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 0 */ - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ - /* USER CODE END SVCall_IRQn 1 */ + /* USER CODE END SVCall_IRQn 1 */ } /** - * @brief This function handles Debug monitor. - */ + * @brief This function handles Debug monitor. + */ void DebugMon_Handler(void) { - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - /* USER CODE END DebugMonitor_IRQn 1 */ + /* USER CODE END DebugMonitor_IRQn 1 */ } /** - * @brief This function handles Pendable request for system service. - */ + * @brief This function handles Pendable request for system service. + */ void PendSV_Handler(void) { - /* USER CODE BEGIN PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 0 */ - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ - /* USER CODE END PendSV_IRQn 1 */ + /* USER CODE END PendSV_IRQn 1 */ } /** - * @brief This function handles System tick timer. - */ + * @brief This function handles System tick timer. + */ void SysTick_Handler(void) { - /* USER CODE BEGIN SysTick_IRQn 0 */ + /* USER CODE BEGIN SysTick_IRQn 0 */ - /* USER CODE END SysTick_IRQn 0 */ + /* USER CODE END SysTick_IRQn 0 */ - /* USER CODE BEGIN SysTick_IRQn 1 */ + /* USER CODE BEGIN SysTick_IRQn 1 */ - /* USER CODE END SysTick_IRQn 1 */ + /* USER CODE END SysTick_IRQn 1 */ } /******************************************************************************/ diff --git a/DashPanel/Core/Src/syscalls.c b/DashPanel/Core/Src/syscalls.c index e10d76fa2..6abf331cb 100644 --- a/DashPanel/Core/Src/syscalls.c +++ b/DashPanel/Core/Src/syscalls.c @@ -21,158 +21,147 @@ */ /* Includes */ -#include -#include #include -#include #include -#include +#include +#include +#include #include #include - +#include /* Variables */ extern int __io_putchar(int ch) __attribute__((weak)); extern int __io_getchar(void) __attribute__((weak)); - -char *__env[1] = { 0 }; +char *__env[1] = {0}; char **environ = __env; - /* Functions */ -void initialise_monitor_handles() -{ -} +void initialise_monitor_handles() {} -int _getpid(void) -{ - return 1; -} +int _getpid(void) { return 1; } int _kill(int pid, int sig) { - (void)pid; - (void)sig; - errno = EINVAL; - return -1; + (void)pid; + (void)sig; + errno = EINVAL; + return -1; } -void _exit (int status) +void _exit(int status) { - _kill(status, -1); - while (1) {} /* Make sure we hang here */ + _kill(status, -1); + while (1) {} /* Make sure we hang here */ } __attribute__((weak)) int _read(int file, char *ptr, int len) { - (void)file; - int DataIdx; + (void)file; + int DataIdx; - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - *ptr++ = __io_getchar(); - } + for (DataIdx = 0; DataIdx < len; DataIdx++) { + *ptr++ = __io_getchar(); + } - return len; + return len; } __attribute__((weak)) int _write(int file, char *ptr, int len) { - (void)file; - int DataIdx; + (void)file; + int DataIdx; - for (DataIdx = 0; DataIdx < len; DataIdx++) - { - __io_putchar(*ptr++); - } - return len; + for (DataIdx = 0; DataIdx < len; DataIdx++) { + __io_putchar(*ptr++); + } + return len; } int _close(int file) { - (void)file; - return -1; + (void)file; + return -1; } - int _fstat(int file, struct stat *st) { - (void)file; - st->st_mode = S_IFCHR; - return 0; + (void)file; + st->st_mode = S_IFCHR; + return 0; } int _isatty(int file) { - (void)file; - return 1; + (void)file; + return 1; } int _lseek(int file, int ptr, int dir) { - (void)file; - (void)ptr; - (void)dir; - return 0; + (void)file; + (void)ptr; + (void)dir; + return 0; } int _open(char *path, int flags, ...) { - (void)path; - (void)flags; - /* Pretend like we always fail */ - return -1; + (void)path; + (void)flags; + /* Pretend like we always fail */ + return -1; } int _wait(int *status) { - (void)status; - errno = ECHILD; - return -1; + (void)status; + errno = ECHILD; + return -1; } int _unlink(char *name) { - (void)name; - errno = ENOENT; - return -1; + (void)name; + errno = ENOENT; + return -1; } clock_t _times(struct tms *buf) { - (void)buf; - return -1; + (void)buf; + return -1; } int _stat(const char *file, struct stat *st) { - (void)file; - st->st_mode = S_IFCHR; - return 0; + (void)file; + st->st_mode = S_IFCHR; + return 0; } int _link(char *old, char *new) { - (void)old; - (void)new; - errno = EMLINK; - return -1; + (void)old; + (void)new; + errno = EMLINK; + return -1; } int _fork(void) { - errno = EAGAIN; - return -1; + errno = EAGAIN; + return -1; } int _execve(char *name, char **argv, char **env) { - (void)name; - (void)argv; - (void)env; - errno = ENOMEM; - return -1; + (void)name; + (void)argv; + (void)env; + errno = ENOMEM; + return -1; } // --- Picolibc Specific Section --- @@ -187,8 +176,8 @@ int _execve(char *name, char **argv, char **env) */ static int starm_putc(char c, FILE *file) { - (void) file; - __io_putchar(c); + (void)file; + __io_putchar(c); return c; } @@ -201,18 +190,15 @@ static int starm_putc(char c, FILE *file) static int starm_getc(FILE *file) { unsigned char c; - (void) file; - c = __io_getchar(); + (void)file; + c = __io_getchar(); return c; } // Define and initialize the standard I/O streams for Picolibc. // FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to a FILE structure. // _FDEV_SETUP_RW indicates the stream is for reading and writing. -static FILE __stdio = FDEV_SETUP_STREAM(starm_putc, - starm_getc, - NULL, - _FDEV_SETUP_RW); +static FILE __stdio = FDEV_SETUP_STREAM(starm_putc, starm_getc, NULL, _FDEV_SETUP_RW); // Assign the standard stream pointers (stdin, stdout, stderr) to the initialized stream. // Picolibc uses these pointers for standard I/O operations (printf, scanf, etc.). diff --git a/DashPanel/Core/Src/sysmem.c b/DashPanel/Core/Src/sysmem.c index a875d42c0..3a092d114 100644 --- a/DashPanel/Core/Src/sysmem.c +++ b/DashPanel/Core/Src/sysmem.c @@ -22,8 +22,8 @@ /* Includes */ #include -#include #include +#include /** * Pointer to the current high watermark of the heap usage @@ -53,35 +53,33 @@ static uint8_t *__sbrk_heap_end = NULL; */ void *_sbrk(ptrdiff_t incr) { - extern uint8_t _end; /* Symbol defined in the linker script */ - extern uint8_t _estack; /* Symbol defined in the linker script */ - extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ - const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; - const uint8_t *max_heap = (uint8_t *)stack_limit; - uint8_t *prev_heap_end; + extern uint8_t _end; /* Symbol defined in the linker script */ + extern uint8_t _estack; /* Symbol defined in the linker script */ + extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ + const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; + const uint8_t *max_heap = (uint8_t *)stack_limit; + uint8_t *prev_heap_end; - /* Initialize heap end at first call */ - if (NULL == __sbrk_heap_end) - { - __sbrk_heap_end = &_end; - } + /* Initialize heap end at first call */ + if (NULL == __sbrk_heap_end) { + __sbrk_heap_end = &_end; + } - /* Protect heap from growing into the reserved MSP stack */ - if (__sbrk_heap_end + incr > max_heap) - { - errno = ENOMEM; - return (void *)-1; - } + /* Protect heap from growing into the reserved MSP stack */ + if (__sbrk_heap_end + incr > max_heap) { + errno = ENOMEM; + return (void *)-1; + } - prev_heap_end = __sbrk_heap_end; - __sbrk_heap_end += incr; + prev_heap_end = __sbrk_heap_end; + __sbrk_heap_end += incr; - return (void *)prev_heap_end; + return (void *)prev_heap_end; } #if defined(__PICOLIBC__) - // Picolibc expects syscalls without the leading underscore. - // This creates a strong alias so that - // calls to `sbrk()` are resolved to our `_sbrk()` implementation. - __strong_reference(_sbrk, sbrk); +// Picolibc expects syscalls without the leading underscore. +// This creates a strong alias so that +// calls to `sbrk()` are resolved to our `_sbrk()` implementation. +__strong_reference(_sbrk, sbrk); #endif diff --git a/DashPanel/Core/Src/system_stm32g4xx.c b/DashPanel/Core/Src/system_stm32g4xx.c index 922e57abc..4eec0cb3c 100644 --- a/DashPanel/Core/Src/system_stm32g4xx.c +++ b/DashPanel/Core/Src/system_stm32g4xx.c @@ -1,109 +1,109 @@ /** - ****************************************************************************** - * @file system_stm32g4xx.c - * @author MCD Application Team - * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32g4xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * After each device reset the HSI (16 MHz) is used as system clock source. - * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to - * configure the system clock before to branch to main program. - * - * This file configures the system clock as follows: - *============================================================================= - *----------------------------------------------------------------------------- - * System Clock source | HSI - *----------------------------------------------------------------------------- - * SYSCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * HCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * AHB Prescaler | 1 - *----------------------------------------------------------------------------- - * APB1 Prescaler | 1 - *----------------------------------------------------------------------------- - * APB2 Prescaler | 1 - *----------------------------------------------------------------------------- - * PLL_M | 1 - *----------------------------------------------------------------------------- - * PLL_N | 16 - *----------------------------------------------------------------------------- - * PLL_P | 7 - *----------------------------------------------------------------------------- - * PLL_Q | 2 - *----------------------------------------------------------------------------- - * PLL_R | 2 - *----------------------------------------------------------------------------- - * Require 48MHz for RNG | Disabled - *----------------------------------------------------------------------------- - *============================================================================= - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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. - * - ****************************************************************************** - */ + ****************************************************************************** + * @file system_stm32g4xx.c + * @author MCD Application Team + * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File + * + * This file provides two functions and one global variable to be called from + * user application: + * - SystemInit(): This function is called at startup just after reset and + * before branch to main program. This call is made inside + * the "startup_stm32g4xx.s" file. + * + * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used + * by the user application to setup the SysTick + * timer or configure other parameters. + * + * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must + * be called whenever the core clock is changed + * during program execution. + * + * After each device reset the HSI (16 MHz) is used as system clock source. + * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to + * configure the system clock before to branch to main program. + * + * This file configures the system clock as follows: + *============================================================================= + *----------------------------------------------------------------------------- + * System Clock source | HSI + *----------------------------------------------------------------------------- + * SYSCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * HCLK(Hz) | 16000000 + *----------------------------------------------------------------------------- + * AHB Prescaler | 1 + *----------------------------------------------------------------------------- + * APB1 Prescaler | 1 + *----------------------------------------------------------------------------- + * APB2 Prescaler | 1 + *----------------------------------------------------------------------------- + * PLL_M | 1 + *----------------------------------------------------------------------------- + * PLL_N | 16 + *----------------------------------------------------------------------------- + * PLL_P | 7 + *----------------------------------------------------------------------------- + * PLL_Q | 2 + *----------------------------------------------------------------------------- + * PLL_R | 2 + *----------------------------------------------------------------------------- + * Require 48MHz for RNG | Disabled + *----------------------------------------------------------------------------- + *============================================================================= + ****************************************************************************** + * @attention + * + * Copyright (c) 2019 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. + * + ****************************************************************************** + */ /** @addtogroup CMSIS - * @{ - */ + * @{ + */ /** @addtogroup stm32g4xx_system - * @{ - */ + * @{ + */ /** @addtogroup STM32G4xx_System_Private_Includes - * @{ - */ + * @{ + */ #include "stm32g4xx.h" -#if !defined (HSE_VALUE) - #define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ +#if !defined(HSE_VALUE) +#define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ -#if !defined (HSI_VALUE) - #define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ +#if !defined(HSI_VALUE) +#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_TypesDefinitions - * @{ - */ + * @{ + */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_Defines - * @{ - */ + * @{ + */ /************************* Miscellaneous Configuration ************************/ /* Note: Following vector table addresses must be defined in line with linker - configuration. */ + configuration. */ /*!< Uncomment the following line if you need to relocate the vector table anywhere in Flash or Sram, else the vector table is kept at the automatic remap of boot address selected */ @@ -114,172 +114,171 @@ in Sram else user remap will be done in Flash. */ /* #define VECT_TAB_SRAM */ #if defined(VECT_TAB_SRAM) -#define VECT_TAB_BASE_ADDRESS SRAM_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ +#define VECT_TAB_BASE_ADDRESS \ + SRAM_BASE /*!< Vector Table base address field. \ + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET \ + 0x00000000U /*!< Vector Table base offset field. \ + This value must be a multiple of 0x200. */ #else -#define VECT_TAB_BASE_ADDRESS FLASH_BASE /*!< Vector Table base address field. - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET 0x00000000U /*!< Vector Table base offset field. - This value must be a multiple of 0x200. */ -#endif /* VECT_TAB_SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -/******************************************************************************/ -/** - * @} - */ +#define VECT_TAB_BASE_ADDRESS \ + FLASH_BASE /*!< Vector Table base address field. \ + This value must be a multiple of 0x200. */ +#define VECT_TAB_OFFSET \ + 0x00000000U /*!< Vector Table base offset field. \ + This value must be a multiple of 0x200. */ +#endif /* VECT_TAB_SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ + /******************************************************************************/ + /** + * @} + */ /** @addtogroup STM32G4xx_System_Private_Macros - * @{ - */ + * @{ + */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_Variables - * @{ - */ - /* The SystemCoreClock variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. - */ - uint32_t SystemCoreClock = HSI_VALUE; - - const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; - const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; + * @{ + */ +/* The SystemCoreClock variable is updated in three ways: + 1) by calling CMSIS function SystemCoreClockUpdate() + 2) by calling HAL API function HAL_RCC_GetHCLKFreq() + 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency + Note: If you use this function to configure the system clock; then there + is no need to call the 2 first functions listed above, since SystemCoreClock + variable is updated automatically. +*/ +uint32_t SystemCoreClock = HSI_VALUE; + +const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; +const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_FunctionPrototypes - * @{ - */ + * @{ + */ /** - * @} - */ + * @} + */ /** @addtogroup STM32G4xx_System_Private_Functions - * @{ - */ + * @{ + */ /** - * @brief Setup the microcontroller system. - * @param None - * @retval None - */ + * @brief Setup the microcontroller system. + * @param None + * @retval None + */ void SystemInit(void) { - /* FPU settings ------------------------------------------------------------*/ - #if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << (10*2))|(3UL << (11*2))); /* set CP10 and CP11 Full Access */ - #endif +/* FPU settings ------------------------------------------------------------*/ +#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) + SCB->CPACR |= ((3UL << (10 * 2)) | (3UL << (11 * 2))); /* set CP10 and CP11 Full Access */ +#endif - /* Configure the Vector Table location add offset address ------------------*/ + /* Configure the Vector Table location add offset address ------------------*/ #if defined(USER_VECT_TAB_ADDRESS) - SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ + SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ +#endif /* USER_VECT_TAB_ADDRESS */ } /** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 24 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ + * @brief Update SystemCoreClock variable according to Clock Register Values. + * The SystemCoreClock variable contains the core clock (HCLK), it can + * be used by the user application to setup the SysTick timer or configure + * other parameters. + * + * @note Each time the core clock (HCLK) changes, this function must be called + * to update SystemCoreClock variable value. Otherwise, any configuration + * based on this variable will be incorrect. + * + * @note - The system frequency computed by this function is not the real + * frequency in the chip. It is calculated based on the predefined + * constant and the selected clock source: + * + * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) + * + * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) + * + * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) + * or HSI_VALUE(*) multiplied/divided by the PLL factors. + * + * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 16 MHz) but the real value may vary depending on the variations + * in voltage and temperature. + * + * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value + * 24 MHz), user has to ensure that HSE_VALUE is same as the real + * frequency of the crystal used. Otherwise, this function may + * have wrong result. + * + * - The result of this function could be not correct when using fractional + * value for HSE crystal. + * + * @param None + * @retval None + */ void SystemCoreClockUpdate(void) { - uint32_t tmp, pllvco, pllr, pllsource, pllm; - - /* Get SYSCLK source -------------------------------------------------------*/ - switch (RCC->CFGR & RCC_CFGR_SWS) - { - case 0x04: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - - case 0x08: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - - case 0x0C: /* PLL used as system clock source */ - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN - SYSCLK = PLL_VCO / PLLR - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); - pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U ; - if (pllsource == 0x02UL) /* HSI used as PLL clock source */ - { - pllvco = (HSI_VALUE / pllm); - } - else /* HSE used as PLL clock source */ - { - pllvco = (HSE_VALUE / pllm); - } - pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); - pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; - SystemCoreClock = pllvco/pllr; - break; - - default: - break; - } - /* Compute HCLK clock frequency --------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK clock frequency */ - SystemCoreClock >>= tmp; + uint32_t tmp, pllvco, pllr, pllsource, pllm; + + /* Get SYSCLK source -------------------------------------------------------*/ + switch (RCC->CFGR & RCC_CFGR_SWS) { + case 0x04: /* HSI used as system clock source */ + SystemCoreClock = HSI_VALUE; + break; + + case 0x08: /* HSE used as system clock source */ + SystemCoreClock = HSE_VALUE; + break; + + case 0x0C: /* PLL used as system clock source */ + /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN + SYSCLK = PLL_VCO / PLLR + */ + pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); + pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U; + if (pllsource == 0x02UL) /* HSI used as PLL clock source */ + { + pllvco = (HSI_VALUE / pllm); + } else /* HSE used as PLL clock source */ + { + pllvco = (HSE_VALUE / pllm); + } + pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); + pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; + SystemCoreClock = pllvco / pllr; + break; + + default: + break; + } + /* Compute HCLK clock frequency --------------------------------------------*/ + /* Get HCLK prescaler */ + tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; + /* HCLK clock frequency */ + SystemCoreClock >>= tmp; } - /** - * @} - */ + * @} + */ /** - * @} - */ + * @} + */ /** - * @} - */ - - + * @} + */ From 3704e8607ffd0a40c8228e722b9ee0f66518cd8a Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 3 Feb 2026 13:18:13 -0800 Subject: [PATCH 43/95] Enable ITM in main function Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Core/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 6f3dc53e5..30d753128 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -111,7 +111,7 @@ int main(void) MX_GPIO_Init(); MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ - + ITM_Enable() /* USER CODE END 2 */ /* Infinite loop */ From 7bbee26cb2f45fcd7af7212bf2a52b23d8722dd3 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:19:18 +0000 Subject: [PATCH 44/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 30d753128..a3f8cac06 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -112,11 +112,12 @@ int main(void) MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ ITM_Enable() - /* USER CODE END 2 */ + /* USER CODE END 2 */ - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) { + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) + { /* USER CODE END WHILE */ LOGOMATIC("Hello from DashPanel!\n"); LL_mDelay(1000); From dae3bf1a9ee966024fe31b27549449e20d4d2321 Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 3 Feb 2026 13:20:53 -0800 Subject: [PATCH 45/95] Missing semicolon for enabling ITM Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Core/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index a3f8cac06..e11e1194d 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -111,7 +111,7 @@ int main(void) MX_GPIO_Init(); MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ - ITM_Enable() + ITM_Enable(); /* USER CODE END 2 */ /* Infinite loop */ From 1bc759dd914252d87db3452bf0128263e54afe4b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 3 Feb 2026 21:21:56 +0000 Subject: [PATCH 46/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index e11e1194d..78601e35f 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -112,12 +112,11 @@ int main(void) MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ ITM_Enable(); - /* USER CODE END 2 */ + /* USER CODE END 2 */ - /* Infinite loop */ - /* USER CODE BEGIN WHILE */ - while (1) - { + /* Infinite loop */ + /* USER CODE BEGIN WHILE */ + while (1) { /* USER CODE END WHILE */ LOGOMATIC("Hello from DashPanel!\n"); LL_mDelay(1000); From ba7a9552175d624227724d97895c9f60abf81242 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 5 Feb 2026 21:02:56 -0800 Subject: [PATCH 47/95] initialize dash panel can stuff Co-authored-by: David Uzunov Co-authored-by: Anthony Ma Co-authored-by: Aagrim Hoysal --- DashPanel/Application/Inc/CANdler.h | 7 +++ DashPanel/Application/Inc/main2.h | 0 DashPanel/Application/Src/CANdler.c | 75 +++++++++++++++++++++++++++++ DashPanel/Application/Src/main2.c | 0 DashPanel/Core/Src/main.c | 32 +++++++++--- DashPanel/DASHPLANEL.md | 23 +++++++++ G4PERTESTING/Core/Inc/main.h | 1 + G4PERTESTING/Core/Src/main.c | 3 ++ 8 files changed, 133 insertions(+), 8 deletions(-) create mode 100644 DashPanel/Application/Inc/CANdler.h create mode 100644 DashPanel/Application/Inc/main2.h create mode 100644 DashPanel/Application/Src/CANdler.c create mode 100644 DashPanel/Application/Src/main2.c create mode 100644 DashPanel/DASHPLANEL.md diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h new file mode 100644 index 000000000..5056eb4c7 --- /dev/null +++ b/DashPanel/Application/Inc/CANdler.h @@ -0,0 +1,7 @@ +#ifndef CANDLER_H +#define CANDLER_H + +void CANInitialize(); +void CAN_callback(uint32_t ID, void *data, uint32_t size); + +#endif diff --git a/DashPanel/Application/Inc/main2.h b/DashPanel/Application/Inc/main2.h new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c new file mode 100644 index 000000000..9f1f1d2ae --- /dev/null +++ b/DashPanel/Application/Src/CANdler.c @@ -0,0 +1,75 @@ +#include "can.h" +#include "stm32g4xx_hal_fdcan.h" +#include "CANdler.h" + +#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID +#define PING_ID 2 // ID of ping message - TODO: change with correct ID + +void CANInitialize() { + CANConfig canCfg; + + canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; + canCfg.hal_fdcan_init.FrameFormat = FDCAN_FRAME_FD_NO_BRS; + canCfg.hal_fdcan_init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; + canCfg.hal_fdcan_init.Mode = FDCAN_MODE_NORMAL; + canCfg.hal_fdcan_init.AutoRetransmission = ENABLE; + canCfg.hal_fdcan_init.TransmitPause = DISABLE; + canCfg.hal_fdcan_init.ProtocolException = ENABLE; + canCfg.hal_fdcan_init.NominalPrescaler = 1; + 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.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.StdFiltersNbr = 1; + canCfg.hal_fdcan_init.ExtFiltersNbr = 0; + + canCfg.rx_callback = CAN_callback; // PLEASE SET + canCfg.rx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_buffer_length = 3; // PLEASE SET + + // canCfg.rx_gpio = GPIOB; + // canCfg.init_rx_gpio.Pin = GPIO_PIN_12; + canCfg.init_rx_gpio.Mode = GPIO_MODE_AF_PP; + canCfg.init_rx_gpio.Pull = GPIO_PULLUP; + canCfg.init_rx_gpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + // canCfg.init_rx_gpio.Alternate = GPIO_AF9_FDCAN2; + + // canCfg.tx_gpio = GPIOB; + // canCfg.init_tx_gpio.Pin = GPIO_PIN_13; + canCfg.init_tx_gpio.Mode = GPIO_MODE_AF_PP; + canCfg.init_tx_gpio.Pull = GPIO_NOPULL; + canCfg.init_tx_gpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + // canCfg.init_tx_gpio.Alternate = GPIO_AF9_FDCAN2; + + // FDCAN_FilterTypeDef filter; + // can_add_filter(can2Handle, &filter); + /* USER CODE END 2 */ + + + // FDCAN_TxHeaderTypeDef TxHeader = { + // .Identifier = 1, + + // .IdType = FDCAN_STANDARD_ID, + // .TxFrameType = FDCAN_DATA_FRAME, + // .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node + // // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors + // .DataLength = 1, + // .BitRateSwitch = FDCAN_BRS_OFF, + // .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages + // .MessageMarker = 0 // also change this to a real address if you change fifo control + // }; + CANHandle *can_handler = can_init(&canCfg); + can_start(can_handler); +} + +void CAN_callback(uint32_t ID, void *data, uint32_t size){ + if (ID == ECU_ID) { + // process data + } else if (ID == PING_ID) { + // process ping + } +} diff --git a/DashPanel/Application/Src/main2.c b/DashPanel/Application/Src/main2.c new file mode 100644 index 000000000..e69de29bb diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 78601e35f..d003f171b 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -18,6 +18,7 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" +#include "CANdler.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -97,6 +98,7 @@ int main(void) LL_PWR_DisableUCPDDeadBattery(); /* USER CODE BEGIN Init */ + CANInitialize(); /* USER CODE END Init */ @@ -129,28 +131,42 @@ int main(void) * @brief System Clock Configuration * @retval None */ + void SystemClock_Config(void) { - LL_FLASH_SetLatency(LL_FLASH_LATENCY_0); - while (LL_FLASH_GetLatency() != LL_FLASH_LATENCY_0) {} - LL_PWR_SetRegulVoltageScaling(LL_PWR_REGU_VOLTAGE_SCALE1); + 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_SetSysClkSource(LL_RCC_SYS_CLKSOURCE_HSI); + 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_2); /* Wait till System clock is ready */ - while (LL_RCC_GetSysClkSource() != LL_RCC_SYS_CLKSOURCE_STATUS_HSI) {} + 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); - LL_Init1msTick(16000000); - - LL_SetSystemCoreClock(16000000); + /* Update the time base */ + if (HAL_InitTick(TICK_INT_PRIORITY) != HAL_OK) { + Error_Handler(); + } } /** diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md new file mode 100644 index 000000000..73994e311 --- /dev/null +++ b/DashPanel/DASHPLANEL.md @@ -0,0 +1,23 @@ +# DASH PLANel + +## CAN + +1. Set up CANdler with help of CAN team +2. Export button inputs +3. Import ECU CAN messages + + + +## Buttons + +1. Process button inputs (THE BUTTONS DO NOT LATCH) +2. Implement debouncing + +## LED + +1. Integrate NeoPixel +2. Set up lights + +## Testing + +1. Implement LP-UART for async & LOGOMATIC diff --git a/G4PERTESTING/Core/Inc/main.h b/G4PERTESTING/Core/Inc/main.h index 23d7ffce4..edc4c0b10 100644 --- a/G4PERTESTING/Core/Inc/main.h +++ b/G4PERTESTING/Core/Inc/main.h @@ -105,6 +105,7 @@ void Error_Handler(void); #define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ +extern CANHandle /* USER CODE END Private defines */ diff --git a/G4PERTESTING/Core/Src/main.c b/G4PERTESTING/Core/Src/main.c index ba6196726..48f7bbafe 100644 --- a/G4PERTESTING/Core/Src/main.c +++ b/G4PERTESTING/Core/Src/main.c @@ -105,6 +105,9 @@ int main(void) MX_TIM2_Init(); /* USER CODE BEGIN 2 */ + /* Initialize CAN interface */ + + /* USER CODE END 2 */ /* Infinite loop */ From ce45f0af7cb1a168098835a857846bf23be1755d Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 05:04:00 +0000 Subject: [PATCH 48/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 32 +++++++++++++++-------------- DashPanel/Core/Src/main.c | 1 + G4PERTESTING/Core/Src/main.c | 1 - 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 9f1f1d2ae..215a8dfcd 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,12 +1,14 @@ +#include "CANdler.h" + #include "can.h" #include "stm32g4xx_hal_fdcan.h" -#include "CANdler.h" -#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID +#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID #define PING_ID 2 // ID of ping message - TODO: change with correct ID -void CANInitialize() { - CANConfig canCfg; +void CANInitialize() +{ + CANConfig canCfg; canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; canCfg.hal_fdcan_init.FrameFormat = FDCAN_FRAME_FD_NO_BRS; @@ -26,10 +28,10 @@ void CANInitialize() { canCfg.hal_fdcan_init.StdFiltersNbr = 1; canCfg.hal_fdcan_init.ExtFiltersNbr = 0; - canCfg.rx_callback = CAN_callback; // PLEASE SET - canCfg.rx_interrupt_priority = 0; // PLEASE SET - canCfg.tx_interrupt_priority = 0; // PLEASE SET - canCfg.tx_buffer_length = 3; // PLEASE SET + canCfg.rx_callback = CAN_callback; // PLEASE SET + canCfg.rx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_interrupt_priority = 0; // PLEASE SET + canCfg.tx_buffer_length = 3; // PLEASE SET // canCfg.rx_gpio = GPIOB; // canCfg.init_rx_gpio.Pin = GPIO_PIN_12; @@ -49,7 +51,6 @@ void CANInitialize() { // can_add_filter(can2Handle, &filter); /* USER CODE END 2 */ - // FDCAN_TxHeaderTypeDef TxHeader = { // .Identifier = 1, @@ -66,10 +67,11 @@ void CANInitialize() { can_start(can_handler); } -void CAN_callback(uint32_t ID, void *data, uint32_t size){ - if (ID == ECU_ID) { - // process data - } else if (ID == PING_ID) { - // process ping - } +void CAN_callback(uint32_t ID, void *data, uint32_t size) +{ + if (ID == ECU_ID) { + // process data + } else if (ID == PING_ID) { + // process ping + } } diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index d003f171b..0da50c7de 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -18,6 +18,7 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" + #include "CANdler.h" /* Private includes ----------------------------------------------------------*/ diff --git a/G4PERTESTING/Core/Src/main.c b/G4PERTESTING/Core/Src/main.c index 48f7bbafe..ee28d20d0 100644 --- a/G4PERTESTING/Core/Src/main.c +++ b/G4PERTESTING/Core/Src/main.c @@ -107,7 +107,6 @@ int main(void) /* Initialize CAN interface */ - /* USER CODE END 2 */ /* Infinite loop */ From dbdbb861b7e39500d9f9b66741873a82f4df1ad0 Mon Sep 17 00:00:00 2001 From: DavidUzunov Date: Thu, 5 Feb 2026 22:00:29 -0800 Subject: [PATCH 49/95] Did some things Co-authored-by: Bailey Say Co-authored-by: Anthony Ma Co-authored-by: Aagrim Hoysal --- DashPanel/Application/Inc/CANdler.h | 15 ++++++++++++ DashPanel/Application/Src/CANdler.c | 38 +++++++++++++++++++---------- DashPanel/DASHPLANEL.md | 5 +++- DashPanel/README.md | 27 ++++++++++++++++++++ 4 files changed, 71 insertions(+), 14 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 5056eb4c7..110d4059f 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,6 +1,21 @@ #ifndef CANDLER_H #define CANDLER_H +typedef struct { + uint16_t vehicleSpeed; + uint8_t ECUState; +} DashStatus; +typedef struct { + uint16_t vehicleSpeed; + uint8_t ECUState; +} CAN_MSG_ECU; + +typedef struct { + +} CAN_MSG_PING; + +extern DashStatus dashStatus; + void CANInitialize(); void CAN_callback(uint32_t ID, void *data, uint32_t size); diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 215a8dfcd..56fe28a45 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -6,8 +6,12 @@ #define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID #define PING_ID 2 // ID of ping message - TODO: change with correct ID +DashStatus dashStatus; + void CANInitialize() { + dashStatus = {0}; + CANConfig canCfg; canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; @@ -51,27 +55,35 @@ void CANInitialize() // can_add_filter(can2Handle, &filter); /* USER CODE END 2 */ - // FDCAN_TxHeaderTypeDef TxHeader = { - // .Identifier = 1, - - // .IdType = FDCAN_STANDARD_ID, - // .TxFrameType = FDCAN_DATA_FRAME, - // .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node - // // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors - // .DataLength = 1, - // .BitRateSwitch = FDCAN_BRS_OFF, - // .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages - // .MessageMarker = 0 // also change this to a real address if you change fifo control - // }; CANHandle *can_handler = can_init(&canCfg); can_start(can_handler); } +void CAN_sendPing() { + FDCAN_TxHeaderTypeDef PingTxHeader = { + .Identifier = GR_DASH_PANEL | , + + .IdType = FDCAN_STANDARD_ID, + .TxFrameType = FDCAN_DATA_FRAME, + .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node + // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors + .DataLength = 4, + .BitRateSwitch = FDCAN_BRS_OFF, + .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages + .MessageMarker = 0 // also change this to a real address if you change fifo control + }; +} + void CAN_callback(uint32_t ID, void *data, uint32_t size) { + // Process data if (ID == ECU_ID) { - // process data + CAN_MSG_ECU* ecu_data = (CAN_MSG_ECU*) data; + dashStatus->vehicleSpeed = ecu_data->vehicleSpeed; + dashStatus->ECUState = ecu_data->ECUState; + // Process data } else if (ID == PING_ID) { // process ping + CAN_sendPing(); } } diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index 73994e311..2cda667fa 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -6,7 +6,10 @@ 2. Export button inputs 3. Import ECU CAN messages - +- Torque, Current, Speed, or put battery before drive +- Probably need to figure out what we're putting on the board for now +- We should set up the ECU send too... +- Also update the README ## Buttons diff --git a/DashPanel/README.md b/DashPanel/README.md index e69de29bb..372b72035 100644 --- a/DashPanel/README.md +++ b/DashPanel/README.md @@ -0,0 +1,27 @@ +# Button mappings + +## Butt1 + +TS-Active +Connected to PA3 + +## Butt2 + +RTD(Ready to Drive) +Connected to PA4 + +## D1 + +idk + +## D2 + +idk + +## D3 + +idk + +## D4 + +idk From bc96f3b9b9ebce7bafaafaae5864b2502b3f4a07 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 6 Feb 2026 06:01:34 +0000 Subject: [PATCH 50/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 8 ++++---- DashPanel/Application/Src/CANdler.c | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 110d4059f..079780564 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -2,12 +2,12 @@ #define CANDLER_H typedef struct { - uint16_t vehicleSpeed; - uint8_t ECUState; + uint16_t vehicleSpeed; + uint8_t ECUState; } DashStatus; typedef struct { - uint16_t vehicleSpeed; - uint8_t ECUState; + uint16_t vehicleSpeed; + uint8_t ECUState; } CAN_MSG_ECU; typedef struct { diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 56fe28a45..9c5e3926e 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -59,9 +59,10 @@ void CANInitialize() can_start(can_handler); } -void CAN_sendPing() { +void CAN_sendPing() +{ FDCAN_TxHeaderTypeDef PingTxHeader = { - .Identifier = GR_DASH_PANEL | , + .Identifier = GR_DASH_PANEL |, .IdType = FDCAN_STANDARD_ID, .TxFrameType = FDCAN_DATA_FRAME, @@ -78,10 +79,10 @@ void CAN_callback(uint32_t ID, void *data, uint32_t size) { // Process data if (ID == ECU_ID) { - CAN_MSG_ECU* ecu_data = (CAN_MSG_ECU*) data; + CAN_MSG_ECU *ecu_data = (CAN_MSG_ECU *)data; dashStatus->vehicleSpeed = ecu_data->vehicleSpeed; dashStatus->ECUState = ecu_data->ECUState; - // Process data + // Process data } else if (ID == PING_ID) { // process ping CAN_sendPing(); From c071edb4c1c4fe10c92e9a2948900df52b669de8 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Mon, 9 Feb 2026 19:55:37 -0800 Subject: [PATCH 51/95] delete placeholder files --- DashPanel/Application/Inc/empty.txt | 0 DashPanel/Application/Inc/main2.h | 0 DashPanel/Application/Src/empty.txt | 0 DashPanel/Application/Src/main2.c | 0 4 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 DashPanel/Application/Inc/empty.txt delete mode 100644 DashPanel/Application/Inc/main2.h delete mode 100644 DashPanel/Application/Src/empty.txt delete mode 100644 DashPanel/Application/Src/main2.c diff --git a/DashPanel/Application/Inc/empty.txt b/DashPanel/Application/Inc/empty.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/DashPanel/Application/Inc/main2.h b/DashPanel/Application/Inc/main2.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/DashPanel/Application/Src/empty.txt b/DashPanel/Application/Src/empty.txt deleted file mode 100644 index e69de29bb..000000000 diff --git a/DashPanel/Application/Src/main2.c b/DashPanel/Application/Src/main2.c deleted file mode 100644 index e69de29bb..000000000 From 9b31e70d482108b0f56864487d48da83efe63bad Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Mon, 9 Feb 2026 21:10:14 -0800 Subject: [PATCH 52/95] basic gpio interrupt handler setup --- DashPanel/Core/Src/main.c | 55 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 0da50c7de..4f1ccf253 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -51,6 +51,7 @@ void SystemClock_Config(void); static void MX_GPIO_Init(void); static void MX_LPUART1_UART_Init(void); +static void GPIO_Interrupt_Init(void); /* USER CODE BEGIN PFP */ /* USER CODE END PFP */ @@ -100,6 +101,7 @@ int main(void) /* USER CODE BEGIN Init */ CANInitialize(); + GPIO_Interrupt_Init(); /* USER CODE END Init */ @@ -319,6 +321,59 @@ static void MX_GPIO_Init(void) /* USER CODE BEGIN 4 */ +/** + * @brief GPIO Interrupt Handler Setup Function + * @param None + * @retval None + */ +static void GPIO_Interrupt_Init(void) { + + // Map PA3 and PA4 to EXTI lines 3 and 4 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE4); + + LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE3); + LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE4); + LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_0); + LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_0); + + NVIC_SetPriority(EXTI3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); + NVIC_SetPriority(EXTI4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); + + // Enable interrupts + NVIC_EnableIRQ(EXTI3_IRQn); + NVIC_EnableIRQ(EXTI4_IRQn); + +} + +/** + * @brief EXTI Line 3 Interrupt Handler (for TS Active button) + * @param None + * @retval None + */ +void EXTI3_IRQHandler(void) { + + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { + + LOGOMATIC("TS Active Pressed!"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); + } + +} + +/** + * @brief EXTI Line 4 Interrupt Handler (for RTD button) + * @param None + * @retval None + */ +void EXTI4_IRQHandler(void) { + + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { + + LOGOMATIC("RTD Pressed!"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); + } +} /* USER CODE END 4 */ /** From b45900e602a54f5de1f10b353887f66784a4c56b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 05:11:14 +0000 Subject: [PATCH 53/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 4f1ccf253..cb98fe56e 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -326,7 +326,8 @@ static void MX_GPIO_Init(void) * @param None * @retval None */ -static void GPIO_Interrupt_Init(void) { +static void GPIO_Interrupt_Init(void) +{ // Map PA3 and PA4 to EXTI lines 3 and 4 LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); @@ -343,7 +344,6 @@ static void GPIO_Interrupt_Init(void) { // Enable interrupts NVIC_EnableIRQ(EXTI3_IRQn); NVIC_EnableIRQ(EXTI4_IRQn); - } /** @@ -351,14 +351,14 @@ static void GPIO_Interrupt_Init(void) { * @param None * @retval None */ -void EXTI3_IRQHandler(void) { +void EXTI3_IRQHandler(void) +{ if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { LOGOMATIC("TS Active Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); } - } /** @@ -366,7 +366,8 @@ void EXTI3_IRQHandler(void) { * @param None * @retval None */ -void EXTI4_IRQHandler(void) { +void EXTI4_IRQHandler(void) +{ if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { From d6ca806a09fd21009282e2eb60860d3c93d3b7fb Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Tue, 10 Feb 2026 12:47:05 -0800 Subject: [PATCH 54/95] more candler stuff --- DashPanel/Application/Inc/CANdler.h | 10 +++++-- DashPanel/Application/Inc/dashutils.h | 6 ++++ DashPanel/Application/Src/CANdler.c | 40 +++++++++++++++++---------- DashPanel/Application/Src/dashutils.c | 10 +++++++ DashPanel/Core/Src/main.c | 25 +++++++++-------- DashPanel/DASHPLANEL.md | 4 +-- 6 files changed, 64 insertions(+), 31 deletions(-) create mode 100644 DashPanel/Application/Inc/dashutils.h create mode 100644 DashPanel/Application/Src/dashutils.c diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 079780564..391b25832 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,5 +1,6 @@ #ifndef CANDLER_H #define CANDLER_H +#include "can.h" typedef struct { uint16_t vehicleSpeed; @@ -8,15 +9,18 @@ typedef struct { typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; -} CAN_MSG_ECU; +} CAN_RECEIVE_ECU; typedef struct { - -} CAN_MSG_PING; + uint8_t TSActiveButton; + uint8_t RTDButton; +} CAN_SEND_ECU; extern DashStatus dashStatus; +extern CANHandle * can_handler; void CANInitialize(); +void CAN_sendPing(GR_OLD_NODE_ID to); void CAN_callback(uint32_t ID, void *data, uint32_t size); #endif diff --git a/DashPanel/Application/Inc/dashutils.h b/DashPanel/Application/Inc/dashutils.h new file mode 100644 index 000000000..e19e47ae4 --- /dev/null +++ b/DashPanel/Application/Inc/dashutils.h @@ -0,0 +1,6 @@ +#ifdef DASHPANEL_UTILS_H +#define DASHPANEL_UTILS_H + +uint32_t MillisecondsSinceBoot(void); + +#endif // DASHPANEL_UTILS_H diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 9c5e3926e..4e50c8987 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,11 +1,13 @@ #include "CANdler.h" #include "can.h" +#include "dashutils.h" #include "stm32g4xx_hal_fdcan.h" #define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID #define PING_ID 2 // ID of ping message - TODO: change with correct ID +CANHandle *can_handler; DashStatus dashStatus; void CANInitialize() @@ -55,24 +57,34 @@ void CANInitialize() // can_add_filter(can2Handle, &filter); /* USER CODE END 2 */ - CANHandle *can_handler = can_init(&canCfg); + can_handler = can_init(&canCfg); can_start(can_handler); } -void CAN_sendPing() +void CAN_sendPing(GR_OLD_NODE_ID to) { - FDCAN_TxHeaderTypeDef PingTxHeader = { - .Identifier = GR_DASH_PANEL |, - - .IdType = FDCAN_STANDARD_ID, - .TxFrameType = FDCAN_DATA_FRAME, - .ErrorStateIndicator = FDCAN_ESI_ACTIVE, // honestly this might be a value you have to read from a node - // FDCAN_ESI_ACTIVE is just a state that assumes there are minimal errors - .DataLength = 4, - .BitRateSwitch = FDCAN_BRS_OFF, - .TxEventFifoControl = FDCAN_NO_TX_EVENTS, // change to FDCAN_STORE_TX_EVENTS if you need to store info regarding transmitted messages - .MessageMarker = 0 // also change this to a real address if you change fifo control - }; + FDCANTxMessage pingMsg; + pingMsg.tx_header.Identifier = (GR_DASH_PANEL<<20) | (MSG_PING<<8) | to; + pingMsg.tx_header.IdType = FDCAN_STANDARD_ID; + pingMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME; + pingMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; + pingMsg.tx_header.DataLength = 4; + pingMsg.tx_header.BitRateSwitch = FDCAN_BRS_OFF; + pingMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; + pingMsg.tx_header.MessageMarker = 0; + + ((uint32_t*) (pingMsg.data))[0] = MillisecondsSinceBoot(); + can_send(can_handler, &pingMsg); +} + +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU* msg) { + + FDCANTxMessage sendECUMsg; + + // TODO: set up the message + + can_send(c, &sendECUMsg); + } void CAN_callback(uint32_t ID, void *data, uint32_t size) diff --git a/DashPanel/Application/Src/dashutils.c b/DashPanel/Application/Src/dashutils.c new file mode 100644 index 000000000..16d979019 --- /dev/null +++ b/DashPanel/Application/Src/dashutils.c @@ -0,0 +1,10 @@ +#include "dashutils.h" +#include "main.h" + +// from ECU +uint32_t MillisecondsSinceBoot(void) +{ + // For some reason, GetTickFreq returns period in millisecon instead of frequency + // See https://community.st.com/t5/stm32-mcus-embedded-software/name-amp-description-of-hal-gettickfreq-misleading/td-p/242457 + return HAL_GetTick() * HAL_GetTickFreq(); +} diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index cb98fe56e..681f42b4c 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -284,33 +284,25 @@ static void MX_GPIO_Init(void) /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_6; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_7; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); /**/ GPIO_InitStruct.Pin = LL_GPIO_PIN_4; - GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOC, &GPIO_InitStruct); @@ -356,6 +348,8 @@ void EXTI3_IRQHandler(void) if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { + // Blame Electronics if hardware debounce doesn't work + LOGOMATIC("TS Active Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); } @@ -371,6 +365,13 @@ void EXTI4_IRQHandler(void) if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { + // Blame Electronics if hardware debounce doesn't work + + CAN_SEND_ECU msg_struct; + msg_struct.TSActiveButton = 0; + msg_struct.RTDButton = 1; + + CAN_sendECU(can_handler, &msg_struct); LOGOMATIC("RTD Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); } diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index 2cda667fa..dd0a13a07 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -13,8 +13,8 @@ ## Buttons -1. Process button inputs (THE BUTTONS DO NOT LATCH) -2. Implement debouncing +1. Test button interrupts +2. Move the CAN messages to grand loop + make global status + create CAN send flag ## LED From 1e64eed9514bb9cc8a7336de0c96a0dd50b45df6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 10 Feb 2026 20:48:17 +0000 Subject: [PATCH 55/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 2 +- DashPanel/Application/Src/CANdler.c | 8 ++++---- DashPanel/Application/Src/dashutils.c | 1 + 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 391b25832..70512f011 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -17,7 +17,7 @@ typedef struct { } CAN_SEND_ECU; extern DashStatus dashStatus; -extern CANHandle * can_handler; +extern CANHandle *can_handler; void CANInitialize(); void CAN_sendPing(GR_OLD_NODE_ID to); diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 4e50c8987..cee848a4f 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -64,7 +64,7 @@ void CANInitialize() void CAN_sendPing(GR_OLD_NODE_ID to) { FDCANTxMessage pingMsg; - pingMsg.tx_header.Identifier = (GR_DASH_PANEL<<20) | (MSG_PING<<8) | to; + pingMsg.tx_header.Identifier = (GR_DASH_PANEL << 20) | (MSG_PING << 8) | to; pingMsg.tx_header.IdType = FDCAN_STANDARD_ID; pingMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME; pingMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; @@ -73,18 +73,18 @@ void CAN_sendPing(GR_OLD_NODE_ID to) pingMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; pingMsg.tx_header.MessageMarker = 0; - ((uint32_t*) (pingMsg.data))[0] = MillisecondsSinceBoot(); + ((uint32_t *)(pingMsg.data))[0] = MillisecondsSinceBoot(); can_send(can_handler, &pingMsg); } -void CAN_sendECU(CANHandle *c, CAN_SEND_ECU* msg) { +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) +{ FDCANTxMessage sendECUMsg; // TODO: set up the message can_send(c, &sendECUMsg); - } void CAN_callback(uint32_t ID, void *data, uint32_t size) diff --git a/DashPanel/Application/Src/dashutils.c b/DashPanel/Application/Src/dashutils.c index 16d979019..4178d408a 100644 --- a/DashPanel/Application/Src/dashutils.c +++ b/DashPanel/Application/Src/dashutils.c @@ -1,4 +1,5 @@ #include "dashutils.h" + #include "main.h" // from ECU From 4c436b6d5a05e0806c149d9357a95b75f820ac91 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 21:33:37 -0800 Subject: [PATCH 56/95] move CAN send to main loop --- DashPanel/Application/Inc/CANdler.h | 4 ++++ DashPanel/Application/Src/CANdler.c | 3 +++ DashPanel/Core/Src/main.c | 29 ++++++++++++++++++++++------- 3 files changed, 29 insertions(+), 7 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 70512f011..2b43e58fd 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -5,6 +5,8 @@ typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; + uint8_t TSActiveButton; + uint8_t RTDButton; } DashStatus; typedef struct { uint16_t vehicleSpeed; @@ -18,9 +20,11 @@ typedef struct { extern DashStatus dashStatus; extern CANHandle *can_handler; +extern bool canReadyToSend; void CANInitialize(); void CAN_sendPing(GR_OLD_NODE_ID to); void CAN_callback(uint32_t ID, void *data, uint32_t size); +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg); #endif diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index cee848a4f..406a55c1f 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -9,10 +9,13 @@ CANHandle *can_handler; DashStatus dashStatus; +bool canReadyToSend; + void CANInitialize() { dashStatus = {0}; + canReadyToSend = false; CANConfig canCfg; diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 681f42b4c..21e4067db 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -123,8 +123,24 @@ int main(void) /* USER CODE BEGIN WHILE */ while (1) { /* USER CODE END WHILE */ - LOGOMATIC("Hello from DashPanel!\n"); - LL_mDelay(1000); + // LOGOMATIC("Hello from DashPanel!\n"); + // LL_mDelay(1000); + + if (canReadyToSend) { + + CAN_SEND_ECU msg_struct; + msg_struct.TSActiveButton = dashStatus.TSActiveButton; + msg_struct.RTDButton = dashStatus.RTDButton; + + // Kinda weird ngl but it doesn't matter + if (dashStatus.TSActiveButton) dashStatus.TSActiveButton = 0; + if (dashStatus.RTDButton) dashStatus.RTDButton = 0; + + CAN_sendECU(can_handler, &msg_struct); + + canReadyToSend = false; + + } /* USER CODE BEGIN 3 */ } /* USER CODE END 3 */ @@ -350,6 +366,8 @@ void EXTI3_IRQHandler(void) // Blame Electronics if hardware debounce doesn't work + dashStatus.TSActiveButton = 1; + canReadyToSend = true; LOGOMATIC("TS Active Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); } @@ -367,11 +385,8 @@ void EXTI4_IRQHandler(void) // Blame Electronics if hardware debounce doesn't work - CAN_SEND_ECU msg_struct; - msg_struct.TSActiveButton = 0; - msg_struct.RTDButton = 1; - - CAN_sendECU(can_handler, &msg_struct); + dashStatus.RTDButton = 1; + canReadyToSend = true; LOGOMATIC("RTD Pressed!"); LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); } From 6ed77ec53c8a6165b1843c4bc75b1107a24bfce6 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:34:39 +0000 Subject: [PATCH 57/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 1 - DashPanel/Core/Src/main.c | 9 ++++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 406a55c1f..4a39da2fa 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -11,7 +11,6 @@ CANHandle *can_handler; DashStatus dashStatus; bool canReadyToSend; - void CANInitialize() { dashStatus = {0}; diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 21e4067db..36a75f03a 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -133,13 +133,16 @@ int main(void) msg_struct.RTDButton = dashStatus.RTDButton; // Kinda weird ngl but it doesn't matter - if (dashStatus.TSActiveButton) dashStatus.TSActiveButton = 0; - if (dashStatus.RTDButton) dashStatus.RTDButton = 0; + if (dashStatus.TSActiveButton) { + dashStatus.TSActiveButton = 0; + } + if (dashStatus.RTDButton) { + dashStatus.RTDButton = 0; + } CAN_sendECU(can_handler, &msg_struct); canReadyToSend = false; - } /* USER CODE BEGIN 3 */ } From e76fb07216d561f81dc9da3dc37fe97ea183435f Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 21:45:05 -0800 Subject: [PATCH 58/95] include gr old node --- DashPanel/Application/Inc/CANdler.h | 1 + 1 file changed, 1 insertion(+) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 2b43e58fd..e5f92a400 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,6 +1,7 @@ #ifndef CANDLER_H #define CANDLER_H #include "can.h" +#include "GR_OLD_NODE_ID.h" typedef struct { uint16_t vehicleSpeed; From 381d5e2eb4fb7d3ee8eec36158a610d42618ed4b Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:46:09 +0000 Subject: [PATCH 59/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index e5f92a400..f02156000 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,7 +1,7 @@ #ifndef CANDLER_H #define CANDLER_H -#include "can.h" #include "GR_OLD_NODE_ID.h" +#include "can.h" typedef struct { uint16_t vehicleSpeed; From 4fe161ab16aa38e5a6c8f947e2bdc09afd1391f5 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 21:49:45 -0800 Subject: [PATCH 60/95] including stuff --- DashPanel/Application/Inc/CANdler.h | 4 ++++ DashPanel/CMakeLists.txt | 2 ++ 2 files changed, 6 insertions(+) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index f02156000..014416174 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,7 +1,11 @@ #ifndef CANDLER_H #define CANDLER_H #include "GR_OLD_NODE_ID.h" +<<<<<<< Updated upstream #include "can.h" +======= +#include "GR_OLD_MSG_ID.h" +>>>>>>> Stashed changes typedef struct { uint16_t vehicleSpeed; diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index 927279519..b52f34c7b 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -33,6 +33,8 @@ target_sources( Core/Src/sysmem.c Core/Src/system_stm32g4xx.c # Application + Application/Src/CANdler.c + Application/Src/dashutils.c # TODO ) From de0e4254fd4a0a5ad7d1b3fcb5210c8fe5329db1 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:50:26 +0000 Subject: [PATCH 61/95] Automatic CMake Format: Standardized formatting automatically --- DashPanel/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index b52f34c7b..1c8b6621f 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -32,7 +32,7 @@ target_sources( Core/Src/syscalls.c Core/Src/sysmem.c Core/Src/system_stm32g4xx.c - # Application + # Application Application/Src/CANdler.c Application/Src/dashutils.c # TODO From 925ab83fa3c1aa23eadcb1214a6124a2fb4eba39 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:51:28 +0000 Subject: [PATCH 62/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 014416174..396b4add7 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -3,11 +3,11 @@ #include "GR_OLD_NODE_ID.h" <<<<<<< Updated upstream #include "can.h" -======= + ======= #include "GR_OLD_MSG_ID.h" ->>>>>>> Stashed changes + >>>>>>> Stashed changes -typedef struct { + typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; uint8_t TSActiveButton; From abab4c392379b662ef9fa681d6515f7c5b0c640c Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 05:52:32 +0000 Subject: [PATCH 63/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 396b4add7..d14152099 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -3,11 +3,12 @@ #include "GR_OLD_NODE_ID.h" <<<<<<< Updated upstream #include "can.h" - ======= + == == == + = #include "GR_OLD_MSG_ID.h" - >>>>>>> Stashed changes + >>>>>>> Stashed changes - typedef struct { + typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; uint8_t TSActiveButton; From c24eb20d543d356dd88cfee38da2cc99cb170489 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 23:09:23 -0800 Subject: [PATCH 64/95] yeah --- DashPanel/Application/Inc/CANdler.h | 4 +++- DashPanel/Application/Src/CANdler.c | 19 +++++++++++-------- DashPanel/CMakeLists.txt | 1 + DashPanel/DASHPLANEL.md | 2 +- 4 files changed, 16 insertions(+), 10 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index d14152099..db972946c 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,12 +1,14 @@ #ifndef CANDLER_H #define CANDLER_H #include "GR_OLD_NODE_ID.h" -<<<<<<< Updated upstream #include "can.h" +<<<<<<< Updated upstream == == == = #include "GR_OLD_MSG_ID.h" >>>>>>> Stashed changes +======= +>>>>>>> Stashed changes typedef struct { uint16_t vehicleSpeed; diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 4a39da2fa..1e33adc2f 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,19 +1,21 @@ #include "CANdler.h" +#include "main.h" #include "can.h" #include "dashutils.h" #include "stm32g4xx_hal_fdcan.h" +#include "GR_OLD_MSG_ID.h" +#include "GR_OLD_NODE_ID.h" -#define ECU_ID 1 // ID of correct ECU message - TODO: change with correct ID -#define PING_ID 2 // ID of ping message - TODO: change with correct ID +#define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID +#define PING_ID MSG_PING // ID of ping message - TODO: change with correct ID CANHandle *can_handler; -DashStatus dashStatus; +DashStatus dashStatus = {0}; bool canReadyToSend; void CANInitialize() { - dashStatus = {0}; canReadyToSend = false; CANConfig canCfg; @@ -93,12 +95,13 @@ void CAN_callback(uint32_t ID, void *data, uint32_t size) { // Process data if (ID == ECU_ID) { - CAN_MSG_ECU *ecu_data = (CAN_MSG_ECU *)data; - dashStatus->vehicleSpeed = ecu_data->vehicleSpeed; - dashStatus->ECUState = ecu_data->ECUState; + CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; + dashStatus.vehicleSpeed = ecu_data->vehicleSpeed; + dashStatus.ECUState = ecu_data->ECUState; // Process data } else if (ID == PING_ID) { // process ping - CAN_sendPing(); + // TODO: fix ping + // CAN_sendPing(); } } diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index 1c8b6621f..98db91f73 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -43,6 +43,7 @@ target_link_libraries( INTERFACE GR_OLD_CAN_MESSAGES PERIPHERAL_CAN_LIB + CircularBuffer_Lib ) target_include_directories( diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index dd0a13a07..b1d942c16 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -14,7 +14,7 @@ ## Buttons 1. Test button interrupts -2. Move the CAN messages to grand loop + make global status + create CAN send flag +2. Actually set up CAN send and ping ## LED From 5b0bd5480196a6269f129a0a083b29e3e5d999c8 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 12 Feb 2026 23:12:00 -0800 Subject: [PATCH 65/95] get rid of git merge stuff --- DashPanel/Application/Inc/CANdler.h | 6 ------ 1 file changed, 6 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index db972946c..ab03d8d2b 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -2,13 +2,7 @@ #define CANDLER_H #include "GR_OLD_NODE_ID.h" #include "can.h" -<<<<<<< Updated upstream - == == == - = #include "GR_OLD_MSG_ID.h" - >>>>>>> Stashed changes -======= ->>>>>>> Stashed changes typedef struct { uint16_t vehicleSpeed; From 3342d2873bb3502a09888fa0ec856635e933d4ea Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 13 Feb 2026 07:13:03 +0000 Subject: [PATCH 66/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Inc/CANdler.h | 4 ++-- DashPanel/Application/Src/CANdler.c | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index ab03d8d2b..7b5b3e3c1 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -1,10 +1,10 @@ #ifndef CANDLER_H #define CANDLER_H +#include "GR_OLD_MSG_ID.h" #include "GR_OLD_NODE_ID.h" #include "can.h" -#include "GR_OLD_MSG_ID.h" - typedef struct { +typedef struct { uint16_t vehicleSpeed; uint8_t ECUState; uint8_t TSActiveButton; diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 1e33adc2f..f8b6052af 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -1,13 +1,13 @@ #include "CANdler.h" -#include "main.h" +#include "GR_OLD_MSG_ID.h" +#include "GR_OLD_NODE_ID.h" #include "can.h" #include "dashutils.h" +#include "main.h" #include "stm32g4xx_hal_fdcan.h" -#include "GR_OLD_MSG_ID.h" -#include "GR_OLD_NODE_ID.h" -#define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID +#define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID #define PING_ID MSG_PING // ID of ping message - TODO: change with correct ID CANHandle *can_handler; From 14ce3c62e7151e12029c5eeef9d2a975433d28fe Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Sat, 14 Feb 2026 02:16:49 -0800 Subject: [PATCH 67/95] Setup logomatic --- DashPanel/Core/Src/main.c | 104 +++++++------------------------------- 1 file changed, 17 insertions(+), 87 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 36a75f03a..0d08b22f9 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -19,6 +19,7 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" +#include "dashutils.h" #include "CANdler.h" /* Private includes ----------------------------------------------------------*/ @@ -44,13 +45,24 @@ /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ - +LogomaticConfig logomaticConfig = {.clock_source = LOGOMATIC_PCLK1, + .bus = LOGOMATIC_BUS, + .gpio_port = LOGOMATIC_GPIOA, + .gpio_pin_rx_tx_mask = LL_GPIO_PIN_2 | LL_GPIO_PIN_3, + .baud_rate = 115200, + .data_width = LOGOMATIC_DATAWIDTH_8B, + .stop_bits = LOGOMATIC_STOPBITS_1, + .parity = LOGOMATIC_PARITY_NONE, + .transfer_direction = LOGOMATIC_DIRECTION_TX, + .hardware_flow_control = LOGOMATIC_HWCONTROL_NONE, + .prescaler = LOGOMATIC_PRESCALER_DIV1, + .tx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8, + .rx_fifo_threshold = LOGOMATIC_FIFOTHRESHOLD_1_8}; /* USER CODE END PV */ /* Private function prototypes -----------------------------------------------*/ void SystemClock_Config(void); static void MX_GPIO_Init(void); -static void MX_LPUART1_UART_Init(void); static void GPIO_Interrupt_Init(void); /* USER CODE BEGIN PFP */ @@ -58,18 +70,7 @@ static void GPIO_Interrupt_Init(void); /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ -/* Enable ITM for SWO output */ -static void ITM_Enable(void) -{ - /* Enable TRC (Trace) */ - CoreDebug->DEMCR |= CoreDebug_DEMCR_TRCENA_Msk; - - /* Enable stimulus port 0 */ - ITM->TER |= (1UL << 0); - /* Set trace control register */ - ITM->TCR |= ITM_TCR_ITMENA_Msk; -} /* USER CODE END 0 */ /** @@ -102,21 +103,20 @@ int main(void) /* USER CODE BEGIN Init */ CANInitialize(); GPIO_Interrupt_Init(); - + Setup_Logomatic(&logomaticConfig); /* USER CODE END Init */ /* Configure the system clock */ SystemClock_Config(); /* USER CODE BEGIN SysInit */ - + LOGOMATIC("Boot completed at %lu ms\n", MillisecondsSinceBoot()); /* USER CODE END SysInit */ /* Initialize all configured peripherals */ MX_GPIO_Init(); - MX_LPUART1_UART_Init(); /* USER CODE BEGIN 2 */ - ITM_Enable(); + /* USER CODE END 2 */ /* Infinite loop */ @@ -191,76 +191,6 @@ void SystemClock_Config(void) } } -/** - * @brief LPUART1 Initialization Function - * @param None - * @retval None - */ -static void MX_LPUART1_UART_Init(void) -{ - - /* USER CODE BEGIN LPUART1_Init 0 */ - - /* USER CODE END LPUART1_Init 0 */ - - LL_LPUART_InitTypeDef LPUART_InitStruct = {0}; - - LL_GPIO_InitTypeDef GPIO_InitStruct = {0}; - - LL_RCC_SetLPUARTClockSource(LL_RCC_LPUART1_CLKSOURCE_PCLK1); - - /* Peripheral clock enable */ - LL_APB1_GRP2_EnableClock(LL_APB1_GRP2_PERIPH_LPUART1); - - LL_AHB2_GRP1_EnableClock(LL_AHB2_GRP1_PERIPH_GPIOC); - /**LPUART1 GPIO Configuration - PC0 ------> LPUART1_RX - PC1 ------> LPUART1_TX - */ - GPIO_InitStruct.Pin = LL_GPIO_PIN_0; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - GPIO_InitStruct.Pin = LL_GPIO_PIN_1; - GPIO_InitStruct.Mode = LL_GPIO_MODE_ALTERNATE; - GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.OutputType = LL_GPIO_OUTPUT_PUSHPULL; - GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; - GPIO_InitStruct.Alternate = LL_GPIO_AF_8; - LL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /* USER CODE BEGIN LPUART1_Init 1 */ - - /* USER CODE END LPUART1_Init 1 */ - LPUART_InitStruct.PrescalerValue = LL_LPUART_PRESCALER_DIV1; - LPUART_InitStruct.BaudRate = 115200; - LPUART_InitStruct.DataWidth = LL_LPUART_DATAWIDTH_8B; - LPUART_InitStruct.StopBits = LL_LPUART_STOPBITS_1; - LPUART_InitStruct.Parity = LL_LPUART_PARITY_NONE; - LPUART_InitStruct.TransferDirection = LL_LPUART_DIRECTION_TX_RX; - LPUART_InitStruct.HardwareFlowControl = LL_LPUART_HWCONTROL_NONE; - LL_LPUART_Init(LPUART1, &LPUART_InitStruct); - LL_LPUART_SetTXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_SetRXFIFOThreshold(LPUART1, LL_LPUART_FIFOTHRESHOLD_1_8); - LL_LPUART_DisableFIFO(LPUART1); - - /* USER CODE BEGIN WKUPType LPUART1 */ - - /* USER CODE END WKUPType LPUART1 */ - - LL_LPUART_Enable(LPUART1); - - /* Polling LPUART1 initialisation */ - while ((!(LL_LPUART_IsActiveFlag_TEACK(LPUART1))) || (!(LL_LPUART_IsActiveFlag_REACK(LPUART1)))) {} - /* USER CODE BEGIN LPUART1_Init 2 */ - - /* USER CODE END LPUART1_Init 2 */ -} - /** * @brief GPIO Initialization Function * @param None From d7e26aecc4435deba030cef6f3f8fb463ae8a0c1 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Sat, 14 Feb 2026 02:17:17 -0800 Subject: [PATCH 68/95] Correct `#ifdef` to `#ifndef` for header guard for dash utils --- DashPanel/Application/Inc/dashutils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/DashPanel/Application/Inc/dashutils.h b/DashPanel/Application/Inc/dashutils.h index e19e47ae4..c2df97745 100644 --- a/DashPanel/Application/Inc/dashutils.h +++ b/DashPanel/Application/Inc/dashutils.h @@ -1,4 +1,6 @@ -#ifdef DASHPANEL_UTILS_H +#include + +#ifndef DASHPANEL_UTILS_H #define DASHPANEL_UTILS_H uint32_t MillisecondsSinceBoot(void); From 51ce61f76b1c889749f7baccdf8b12288dacf871 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Sat, 14 Feb 2026 02:21:34 -0800 Subject: [PATCH 69/95] Reset arbitrary changes to `G4PERTESTING` that should not be on this branch --- G4PERTESTING/Core/Inc/main.h | 1 - G4PERTESTING/Core/Src/main.c | 2 -- 2 files changed, 3 deletions(-) diff --git a/G4PERTESTING/Core/Inc/main.h b/G4PERTESTING/Core/Inc/main.h index edc4c0b10..23d7ffce4 100644 --- a/G4PERTESTING/Core/Inc/main.h +++ b/G4PERTESTING/Core/Inc/main.h @@ -105,7 +105,6 @@ void Error_Handler(void); #define SOFTWARE_OK_CONTROL_GPIO_Port GPIOB /* USER CODE BEGIN Private defines */ -extern CANHandle /* USER CODE END Private defines */ diff --git a/G4PERTESTING/Core/Src/main.c b/G4PERTESTING/Core/Src/main.c index ee28d20d0..ba6196726 100644 --- a/G4PERTESTING/Core/Src/main.c +++ b/G4PERTESTING/Core/Src/main.c @@ -105,8 +105,6 @@ int main(void) MX_TIM2_Init(); /* USER CODE BEGIN 2 */ - /* Initialize CAN interface */ - /* USER CODE END 2 */ /* Infinite loop */ From 9c2cf1b18bf1f40a657a153676e359c58b8d6478 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 07:08:29 +0000 Subject: [PATCH 70/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 0d08b22f9..6d03b9284 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -19,8 +19,8 @@ /* Includes ------------------------------------------------------------------*/ #include "main.h" -#include "dashutils.h" #include "CANdler.h" +#include "dashutils.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ From 896d7145bae758c0cc3856cfce6653ee58906eef Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Mon, 16 Feb 2026 12:15:19 +0000 Subject: [PATCH 71/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/syscalls.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/DashPanel/Core/Src/syscalls.c b/DashPanel/Core/Src/syscalls.c index 6abf331cb..d2b217993 100644 --- a/DashPanel/Core/Src/syscalls.c +++ b/DashPanel/Core/Src/syscalls.c @@ -40,7 +40,10 @@ char **environ = __env; /* Functions */ void initialise_monitor_handles() {} -int _getpid(void) { return 1; } +int _getpid(void) +{ + return 1; +} int _kill(int pid, int sig) { From 3062f713dfedca07c5e193626a1d9ebeedd1f329 Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Mon, 16 Feb 2026 14:43:58 -0800 Subject: [PATCH 72/95] Update build command in tasks.json to use presets Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- .vscode/tasks.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 29b177bbe..2d4727490 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -34,7 +34,7 @@ "dependsOn": [ "CMake: configure" ], - "command": "cmake --build build/${command:cmake.activeBuildPresetName} --target DashPanel" + "command": "cmake --build --preset ${command:cmake.activeBuildPresetName} --target DashPanel" }, { "label": "CMake: configure and build G4HELLO", From 168700e881cb396ef3839ea2d02d273418086cee Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 17 Feb 2026 23:40:21 -0800 Subject: [PATCH 73/95] Mark size parameter in CAN callback as unused with a FIXME comment Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Application/Src/CANdler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index f8b6052af..c7bf3390e 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -5,6 +5,7 @@ #include "can.h" #include "dashutils.h" #include "main.h" +#include "Unused.h" #include "stm32g4xx_hal_fdcan.h" #define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID @@ -93,6 +94,8 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { + UNUSED(size) # FIXME Validate actual size versus expected size for different messages! + // Process data if (ID == ECU_ID) { CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; From 4f4467ceeb97eaa58dc0d9124e31599972a79838 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 07:41:22 +0000 Subject: [PATCH 74/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index c7bf3390e..4d170b8c5 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -2,10 +2,10 @@ #include "GR_OLD_MSG_ID.h" #include "GR_OLD_NODE_ID.h" +#include "Unused.h" #include "can.h" #include "dashutils.h" #include "main.h" -#include "Unused.h" #include "stm32g4xx_hal_fdcan.h" #define ECU_ID GR_ECU // ID of correct ECU message - TODO: change with correct ID @@ -97,12 +97,15 @@ void CAN_callback(uint32_t ID, void *data, uint32_t size) UNUSED(size) # FIXME Validate actual size versus expected size for different messages! // Process data - if (ID == ECU_ID) { + if (ID == ECU_ID) + { CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; dashStatus.vehicleSpeed = ecu_data->vehicleSpeed; dashStatus.ECUState = ecu_data->ECUState; // Process data - } else if (ID == PING_ID) { + } + else if (ID == PING_ID) + { // process ping // TODO: fix ping // CAN_sendPing(); From e149e6c5ddaf97d1c95b7077d51689b25cb69f2d Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 17 Feb 2026 23:41:55 -0800 Subject: [PATCH 75/95] Fix comment Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 4d170b8c5..5d07381ec 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,7 +94,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size) # FIXME Validate actual size versus expected size for different messages! + UNUSED(size) // FIXME Validate actual size versus expected size for different messages! // Process data if (ID == ECU_ID) From 77092596017aaf2a144f5c8f73a9054cea646ccb Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 07:42:56 +0000 Subject: [PATCH 76/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 5d07381ec..32f5e7b70 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,18 +94,15 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size) // FIXME Validate actual size versus expected size for different messages! - + UNUSED(size) // FIXME Validate actual size versus expected size for different messages! + // Process data - if (ID == ECU_ID) - { + if (ID == ECU_ID) { CAN_RECEIVE_ECU *ecu_data = (CAN_RECEIVE_ECU *)data; dashStatus.vehicleSpeed = ecu_data->vehicleSpeed; dashStatus.ECUState = ecu_data->ECUState; // Process data - } - else if (ID == PING_ID) - { + } else if (ID == PING_ID) { // process ping // TODO: fix ping // CAN_sendPing(); From b2a871b8001ca7bcb173a976e556d6639349a773 Mon Sep 17 00:00:00 2001 From: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> Date: Tue, 17 Feb 2026 23:44:23 -0800 Subject: [PATCH 77/95] Need sleep before committing tiny changes Signed-off-by: Daniel Hansen <105574022+dchansen06@users.noreply.github.com> --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 32f5e7b70..e0114a238 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,7 +94,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size) // FIXME Validate actual size versus expected size for different messages! + UNUSED(size); // FIXME Validate actual size versus expected size for different messages! // Process data if (ID == ECU_ID) { From bd8cca3e4cf95e3d5c8baf5444096464df229e43 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Wed, 18 Feb 2026 07:45:25 +0000 Subject: [PATCH 78/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index e0114a238..92d96cdb1 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -94,7 +94,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) void CAN_callback(uint32_t ID, void *data, uint32_t size) { - UNUSED(size); // FIXME Validate actual size versus expected size for different messages! + UNUSED(size); // FIXME Validate actual size versus expected size for different messages! // Process data if (ID == ECU_ID) { From a4c8166ceae959fe92b3a97906ba4e89379fd985 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 19 Feb 2026 20:22:36 -0800 Subject: [PATCH 79/95] kinda set up the send msg --- DashPanel/Application/Src/CANdler.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 92d96cdb1..90dbee640 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -86,8 +86,16 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) { FDCANTxMessage sendECUMsg; - - // TODO: set up the message + sendECUMsg.tx_header.Identifier = (GR_DASH_PANEL << 20) | (MSG_PING << 8) | to; // TODO: replace identifier with correct values + sendECUMsg.tx_header.IdType = FDCAN_STANDARD_ID; + sendECUMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME; + sendECUMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; + sendECUMsg.tx_header.DataLength = sizeof(CAN_SEND_ECU); + sendECUMsg.tx_header.BitRateSwitch = FDCAN_BRS_OFF; + sendECUMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; + sendECUMsg.tx_header.MessageMarker = 0; + + ((uint32_t *)(sendECUMsg.data))[0] = *msg; can_send(c, &sendECUMsg); } From ade87e70b031e41aeb3e5fcedb53602d6dbb6324 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 19 Feb 2026 20:53:11 -0800 Subject: [PATCH 80/95] hypothetically can works --- DashPanel/Application/Inc/CANdler.h | 2 +- DashPanel/Application/Src/CANdler.c | 6 +++--- DashPanel/Core/Src/main.c | 2 +- DashPanel/DASHPLANEL.md | 6 +----- 4 files changed, 6 insertions(+), 10 deletions(-) diff --git a/DashPanel/Application/Inc/CANdler.h b/DashPanel/Application/Inc/CANdler.h index 7b5b3e3c1..2c6fc16a9 100644 --- a/DashPanel/Application/Inc/CANdler.h +++ b/DashPanel/Application/Inc/CANdler.h @@ -27,6 +27,6 @@ extern bool canReadyToSend; void CANInitialize(); void CAN_sendPing(GR_OLD_NODE_ID to); void CAN_callback(uint32_t ID, void *data, uint32_t size); -void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg); +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to); #endif diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 90dbee640..c666a56ed 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -82,11 +82,11 @@ void CAN_sendPing(GR_OLD_NODE_ID to) can_send(can_handler, &pingMsg); } -void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to); { FDCANTxMessage sendECUMsg; - sendECUMsg.tx_header.Identifier = (GR_DASH_PANEL << 20) | (MSG_PING << 8) | to; // TODO: replace identifier with correct values + sendECUMsg.tx_header.Identifier = (GR_DASH_PANEL << 20) | (MSG_DASH_STATUS << 8) | to; // TODO: replace identifier with correct values sendECUMsg.tx_header.IdType = FDCAN_STANDARD_ID; sendECUMsg.tx_header.TxFrameType = FDCAN_DATA_FRAME; sendECUMsg.tx_header.ErrorStateIndicator = FDCAN_ESI_ACTIVE; @@ -95,7 +95,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg) sendECUMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; sendECUMsg.tx_header.MessageMarker = 0; - ((uint32_t *)(sendECUMsg.data))[0] = *msg; + ( (uint32_t *)(sendECUMsg.data))[0] = *msg; can_send(c, &sendECUMsg); } diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 6d03b9284..cba68ebaf 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -140,7 +140,7 @@ int main(void) dashStatus.RTDButton = 0; } - CAN_sendECU(can_handler, &msg_struct); + CAN_sendECU(can_handler, &msg_struct, GR_ECU); canReadyToSend = false; } diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index b1d942c16..929c172a2 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -2,19 +2,15 @@ ## CAN -1. Set up CANdler with help of CAN team -2. Export button inputs -3. Import ECU CAN messages +1. Test CAN - Torque, Current, Speed, or put battery before drive - Probably need to figure out what we're putting on the board for now -- We should set up the ECU send too... - Also update the README ## Buttons 1. Test button interrupts -2. Actually set up CAN send and ping ## LED From 4508b13741d02f83d48a3b411378be53d38cadab Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 05:03:01 +0000 Subject: [PATCH 81/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index c666a56ed..5279e2028 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -95,7 +95,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to); sendECUMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; sendECUMsg.tx_header.MessageMarker = 0; - ( (uint32_t *)(sendECUMsg.data))[0] = *msg; + ((uint32_t *)(sendECUMsg.data))[0] = *msg; can_send(c, &sendECUMsg); } From dac17355f8ab300362d43f66bfbb25e745f0d064 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Thu, 19 Feb 2026 21:43:46 -0800 Subject: [PATCH 82/95] silly mistake --- DashPanel/Application/Src/CANdler.c | 4 ++-- DashPanel/Core/Src/main.c | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 5279e2028..25fbb5712 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -82,7 +82,7 @@ void CAN_sendPing(GR_OLD_NODE_ID to) can_send(can_handler, &pingMsg); } -void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to); +void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to) { FDCANTxMessage sendECUMsg; @@ -95,7 +95,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to); sendECUMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; sendECUMsg.tx_header.MessageMarker = 0; - ((uint32_t *)(sendECUMsg.data))[0] = *msg; + ((uint32_t *)(sendECUMsg.data))[0] = (uint32_t *) msg; can_send(c, &sendECUMsg); } diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index cba68ebaf..5b0ed8b5d 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -110,7 +110,8 @@ int main(void) SystemClock_Config(); /* USER CODE BEGIN SysInit */ - LOGOMATIC("Boot completed at %lu ms\n", MillisecondsSinceBoot()); + LL_mDelay(50); + LOGOMATIC("\nBoot completed at %lu ms\n", MillisecondsSinceBoot()); /* USER CODE END SysInit */ /* Initialize all configured peripherals */ @@ -276,8 +277,8 @@ static void GPIO_Interrupt_Init(void) LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE3); LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE4); - LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_0); - LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_0); + LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_3); + LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_4); NVIC_SetPriority(EXTI3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); NVIC_SetPriority(EXTI4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); From 93f48202c03f3cf67f5a0150ea8ccfd186056bd2 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Feb 2026 09:17:26 +0000 Subject: [PATCH 83/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 25fbb5712..d501a573f 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -95,7 +95,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to) sendECUMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; sendECUMsg.tx_header.MessageMarker = 0; - ((uint32_t *)(sendECUMsg.data))[0] = (uint32_t *) msg; + ((uint32_t *)(sendECUMsg.data))[0] = (uint32_t *)msg; can_send(c, &sendECUMsg); } From cc3c643c8e19495bc195ef9cf7c45f7cc3024f52 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Fri, 20 Feb 2026 02:09:17 -0800 Subject: [PATCH 84/95] Get rid of files no longer needed Signed-off-by: Daniel Hansen --- DashPanel/CMakeLists.txt | 3 - DashPanel/Core/Src/syscalls.c | 233 --------------------- DashPanel/Core/Src/sysmem.c | 85 -------- DashPanel/Core/Src/system_stm32g4xx.c | 284 -------------------------- 4 files changed, 605 deletions(-) delete mode 100644 DashPanel/Core/Src/syscalls.c delete mode 100644 DashPanel/Core/Src/sysmem.c delete mode 100644 DashPanel/Core/Src/system_stm32g4xx.c diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index 98db91f73..dbd448a22 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -29,9 +29,6 @@ target_sources( # Core Core/Src/main.c Core/Src/stm32g4xx_it.c - Core/Src/syscalls.c - Core/Src/sysmem.c - Core/Src/system_stm32g4xx.c # Application Application/Src/CANdler.c Application/Src/dashutils.c diff --git a/DashPanel/Core/Src/syscalls.c b/DashPanel/Core/Src/syscalls.c deleted file mode 100644 index d2b217993..000000000 --- a/DashPanel/Core/Src/syscalls.c +++ /dev/null @@ -1,233 +0,0 @@ -/** - ****************************************************************************** - * @file syscalls.c - * @author Auto-generated by STM32CubeMX - * @brief Minimal System calls file - * - * For more information about which c-functions - * need which of these lowlevel functions - * please consult the Newlib or Picolibc libc-manual - ****************************************************************************** - * @attention - * - * Copyright (c) 2020-2025 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. - * - ****************************************************************************** - */ - -/* Includes */ -#include -#include -#include -#include -#include -#include -#include -#include - -/* Variables */ -extern int __io_putchar(int ch) __attribute__((weak)); -extern int __io_getchar(void) __attribute__((weak)); - -char *__env[1] = {0}; -char **environ = __env; - -/* Functions */ -void initialise_monitor_handles() {} - -int _getpid(void) -{ - return 1; -} - -int _kill(int pid, int sig) -{ - (void)pid; - (void)sig; - errno = EINVAL; - return -1; -} - -void _exit(int status) -{ - _kill(status, -1); - while (1) {} /* Make sure we hang here */ -} - -__attribute__((weak)) int _read(int file, char *ptr, int len) -{ - (void)file; - int DataIdx; - - for (DataIdx = 0; DataIdx < len; DataIdx++) { - *ptr++ = __io_getchar(); - } - - return len; -} - -__attribute__((weak)) int _write(int file, char *ptr, int len) -{ - (void)file; - int DataIdx; - - for (DataIdx = 0; DataIdx < len; DataIdx++) { - __io_putchar(*ptr++); - } - return len; -} - -int _close(int file) -{ - (void)file; - return -1; -} - -int _fstat(int file, struct stat *st) -{ - (void)file; - st->st_mode = S_IFCHR; - return 0; -} - -int _isatty(int file) -{ - (void)file; - return 1; -} - -int _lseek(int file, int ptr, int dir) -{ - (void)file; - (void)ptr; - (void)dir; - return 0; -} - -int _open(char *path, int flags, ...) -{ - (void)path; - (void)flags; - /* Pretend like we always fail */ - return -1; -} - -int _wait(int *status) -{ - (void)status; - errno = ECHILD; - return -1; -} - -int _unlink(char *name) -{ - (void)name; - errno = ENOENT; - return -1; -} - -clock_t _times(struct tms *buf) -{ - (void)buf; - return -1; -} - -int _stat(const char *file, struct stat *st) -{ - (void)file; - st->st_mode = S_IFCHR; - return 0; -} - -int _link(char *old, char *new) -{ - (void)old; - (void)new; - errno = EMLINK; - return -1; -} - -int _fork(void) -{ - errno = EAGAIN; - return -1; -} - -int _execve(char *name, char **argv, char **env) -{ - (void)name; - (void)argv; - (void)env; - errno = ENOMEM; - return -1; -} - -// --- Picolibc Specific Section --- -#if defined(__PICOLIBC__) - -/** - * @brief Picolibc helper function to output a character to a FILE stream. - * This redirects the output to the low-level __io_putchar function. - * @param c Character to write. - * @param file FILE stream pointer (ignored). - * @retval int The character written. - */ -static int starm_putc(char c, FILE *file) -{ - (void)file; - __io_putchar(c); - return c; -} - -/** - * @brief Picolibc helper function to input a character from a FILE stream. - * This redirects the input from the low-level __io_getchar function. - * @param file FILE stream pointer (ignored). - * @retval int The character read, cast to an unsigned char then int. - */ -static int starm_getc(FILE *file) -{ - unsigned char c; - (void)file; - c = __io_getchar(); - return c; -} - -// Define and initialize the standard I/O streams for Picolibc. -// FDEV_SETUP_STREAM connects the starm_putc and starm_getc helper functions to a FILE structure. -// _FDEV_SETUP_RW indicates the stream is for reading and writing. -static FILE __stdio = FDEV_SETUP_STREAM(starm_putc, starm_getc, NULL, _FDEV_SETUP_RW); - -// Assign the standard stream pointers (stdin, stdout, stderr) to the initialized stream. -// Picolibc uses these pointers for standard I/O operations (printf, scanf, etc.). -FILE *const stdin = &__stdio; -__strong_reference(stdin, stdout); -__strong_reference(stdin, stderr); - -// Create strong aliases mapping standard C library function names (without underscore) -// to the implemented system call stubs (with underscore). Picolibc uses these -// standard names internally, so this linking is required. -__strong_reference(_read, read); -__strong_reference(_write, write); -__strong_reference(_times, times); -__strong_reference(_execve, execve); -__strong_reference(_fork, fork); -__strong_reference(_link, link); -__strong_reference(_unlink, unlink); -__strong_reference(_stat, stat); -__strong_reference(_wait, wait); -__strong_reference(_open, open); -__strong_reference(_close, close); -__strong_reference(_lseek, lseek); -__strong_reference(_isatty, isatty); -__strong_reference(_fstat, fstat); -__strong_reference(_exit, exit); -__strong_reference(_kill, kill); -__strong_reference(_getpid, getpid); - -#endif //__PICOLIBC__ diff --git a/DashPanel/Core/Src/sysmem.c b/DashPanel/Core/Src/sysmem.c deleted file mode 100644 index 3a092d114..000000000 --- a/DashPanel/Core/Src/sysmem.c +++ /dev/null @@ -1,85 +0,0 @@ -/** - ****************************************************************************** - * @file sysmem.c - * @author Generated by STM32CubeMX - * @brief System Memory calls file - * - * For more information about which C functions - * need which of these lowlevel functions - * please consult the Newlib or Picolibc libc manual - ****************************************************************************** - * @attention - * - * Copyright (c) 2025 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. - * - ****************************************************************************** - */ - -/* Includes */ -#include -#include -#include - -/** - * Pointer to the current high watermark of the heap usage - */ -static uint8_t *__sbrk_heap_end = NULL; - -/** - * @brief _sbrk() allocates memory to the newlib heap and is used by malloc - * and others from the C library - * - * @verbatim - * ############################################################################ - * # .data # .bss # newlib heap # MSP stack # - * # # # # Reserved by _Min_Stack_Size # - * ############################################################################ - * ^-- RAM start ^-- _end _estack, RAM end --^ - * @endverbatim - * - * This implementation starts allocating at the '_end' linker symbol - * The '_Min_Stack_Size' linker symbol reserves a memory for the MSP stack - * The implementation considers '_estack' linker symbol to be RAM end - * NOTE: If the MSP stack, at any point during execution, grows larger than the - * reserved size, please increase the '_Min_Stack_Size'. - * - * @param incr Memory size - * @return Pointer to allocated memory - */ -void *_sbrk(ptrdiff_t incr) -{ - extern uint8_t _end; /* Symbol defined in the linker script */ - extern uint8_t _estack; /* Symbol defined in the linker script */ - extern uint32_t _Min_Stack_Size; /* Symbol defined in the linker script */ - const uint32_t stack_limit = (uint32_t)&_estack - (uint32_t)&_Min_Stack_Size; - const uint8_t *max_heap = (uint8_t *)stack_limit; - uint8_t *prev_heap_end; - - /* Initialize heap end at first call */ - if (NULL == __sbrk_heap_end) { - __sbrk_heap_end = &_end; - } - - /* Protect heap from growing into the reserved MSP stack */ - if (__sbrk_heap_end + incr > max_heap) { - errno = ENOMEM; - return (void *)-1; - } - - prev_heap_end = __sbrk_heap_end; - __sbrk_heap_end += incr; - - return (void *)prev_heap_end; -} - -#if defined(__PICOLIBC__) -// Picolibc expects syscalls without the leading underscore. -// This creates a strong alias so that -// calls to `sbrk()` are resolved to our `_sbrk()` implementation. -__strong_reference(_sbrk, sbrk); -#endif diff --git a/DashPanel/Core/Src/system_stm32g4xx.c b/DashPanel/Core/Src/system_stm32g4xx.c deleted file mode 100644 index 4eec0cb3c..000000000 --- a/DashPanel/Core/Src/system_stm32g4xx.c +++ /dev/null @@ -1,284 +0,0 @@ -/** - ****************************************************************************** - * @file system_stm32g4xx.c - * @author MCD Application Team - * @brief CMSIS Cortex-M4 Device Peripheral Access Layer System Source File - * - * This file provides two functions and one global variable to be called from - * user application: - * - SystemInit(): This function is called at startup just after reset and - * before branch to main program. This call is made inside - * the "startup_stm32g4xx.s" file. - * - * - SystemCoreClock variable: Contains the core clock (HCLK), it can be used - * by the user application to setup the SysTick - * timer or configure other parameters. - * - * - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must - * be called whenever the core clock is changed - * during program execution. - * - * After each device reset the HSI (16 MHz) is used as system clock source. - * Then SystemInit() function is called, in "startup_stm32g4xx.s" file, to - * configure the system clock before to branch to main program. - * - * This file configures the system clock as follows: - *============================================================================= - *----------------------------------------------------------------------------- - * System Clock source | HSI - *----------------------------------------------------------------------------- - * SYSCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * HCLK(Hz) | 16000000 - *----------------------------------------------------------------------------- - * AHB Prescaler | 1 - *----------------------------------------------------------------------------- - * APB1 Prescaler | 1 - *----------------------------------------------------------------------------- - * APB2 Prescaler | 1 - *----------------------------------------------------------------------------- - * PLL_M | 1 - *----------------------------------------------------------------------------- - * PLL_N | 16 - *----------------------------------------------------------------------------- - * PLL_P | 7 - *----------------------------------------------------------------------------- - * PLL_Q | 2 - *----------------------------------------------------------------------------- - * PLL_R | 2 - *----------------------------------------------------------------------------- - * Require 48MHz for RNG | Disabled - *----------------------------------------------------------------------------- - *============================================================================= - ****************************************************************************** - * @attention - * - * Copyright (c) 2019 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. - * - ****************************************************************************** - */ - -/** @addtogroup CMSIS - * @{ - */ - -/** @addtogroup stm32g4xx_system - * @{ - */ - -/** @addtogroup STM32G4xx_System_Private_Includes - * @{ - */ - -#include "stm32g4xx.h" - -#if !defined(HSE_VALUE) -#define HSE_VALUE 24000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined(HSI_VALUE) -#define HSI_VALUE 16000000U /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_TypesDefinitions - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Defines - * @{ - */ - -/************************* Miscellaneous Configuration ************************/ -/* Note: Following vector table addresses must be defined in line with linker - configuration. */ -/*!< Uncomment the following line if you need to relocate the vector table - anywhere in Flash or Sram, else the vector table is kept at the automatic - remap of boot address selected */ -/* #define USER_VECT_TAB_ADDRESS */ - -#if defined(USER_VECT_TAB_ADDRESS) -/*!< Uncomment the following line if you need to relocate your vector Table - in Sram else user remap will be done in Flash. */ -/* #define VECT_TAB_SRAM */ -#if defined(VECT_TAB_SRAM) -#define VECT_TAB_BASE_ADDRESS \ - SRAM_BASE /*!< Vector Table base address field. \ - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET \ - 0x00000000U /*!< Vector Table base offset field. \ - This value must be a multiple of 0x200. */ -#else -#define VECT_TAB_BASE_ADDRESS \ - FLASH_BASE /*!< Vector Table base address field. \ - This value must be a multiple of 0x200. */ -#define VECT_TAB_OFFSET \ - 0x00000000U /*!< Vector Table base offset field. \ - This value must be a multiple of 0x200. */ -#endif /* VECT_TAB_SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ - /******************************************************************************/ - /** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Macros - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Variables - * @{ - */ -/* The SystemCoreClock variable is updated in three ways: - 1) by calling CMSIS function SystemCoreClockUpdate() - 2) by calling HAL API function HAL_RCC_GetHCLKFreq() - 3) each time HAL_RCC_ClockConfig() is called to configure the system clock frequency - Note: If you use this function to configure the system clock; then there - is no need to call the 2 first functions listed above, since SystemCoreClock - variable is updated automatically. -*/ -uint32_t SystemCoreClock = HSI_VALUE; - -const uint8_t AHBPrescTable[16] = {0U, 0U, 0U, 0U, 0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U, 6U, 7U, 8U, 9U}; -const uint8_t APBPrescTable[8] = {0U, 0U, 0U, 0U, 1U, 2U, 3U, 4U}; - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_FunctionPrototypes - * @{ - */ - -/** - * @} - */ - -/** @addtogroup STM32G4xx_System_Private_Functions - * @{ - */ - -/** - * @brief Setup the microcontroller system. - * @param None - * @retval None - */ - -void SystemInit(void) -{ -/* FPU settings ------------------------------------------------------------*/ -#if (__FPU_PRESENT == 1) && (__FPU_USED == 1) - SCB->CPACR |= ((3UL << (10 * 2)) | (3UL << (11 * 2))); /* set CP10 and CP11 Full Access */ -#endif - - /* Configure the Vector Table location add offset address ------------------*/ -#if defined(USER_VECT_TAB_ADDRESS) - SCB->VTOR = VECT_TAB_BASE_ADDRESS | VECT_TAB_OFFSET; /* Vector Table Relocation in Internal SRAM */ -#endif /* USER_VECT_TAB_ADDRESS */ -} - -/** - * @brief Update SystemCoreClock variable according to Clock Register Values. - * The SystemCoreClock variable contains the core clock (HCLK), it can - * be used by the user application to setup the SysTick timer or configure - * other parameters. - * - * @note Each time the core clock (HCLK) changes, this function must be called - * to update SystemCoreClock variable value. Otherwise, any configuration - * based on this variable will be incorrect. - * - * @note - The system frequency computed by this function is not the real - * frequency in the chip. It is calculated based on the predefined - * constant and the selected clock source: - * - * - If SYSCLK source is HSI, SystemCoreClock will contain the HSI_VALUE(**) - * - * - If SYSCLK source is HSE, SystemCoreClock will contain the HSE_VALUE(***) - * - * - If SYSCLK source is PLL, SystemCoreClock will contain the HSE_VALUE(***) - * or HSI_VALUE(*) multiplied/divided by the PLL factors. - * - * (**) HSI_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 16 MHz) but the real value may vary depending on the variations - * in voltage and temperature. - * - * (***) HSE_VALUE is a constant defined in stm32g4xx_hal.h file (default value - * 24 MHz), user has to ensure that HSE_VALUE is same as the real - * frequency of the crystal used. Otherwise, this function may - * have wrong result. - * - * - The result of this function could be not correct when using fractional - * value for HSE crystal. - * - * @param None - * @retval None - */ -void SystemCoreClockUpdate(void) -{ - uint32_t tmp, pllvco, pllr, pllsource, pllm; - - /* Get SYSCLK source -------------------------------------------------------*/ - switch (RCC->CFGR & RCC_CFGR_SWS) { - case 0x04: /* HSI used as system clock source */ - SystemCoreClock = HSI_VALUE; - break; - - case 0x08: /* HSE used as system clock source */ - SystemCoreClock = HSE_VALUE; - break; - - case 0x0C: /* PLL used as system clock source */ - /* PLL_VCO = (HSE_VALUE or HSI_VALUE / PLLM) * PLLN - SYSCLK = PLL_VCO / PLLR - */ - pllsource = (RCC->PLLCFGR & RCC_PLLCFGR_PLLSRC); - pllm = ((RCC->PLLCFGR & RCC_PLLCFGR_PLLM) >> 4) + 1U; - if (pllsource == 0x02UL) /* HSI used as PLL clock source */ - { - pllvco = (HSI_VALUE / pllm); - } else /* HSE used as PLL clock source */ - { - pllvco = (HSE_VALUE / pllm); - } - pllvco = pllvco * ((RCC->PLLCFGR & RCC_PLLCFGR_PLLN) >> 8); - pllr = (((RCC->PLLCFGR & RCC_PLLCFGR_PLLR) >> 25) + 1U) * 2U; - SystemCoreClock = pllvco / pllr; - break; - - default: - break; - } - /* Compute HCLK clock frequency --------------------------------------------*/ - /* Get HCLK prescaler */ - tmp = AHBPrescTable[((RCC->CFGR & RCC_CFGR_HPRE) >> 4)]; - /* HCLK clock frequency */ - SystemCoreClock >>= tmp; -} - -/** - * @} - */ - -/** - * @} - */ - -/** - * @} - */ From 8fb538af32cfb4ca54839ce523fd583b739a2b3e Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Fri, 20 Feb 2026 02:20:33 -0800 Subject: [PATCH 85/95] Fixed pinout and associated for user button on stm32 nucleo Signed-off-by: Daniel Hansen --- DashPanel/Core/Src/main.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 5b0ed8b5d..ed079228d 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -256,6 +256,11 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + GPIO_InitStruct.Pin = LL_GPIO_PIN_13; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(GPIOC, &GPIO_InitStruct); + /* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */ @@ -286,6 +291,12 @@ static void GPIO_Interrupt_Init(void) // Enable interrupts NVIC_EnableIRQ(EXTI3_IRQn); NVIC_EnableIRQ(EXTI4_IRQn); + + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTC, LL_SYSCFG_EXTI_LINE13); + LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_13); + LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_13); + NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); + NVIC_EnableIRQ(EXTI15_10_IRQn); } /** @@ -327,6 +338,19 @@ void EXTI4_IRQHandler(void) } /* USER CODE END 4 */ +/** + * @brief EXTI Line[15:10] Interrupt Handler (for PC13 button) + * @param None + * @retval None + */ +void EXTI15_10_IRQHandler(void) +{ + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_13)) { + LOGOMATIC("PC13 Button Pressed!\n"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_13); + } +} + /** * @brief This function is executed in case of error occurrence. * @retval None From f0660cf1ccf5f3885496e056de9bde9d02b3818b Mon Sep 17 00:00:00 2001 From: Anthony Ma Date: Mon, 23 Feb 2026 20:03:34 -0800 Subject: [PATCH 86/95] Added EXTI interrupt to toggle LED when blue button pressed --- DashPanel/Application/Src/CANdler.c | 2 +- DashPanel/Core/Src/main.c | 36 ++++++++++++----------------- DashPanel/Core/Src/stm32g4xx_it.c | 15 +++++++++++- 3 files changed, 30 insertions(+), 23 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index d501a573f..d9cc6b766 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -95,7 +95,7 @@ void CAN_sendECU(CANHandle *c, CAN_SEND_ECU *msg, GR_OLD_NODE_ID to) sendECUMsg.tx_header.TxEventFifoControl = FDCAN_NO_TX_EVENTS; sendECUMsg.tx_header.MessageMarker = 0; - ((uint32_t *)(sendECUMsg.data))[0] = (uint32_t *)msg; + ((uint32_t *)(sendECUMsg.data))[0] = (uint32_t)msg; can_send(c, &sendECUMsg); } diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index ed079228d..ecd64d0c6 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -232,9 +232,9 @@ static void MX_GPIO_Init(void) GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(RTD_BTN_GPIO_Port, &GPIO_InitStruct); - /**/ + // PA5 for the toggling LED GPIO_InitStruct.Pin = LL_GPIO_PIN_5; - GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; LL_GPIO_Init(GPIOA, &GPIO_InitStruct); @@ -275,6 +275,19 @@ static void MX_GPIO_Init(void) */ static void GPIO_Interrupt_Init(void) { + // Map PC13 to External Line 13 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTC, LL_SYSCFG_EXTI_LINE13); + // Initialize + LL_EXTI_InitTypeDef EXTI_Init = {0}; + EXTI_Init.Line_0_31 = LL_EXTI_LINE_13; + EXTI_Init.LineCommand = ENABLE; + EXTI_Init.Mode = LL_EXTI_MODE_IT; + EXTI_Init.Trigger = LL_EXTI_TRIGGER_RISING; + LL_EXTI_Init(&EXTI_Init); + // Set default priority + NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); + // Enable Interrupt + NVIC_EnableIRQ(EXTI15_10_IRQn); // Map PA3 and PA4 to EXTI lines 3 and 4 LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); @@ -291,12 +304,6 @@ static void GPIO_Interrupt_Init(void) // Enable interrupts NVIC_EnableIRQ(EXTI3_IRQn); NVIC_EnableIRQ(EXTI4_IRQn); - - LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTC, LL_SYSCFG_EXTI_LINE13); - LL_EXTI_EnableIT_0_31(LL_EXTI_LINE_13); - LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_13); - NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); - NVIC_EnableIRQ(EXTI15_10_IRQn); } /** @@ -338,19 +345,6 @@ void EXTI4_IRQHandler(void) } /* USER CODE END 4 */ -/** - * @brief EXTI Line[15:10] Interrupt Handler (for PC13 button) - * @param None - * @retval None - */ -void EXTI15_10_IRQHandler(void) -{ - if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_13)) { - LOGOMATIC("PC13 Button Pressed!\n"); - LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_13); - } -} - /** * @brief This function is executed in case of error occurrence. * @retval None diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c index ccc490cc1..406d3ca77 100644 --- a/DashPanel/Core/Src/stm32g4xx_it.c +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -21,6 +21,7 @@ #include "stm32g4xx_it.h" #include "main.h" +#include "Logomatic.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ @@ -194,5 +195,17 @@ void SysTick_Handler(void) /******************************************************************************/ /* USER CODE BEGIN 1 */ - +/** + * @brief EXTI Line[15:10] Interrupt Handler (for PC13 button) + * @param None + * @retval None + */ +void EXTI15_10_IRQHandler(void) +{ + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_13)) { + LOGOMATIC("PC13 Button Pressed!\n"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_13); + LL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); + } +} /* USER CODE END 1 */ From 937e90170a8a290f9e0fd78f48dbce3ac252b795 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 04:05:10 +0000 Subject: [PATCH 87/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 8 ++++---- DashPanel/Core/Src/stm32g4xx_it.c | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index ecd64d0c6..2ebb04da4 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -280,10 +280,10 @@ static void GPIO_Interrupt_Init(void) // Initialize LL_EXTI_InitTypeDef EXTI_Init = {0}; EXTI_Init.Line_0_31 = LL_EXTI_LINE_13; - EXTI_Init.LineCommand = ENABLE; - EXTI_Init.Mode = LL_EXTI_MODE_IT; - EXTI_Init.Trigger = LL_EXTI_TRIGGER_RISING; - LL_EXTI_Init(&EXTI_Init); + EXTI_Init.LineCommand = ENABLE; + EXTI_Init.Mode = LL_EXTI_MODE_IT; + EXTI_Init.Trigger = LL_EXTI_TRIGGER_RISING; + LL_EXTI_Init(&EXTI_Init); // Set default priority NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); // Enable Interrupt diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c index 406d3ca77..5213fa8d0 100644 --- a/DashPanel/Core/Src/stm32g4xx_it.c +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -20,8 +20,8 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx_it.h" -#include "main.h" #include "Logomatic.h" +#include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ From eb688f75168bdc11c1b8184dce052ae64f1383c9 Mon Sep 17 00:00:00 2001 From: Anthony Ma Date: Mon, 23 Feb 2026 20:21:13 -0800 Subject: [PATCH 88/95] External Interrupts for PA4 works with Logomatic, PA3 should work but can't test due to not being exposed --- DashPanel/Core/Src/main.c | 69 +++++++------------------------ DashPanel/Core/Src/stm32g4xx_it.c | 40 +++++++++++++++++- 2 files changed, 54 insertions(+), 55 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index ecd64d0c6..8ddabffd6 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -110,7 +110,7 @@ int main(void) SystemClock_Config(); /* USER CODE BEGIN SysInit */ - LL_mDelay(50); + LL_mDelay(150); LOGOMATIC("\nBoot completed at %lu ms\n", MillisecondsSinceBoot()); /* USER CODE END SysInit */ @@ -275,74 +275,35 @@ static void MX_GPIO_Init(void) */ static void GPIO_Interrupt_Init(void) { - // Map PC13 to External Line 13 - LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTC, LL_SYSCFG_EXTI_LINE13); - // Initialize + // Map pins to External Lines + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTC, LL_SYSCFG_EXTI_LINE13); //PC13 --> EXTI 13 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); // PA3 --> EXTI 3 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE4); // PA4 --> EXTI 4 + + // Initialize the Interrupts LL_EXTI_InitTypeDef EXTI_Init = {0}; - EXTI_Init.Line_0_31 = LL_EXTI_LINE_13; + EXTI_Init.Line_0_31 = LL_EXTI_LINE_13; // EXTI 13 EXTI_Init.LineCommand = ENABLE; EXTI_Init.Mode = LL_EXTI_MODE_IT; EXTI_Init.Trigger = LL_EXTI_TRIGGER_RISING; LL_EXTI_Init(&EXTI_Init); + EXTI_Init.Line_0_31 = LL_EXTI_LINE_3; // EXTI 3 + LL_EXTI_Init(&EXTI_Init); + EXTI_Init.Line_0_31 = LL_EXTI_LINE_4; // EXTI 4 + LL_EXTI_Init(&EXTI_Init); + // Set default priority NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); - // Enable Interrupt - NVIC_EnableIRQ(EXTI15_10_IRQn); - - // Map PA3 and PA4 to EXTI lines 3 and 4 - LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); - LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE4); - - LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE3); - LL_EXTI_EnableIT_0_31(LL_SYSCFG_EXTI_LINE4); - LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_3); - LL_EXTI_EnableRisingTrig_0_31(LL_EXTI_LINE_4); - NVIC_SetPriority(EXTI3_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); NVIC_SetPriority(EXTI4_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); - // Enable interrupts + // Enable Interrupt + NVIC_EnableIRQ(EXTI15_10_IRQn); NVIC_EnableIRQ(EXTI3_IRQn); NVIC_EnableIRQ(EXTI4_IRQn); } -/** - * @brief EXTI Line 3 Interrupt Handler (for TS Active button) - * @param None - * @retval None - */ -void EXTI3_IRQHandler(void) -{ - if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { - - // Blame Electronics if hardware debounce doesn't work - - dashStatus.TSActiveButton = 1; - canReadyToSend = true; - LOGOMATIC("TS Active Pressed!"); - LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); - } -} - -/** - * @brief EXTI Line 4 Interrupt Handler (for RTD button) - * @param None - * @retval None - */ -void EXTI4_IRQHandler(void) -{ - - if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { - - // Blame Electronics if hardware debounce doesn't work - - dashStatus.RTDButton = 1; - canReadyToSend = true; - LOGOMATIC("RTD Pressed!"); - LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); - } -} /* USER CODE END 4 */ /** diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c index 406d3ca77..89cfcab8e 100644 --- a/DashPanel/Core/Src/stm32g4xx_it.c +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -21,7 +21,8 @@ #include "stm32g4xx_it.h" #include "main.h" -#include "Logomatic.h" +#include "Logomatic.h" // For Logomatic +#include "CANdler.h" // For CAN stuff /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ @@ -208,4 +209,41 @@ void EXTI15_10_IRQHandler(void) LL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); } } + +/** + * @brief EXTI Line 3 Interrupt Handler (for TS Active button) + * @param None + * @retval None + */ +void EXTI3_IRQHandler(void) +{ + + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_3)) { + + // Blame Electronics if hardware debounce doesn't work + dashStatus.TSActiveButton = 1; + canReadyToSend = true; + LOGOMATIC("TS Active Pressed!"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_3); + } +} + +/** + * @brief EXTI Line 4 Interrupt Handler (for RTD button) + * @param None + * @retval None + */ +void EXTI4_IRQHandler(void) +{ + + if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_4)) { + + // Blame Electronics if hardware debounce doesn't work + + dashStatus.RTDButton = 1; + canReadyToSend = true; + LOGOMATIC("RTD Pressed!"); + LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_4); + } +} /* USER CODE END 1 */ From a9465c8ae14ecf155c7df5084dc357374c57f854 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 04:25:01 +0000 Subject: [PATCH 89/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Core/Src/main.c | 19 +++++++++---------- DashPanel/Core/Src/stm32g4xx_it.c | 4 ++-- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/DashPanel/Core/Src/main.c b/DashPanel/Core/Src/main.c index 8ddabffd6..124b672e1 100644 --- a/DashPanel/Core/Src/main.c +++ b/DashPanel/Core/Src/main.c @@ -276,21 +276,21 @@ static void MX_GPIO_Init(void) static void GPIO_Interrupt_Init(void) { // Map pins to External Lines - LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTC, LL_SYSCFG_EXTI_LINE13); //PC13 --> EXTI 13 - LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); // PA3 --> EXTI 3 - LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE4); // PA4 --> EXTI 4 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTC, LL_SYSCFG_EXTI_LINE13); // PC13 --> EXTI 13 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE3); // PA3 --> EXTI 3 + LL_SYSCFG_SetEXTISource(LL_SYSCFG_EXTI_PORTA, LL_SYSCFG_EXTI_LINE4); // PA4 --> EXTI 4 // Initialize the Interrupts LL_EXTI_InitTypeDef EXTI_Init = {0}; EXTI_Init.Line_0_31 = LL_EXTI_LINE_13; // EXTI 13 - EXTI_Init.LineCommand = ENABLE; - EXTI_Init.Mode = LL_EXTI_MODE_IT; - EXTI_Init.Trigger = LL_EXTI_TRIGGER_RISING; - LL_EXTI_Init(&EXTI_Init); + EXTI_Init.LineCommand = ENABLE; + EXTI_Init.Mode = LL_EXTI_MODE_IT; + EXTI_Init.Trigger = LL_EXTI_TRIGGER_RISING; + LL_EXTI_Init(&EXTI_Init); EXTI_Init.Line_0_31 = LL_EXTI_LINE_3; // EXTI 3 - LL_EXTI_Init(&EXTI_Init); + LL_EXTI_Init(&EXTI_Init); EXTI_Init.Line_0_31 = LL_EXTI_LINE_4; // EXTI 4 - LL_EXTI_Init(&EXTI_Init); + LL_EXTI_Init(&EXTI_Init); // Set default priority NVIC_SetPriority(EXTI15_10_IRQn, NVIC_EncodePriority(NVIC_GetPriorityGrouping(), 0, 0)); @@ -303,7 +303,6 @@ static void GPIO_Interrupt_Init(void) NVIC_EnableIRQ(EXTI4_IRQn); } - /* USER CODE END 4 */ /** diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c index 89cfcab8e..b1c7d0d96 100644 --- a/DashPanel/Core/Src/stm32g4xx_it.c +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -20,9 +20,9 @@ /* Includes ------------------------------------------------------------------*/ #include "stm32g4xx_it.h" -#include "main.h" +#include "CANdler.h" // For CAN stuff #include "Logomatic.h" // For Logomatic -#include "CANdler.h" // For CAN stuff +#include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ /* USER CODE END Includes */ From 4e3730f24d02986fe562bd5f5a7a851e6c559d78 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Mon, 23 Feb 2026 21:08:18 -0800 Subject: [PATCH 90/95] Fix indentation of cmake it was bugging me --- DashPanel/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index dbd448a22..e40726810 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -32,7 +32,7 @@ target_sources( # Application Application/Src/CANdler.c Application/Src/dashutils.c - # TODO + # TODO ) target_link_libraries( From 7ac42e8681a66a13519511c1d48719f9b0d559b4 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 05:09:00 +0000 Subject: [PATCH 91/95] Automatic CMake Format: Standardized formatting automatically --- DashPanel/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/CMakeLists.txt b/DashPanel/CMakeLists.txt index e40726810..dbd448a22 100644 --- a/DashPanel/CMakeLists.txt +++ b/DashPanel/CMakeLists.txt @@ -32,7 +32,7 @@ target_sources( # Application Application/Src/CANdler.c Application/Src/dashutils.c - # TODO + # TODO ) target_link_libraries( From ca0624f9fcc8a929287ec2979e059090126e2650 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Mon, 23 Feb 2026 21:31:43 -0800 Subject: [PATCH 92/95] Make button trip things Signed-off-by: Daniel Hansen --- DashPanel/Core/Src/stm32g4xx_it.c | 1 + 1 file changed, 1 insertion(+) diff --git a/DashPanel/Core/Src/stm32g4xx_it.c b/DashPanel/Core/Src/stm32g4xx_it.c index b1c7d0d96..ffef69c44 100644 --- a/DashPanel/Core/Src/stm32g4xx_it.c +++ b/DashPanel/Core/Src/stm32g4xx_it.c @@ -205,6 +205,7 @@ void EXTI15_10_IRQHandler(void) { if (LL_EXTI_IsActiveFlag_0_31(LL_EXTI_LINE_13)) { LOGOMATIC("PC13 Button Pressed!\n"); + canReadyToSend = true; LL_EXTI_ClearFlag_0_31(LL_EXTI_LINE_13); LL_GPIO_TogglePin(GPIOA, GPIO_PIN_5); } From 032fca88e5d2678b89e84c7212c7ef11d4ce10b2 Mon Sep 17 00:00:00 2001 From: Daniel Hansen Date: Mon, 23 Feb 2026 21:31:55 -0800 Subject: [PATCH 93/95] Use internal loopback and fix pins and clock Signed-off-by: Daniel Hansen --- DashPanel/Application/Src/CANdler.c | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index d9cc6b766..f54ed6d33 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -24,7 +24,7 @@ void CANInitialize() canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; canCfg.hal_fdcan_init.FrameFormat = FDCAN_FRAME_FD_NO_BRS; canCfg.hal_fdcan_init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; - canCfg.hal_fdcan_init.Mode = FDCAN_MODE_NORMAL; + canCfg.hal_fdcan_init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK; // TODO Change canCfg.hal_fdcan_init.AutoRetransmission = ENABLE; canCfg.hal_fdcan_init.TransmitPause = DISABLE; canCfg.hal_fdcan_init.ProtocolException = ENABLE; @@ -44,25 +44,19 @@ void CANInitialize() canCfg.tx_interrupt_priority = 0; // PLEASE SET canCfg.tx_buffer_length = 3; // PLEASE SET - // canCfg.rx_gpio = GPIOB; - // canCfg.init_rx_gpio.Pin = GPIO_PIN_12; - canCfg.init_rx_gpio.Mode = GPIO_MODE_AF_PP; - canCfg.init_rx_gpio.Pull = GPIO_PULLUP; - canCfg.init_rx_gpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - // canCfg.init_rx_gpio.Alternate = GPIO_AF9_FDCAN2; + canCfg.fdcan_instance = FDCAN1; + canCfg.rx_gpio = GPIOA; + canCfg.init_rx_gpio.Pin = GPIO_PIN_11; + canCfg.init_rx_gpio.Alternate = GPIO_AF9_FDCAN1; - // canCfg.tx_gpio = GPIOB; - // canCfg.init_tx_gpio.Pin = GPIO_PIN_13; - canCfg.init_tx_gpio.Mode = GPIO_MODE_AF_PP; - canCfg.init_tx_gpio.Pull = GPIO_NOPULL; - canCfg.init_tx_gpio.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - // canCfg.init_tx_gpio.Alternate = GPIO_AF9_FDCAN2; - - // FDCAN_FilterTypeDef filter; - // can_add_filter(can2Handle, &filter); - /* USER CODE END 2 */ + canCfg.tx_gpio = GPIOA; + canCfg.init_tx_gpio.Pin = GPIO_PIN_12; + canCfg.init_tx_gpio.Alternate = GPIO_AF9_FDCAN1; can_handler = can_init(&canCfg); + HAL_FDCAN_ConfigGlobalFilter(can_handler->hal_fdcanP, 0, 0, 0, 0); + can_set_clksource(LL_RCC_FDCAN_CLKSOURCE_PCLK1); + can_start(can_handler); } From dc475cffed27501b1da189efa371bed93e0081e5 Mon Sep 17 00:00:00 2001 From: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Date: Tue, 24 Feb 2026 05:33:15 +0000 Subject: [PATCH 94/95] Automatic Clang-Format: Standardized formatting automatically --- DashPanel/Application/Src/CANdler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index f54ed6d33..0e97223b3 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -24,7 +24,7 @@ void CANInitialize() canCfg.hal_fdcan_init.ClockDivider = FDCAN_CLOCK_DIV1; canCfg.hal_fdcan_init.FrameFormat = FDCAN_FRAME_FD_NO_BRS; canCfg.hal_fdcan_init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; - canCfg.hal_fdcan_init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK; // TODO Change + canCfg.hal_fdcan_init.Mode = FDCAN_MODE_INTERNAL_LOOPBACK; // TODO Change canCfg.hal_fdcan_init.AutoRetransmission = ENABLE; canCfg.hal_fdcan_init.TransmitPause = DISABLE; canCfg.hal_fdcan_init.ProtocolException = ENABLE; From 0f44512e4a887e6306f502941e66eede12083ea0 Mon Sep 17 00:00:00 2001 From: Bailey Say Date: Mon, 23 Feb 2026 22:32:38 -0800 Subject: [PATCH 95/95] update dash planel --- DashPanel/Application/Src/CANdler.c | 2 +- DashPanel/DASHPLANEL.md | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/DashPanel/Application/Src/CANdler.c b/DashPanel/Application/Src/CANdler.c index 0e97223b3..586364855 100644 --- a/DashPanel/Application/Src/CANdler.c +++ b/DashPanel/Application/Src/CANdler.c @@ -107,6 +107,6 @@ void CAN_callback(uint32_t ID, void *data, uint32_t size) } else if (ID == PING_ID) { // process ping // TODO: fix ping - // CAN_sendPing(); + CAN_sendPing(); } } diff --git a/DashPanel/DASHPLANEL.md b/DashPanel/DASHPLANEL.md index 929c172a2..49e04397c 100644 --- a/DashPanel/DASHPLANEL.md +++ b/DashPanel/DASHPLANEL.md @@ -1,16 +1,14 @@ # DASH PLANel -## CAN +- Update the README -1. Test CAN +## Notes: - Torque, Current, Speed, or put battery before drive -- Probably need to figure out what we're putting on the board for now -- Also update the README -## Buttons +## CAN -1. Test button interrupts +- Test ping ## LED