Skip to content

Commit

Permalink
small refactoring of TIMER_DIFF (#24678)
Browse files Browse the repository at this point in the history
A small refactoring of the defines TIMER_DIFF_8, TIMER_DIFF_16, TIMER_DIFF_32, TIMER_DIFF_RAW.
Removing obsolete TIMER_DIFF helper.
Discussion: #24652
  • Loading branch information
boessu authored Dec 16, 2024
1 parent 0f3993b commit d3c9dff
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions platforms/timer.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.

#include <stdint.h>

#define TIMER_DIFF(a, b, max) ((max == UINT8_MAX) ? ((uint8_t)((a) - (b))) : ((max == UINT16_MAX) ? ((uint16_t)((a) - (b))) : ((max == UINT32_MAX) ? ((uint32_t)((a) - (b))) : ((a) >= (b) ? (a) - (b) : (max) + 1 - (b) + (a)))))
#define TIMER_DIFF_8(a, b) TIMER_DIFF(a, b, UINT8_MAX)
#define TIMER_DIFF_16(a, b) TIMER_DIFF(a, b, UINT16_MAX)
#define TIMER_DIFF_32(a, b) TIMER_DIFF(a, b, UINT32_MAX)
#define TIMER_DIFF_8(a, b) (uint8_t)((a) - (b))
#define TIMER_DIFF_16(a, b) (uint16_t)((a) - (b))
#define TIMER_DIFF_32(a, b) (uint32_t)((a) - (b))
#define TIMER_DIFF_RAW(a, b) TIMER_DIFF_8(a, b)

#ifdef __cplusplus
Expand Down

0 comments on commit d3c9dff

Please sign in to comment.