hsk-libs-dev  270
High Speed Karlsruhe XC878 library collection
hsk_timer01.h
Go to the documentation of this file.
1 /** \file
2  * HSK Timer 0/1 headers
3  *
4  * Provides access to the timers 0 and 1. Each timer can be provided with
5  * a callback function that will be called by the timers ISR.
6  *
7  * @author kami
8  */
9 
10 #ifndef _HSK_TIMER01_H_
11 #define _HSK_TIMER01_H_
12 
13 /*
14  * ISR prototypes for SDCC.
15  */
16 #ifdef SDCC
17 #include "hsk_timer01.isr"
18 #endif /* SDCC */
19 
20 /*
21  * C51 does not include the used register bank in pointer types.
22  */
23 #ifdef __C51__
24  #define using(bank)
25 #endif
26 
27 /*
28  * SDCC does not like the \c code keyword for function pointers, C51 needs it
29  * or it will use generic pointers.
30  */
31 #ifdef SDCC
32  #undef code
33  #define code
34 #endif /* SDCC */
35 
36 /**
37  * Setup timer 0 to tick at a given interval.
38  *
39  * The callback function will be called by the interrupt once the
40  * interrupt has been enabled. Note that the callback function is
41  * entered with the current page unknown.
42  *
43  * This works on the assumption, that PCLK is set to 24MHz.
44  *
45  * @param interval
46  * The ticking interval in µs, don't go beyond 5461.
47  * @param callback
48  * A function pointer to a callback function.
49  */
50 void hsk_timer0_setup(const uword interval,
51  const void (code * const __xdata callback)
52  (void) using(1));
53 
54 /**
55  * Enables the timer 0 and its interrupt.
56  */
57 void hsk_timer0_enable(void);
58 
59 /**
60  * Disables timer 0 and its interrupt.
61  */
62 void hsk_timer0_disable(void);
63 
64 /**
65  * Setup timer 1 to tick at a given interval.
66  *
67  * The callback function will be called by the interrupt once the
68  * interrupt has been enabled. Note that the callback function is
69  * entered with the current page unknown.
70  *
71  * This works on the assumption, that PCLK is set to 24MHz.
72  *
73  * @param interval
74  * The ticking interval in µs, don't go beyond 5461.
75  * @param callback
76  * A function pointer to a callback function.
77  */
78 void hsk_timer1_setup(const uword interval,
79  const void (code * const __xdata callback)
80  (void) using(1));
81 
82 /**
83  * Enables the timer 1 and its interrupt.
84  */
85 void hsk_timer1_enable(void);
86 
87 /**
88  * Disables timer 1 and its interrupt.
89  */
90 void hsk_timer1_disable(void);
91 
92 /*
93  * Restore the usual meaning of \c code.
94  */
95 #ifdef SDCC
96  #undef code
97  #define code __code
98 #endif
99 
100 /*
101  * Restore the usual meaning of \c using(bank).
102  */
103 #ifdef __C51__
104  #undef using
105 #endif /* __C51__ */
106 
107 #endif /* _HSK_TIMER01_H_ */
void hsk_timer0_disable(void)
Disables timer 0 and its interrupt.
Definition: hsk_timer01.c:169
void hsk_timer1_enable(void)
Enables the timer 1 and its interrupt.
Definition: hsk_timer01.c:180
void hsk_timer1_setup(const uword interval, const void(*const callback)(void))
Setup timer 1 to tick at a given interval.
Definition: hsk_timer01.c:174
void hsk_timer0_setup(const uword interval, const void(*const callback)(void))
Setup timer 0 to tick at a given interval.
Definition: hsk_timer01.c:158
void hsk_timer1_disable(void)
Disables timer 1 and its interrupt.
Definition: hsk_timer01.c:185
void hsk_timer0_enable(void)
Enables the timer 0 and its interrupt.
Definition: hsk_timer01.c:164