1 /* 2 * Copyright (c) 2023 HPMicro 3 * 4 * SPDX-License-Identifier: BSD-3-Clause 5 * 6 */ 7 8 #ifndef HPM_ENC_POS_COMMON_H 9 #define HPM_ENC_POS_COMMON_H 10 11 #include "hpm_common.h" 12 13 #ifdef __cplusplus 14 extern "C" { 15 #endif 16 17 /** 18 * @brief caculate degree of angle from pos 19 * 20 * @param[in] pos position value 21 * @return degree of angle. 22 */ 23 float encoder_position_to_deg(uint32_t pos); 24 25 /** 26 * @brief caculate posistion from degree of angle 27 * 28 * @param[in] deg degree of angle 29 * @return position value. 30 */ 31 uint32_t encoder_deg_to_position(float deg); 32 33 /** 34 * @brief caculate radian of angle from pos 35 * 36 * @param[in] pos position value 37 * @return radian of angle. 38 */ 39 float encoder_position_to_rad(uint32_t pos); 40 41 /** 42 * @brief caculate posistion from radian of angle 43 * 44 * @param[in] rad radian of angle 45 * @return position value. 46 */ 47 uint32_t encoder_rad_to_position(float rad); 48 49 #ifdef __cplusplus 50 } 51 #endif 52 /** 53 * @} 54 */ 55 #endif /* HPM_ENC_POS_COMMON_H */ 56