变更
This commit is contained in:
31
BoooomCTL/Data/Angle/Angle.c
Normal file
31
BoooomCTL/Data/Angle/Angle.c
Normal file
@@ -0,0 +1,31 @@
|
||||
//
|
||||
// Created by ZK on 2023/3/14.
|
||||
//
|
||||
|
||||
#include "Angle.h"
|
||||
|
||||
|
||||
//#define EncoderName MT6816
|
||||
float32_t getAngle_MT6816() {
|
||||
// printf("Test");
|
||||
|
||||
return M_PI;
|
||||
}
|
||||
|
||||
float32_t getAngle_AS5600() {
|
||||
// printf("Test");
|
||||
|
||||
return 0.0f;
|
||||
}
|
||||
|
||||
bool Data_Init(tData *data) {
|
||||
switch (data->Angle.EncoderModel) {
|
||||
case MT6816:
|
||||
data->Angle.getAngle = getAngle_MT6816;
|
||||
break;
|
||||
case AS5600:
|
||||
data->Angle.getAngle = getAngle_AS5600;
|
||||
break;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
66
BoooomCTL/Data/Angle/Angle.h
Normal file
66
BoooomCTL/Data/Angle/Angle.h
Normal file
@@ -0,0 +1,66 @@
|
||||
//
|
||||
// Created by ZK on 2023/3/14.
|
||||
//
|
||||
|
||||
#ifndef BOOOOMFOC_STSPIN32G4_EVB_ANGLE_H
|
||||
#define BOOOOMFOC_STSPIN32G4_EVB_ANGLE_H
|
||||
|
||||
#include "APP_Main.h"
|
||||
|
||||
typedef enum {
|
||||
MT6816,
|
||||
AS5600
|
||||
} tEncoderModel;
|
||||
|
||||
typedef struct {
|
||||
tEncoderModel EncoderModel;
|
||||
|
||||
float32_t (*getAngle)();
|
||||
} tAngle;
|
||||
|
||||
typedef struct {
|
||||
tAngle Angle;
|
||||
|
||||
float32_t (*Angle_Init)();
|
||||
} tData;
|
||||
|
||||
float32_t getAngle_MT6816();
|
||||
|
||||
float32_t getAngle_AS5600();
|
||||
|
||||
bool Data_Init(tData *data);
|
||||
|
||||
|
||||
typedef struct sMT6825 {
|
||||
bool no_mag;
|
||||
bool over_speed;
|
||||
uint32_t angle;
|
||||
|
||||
uint8_t rx_err_count;
|
||||
uint8_t check_err_count;
|
||||
} tMT6825;
|
||||
|
||||
typedef struct sEncoder {
|
||||
int raw;
|
||||
int count_in_cpr;
|
||||
int count_in_cpr_prev;
|
||||
|
||||
int64_t shadow_count;
|
||||
|
||||
// pll use
|
||||
float pos_cpr_counts;
|
||||
float vel_estimate_counts;
|
||||
|
||||
float pos;
|
||||
float vel;
|
||||
|
||||
float phase;
|
||||
float phase_vel;
|
||||
|
||||
float pll_kp;
|
||||
float pll_ki;
|
||||
float interpolation;
|
||||
float snap_threshold;
|
||||
} tEncoder;
|
||||
|
||||
#endif //BOOOOMFOC_STSPIN32G4_EVB_ANGLE_H
|
||||
5
BoooomCTL/Data/Angle/MT6816/MT6816.c
Normal file
5
BoooomCTL/Data/Angle/MT6816/MT6816.c
Normal file
@@ -0,0 +1,5 @@
|
||||
//
|
||||
// Created by ZK on 2023/3/14.
|
||||
//
|
||||
|
||||
#include "MT6816.h"
|
||||
8
BoooomCTL/Data/Angle/MT6816/MT6816.h
Normal file
8
BoooomCTL/Data/Angle/MT6816/MT6816.h
Normal file
@@ -0,0 +1,8 @@
|
||||
//
|
||||
// Created by ZK on 2023/3/14.
|
||||
//
|
||||
|
||||
#ifndef BOOOOMFOC_STSPIN32G4_EVB_MT6816_H
|
||||
#define BOOOOMFOC_STSPIN32G4_EVB_MT6816_H
|
||||
|
||||
#endif //BOOOOMFOC_STSPIN32G4_EVB_MT6816_H
|
||||
Reference in New Issue
Block a user