/*
 * pid.h
 *
 *  Created on: 2023/10/07
 *      Author: BestTechnology
 */

#ifndef PID_H_
#define PID_H_

#include <stdint.h>

typedef struct {
    int32_t Kp, Ki, Kd, Kf, delta_t;
    int32_t min, max;
    int32_t err[2];
    int32_t integral;
} TPIDParam_int, *PPIDParam_int;

void PIDReset_int (PPIDParam_int param);
int32_t PIDUpdate_int (PPIDParam_int param, int32_t feedback, int32_t target);

typedef struct {
    double Kp, Ki, Kd, Kf, delta_t;
    double min, max;
    double err[2];
    double integral;
} TPIDParam_real, *PPIDParam_real;

void PIDReset_real (PPIDParam_real param);
double PIDUpdate_real (PPIDParam_real param, double feedback, double target);

#endif /* PID_H_ */
