AP_Math: Add functions to convert microseconds to/from nanoseconds

This commit is contained in:
José Roberto de Souza 2015-10-27 14:07:51 -02:00 committed by Andrew Tridgell
parent ca533a9d94
commit d53911e3f6
1 changed files with 11 additions and 0 deletions

View File

@ -235,6 +235,7 @@ static inline float minf(float a, float b)
}
#define NSEC_PER_SEC 1000000000ULL
#define NSEC_PER_USEC 1000ULL
inline uint32_t hz_to_nsec(uint32_t freq)
{
@ -246,6 +247,16 @@ inline uint32_t nsec_to_hz(uint32_t usec)
return NSEC_PER_SEC / usec;
}
inline uint32_t usec_to_nsec(uint32_t usec)
{
return usec * NSEC_PER_USEC;
}
inline uint32_t nsec_to_usec(uint32_t nsec)
{
return nsec / NSEC_PER_USEC;
}
#undef INLINE
#endif // AP_MATH_H