проект запущен шим идет, нужно запустить с пид регулятором вывести все измерения в структуру
This commit is contained in:
@@ -4,6 +4,63 @@
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
## Runtime configuration model
|
||||
|
||||
`g_dcdc_config` is intentionally a global `volatile` structure so it can be
|
||||
edited from Keil **Watch**, **Memory**, or a future UART command parser while
|
||||
the firmware is running.
|
||||
|
||||
Typical live edits during the current HRTIM test:
|
||||
|
||||
- `g_dcdc_config.mode = DCDC_MODE_PWM_TEST`
|
||||
- `g_dcdc_config.pwm.frequency_hz = 200000`
|
||||
- `g_dcdc_config.pwm.test_duty_permille = 100`
|
||||
- `g_dcdc_config.pwm.deadtime_rising_ticks = 34`
|
||||
- `g_dcdc_config.pwm.deadtime_falling_ticks = 34`
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
DCDC_MODE_MONITOR = 0,
|
||||
DCDC_MODE_PWM_TEST,
|
||||
DCDC_MODE_CLOSED_LOOP
|
||||
} DCDC_Mode;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t frequency_hz;
|
||||
uint32_t test_duty_permille;
|
||||
uint32_t max_duty_permille;
|
||||
uint32_t deadtime_enable;
|
||||
uint32_t deadtime_rising_ticks;
|
||||
uint32_t deadtime_falling_ticks;
|
||||
} DCDC_PwmRuntimeConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t target_vout_mv;
|
||||
uint32_t min_vin_mv;
|
||||
uint32_t max_vout_mv;
|
||||
uint32_t current_limit_ma;
|
||||
uint32_t hard_current_ma;
|
||||
} DCDC_LimitsRuntimeConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
int32_t kp_ticks_per_100mv;
|
||||
int32_t ki_ticks_per_100mv;
|
||||
int32_t current_limit_kp;
|
||||
} DCDC_LoopRuntimeConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32_t mode;
|
||||
uint32_t connect_usbpd_input;
|
||||
DCDC_PwmRuntimeConfig pwm;
|
||||
DCDC_LimitsRuntimeConfig limits;
|
||||
DCDC_LoopRuntimeConfig loop;
|
||||
} DCDC_RuntimeConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t vin_raw;
|
||||
@@ -18,6 +75,7 @@ typedef enum
|
||||
{
|
||||
DCDC_STATE_STOPPED = 0,
|
||||
DCDC_STATE_READY,
|
||||
DCDC_STATE_PWM_TEST,
|
||||
DCDC_STATE_RUNNING,
|
||||
DCDC_STATE_FAULT
|
||||
} DCDC_State;
|
||||
@@ -31,17 +89,24 @@ typedef enum
|
||||
DCDC_FAULT_HRTIM
|
||||
} DCDC_Fault;
|
||||
|
||||
extern volatile DCDC_RuntimeConfig g_dcdc_config;
|
||||
|
||||
void DCDC_Init(void);
|
||||
void DCDC_Start(void);
|
||||
void DCDC_StartPwmTest(void);
|
||||
void DCDC_Stop(void);
|
||||
void DCDC_Service1ms(void);
|
||||
void DCDC_ApplyRuntimeConfig(void);
|
||||
void DCDC_ControlStep(void);
|
||||
void DCDC_ReadMeasurements(DCDC_Measurements *out);
|
||||
|
||||
DCDC_Mode DCDC_GetMode(void);
|
||||
DCDC_State DCDC_GetState(void);
|
||||
DCDC_Fault DCDC_GetFault(void);
|
||||
bool DCDC_IsHrtimReady(void);
|
||||
uint32_t DCDC_GetDutyTicks(void);
|
||||
uint32_t DCDC_GetPeriodTicks(void);
|
||||
const char *DCDC_ModeText(DCDC_Mode mode);
|
||||
const char *DCDC_StateText(DCDC_State state);
|
||||
const char *DCDC_FaultText(DCDC_Fault fault);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user