-
Notifications
You must be signed in to change notification settings - Fork 1
/
tmr1.h
51 lines (44 loc) · 1.12 KB
/
tmr1.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
#ifndef __TMR1_H__
#define __TMR1_H__
#include <stdint.h>
#include <stdbool.h>
//simple counter mode only
//clock sources, not all listed here
typedef enum {
tmr1_FOSC4 = 1,
tmr1_FOSC = 2,
tmr1_HFINTOSC = 3,
tmr1_MFINTOSC_500khz = 5
}
tmr1_clksrc_t;
// prescale
typedef enum
{
tmr1_PRE1, tmr1_PRE2, tmr1_PRE4, tmr1_PRE8
}
tmr1_pre_t;
//power off timer1
void
tmr1_deinit (void);
//power on, init timer1 to clock source, prescale
void
tmr1_init (tmr1_clksrc_t, tmr1_pre_t);
//stop timer1
void
tmr1_stop (bool);
//turn on timer1
void
tmr1_on (bool);
//set timer1 value
void
tmr1_set (uint16_t);
//get timer1 value
uint16_t
tmr1_get (void);
//turn on timer1 irq, set isr function
void
tmr1_irqon (void(*)(void));
//turn off irq
void
tmr1_irqoff (void);
#endif //__TMR1_H__