STM32G474RB firmware for solar buck converter with MPPT, CC control, Vfly compensation, and adaptive deadtime. Includes Textual TUI debug console for real-time telemetry, parameter tuning, and SQLite logging. Added pyproject.toml for uv: `cd code64 && uv run debug-console` Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
132 lines
3.9 KiB
C
132 lines
3.9 KiB
C
/* 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) 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.
|
|
*
|
|
******************************************************************************
|
|
*/
|
|
/* USER CODE END Header */
|
|
|
|
/* Define to prevent recursive inclusion -------------------------------------*/
|
|
#ifndef __MAIN_H
|
|
#define __MAIN_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/* Includes ------------------------------------------------------------------*/
|
|
#include "stm32g4xx_hal.h"
|
|
|
|
/* Private includes ----------------------------------------------------------*/
|
|
/* USER CODE BEGIN Includes */
|
|
|
|
/* USER CODE END Includes */
|
|
|
|
/* Exported types ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN ET */
|
|
|
|
extern volatile int16_t last_tmp;
|
|
extern volatile int16_t vfly_correction;
|
|
|
|
/* USER CODE END ET */
|
|
|
|
/* Exported constants --------------------------------------------------------*/
|
|
/* USER CODE BEGIN EC */
|
|
|
|
/* USER CODE END EC */
|
|
|
|
/* Exported macro ------------------------------------------------------------*/
|
|
/* USER CODE BEGIN EM */
|
|
|
|
/* USER CODE END EM */
|
|
|
|
void HAL_HRTIM_MspPostInit(HRTIM_HandleTypeDef *hhrtim);
|
|
|
|
void HAL_TIM_MspPostInit(TIM_HandleTypeDef *htim);
|
|
|
|
/* Exported functions prototypes ---------------------------------------------*/
|
|
void Error_Handler(void);
|
|
|
|
/* USER CODE BEGIN EFP */
|
|
|
|
/* USER CODE END EFP */
|
|
|
|
/* Private defines -----------------------------------------------------------*/
|
|
#define ALARM_Pin GPIO_PIN_13
|
|
#define ALARM_GPIO_Port GPIOC
|
|
#define V_IN_ADC_Pin GPIO_PIN_0
|
|
#define V_IN_ADC_GPIO_Port GPIOC
|
|
#define I_IN_COMP_ADC_Pin GPIO_PIN_1
|
|
#define I_IN_COMP_ADC_GPIO_Port GPIOC
|
|
#define NTC_BOARD_Pin GPIO_PIN_2
|
|
#define NTC_BOARD_GPIO_Port GPIOC
|
|
#define TEMP_OP__Pin GPIO_PIN_1
|
|
#define TEMP_OP__GPIO_Port GPIOA
|
|
#define TEMP_OUT_ADC_Pin GPIO_PIN_2
|
|
#define TEMP_OUT_ADC_GPIO_Port GPIOA
|
|
#define TEMP_OP_A3_Pin GPIO_PIN_3
|
|
#define TEMP_OP_A3_GPIO_Port GPIOA
|
|
#define VFLY_OP__Pin GPIO_PIN_5
|
|
#define VFLY_OP__GPIO_Port GPIOA
|
|
#define VFLY_OUT_ADC_Pin GPIO_PIN_6
|
|
#define VFLY_OUT_ADC_GPIO_Port GPIOA
|
|
#define VFLY_OP_A7_Pin GPIO_PIN_7
|
|
#define VFLY_OP_A7_GPIO_Port GPIOA
|
|
#define I_LOAD_ADC_Pin GPIO_PIN_4
|
|
#define I_LOAD_ADC_GPIO_Port GPIOC
|
|
#define TEST_PC5_Pin GPIO_PIN_5
|
|
#define TEST_PC5_GPIO_Port GPIOC
|
|
#define I_LOAD_COMP_Pin GPIO_PIN_0
|
|
#define I_LOAD_COMP_GPIO_Port GPIOB
|
|
#define V_OUT_COMP_ADC3_Pin GPIO_PIN_1
|
|
#define V_OUT_COMP_ADC3_GPIO_Port GPIOB
|
|
#define DISCONNECT_OUTPUT_Pin GPIO_PIN_10
|
|
#define DISCONNECT_OUTPUT_GPIO_Port GPIOB
|
|
#define VBAT_ADC_Pin GPIO_PIN_12
|
|
#define VBAT_ADC_GPIO_Port GPIOB
|
|
#define ENABLE_ISO_FET_Pin GPIO_PIN_13
|
|
#define ENABLE_ISO_FET_GPIO_Port GPIOB
|
|
#define PWM4_Pin GPIO_PIN_6
|
|
#define PWM4_GPIO_Port GPIOC
|
|
#define PWM1_Pin GPIO_PIN_7
|
|
#define PWM1_GPIO_Port GPIOC
|
|
#define PWM3_Pin GPIO_PIN_8
|
|
#define PWM3_GPIO_Port GPIOC
|
|
#define PWM2_Pin GPIO_PIN_9
|
|
#define PWM2_GPIO_Port GPIOC
|
|
#define VCP_TX_Pin GPIO_PIN_10
|
|
#define VCP_TX_GPIO_Port GPIOC
|
|
#define VCP_RX_Pin GPIO_PIN_11
|
|
#define VCP_RX_GPIO_Port GPIOC
|
|
#define FDCAN_SILENT_Pin GPIO_PIN_2
|
|
#define FDCAN_SILENT_GPIO_Port GPIOD
|
|
#define PRECHARGE_Pin GPIO_PIN_4
|
|
#define PRECHARGE_GPIO_Port GPIOB
|
|
#define DISCONNECT_INPUT_Pin GPIO_PIN_9
|
|
#define DISCONNECT_INPUT_GPIO_Port GPIOB
|
|
|
|
/* USER CODE BEGIN Private defines */
|
|
#define DUTY_TICKS_MIN (680)
|
|
#define DUTY_TICKS_MAX (6120)
|
|
#define DUTY_TICKS_MID (6800)
|
|
#define DT_HARD_MIN 14
|
|
/* USER CODE END Private defines */
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* __MAIN_H */
|