board
Solar MPPT Power System
Public Unreviewedby TylerK
A 30 W solar battery charger with regulated 5 V and 3.3 V rails: an STM32G031 running perturb & observe MPPT and a CC/CV charge state machine, steering a TI LM5175 4-switch buck-boost through a single analog control input. Four-layer KiCad board, schematic and PCB generated from Python, with an electrothermal simulation run against the published board file.
main
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
/*
* main.h -- a STAND-IN for the main.h STM32CubeMX generates.
*
* It exists for one purpose: to let the application layer be compiled for
* the real target (Cortex-M0+, arm-none-eabi) without a CubeMX installation,
* so that syntax, types, HAL call signatures and -- importantly on a
* 64KB/8KB part -- code and data size can all be checked in CI.
*
* It is NOT a HAL implementation and must never be linked into a real
* binary. Every declaration here matches the signature CubeMX/the STM32G0
* HAL provides; if one drifts, this build breaks, which is the point.
*/
#ifndef MAIN_H_STUB
#define MAIN_H_STUB
#include <stdint.h>
#include <stddef.h>
typedef enum { HAL_OK = 0, HAL_ERROR, HAL_BUSY, HAL_TIMEOUT } HAL_StatusTypeDef;
typedef enum { GPIO_PIN_RESET = 0, GPIO_PIN_SET } GPIO_PinState;
typedef struct { uint32_t dummy; } GPIO_TypeDef;
typedef struct { uint32_t Instance; uint32_t dummy; } ADC_HandleTypeDef;
typedef struct { uint32_t Instance; uint32_t arr; } TIM_HandleTypeDef;
typedef struct { uint32_t Instance; uint32_t dummy; } UART_HandleTypeDef;
extern ADC_HandleTypeDef hadc1;
extern TIM_HandleTypeDef htim14;
extern UART_HandleTypeDef huart1;
extern GPIO_TypeDef *GPIOA;
extern GPIO_TypeDef *GPIOB;
#define TIM_CHANNEL_1 0x00000000U
#define LED1_GPIO_Port GPIOA
#define LED1_Pin ((uint16_t)(1U << 6))
#define LED2_GPIO_Port GPIOA
#define LED2_Pin ((uint16_t)(1U << 7))
#define MPPT_PGOOD_GPIO_Port GPIOA
#define MPPT_PGOOD_Pin ((uint16_t)(1U << 8))
#define BIAS_PGOOD_GPIO_Port GPIOB
#define BIAS_PGOOD_Pin ((uint16_t)(1U << 3))
uint32_t HAL_GetTick(void);
HAL_StatusTypeDef HAL_ADC_Start(ADC_HandleTypeDef *h);
HAL_StatusTypeDef HAL_ADC_Stop(ADC_HandleTypeDef *h);
HAL_StatusTypeDef HAL_ADC_PollForConversion(ADC_HandleTypeDef *h, uint32_t timeout);
uint32_t HAL_ADC_GetValue(const ADC_HandleTypeDef *h);
GPIO_PinState HAL_GPIO_ReadPin(GPIO_TypeDef *port, uint16_t pin);
void HAL_GPIO_WritePin(GPIO_TypeDef *port, uint16_t pin, GPIO_PinState st);
HAL_StatusTypeDef HAL_TIM_PWM_Start(TIM_HandleTypeDef *h, uint32_t ch);
HAL_StatusTypeDef HAL_UART_Transmit(UART_HandleTypeDef *h, uint8_t *d, uint16_t n, uint32_t to);
#define __HAL_TIM_SET_COMPARE(h, ch, v) ((void)((h)->arr = (uint32_t)(v)))
#define __HAL_TIM_GET_AUTORELOAD(h) ((h)->arr)
#endif /* MAIN_H_STUB */