btstack_util: btstack_time_delta provides delta between two timestamps

This commit is contained in:
Matthias Ringwald 2019-06-17 22:12:52 +02:00
parent 36d972ad05
commit 68af39674d
2 changed files with 14 additions and 1 deletions

View File

@ -166,6 +166,14 @@ uint32_t btstack_max(uint32_t a, uint32_t b){
return a > b ? a : b;
}
/**
* @brief Calculate delta between two points in time
* @returns 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);
}
static const char * char_to_nibble = "0123456789ABCDEF";
char char_for_nibble(int nibble){

View File

@ -90,7 +90,12 @@ 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
* @returns 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 Read 16/24/32 bit little endian value from buffer
* @param buffer