hsk_libs-dev  163:b63ae088cc97
High Speed Karlsruhe XC878 library collection
 All Data Structures Files Functions Variables Typedefs Macros Groups Pages
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)(void) using(1));
52 
53 /**
54  * Enables the timer 0 and its interrupt.
55  */
56 void hsk_timer0_enable(void);
57 
58 /**
59  * Disables timer 0 and its interrupt.
60  */
61 void hsk_timer0_disable(void);
62 
63 /**
64  * Setup timer 1 to tick at a given interval.
65  *
66  * The callback function will be called by the interrupt once the
67  * interrupt has been enabled. Note that the callback function is
68  * entered with the current page unknown.
69  *
70  * This works on the assumption, that PCLK is set to 24MHz.
71  *
72  * @param interval
73  * The ticking interval in µs, don't go beyond 5461.
74  * @param callback
75  * A function pointer to a callback function.
76  */
77 void hsk_timer1_setup(const uword interval,
78  const void (code * const __xdata callback)(void) using(1));
79 
80 /**
81  * Enables the timer 1 and its interrupt.
82  */
83 void hsk_timer1_enable(void);
84 
85 /**
86  * Disables timer 1 and its interrupt.
87  */
88 void hsk_timer1_disable(void);
89 
90 /*
91  * Restore the usual meaning of \c code.
92  */
93 #ifdef SDCC
94  #undef code
95  #define code __code
96 #endif
97 
98 /*
99  * Restore the usual meaning of \c using(bank).
100  */
101 #ifdef __C51__
102  #undef using
103 #endif /* __C51__ */
104 
105 #endif /* _HSK_TIMER01_H_ */