HPM SDK
HPMicro Software Development Kit
hpm_motor_math.h File Reference
#include <stdint.h>
#include <math.h>

Go to the source code of this file.

Macros

#define HPM_MOTOR_MATH_MOD_Q_SW   (1)
 Motor library using mathematical format. More...
 
#define HPM_MOTOR_MATH_MOD_Q_HW   (2)
 
#define HPM_MOTOR_MATH_MOD_DSP_FP   (3)
 
#define HPM_MOTOR_MATH_MOD_Q_ALL   (4)
 
#define HPM_MOTOR_MATH_MOD_FP   (5)
 
#define HPM_QMATH_MOD_Q15   (15)
 Q-format. More...
 
#define HPM_QMATH_MOD_Q31   (31)
 
#define HPM_MOTOR_MATH_MOD   HPM_MOTOR_MATH_MOD_FP
 User-defined profiles. More...
 
#define HPM_QMATH_N   HPM_QMATH_MOD_Q31
 
#define HPM_SOFT_Q_N   (15)
 
#define HPM_MOTOR_MATH_FL_MDF(from_f32)   (from_f32)
 
#define HPM_MOTOR_MATH_MDF_FL(from_mdf)   (from_mdf)
 
#define HPM_MOTOR_MATH_MUL(x, y)   (x*y)
 
#define HPM_MOTOR_MATH_DIV(x, y)   (x/y)
 
#define HPM_MOTOR_MATH_ATAN2(x, y)   atan2(x, y)
 
#define HPM_MOTOR_MATH_ATAN(x)   atan(x)
 
#define HPM_MOTOR_MATH_FABS(x)   abs(x)
 

Typedefs

typedef float HPM_MOTOR_MATH_TYPE
 

Functions

HPM_MOTOR_MATH_TYPE hpm_dsp_hw_f32_q (float from_f32)
 Floating point to Q format conversion. More...
 
float hpm_dsp_hw_q_f32 (HPM_MOTOR_MATH_TYPE from_mdf)
 Q format to floating point conversion. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_mul_q (HPM_MOTOR_MATH_TYPE x, HPM_MOTOR_MATH_TYPE y)
 Q-format multiplication. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_div_q (HPM_MOTOR_MATH_TYPE x, HPM_MOTOR_MATH_TYPE y)
 Q-format division. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_atan_q (HPM_MOTOR_MATH_TYPE x)
 Q-format atan. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_atan2_q (HPM_MOTOR_MATH_TYPE x, HPM_MOTOR_MATH_TYPE y)
 Q-format atan2. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_abs_q (HPM_MOTOR_MATH_TYPE x)
 Q-format absolute. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_mul_fp (HPM_MOTOR_MATH_TYPE x, HPM_MOTOR_MATH_TYPE y)
 Floating-point multiplication. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_div_fp (HPM_MOTOR_MATH_TYPE x, HPM_MOTOR_MATH_TYPE y)
 Floating-point division. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_atan_fp (HPM_MOTOR_MATH_TYPE x)
 Floating-point atan. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_atan2_fp (HPM_MOTOR_MATH_TYPE x, HPM_MOTOR_MATH_TYPE y)
 Floating-point atan2. More...
 
HPM_MOTOR_MATH_TYPE hpm_dsp_hw_abs_fp (HPM_MOTOR_MATH_TYPE x)
 Floating-point absolute. More...
 
static HPM_MOTOR_MATH_TYPE soft_conv_float_to_q31 (float x)
 
static float soft_conv_q31_to_float (HPM_MOTOR_MATH_TYPE x)