Fix CubeMX's wrongdoing

This commit is contained in:
Julian Marmier 2024-06-12 22:37:51 +02:00
parent c07df344f3
commit 171d2807d4
5 changed files with 363 additions and 388 deletions

View File

@ -7,7 +7,7 @@
extern "C" { extern "C" {
#endif #endif
#define NUM_BUTTONS 6 #define NUM_BUTTONS 7
#define NUM_ENCS 2 #define NUM_ENCS 2
#define BUTTON_MIN_INTERVAL 50 // ms #define BUTTON_MIN_INTERVAL 50 // ms
#define ENC_MAX_PHASE 50 // ms #define ENC_MAX_PHASE 50 // ms

View File

@ -17,12 +17,15 @@
*/ */
/* USER CODE END Header */ /* USER CODE END Header */
/* Includes ------------------------------------------------------------------*/ /* Includes ------------------------------------------------------------------*/
#include "app_threadx.h"
#include "main.h" #include "main.h"
#include "app_threadx.h"
#include "app_touchgfx.h" #include "app_touchgfx.h"
/* Private includes ----------------------------------------------------------*/ /* Private includes ----------------------------------------------------------*/
/* USER CODE BEGIN Includes */ /* USER CODE BEGIN Includes */
#include <stdint.h>
#include "ft_logo_orange_rgb565.h" #include "ft_logo_orange_rgb565.h"
#include "ft_logo_rainbow_rgb565.h" #include "ft_logo_rainbow_rgb565.h"
#include "hx8357d.h" #include "hx8357d.h"
@ -30,8 +33,6 @@
#include "params.h" #include "params.h"
#include "shorttimer.h" #include "shorttimer.h"
#include <stdint.h>
/* USER CODE END Includes */ /* USER CODE END Includes */
/* Private typedef -----------------------------------------------------------*/ /* Private typedef -----------------------------------------------------------*/
@ -103,16 +104,15 @@ static void MX_DMA2D_Init(void);
* @brief The application entry point. * @brief The application entry point.
* @retval int * @retval int
*/ */
int main(void) 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. */ /* Reset of all peripherals, Initializes the Flash interface and the Systick.
*/
HAL_Init(); HAL_Init();
/* USER CODE BEGIN Init */ /* USER CODE BEGIN Init */
@ -173,8 +173,7 @@ int main(void)
* @brief System Clock Configuration * @brief System Clock Configuration
* @retval None * @retval None
*/ */
void SystemClock_Config(void) void SystemClock_Config(void) {
{
RCC_OscInitTypeDef RCC_OscInitStruct = {0}; RCC_OscInitTypeDef RCC_OscInitStruct = {0};
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
@ -189,7 +188,8 @@ void SystemClock_Config(void)
*/ */
__HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2); __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE2);
while(!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {} while (!__HAL_PWR_GET_FLAG(PWR_FLAG_VOSRDY)) {
}
/** Initializes the RCC Oscillators according to the specified parameters /** Initializes the RCC Oscillators according to the specified parameters
* in the RCC_OscInitTypeDef structure. * in the RCC_OscInitTypeDef structure.
@ -206,16 +206,15 @@ void SystemClock_Config(void)
RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3; RCC_OscInitStruct.PLL.PLLRGE = RCC_PLL1VCIRANGE_3;
RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE; RCC_OscInitStruct.PLL.PLLVCOSEL = RCC_PLL1VCOWIDE;
RCC_OscInitStruct.PLL.PLLFRACN = 0; RCC_OscInitStruct.PLL.PLLFRACN = 0;
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/** Initializes the CPU, AHB and APB buses clocks /** Initializes the CPU, AHB and APB buses clocks
*/ */
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK |
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2 RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2 |
|RCC_CLOCKTYPE_D3PCLK1|RCC_CLOCKTYPE_D1PCLK1; RCC_CLOCKTYPE_D3PCLK1 | RCC_CLOCKTYPE_D1PCLK1;
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1; RCC_ClkInitStruct.SYSCLKDivider = RCC_SYSCLK_DIV1;
RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1; RCC_ClkInitStruct.AHBCLKDivider = RCC_HCLK_DIV1;
@ -224,8 +223,7 @@ void SystemClock_Config(void)
RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2; RCC_ClkInitStruct.APB2CLKDivider = RCC_APB2_DIV2;
RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2; RCC_ClkInitStruct.APB4CLKDivider = RCC_APB4_DIV2;
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
} }
@ -235,9 +233,7 @@ void SystemClock_Config(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_CRC_Init(void) static void MX_CRC_Init(void) {
{
/* USER CODE BEGIN CRC_Init 0 */ /* USER CODE BEGIN CRC_Init 0 */
/* USER CODE END CRC_Init 0 */ /* USER CODE END CRC_Init 0 */
@ -251,14 +247,12 @@ static void MX_CRC_Init(void)
hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE; hcrc.Init.InputDataInversionMode = CRC_INPUTDATA_INVERSION_NONE;
hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE; hcrc.Init.OutputDataInversionMode = CRC_OUTPUTDATA_INVERSION_DISABLE;
hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES; hcrc.InputDataFormat = CRC_INPUTDATA_FORMAT_BYTES;
if (HAL_CRC_Init(&hcrc) != HAL_OK) if (HAL_CRC_Init(&hcrc) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN CRC_Init 2 */ /* USER CODE BEGIN CRC_Init 2 */
/* USER CODE END CRC_Init 2 */ /* USER CODE END CRC_Init 2 */
} }
/** /**
@ -266,9 +260,7 @@ static void MX_CRC_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_DMA2D_Init(void) static void MX_DMA2D_Init(void) {
{
/* USER CODE BEGIN DMA2D_Init 0 */ /* USER CODE BEGIN DMA2D_Init 0 */
/* USER CODE END DMA2D_Init 0 */ /* USER CODE END DMA2D_Init 0 */
@ -287,18 +279,15 @@ static void MX_DMA2D_Init(void)
hdma2d.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA; hdma2d.LayerCfg[1].AlphaInverted = DMA2D_REGULAR_ALPHA;
hdma2d.LayerCfg[1].RedBlueSwap = DMA2D_RB_REGULAR; hdma2d.LayerCfg[1].RedBlueSwap = DMA2D_RB_REGULAR;
hdma2d.LayerCfg[1].ChromaSubSampling = DMA2D_NO_CSS; hdma2d.LayerCfg[1].ChromaSubSampling = DMA2D_NO_CSS;
if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN DMA2D_Init 2 */ /* USER CODE BEGIN DMA2D_Init 2 */
/* USER CODE END DMA2D_Init 2 */ /* USER CODE END DMA2D_Init 2 */
} }
/** /**
@ -306,9 +295,7 @@ static void MX_DMA2D_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_FDCAN1_Init(void) static void MX_FDCAN1_Init(void) {
{
/* USER CODE BEGIN FDCAN1_Init 0 */ /* USER CODE BEGIN FDCAN1_Init 0 */
/* USER CODE END FDCAN1_Init 0 */ /* USER CODE END FDCAN1_Init 0 */
@ -344,14 +331,12 @@ static void MX_FDCAN1_Init(void)
hfdcan1.Init.TxFifoQueueElmtsNbr = 1; hfdcan1.Init.TxFifoQueueElmtsNbr = 1;
hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION; hfdcan1.Init.TxFifoQueueMode = FDCAN_TX_FIFO_OPERATION;
hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8; hfdcan1.Init.TxElmtSize = FDCAN_DATA_BYTES_8;
if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) if (HAL_FDCAN_Init(&hfdcan1) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN FDCAN1_Init 2 */ /* USER CODE BEGIN FDCAN1_Init 2 */
/* USER CODE END FDCAN1_Init 2 */ /* USER CODE END FDCAN1_Init 2 */
} }
/** /**
@ -359,9 +344,7 @@ static void MX_FDCAN1_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_JPEG_Init(void) static void MX_JPEG_Init(void) {
{
/* USER CODE BEGIN JPEG_Init 0 */ /* USER CODE BEGIN JPEG_Init 0 */
/* USER CODE END JPEG_Init 0 */ /* USER CODE END JPEG_Init 0 */
@ -370,14 +353,12 @@ static void MX_JPEG_Init(void)
/* USER CODE END JPEG_Init 1 */ /* USER CODE END JPEG_Init 1 */
hjpeg.Instance = JPEG; hjpeg.Instance = JPEG;
if (HAL_JPEG_Init(&hjpeg) != HAL_OK) if (HAL_JPEG_Init(&hjpeg) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN JPEG_Init 2 */ /* USER CODE BEGIN JPEG_Init 2 */
/* USER CODE END JPEG_Init 2 */ /* USER CODE END JPEG_Init 2 */
} }
/** /**
@ -385,9 +366,7 @@ static void MX_JPEG_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_LTDC_Init(void) static void MX_LTDC_Init(void) {
{
/* USER CODE BEGIN LTDC_Init 0 */ /* USER CODE BEGIN LTDC_Init 0 */
/* USER CODE END LTDC_Init 0 */ /* USER CODE END LTDC_Init 0 */
@ -413,8 +392,7 @@ static void MX_LTDC_Init(void)
hltdc.Init.Backcolor.Blue = 0; hltdc.Init.Backcolor.Blue = 0;
hltdc.Init.Backcolor.Green = 0; hltdc.Init.Backcolor.Green = 0;
hltdc.Init.Backcolor.Red = 0; hltdc.Init.Backcolor.Red = 0;
if (HAL_LTDC_Init(&hltdc) != HAL_OK) if (HAL_LTDC_Init(&hltdc) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
pLayerCfg.WindowX0 = 0; pLayerCfg.WindowX0 = 0;
@ -432,14 +410,12 @@ static void MX_LTDC_Init(void)
pLayerCfg.Backcolor.Blue = 0; pLayerCfg.Backcolor.Blue = 0;
pLayerCfg.Backcolor.Green = 0; pLayerCfg.Backcolor.Green = 0;
pLayerCfg.Backcolor.Red = 0; pLayerCfg.Backcolor.Red = 0;
if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN LTDC_Init 2 */ /* USER CODE BEGIN LTDC_Init 2 */
/* USER CODE END LTDC_Init 2 */ /* USER CODE END LTDC_Init 2 */
} }
/** /**
@ -447,9 +423,7 @@ static void MX_LTDC_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_OCTOSPI1_Init(void) static void MX_OCTOSPI1_Init(void) {
{
/* USER CODE BEGIN OCTOSPI1_Init 0 */ /* USER CODE BEGIN OCTOSPI1_Init 0 */
/* USER CODE END OCTOSPI1_Init 0 */ /* USER CODE END OCTOSPI1_Init 0 */
@ -476,21 +450,19 @@ static void MX_OCTOSPI1_Init(void)
hospi1.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_BYPASSED; hospi1.Init.DelayBlockBypass = HAL_OSPI_DELAY_BLOCK_BYPASSED;
hospi1.Init.MaxTran = 0; hospi1.Init.MaxTran = 0;
hospi1.Init.Refresh = 0; hospi1.Init.Refresh = 0;
if (HAL_OSPI_Init(&hospi1) != HAL_OK) if (HAL_OSPI_Init(&hospi1) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sOspiManagerCfg.ClkPort = 1; sOspiManagerCfg.ClkPort = 1;
sOspiManagerCfg.NCSPort = 1; sOspiManagerCfg.NCSPort = 1;
sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW; sOspiManagerCfg.IOLowPort = HAL_OSPIM_IOPORT_1_LOW;
if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg, HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) if (HAL_OSPIM_Config(&hospi1, &sOspiManagerCfg,
{ HAL_OSPI_TIMEOUT_DEFAULT_VALUE) != HAL_OK) {
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN OCTOSPI1_Init 2 */ /* USER CODE BEGIN OCTOSPI1_Init 2 */
/* USER CODE END OCTOSPI1_Init 2 */ /* USER CODE END OCTOSPI1_Init 2 */
} }
/** /**
@ -498,9 +470,7 @@ static void MX_OCTOSPI1_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_SPI3_Init(void) static void MX_SPI3_Init(void) {
{
/* USER CODE BEGIN SPI3_Init 0 */ /* USER CODE BEGIN SPI3_Init 0 */
/* USER CODE END SPI3_Init 0 */ /* USER CODE END SPI3_Init 0 */
@ -524,21 +494,21 @@ static void MX_SPI3_Init(void)
hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE; hspi3.Init.NSSPMode = SPI_NSS_PULSE_ENABLE;
hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW; hspi3.Init.NSSPolarity = SPI_NSS_POLARITY_LOW;
hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA; hspi3.Init.FifoThreshold = SPI_FIFO_THRESHOLD_01DATA;
hspi3.Init.TxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; hspi3.Init.TxCRCInitializationPattern =
hspi3.Init.RxCRCInitializationPattern = SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN; SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi3.Init.RxCRCInitializationPattern =
SPI_CRC_INITIALIZATION_ALL_ZERO_PATTERN;
hspi3.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE; hspi3.Init.MasterSSIdleness = SPI_MASTER_SS_IDLENESS_00CYCLE;
hspi3.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE; hspi3.Init.MasterInterDataIdleness = SPI_MASTER_INTERDATA_IDLENESS_00CYCLE;
hspi3.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE; hspi3.Init.MasterReceiverAutoSusp = SPI_MASTER_RX_AUTOSUSP_DISABLE;
hspi3.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE; hspi3.Init.MasterKeepIOState = SPI_MASTER_KEEP_IO_STATE_DISABLE;
hspi3.Init.IOSwap = SPI_IO_SWAP_DISABLE; hspi3.Init.IOSwap = SPI_IO_SWAP_DISABLE;
if (HAL_SPI_Init(&hspi3) != HAL_OK) if (HAL_SPI_Init(&hspi3) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN SPI3_Init 2 */ /* USER CODE BEGIN SPI3_Init 2 */
/* USER CODE END SPI3_Init 2 */ /* USER CODE END SPI3_Init 2 */
} }
/** /**
@ -546,9 +516,7 @@ static void MX_SPI3_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_TIM1_Init(void) static void MX_TIM1_Init(void) {
{
/* USER CODE BEGIN TIM1_Init 0 */ /* USER CODE BEGIN TIM1_Init 0 */
/* USER CODE END TIM1_Init 0 */ /* USER CODE END TIM1_Init 0 */
@ -568,24 +536,20 @@ static void MX_TIM1_Init(void)
htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim1.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim1.Init.RepetitionCounter = 0; htim1.Init.RepetitionCounter = 0;
htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; htim1.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim1) != HAL_OK) if (HAL_TIM_Base_Init(&htim1) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) if (HAL_TIM_ConfigClockSource(&htim1, &sClockSourceConfig) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
if (HAL_TIM_PWM_Init(&htim1) != HAL_OK) if (HAL_TIM_PWM_Init(&htim1) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET; sMasterConfig.MasterOutputTrigger2 = TIM_TRGO2_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) if (HAL_TIMEx_MasterConfigSynchronization(&htim1, &sMasterConfig) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.OCMode = TIM_OCMODE_PWM1;
@ -595,16 +559,13 @@ static void MX_TIM1_Init(void)
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET; sConfigOC.OCIdleState = TIM_OCIDLESTATE_RESET;
sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET; sConfigOC.OCNIdleState = TIM_OCNIDLESTATE_RESET;
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3) != HAL_OK) if (HAL_TIM_PWM_ConfigChannel(&htim1, &sConfigOC, TIM_CHANNEL_3) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE; sBreakDeadTimeConfig.OffStateRunMode = TIM_OSSR_DISABLE;
@ -618,15 +579,13 @@ static void MX_TIM1_Init(void)
sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH; sBreakDeadTimeConfig.Break2Polarity = TIM_BREAK2POLARITY_HIGH;
sBreakDeadTimeConfig.Break2Filter = 0; sBreakDeadTimeConfig.Break2Filter = 0;
sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE; sBreakDeadTimeConfig.AutomaticOutput = TIM_AUTOMATICOUTPUT_DISABLE;
if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK) if (HAL_TIMEx_ConfigBreakDeadTime(&htim1, &sBreakDeadTimeConfig) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN TIM1_Init 2 */ /* USER CODE BEGIN TIM1_Init 2 */
/* USER CODE END TIM1_Init 2 */ /* USER CODE END TIM1_Init 2 */
HAL_TIM_MspPostInit(&htim1); HAL_TIM_MspPostInit(&htim1);
} }
/** /**
@ -634,9 +593,7 @@ static void MX_TIM1_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_TIM2_Init(void) static void MX_TIM2_Init(void) {
{
/* USER CODE BEGIN TIM2_Init 0 */ /* USER CODE BEGIN TIM2_Init 0 */
/* USER CODE END TIM2_Init 0 */ /* USER CODE END TIM2_Init 0 */
@ -654,38 +611,32 @@ static void MX_TIM2_Init(void)
htim2.Init.Period = 99; htim2.Init.Period = 99;
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim2) != HAL_OK) if (HAL_TIM_Base_Init(&htim2) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL; sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) if (HAL_TIM_PWM_Init(&htim2) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 100; sConfigOC.Pulse = 100;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) if (HAL_TIM_PWM_ConfigChannel(&htim2, &sConfigOC, TIM_CHANNEL_4) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN TIM2_Init 2 */ /* USER CODE BEGIN TIM2_Init 2 */
/* USER CODE END TIM2_Init 2 */ /* USER CODE END TIM2_Init 2 */
HAL_TIM_MspPostInit(&htim2); HAL_TIM_MspPostInit(&htim2);
} }
/** /**
@ -693,9 +644,7 @@ static void MX_TIM2_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_TIM4_Init(void) static void MX_TIM4_Init(void) {
{
/* USER CODE BEGIN TIM4_Init 0 */ /* USER CODE BEGIN TIM4_Init 0 */
/* USER CODE END TIM4_Init 0 */ /* USER CODE END TIM4_Init 0 */
@ -712,33 +661,28 @@ static void MX_TIM4_Init(void)
htim4.Init.Period = 65535; htim4.Init.Period = 65535;
htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim4.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; htim4.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_PWM_Init(&htim4) != HAL_OK) if (HAL_TIM_PWM_Init(&htim4) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET; sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE; sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) if (HAL_TIMEx_MasterConfigSynchronization(&htim4, &sMasterConfig) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
sConfigOC.OCMode = TIM_OCMODE_PWM1; sConfigOC.OCMode = TIM_OCMODE_PWM1;
sConfigOC.Pulse = 0; sConfigOC.Pulse = 0;
sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH; sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
sConfigOC.OCFastMode = TIM_OCFAST_DISABLE; sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_1) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) if (HAL_TIM_PWM_ConfigChannel(&htim4, &sConfigOC, TIM_CHANNEL_2) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN TIM4_Init 2 */ /* USER CODE BEGIN TIM4_Init 2 */
/* USER CODE END TIM4_Init 2 */ /* USER CODE END TIM4_Init 2 */
HAL_TIM_MspPostInit(&htim4); HAL_TIM_MspPostInit(&htim4);
} }
/** /**
@ -746,9 +690,7 @@ static void MX_TIM4_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_TIM17_Init(void) static void MX_TIM17_Init(void) {
{
/* USER CODE BEGIN TIM17_Init 0 */ /* USER CODE BEGIN TIM17_Init 0 */
/* USER CODE END TIM17_Init 0 */ /* USER CODE END TIM17_Init 0 */
@ -757,28 +699,24 @@ static void MX_TIM17_Init(void)
/* USER CODE END TIM17_Init 1 */ /* USER CODE END TIM17_Init 1 */
htim17.Instance = TIM17; htim17.Instance = TIM17;
htim17.Init.Prescaler = 16-1; htim17.Init.Prescaler = 16 - 1;
htim17.Init.CounterMode = TIM_COUNTERMODE_UP; htim17.Init.CounterMode = TIM_COUNTERMODE_UP;
htim17.Init.Period = 1000-1; htim17.Init.Period = 1000 - 1;
htim17.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1; htim17.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
htim17.Init.RepetitionCounter = 0; htim17.Init.RepetitionCounter = 0;
htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE; htim17.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
if (HAL_TIM_Base_Init(&htim17) != HAL_OK) if (HAL_TIM_Base_Init(&htim17) != HAL_OK) {
{
Error_Handler(); Error_Handler();
} }
/* USER CODE BEGIN TIM17_Init 2 */ /* USER CODE BEGIN TIM17_Init 2 */
/* USER CODE END TIM17_Init 2 */ /* USER CODE END TIM17_Init 2 */
} }
/** /**
* Enable DMA controller clock * Enable DMA controller clock
*/ */
static void MX_DMA_Init(void) static void MX_DMA_Init(void) {
{
/* DMA controller clock enable */ /* DMA controller clock enable */
__HAL_RCC_DMA1_CLK_ENABLE(); __HAL_RCC_DMA1_CLK_ENABLE();
@ -786,7 +724,6 @@ static void MX_DMA_Init(void)
/* DMA1_Stream0_IRQn interrupt configuration */ /* DMA1_Stream0_IRQn interrupt configuration */
HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0); HAL_NVIC_SetPriority(DMA1_Stream0_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn); HAL_NVIC_EnableIRQ(DMA1_Stream0_IRQn);
} }
/** /**
@ -794,11 +731,10 @@ static void MX_DMA_Init(void)
* @param None * @param None
* @retval None * @retval None
*/ */
static void MX_GPIO_Init(void) static void MX_GPIO_Init(void) {
{
GPIO_InitTypeDef GPIO_InitStruct = {0}; GPIO_InitTypeDef GPIO_InitStruct = {0};
/* USER CODE BEGIN MX_GPIO_Init_1 */ /* USER CODE BEGIN MX_GPIO_Init_1 */
/* USER CODE END MX_GPIO_Init_1 */ /* USER CODE END MX_GPIO_Init_1 */
/* GPIO Ports Clock Enable */ /* GPIO Ports Clock Enable */
__HAL_RCC_GPIOE_CLK_ENABLE(); __HAL_RCC_GPIOE_CLK_ENABLE();
@ -811,33 +747,38 @@ static void MX_GPIO_Init(void)
__HAL_RCC_GPIOG_CLK_ENABLE(); __HAL_RCC_GPIOG_CLK_ENABLE();
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOA, STATUS1_Pin|STATUS2_Pin|DISPSPI_SCL_Pin|DISPSPI_SDA_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(
GPIOA, STATUS1_Pin | STATUS2_Pin | DISPSPI_SCL_Pin | DISPSPI_SDA_Pin,
GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(LED_LE_GPIO_Port, LED_LE_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(LED_LE_GPIO_Port, LED_LE_Pin, GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(GPIOG, DISPSPI_CSX_Pin|DISPSPI_DCX_Pin|DISP_RESET_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(GPIOG, DISPSPI_CSX_Pin | DISPSPI_DCX_Pin | DISP_RESET_Pin,
GPIO_PIN_RESET);
/*Configure GPIO pin Output Level */ /*Configure GPIO pin Output Level */
HAL_GPIO_WritePin(BOOT0_SET_GPIO_Port, BOOT0_SET_Pin, GPIO_PIN_RESET); HAL_GPIO_WritePin(BOOT0_SET_GPIO_Port, BOOT0_SET_Pin, GPIO_PIN_RESET);
/*Configure GPIO pins : ENC1A_Pin ENC1B_Pin ENC2A_Pin ENC2B_Pin */ /*Configure GPIO pins : ENC1A_Pin ENC1B_Pin ENC2A_Pin ENC2B_Pin */
GPIO_InitStruct.Pin = ENC1A_Pin|ENC1B_Pin|ENC2A_Pin|ENC2B_Pin; GPIO_InitStruct.Pin = ENC1A_Pin | ENC1B_Pin | ENC2A_Pin | ENC2B_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING; GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING_FALLING;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); HAL_GPIO_Init(GPIOE, &GPIO_InitStruct);
/*Configure GPIO pins : BTN1_Pin BTN2_Pin BTN3_Pin BTN4_Pin /*Configure GPIO pins : BTN1_Pin BTN2_Pin BTN3_Pin BTN4_Pin
BTN5_Pin BTN6_Pin SW_DRS_Pin */ BTN5_Pin BTN6_Pin SW_DRS_Pin */
GPIO_InitStruct.Pin = BTN1_Pin|BTN2_Pin|BTN3_Pin|BTN4_Pin GPIO_InitStruct.Pin = BTN1_Pin | BTN2_Pin | BTN3_Pin | BTN4_Pin | BTN5_Pin |
|BTN5_Pin|BTN6_Pin|SW_DRS_Pin; BTN6_Pin | SW_DRS_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_INPUT; GPIO_InitStruct.Mode = GPIO_MODE_INPUT;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); HAL_GPIO_Init(GPIOF, &GPIO_InitStruct);
/*Configure GPIO pins : STATUS1_Pin STATUS2_Pin DISPSPI_SCL_Pin DISPSPI_SDA_Pin */ /*Configure GPIO pins : STATUS1_Pin STATUS2_Pin DISPSPI_SCL_Pin
GPIO_InitStruct.Pin = STATUS1_Pin|STATUS2_Pin|DISPSPI_SCL_Pin|DISPSPI_SDA_Pin; * DISPSPI_SDA_Pin */
GPIO_InitStruct.Pin =
STATUS1_Pin | STATUS2_Pin | DISPSPI_SCL_Pin | DISPSPI_SDA_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -851,7 +792,7 @@ static void MX_GPIO_Init(void)
HAL_GPIO_Init(LED_LE_GPIO_Port, &GPIO_InitStruct); HAL_GPIO_Init(LED_LE_GPIO_Port, &GPIO_InitStruct);
/*Configure GPIO pins : DISPSPI_CSX_Pin DISPSPI_DCX_Pin DISP_RESET_Pin */ /*Configure GPIO pins : DISPSPI_CSX_Pin DISPSPI_DCX_Pin DISP_RESET_Pin */
GPIO_InitStruct.Pin = DISPSPI_CSX_Pin|DISPSPI_DCX_Pin|DISP_RESET_Pin; GPIO_InitStruct.Pin = DISPSPI_CSX_Pin | DISPSPI_DCX_Pin | DISP_RESET_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL; GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
@ -874,8 +815,8 @@ static void MX_GPIO_Init(void)
HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0); HAL_NVIC_SetPriority(EXTI9_5_IRQn, 0, 0);
HAL_NVIC_EnableIRQ(EXTI9_5_IRQn); HAL_NVIC_EnableIRQ(EXTI9_5_IRQn);
/* USER CODE BEGIN MX_GPIO_Init_2 */ /* USER CODE BEGIN MX_GPIO_Init_2 */
/* USER CODE END MX_GPIO_Init_2 */ /* USER CODE END MX_GPIO_Init_2 */
} }
/* USER CODE BEGIN 4 */ /* USER CODE BEGIN 4 */
@ -893,8 +834,7 @@ extern "C" {
* @param htim : TIM handle * @param htim : TIM handle
* @retval None * @retval None
*/ */
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim) {
{
/* USER CODE BEGIN Callback 0 */ /* USER CODE BEGIN Callback 0 */
/* USER CODE END Callback 0 */ /* USER CODE END Callback 0 */
@ -912,8 +852,7 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
* @brief This function is executed in case of error occurrence. * @brief This function is executed in case of error occurrence.
* @retval None * @retval None
*/ */
void Error_Handler(void) void Error_Handler(void) {
{
/* USER CODE BEGIN Error_Handler_Debug */ /* USER CODE BEGIN Error_Handler_Debug */
/* User can add his own implementation to report the HAL error return state */ /* User can add his own implementation to report the HAL error return state */
__disable_irq(); __disable_irq();
@ -937,8 +876,7 @@ void _damnyoucubemx() {
* @param line: assert_param error line source number * @param line: assert_param error line source number
* @retval None * @retval None
*/ */
void assert_failed(uint8_t *file, uint32_t line) void assert_failed(uint8_t *file, uint32_t line) {
{
/* USER CODE BEGIN 6 */ /* USER CODE BEGIN 6 */
/* User can add his own implementation to report the file name and line /* 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, number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file,

View File

@ -1,21 +1,22 @@
#include "ui.h" #include "ui.h"
#include <stdint.h>
#include "hx8357d.h"
#include "leds.h"
#include "main.h"
#include "stm32h7a3xx.h" #include "stm32h7a3xx.h"
#include "stm32h7xx_hal.h" #include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_gpio.h" #include "stm32h7xx_hal_gpio.h"
#include "tx_api.h" #include "tx_api.h"
#include "hx8357d.h"
#include "main.h"
#include "vehicle.h" #include "vehicle.h"
#include <stdint.h>
void ui_thread_entry(ULONG _) { void ui_thread_entry(ULONG _) {
GPIO_TypeDef *button_ports[NUM_BUTTONS] = {BTN1_GPIO_Port, BTN2_GPIO_Port, GPIO_TypeDef *button_ports[NUM_BUTTONS] = {
BTN3_GPIO_Port, BTN4_GPIO_Port, BTN1_GPIO_Port, BTN2_GPIO_Port, BTN3_GPIO_Port, BTN4_GPIO_Port,
BTN5_GPIO_Port, BTN6_GPIO_Port}; BTN5_GPIO_Port, BTN6_GPIO_Port, SW_DRS_GPIO_Port};
uint16_t button_pins[NUM_BUTTONS] = {BTN1_Pin, BTN2_Pin, BTN3_Pin, uint16_t button_pins[NUM_BUTTONS] = {BTN1_Pin, BTN2_Pin, BTN3_Pin, BTN4_Pin,
BTN4_Pin, BTN5_Pin, BTN6_Pin}; BTN5_Pin, BTN6_Pin, SW_DRS_Pin};
GPIO_PinState button_states[NUM_BUTTONS] = {GPIO_PIN_RESET}; GPIO_PinState button_states[NUM_BUTTONS] = {GPIO_PIN_RESET};
uint32_t button_press_times[NUM_BUTTONS] = {HAL_GetTick()}; uint32_t button_press_times[NUM_BUTTONS] = {HAL_GetTick()};
@ -43,6 +44,11 @@ void ui_thread_entry(ULONG _) {
if (press_event == 1 && button_states[1]) { if (press_event == 1 && button_states[1]) {
tx_event_flags_set(&gui_update_events, GUI_UPDATE_NEXT_SCREEN, TX_OR); tx_event_flags_set(&gui_update_events, GUI_UPDATE_NEXT_SCREEN, TX_OR);
} }
if (button_states[5] == GPIO_PIN_SET) {
led_start_animation(ANIM_RAINBOW);
}
vehicle_broadcast_buttons(button_states); vehicle_broadcast_buttons(button_states);
// Release so other threads can get scheduled // Release so other threads can get scheduled
tx_thread_sleep(1); tx_thread_sleep(1);

View File

@ -1,16 +1,14 @@
#include "vehicle.h" #include "vehicle.h"
#include "main.h"
#include "ui.h"
#include "vehicle_state.h"
#include "can-halal.h" #include "can-halal.h"
#include "main.h"
#include "stm32h7xx.h" #include "stm32h7xx.h"
#include "stm32h7xx_hal.h" #include "stm32h7xx_hal.h"
#include "stm32h7xx_hal_fdcan.h" #include "stm32h7xx_hal_fdcan.h"
#include "stm32h7xx_hal_gpio.h" #include "stm32h7xx_hal_gpio.h"
#include "tx_api.h" #include "tx_api.h"
#include "ui.h"
#include "vehicle_state.h"
#define CAN_ID_AMS_SLAVE_PANIC 0x9 #define CAN_ID_AMS_SLAVE_PANIC 0x9
#define CAN_ID_AMS_STATUS 0xA #define CAN_ID_AMS_STATUS 0xA
@ -98,7 +96,8 @@ void vehicle_broadcast_param(ParamType param, int32_t value) {
void vehicle_broadcast_buttons(GPIO_PinState *button_states) { void vehicle_broadcast_buttons(GPIO_PinState *button_states) {
uint8_t data = (button_states[0] << 2) | (button_states[1] << 0) | uint8_t data = (button_states[0] << 2) | (button_states[1] << 0) |
(button_states[2] << 1) | (button_states[3] << 3); (button_states[2] << 1) | (button_states[3] << 3) |
(button_states[6] << 4);
ftcan_transmit(CAN_ID_STW_BUTTONS, &data, 1); ftcan_transmit(CAN_ID_STW_BUTTONS, &data, 1);
} }
@ -228,12 +227,14 @@ void ftcan_msg_received_cb(uint16_t id, size_t datalen, const uint8_t *data) {
break; break;
case CAN_ID_ABX_PARAM_CONFIRMED: case CAN_ID_ABX_PARAM_CONFIRMED:
vehicle_state.last_param_confirmed = data[0]; vehicle_state.last_param_confirmed = data[0];
tx_event_flags_set(&gui_update_events, GUI_UPDATE_PARAM_CONFIRMED, TX_OR); tx_event_flags_set(&gui_update_events, GUI_UPDATE_PARAM_CONFIRMED,
TX_OR);
break; break;
case CAN_ID_SHUNT_CURRENT: { case CAN_ID_SHUNT_CURRENT: {
// The first two bytes of shunt result messages are metadata // The first two bytes of shunt result messages are metadata
const uint8_t *result_ptr = &data[2]; const uint8_t *result_ptr = &data[2];
vehicle_state.ts_current = ftcan_unmarshal_signed(&result_ptr, 4) * 1e-3; vehicle_state.ts_current =
ftcan_unmarshal_signed(&result_ptr, 4) * 1e-3;
break; break;
} }
case CAN_ID_SHUNT_VOLTAGE1: { case CAN_ID_SHUNT_VOLTAGE1: {

View File

@ -39,6 +39,34 @@ C_SOURCES = \
Core/Src/main.c \ Core/Src/main.c \
Core/Src/stm32h7xx_it.c \ Core/Src/stm32h7xx_it.c \
Core/Src/stm32h7xx_hal_msp.c \ Core/Src/stm32h7xx_hal_msp.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_cortex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_rcc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_flash_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_gpio.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_hsem.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_mdma.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_i2c_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_exti.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_dma2d.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_fdcan.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_jpeg.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ltdc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ltdc_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_ospi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_spi_ex.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_tim_ex.c \
Core/Src/system_stm32h7xx.c \
Utilities/JPEG/jpeg_utils.c \
Core/Src/app_threadx.c \ Core/Src/app_threadx.c \
Core/Src/stm32h7xx_hal_timebase_tim.c \ Core/Src/stm32h7xx_hal_timebase_tim.c \
AZURE_RTOS/App/app_azure_rtos.c \ AZURE_RTOS/App/app_azure_rtos.c \
@ -199,6 +227,8 @@ Middlewares/ST/threadx/common/src/txe_timer_deactivate.c \
Middlewares/ST/threadx/common/src/txe_timer_delete.c \ Middlewares/ST/threadx/common/src/txe_timer_delete.c \
Middlewares/ST/threadx/common/src/txe_timer_info_get.c \ Middlewares/ST/threadx/common/src/txe_timer_info_get.c \
TouchGFX/App/app_touchgfx.c \ TouchGFX/App/app_touchgfx.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc.c \
Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_crc_ex.c
TouchGFX/target/TouchGFXHAL.cpp \ TouchGFX/target/TouchGFXHAL.cpp \
TouchGFX/target/STM32TouchController.cpp \ TouchGFX/target/STM32TouchController.cpp \
TouchGFX/target/TouchGFXGPIO.cpp \ TouchGFX/target/TouchGFXGPIO.cpp \
@ -212,16 +242,16 @@ Core/Src/syscalls.c
# ASM sources # ASM sources
ASM_SOURCES = \ ASM_SOURCES = \
startup_stm32h7a3xx.s \ startup_stm32h7a3xx.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_misra.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_misra.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_context_restore.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_context_restore.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_context_save.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_context_save.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_interrupt_control.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_interrupt_control.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_interrupt_disable.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_interrupt_disable.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_interrupt_restore.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_interrupt_restore.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_schedule.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_schedule.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_stack_build.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_stack_build.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_system_return.S \ Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_thread_system_return.s \
Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_timer_interrupt.S Middlewares/ST/threadx/ports/cortex_m7/gnu/src/tx_timer_interrupt.s
####################################### #######################################