summaryrefslogtreecommitdiff
path: root/bsp/yichip/yc3121-pos/Libraries/sdk/yc_systick.h
blob: 6044d8c7047f3b63086dfdf63173bc1972f67d8d (plain)
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
File Name    : yc_systick.h
Author       : Yichip
Version      : V1.0
Date         : 2018/03/27
Description  : systick encapsulation.
*/

#ifndef __YC_SYSTICK_H__
#define __YC_SYSTICK_H__
#include "../core/yc3121.h"

#define SYSTICK_SYSCLOCK			1
#define SYSTICK_HALF_SYSCLOCK		0

#define IS_RELOAD_VALUE(x) (x>0&&x<=0xffffff)

typedef int32_t tick;
#define TICK_MAX_VALUE	(int32_t)0x7FFFFFFF


void Systick_Dealy_Ms(uint32_t MS);

/**
 * @brief Initialize systick and start systick
 *
 * @param ReloadValue : the systick reload value
 *
 * @retval 0:succeed  1:error
 */
uint32_t SysTick_Config(uint32_t ReloadValue);


/**
 * @brief get the current value of SystickCount(SystickCount plus one for every overflow interrupt)
 *
 * @param none
 *
 * @retval current value of SystickCount
 */
tick SysTick_GetTick(void);

/**
 * @brief Determine whether the timeout that millisecond.
 *
 * @param start_tick:start tick
 *
 * @param interval:time interval(ms)
 *
 * @retval TRUE is timeout ,FALSE is not timeout
 */
Boolean SysTick_IsTimeOut(tick start_tick,int interval);


/**
 * @brief get relative time .
 *
 * @param start_tick:start tick(start time)
 *
 * @retval the relative time(millisecond)
 */
uint32_t SysTick_GetRelativeTime(tick start_tick);

#endif   /* __YC_SYSTICK_H__ */