2018-08-30 03:07:52 +08:00
|
|
|
#include "samd51j18a.h"
|
|
|
|
#include "timer.h"
|
|
|
|
#include "tmk_core/protocol/arm_atsam/clks.h"
|
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
void set_time(uint64_t tset) {
|
|
|
|
ms_clk = tset;
|
|
|
|
}
|
2019-08-31 02:19:03 +08:00
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
void timer_init(void) {
|
|
|
|
timer_clear();
|
|
|
|
}
|
2019-08-31 02:19:03 +08:00
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
uint16_t timer_read(void) {
|
|
|
|
return (uint16_t)ms_clk;
|
|
|
|
}
|
2019-08-31 02:19:03 +08:00
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
uint32_t timer_read32(void) {
|
|
|
|
return (uint32_t)ms_clk;
|
|
|
|
}
|
2019-08-31 02:19:03 +08:00
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
uint64_t timer_read64(void) {
|
|
|
|
return ms_clk;
|
|
|
|
}
|
2019-08-31 02:19:03 +08:00
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
uint16_t timer_elapsed(uint16_t tlast) {
|
|
|
|
return TIMER_DIFF_16(timer_read(), tlast);
|
|
|
|
}
|
2019-08-31 02:19:03 +08:00
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
uint32_t timer_elapsed32(uint32_t tlast) {
|
|
|
|
return TIMER_DIFF_32(timer_read32(), tlast);
|
|
|
|
}
|
2019-08-31 02:19:03 +08:00
|
|
|
|
2022-02-13 02:29:31 +08:00
|
|
|
void timer_clear(void) {
|
|
|
|
set_time(0);
|
|
|
|
}
|