-
Notifications
You must be signed in to change notification settings - Fork 0
/
Timer.h
73 lines (61 loc) · 1.68 KB
/
Timer.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef TIMER_H
#define TIMER_H
#include <stdint.h>
#define INT_CLK 0
#define EXT_CLK 1
#define TIMER_MODE 0
#define COUNTER_MODE 1
#define BAD_PS 255
#define P1_1 0b00
#define P1_8 0b01
#define P1_64 0b10
#define P1_256 0b11
typedef struct{
uint16_t : 1;
uint16_t TCS : 1;
uint16_t : 1;
uint16_t T32 : 1;
uint16_t TCKPS : 2;
uint16_t TGATE : 1;
uint16_t : 6;
uint16_t TSIDL : 1;
uint16_t : 1;
uint16_t TON : 1;
}TxCON_t;
typedef struct{
uint16_t TMR;
uint16_t : 16;
uint16_t : 16;
uint16_t PR;
uint16_t : 16;
TxCON_t TCON;
}TIMERx_t;
typedef struct{
uint16_t : 1;
uint16_t TCS : 1;
uint16_t : 2;
uint16_t TCKPS : 2;
uint16_t TGATE : 1;
uint16_t : 6;
uint16_t TSIDL : 1;
uint16_t : 1;
uint16_t TON : 1;
}TyCON_t;
typedef struct{
uint16_t TMR;
uint16_t : 16;
uint16_t PR;
uint16_t : 16;
TxCON_t TCON;
}TIMERy_t;
extern volatile TIMERx_t __attribute__ ((sfr(0x0106))) TIMER2_16;
extern volatile TIMERy_t __attribute__ ((sfr(0x010A))) TIMER3_16;
uint16_t SetBTimerMode(TIMERx_t volatile *const pTimer, float T);
void SetBCounterMode(TIMERx_t volatile *const pTimer, uint16_t Limit);
void StopBTimer(TIMERx_t volatile *const pTimer);
void StartBTimer(TIMERx_t volatile *const pTimer);
uint16_t SetCTimerMode(TIMERy_t volatile *const pTimer, float T);
void SetCCounterMode(TIMERy_t volatile *const pTimer, uint16_t Limit);
void StopCTimer(TIMERy_t volatile *const pTimer);
void StartCTimer(TIMERy_t volatile *const pTimer);
#endif