6e984a8b5e
Microsecond (us) delays are now handled by a busy wait loop according to MCU frequency. This replaces the system counter method which had an overhead of around 12us. TC5 device and supporting routines removed as it was the old us delay counter. wait_ms is now properly a macro to CLK_delay_ms. wait_us is now properly a macro to CLK_delay_us. Removed CLK_get_us as it has no use. All calls to CLK_get_ms() have been replaced by timer_read64() with corrected typing. All calls to CLK_delay_ms() have been replaced by wait_ms(). All calls to CLK_delay_us() have been replaced by wait_us() and timings verified or updated as needed after review on scope. Corrected typing of variables using 64bit ms timer readings if needed.
44 lines
593 B
C
44 lines
593 B
C
#include "samd51j18a.h"
|
|
#include "timer.h"
|
|
#include "tmk_core/protocol/arm_atsam/clks.h"
|
|
|
|
void set_time(uint64_t tset)
|
|
{
|
|
ms_clk = tset;
|
|
}
|
|
|
|
void timer_init(void)
|
|
{
|
|
timer_clear();
|
|
}
|
|
|
|
uint16_t timer_read(void)
|
|
{
|
|
return (uint16_t)ms_clk;
|
|
}
|
|
|
|
uint32_t timer_read32(void)
|
|
{
|
|
return (uint32_t)ms_clk;
|
|
}
|
|
|
|
uint64_t timer_read64(void)
|
|
{
|
|
return ms_clk;
|
|
}
|
|
|
|
uint16_t timer_elapsed(uint16_t tlast)
|
|
{
|
|
return TIMER_DIFF_16(timer_read(), tlast);
|
|
}
|
|
|
|
uint32_t timer_elapsed32(uint32_t tlast)
|
|
{
|
|
return TIMER_DIFF_32(timer_read32(), tlast);
|
|
}
|
|
|
|
void timer_clear(void)
|
|
{
|
|
set_time(0);
|
|
}
|