|
@@ -153,7 +153,7 @@ static __INLINE foc_t *foc(void) {
|
|
|
|
|
|
|
|
static __INLINE float motor_encoder_get_angle(void) {
|
|
static __INLINE float motor_encoder_get_angle(void) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
- return hall_sensor_get_theta(true);
|
|
|
|
|
|
|
+ return hall_update_elec_angle();
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
return encoder_get_theta(true);
|
|
return encoder_get_theta(true);
|
|
|
#else
|
|
#else
|
|
@@ -173,7 +173,7 @@ static __INLINE u8 motor_encoder_may_error(void) {
|
|
|
|
|
|
|
|
static __INLINE void motor_encoder_update(bool detect_err) {
|
|
static __INLINE void motor_encoder_update(bool detect_err) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
- hall_sensor_get_theta(detect_err);
|
|
|
|
|
|
|
+ hall_update_elec_angle();
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
encoder_get_theta(detect_err);
|
|
encoder_get_theta(detect_err);
|
|
|
#else
|
|
#else
|
|
@@ -183,7 +183,7 @@ static __INLINE void motor_encoder_update(bool detect_err) {
|
|
|
|
|
|
|
|
static __INLINE float motor_encoder_get_speed(void) {
|
|
static __INLINE float motor_encoder_get_speed(void) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
- return hall_sensor_get_speed();
|
|
|
|
|
|
|
+ return hall_get_velocity();
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
return encoder_get_speed();
|
|
return encoder_get_speed();
|
|
|
#else
|
|
#else
|
|
@@ -193,7 +193,7 @@ static __INLINE float motor_encoder_get_speed(void) {
|
|
|
|
|
|
|
|
static __INLINE float motor_encoder_get_vel_count(void) {
|
|
static __INLINE float motor_encoder_get_vel_count(void) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
- return 0;
|
|
|
|
|
|
|
+ return hall_get_vel_counts();
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
return encoder_get_vel_count();
|
|
return encoder_get_vel_count();
|
|
|
#else
|
|
#else
|
|
@@ -203,7 +203,7 @@ static __INLINE float motor_encoder_get_vel_count(void) {
|
|
|
|
|
|
|
|
static __INLINE float motor_encoder_get_position(void) {
|
|
static __INLINE float motor_encoder_get_position(void) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
- return 0;
|
|
|
|
|
|
|
+ return hall_get_position();
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
return encoder_get_position();
|
|
return encoder_get_position();
|
|
|
#else
|
|
#else
|
|
@@ -214,7 +214,7 @@ static __INLINE float motor_encoder_get_position(void) {
|
|
|
|
|
|
|
|
static __INLINE void motor_encoder_init(void) {
|
|
static __INLINE void motor_encoder_init(void) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
- hall_sensor_init();
|
|
|
|
|
|
|
+ hall_init();
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
encoder_init();
|
|
encoder_init();
|
|
|
#else
|
|
#else
|
|
@@ -224,7 +224,7 @@ static __INLINE void motor_encoder_init(void) {
|
|
|
|
|
|
|
|
static __INLINE void motor_encoder_start(bool start) {
|
|
static __INLINE void motor_encoder_start(bool start) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
- hall_sensor_clear(direction);
|
|
|
|
|
|
|
+ hall_init();
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
encoder_init_clear();
|
|
encoder_init_clear();
|
|
|
#else
|
|
#else
|
|
@@ -232,6 +232,17 @@ static __INLINE void motor_encoder_start(bool start) {
|
|
|
#endif
|
|
#endif
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+static __INLINE void motor_encoder_reinit(void) {
|
|
|
|
|
+#ifdef USE_ENCODER_HALL
|
|
|
|
|
+ hall_init();
|
|
|
|
|
+#elif defined (USE_ENCODER_ABI)
|
|
|
|
|
+ //do nothing
|
|
|
|
|
+#else
|
|
|
|
|
+ #error "Postion sensor ERROR"
|
|
|
|
|
+#endif
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
static __INLINE float motor_encoder_zero_phase_detect(float *enc_off){
|
|
static __INLINE float motor_encoder_zero_phase_detect(float *enc_off){
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
return 0.0f;
|
|
return 0.0f;
|
|
@@ -246,7 +257,7 @@ static __INLINE void motor_encoder_set_direction(s8 dir) {
|
|
|
#ifdef USE_ENCODER_HALL
|
|
#ifdef USE_ENCODER_HALL
|
|
|
hall_set_direction(dir);
|
|
hall_set_direction(dir);
|
|
|
#elif defined (USE_ENCODER_ABI)
|
|
#elif defined (USE_ENCODER_ABI)
|
|
|
- encoder_set_direction(dir);
|
|
|
|
|
|
|
+ //encoder_set_direction(dir);
|
|
|
#else
|
|
#else
|
|
|
#error "Postion sensor ERROR"
|
|
#error "Postion sensor ERROR"
|
|
|
#endif
|
|
#endif
|