1 /** 2 * @file drivers/stepper/adi_tmc/adi_tmc5xxx_common.h 3 * 4 * @brief Common TMC5xxx stepper controller driver definitions 5 */ 6 7 /** 8 * SPDX-FileCopyrightText: Copyright (c) 2024 Jilay Sandeep Pandya 9 * SPDX-License-Identifier: Apache-2.0 10 */ 11 12 #ifndef ZEPHYR_DRIVERS_STEPPER_ADI_TMC_ADI_TMC5XXX_COMMON_H_ 13 #define ZEPHYR_DRIVERS_STEPPER_ADI_TMC_ADI_TMC5XXX_COMMON_H_ 14 15 #include "adi_tmc_reg.h" 16 17 #ifdef __cplusplus 18 extern "C" { 19 #endif 20 21 /** 22 * @name TMC5xxx module functions 23 * @anchor TMC5XXX_FUNCTIONS 24 * 25 * @{ 26 */ 27 28 /** 29 * @brief Calculate the velocity in full clock cycles from the velocity in Hz 30 * 31 * @param velocity_hz Velocity in Hz 32 * @param clock_frequency Clock frequency in Hz 33 * 34 * @return Calculated velocity in full clock cycles 35 */ tmc5xxx_calculate_velocity_from_hz_to_fclk(uint64_t velocity_hz,uint32_t clock_frequency)36static inline uint32_t tmc5xxx_calculate_velocity_from_hz_to_fclk(uint64_t velocity_hz, 37 uint32_t clock_frequency) 38 { 39 __ASSERT_NO_MSG(clock_frequency); 40 return (velocity_hz << TMC5XXX_CLOCK_FREQ_SHIFT) / clock_frequency; 41 } 42 43 /** 44 * @} 45 */ 46 47 #ifdef __cplusplus 48 } 49 #endif 50 51 #endif /* ZEPHYR_DRIVERS_STEPPER_ADI_TMC_ADI_TMC5XXX_COMMON_H_ */ 52