You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #include "cmsis.h"
- #include "timer.h"
-
- /* Mill second tick count */
- volatile uint32_t timer_count = 0;
-
- /* Timer interrupt handler */
- void SysTick_Handler(void) {
- timer_count++;
- }
-
- void timer_init(void)
- {
- timer_count = 0;
- SysTick_Config(SystemCoreClock / 1000); /* 1ms tick */
- }
-
- void timer_clear(void)
- {
- timer_count = 0;
- }
-
- uint16_t timer_read(void)
- {
- return (uint16_t)(timer_count & 0xFFFF);
- }
-
- uint32_t timer_read32(void)
- {
- return timer_count;
- }
-
- uint16_t timer_elapsed(uint16_t last)
- {
- return TIMER_DIFF_16(timer_read(), last);
- }
-
- uint32_t timer_elapsed32(uint32_t last)
- {
- return TIMER_DIFF_32(timer_read32(), last);
- }
|