-
Notifications
You must be signed in to change notification settings - Fork 74
/
smarttimer.h
56 lines (45 loc) · 1.36 KB
/
smarttimer.h
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
/*
* =====================================================================================
*
* Filename: smarttimer.h
*
* Description:
*
* Version: 1.1
* Created: 2016/7/14 ÐÇÆÚËÄ ÉÏÎç 10:48:35
* Revision: none
* Compiler: armcc
*
* Author: lell
* Organization:
*
* =====================================================================================
*/
#ifndef __SMARTTIMER_H__
#define __SMARTTIMER_H__
#include "stm32f10x.h"
//#define STIM_DEBUG
#ifndef NULL
#define NULL ((void *)0)
#endif
#define CLOSE_INTERRUPT() __ASM("CPSID I")
#define OPEN_INTERRUPT() __ASM("CPSIE I")
#define STIM_EVENT_MAX_SIZE 20 /*max size of timer event number */
#define STIM_LOOP_FOREVER (uint16_t)0xffff
#define STIM_INVALID 0xff
#define STIM_EVENT_IDLE 0x00
#define STIM_EVENT_ACTIVE 0x01
#define STIM_EVENT_RECYCLE 0x02
void stim_init ( void );
void stim_tick (void);
void stim_mainloop ( void );
int8_t stim_loop ( uint16_t delayms, void (*callback)(void), uint16_t times);
int8_t stim_runlater ( uint16_t delayms, void (*callback)(void));
void stim_delay ( uint16_t delayms);
void stim_kill_event(int8_t id);
void stim_remove_event(int8_t id);
#ifdef STIM_DEBUG
uint8_t stim_get_eventnum(void);
void stim_print_status(void);
#endif
#endif