//
// Created by ZK on 2023/3/14.
//

#ifndef BOOOOMFOC_STSPIN32G4_EVB_CONTROLLER_H
#define BOOOOMFOC_STSPIN32G4_EVB_CONTROLLER_H

#include "arm_math.h"

typedef struct sFOC {
    bool is_armed;

    float v_bus, v_bus_filt, i_a, i_b, i_c;

    float i_q, i_q_filt, i_d, i_d_filt, i_bus, i_bus_filt, power_filt;
    float dtc_a, dtc_b, dtc_c;

    float current_ctrl_p_gain, current_ctrl_i_gain;
    float current_ctrl_integral_d, current_ctrl_integral_q;
} tFOC;

extern tFOC FOC;


extern void SpeedControl(float32_t target, float32_t angleVal, float32_t valMax);

extern bool FOC_current(float Id_set, float Iq_set, float Theta, float bw);


#endif //BOOOOMFOC_STSPIN32G4_EVB_CONTROLLER_H
