industry/foc/*/foc_velocity.c: add methods to set the zero velocity and direction of the velocity

This commit is contained in:
raiden00pl 2021-10-29 12:10:12 +02:00 committed by Xiang Xiao
parent 6cafdae44a
commit 515a25fbb8
4 changed files with 114 additions and 0 deletions

View File

@ -72,6 +72,14 @@ struct foc_velocity_ops_b16_s
CODE int (*cfg)(FAR foc_velocity_b16_t *h, FAR void *cfg);
/* Zero */
CODE int (*zero)(FAR foc_velocity_b16_t *h);
/* Direction */
CODE int (*dir)(FAR foc_velocity_b16_t *h, b16_t dir);
/* Run */
CODE int (*run)(FAR foc_velocity_b16_t *h,
@ -110,6 +118,18 @@ int foc_velocity_deinit_b16(FAR foc_velocity_b16_t *h);
int foc_velocity_cfg_b16(FAR foc_velocity_b16_t *h, FAR void *cfg);
/****************************************************************************
* Name: foc_velocity_zero_b16
****************************************************************************/
int foc_velocity_zero_b16(FAR foc_velocity_b16_t *h);
/****************************************************************************
* Name: foc_velocity_dir_b16
****************************************************************************/
int foc_velocity_dir_b16(FAR foc_velocity_b16_t *h, b16_t dir);
/****************************************************************************
* Name: foc_velocity_run_b16
****************************************************************************/

View File

@ -72,6 +72,14 @@ struct foc_velocity_ops_f32_s
CODE int (*cfg)(FAR foc_velocity_f32_t *h, FAR void *cfg);
/* Zero */
CODE int (*zero)(FAR foc_velocity_f32_t *h);
/* Direction */
CODE int (*dir)(FAR foc_velocity_f32_t *h, float dir);
/* Run velocity handler */
CODE int (*run)(FAR foc_velocity_f32_t *h,
@ -110,6 +118,18 @@ int foc_velocity_deinit_f32(FAR foc_velocity_f32_t *h);
int foc_velocity_cfg_f32(FAR foc_velocity_f32_t *h, FAR void *cfg);
/****************************************************************************
* Name: foc_velocity_zero_f32
****************************************************************************/
int foc_velocity_zero_f32(FAR foc_velocity_f32_t *h);
/****************************************************************************
* Name: foc_velocity_dir_f32
****************************************************************************/
int foc_velocity_dir_f32(FAR foc_velocity_f32_t *h, float dir);
/****************************************************************************
* Name: foc_velocity_run_f32
****************************************************************************/

View File

@ -130,6 +130,43 @@ int foc_velocity_cfg_b16(FAR foc_velocity_b16_t *h, FAR void *cfg)
return h->ops->cfg(h, cfg);
}
/****************************************************************************
* Name: foc_velocity_zero_b16
*
* Description:
* Zero the FOC velocity handler (fixed16)
*
* Input Parameter:
* h - pointer to FOC velocity handler
*
****************************************************************************/
int foc_velocity_zero_b16(FAR foc_velocity_b16_t *h)
{
DEBUGASSERT(h);
return h->ops->zero(h);
}
/****************************************************************************
* Name: foc_velocity_dir_b16
*
* Description:
* Set the FOC velocity handler direction (fixed16)
*
* Input Parameter:
* h - pointer to FOC velocity handler
* dir - sensor direction (1 if normal -1 if inverted)
*
****************************************************************************/
int foc_velocity_dir_b16(FAR foc_velocity_b16_t *h, b16_t dir)
{
DEBUGASSERT(h);
return h->ops->dir(h, dir);
}
/****************************************************************************
* Name: foc_velocity_run_b16
*

View File

@ -130,6 +130,43 @@ int foc_velocity_cfg_f32(FAR foc_velocity_f32_t *h, FAR void *cfg)
return h->ops->cfg(h, cfg);
}
/****************************************************************************
* Name: foc_velocity_zero_f32
*
* Description:
* Zero the FOC velocity handler (float32)
*
* Input Parameter:
* h - pointer to FOC velocity handler
*
****************************************************************************/
int foc_velocity_zero_f32(FAR foc_velocity_f32_t *h)
{
DEBUGASSERT(h);
return h->ops->zero(h);
}
/****************************************************************************
* Name: foc_velocity_dir_f32
*
* Description:
* Set the FOC velocity handler direction (float32)
*
* Input Parameter:
* h - pointer to FOC velocity handler
* dir - sensor direction (1 if normal -1 if inverted)
*
****************************************************************************/
int foc_velocity_dir_f32(FAR foc_velocity_f32_t *h, float dir)
{
DEBUGASSERT(h);
return h->ops->dir(h, dir);
}
/****************************************************************************
* Name: foc_velocity_run_f32
*