diff --git a/src/btstack_util.c b/src/btstack_util.c index 8296e8873..6f769a7f0 100644 --- a/src/btstack_util.c +++ b/src/btstack_util.c @@ -177,13 +177,20 @@ uint32_t btstack_max(uint32_t a, uint32_t b){ } /** - * @brief Calculate delta between two points in time + * @brief Calculate delta between two uint32_t points in time * @return time_a - time_b - result > 0 if time_a is newer than time_b */ int32_t btstack_time_delta(uint32_t time_a, uint32_t time_b){ return (int32_t)(time_a - time_b); } +/** + * @brief Calculate delta between two uint16_t points in time + * @return time_a - time_b - result > 0 if time_a is newer than time_b + */ +int16_t btstack_time16_delta(uint16_t time_a, uint16_t time_b){ + return (int16_t)(time_a - time_b); +} char char_for_nibble(int nibble){ diff --git a/src/btstack_util.h b/src/btstack_util.h index f3135ea83..e7c1cf72c 100644 --- a/src/btstack_util.h +++ b/src/btstack_util.h @@ -88,11 +88,17 @@ uint32_t btstack_min(uint32_t a, uint32_t b); uint32_t btstack_max(uint32_t a, uint32_t b); /** - * @brief Calculate delta between two points in time + * @brief Calculate delta between two uint32_t points in time * @return time_a - time_b - result > 0 if time_a is newer than time_b */ int32_t btstack_time_delta(uint32_t time_a, uint32_t time_b); +/** + * @brief Calculate delta between two uint16_t points in time + * @return time_a - time_b - result > 0 if time_a is newer than time_b + */ +int16_t btstack_time16_delta(uint16_t time_a, uint16_t time_b); + /** * @brief Read 16/24/32 bit little endian value from buffer * @param buffer