forked from lab85-ru/jtag_avr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
sys_timer.c
35 lines (29 loc) · 1.11 KB
/
sys_timer.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include "stm32f10x.h"
#include "stm32f10x_iwdg.h"
#include "sys_timer.h"
volatile unsigned int sys_tick_counter = 0; // ñ÷åò÷èê ñèñòåìíîãî òàéìåðà
//------------------------------------------------------------------------------
// âîçâðàùàåò òåêóùåå çíà÷åíèå ñèñòåìíîãî òàéìåðà
//------------------------------------------------------------------------------
unsigned int get_sys_counter( void )
{
return sys_tick_counter;
}
//------------------------------------------------------------------------------
// Îáðàáîò÷èê ïðåðûâàíèé îò ñèñòåìíîãî òàéìåðà
//------------------------------------------------------------------------------
void sys_tick_handler( void )
{
/* Reload IWDG counter */
IWDG_ReloadCounter();
sys_tick_counter++;
}
//------------------------------------------------------------------------------
// Íàñòðîéêà ñèñòåìíîãî òàéìåðà
// configCPU_CLOCK_HZ òàêòîâàÿ ÷àñòîòà ÿäðà
// configTICK_RATE_HZ ÷àñòîòà ñ÷åòà òàéìåðà
//------------------------------------------------------------------------------
void sys_timer_setup( void )
{
SysTick_Config( (configCPU_CLOCK_HZ) / (configTICK_RATE_HZ) );
}