1 |
/** |
---|
2 |
TMR0 Generated Driver API Header File |
---|
3 |
|
---|
4 |
@Company |
---|
5 |
Microchip Technology Inc. |
---|
6 |
|
---|
7 |
@File Name |
---|
8 |
tmr0.h |
---|
9 |
|
---|
10 |
@Summary |
---|
11 |
This is the generated header file for the TMR0 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs |
---|
12 |
|
---|
13 |
@Description |
---|
14 |
This header file provides APIs for TMR0. |
---|
15 |
Generation Information : |
---|
16 |
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2 |
---|
17 |
Device : PIC16F1579 |
---|
18 |
Driver Version : 2.01 |
---|
19 |
The generated drivers are tested against the following: |
---|
20 |
Compiler : XC8 1.45 |
---|
21 |
MPLAB : MPLAB X 4.15 |
---|
22 |
*/ |
---|
23 |
|
---|
24 |
/* |
---|
25 |
(c) 2018 Microchip Technology Inc. and its subsidiaries. |
---|
26 |
|
---|
27 |
Subject to your compliance with these terms, you may use Microchip software and any |
---|
28 |
derivatives exclusively with Microchip products. It is your responsibility to comply with third party |
---|
29 |
license terms applicable to your use of third party software (including open source software) that |
---|
30 |
may accompany Microchip software. |
---|
31 |
|
---|
32 |
THIS SOFTWARE IS SUPPLIED BY MICROCHIP "AS IS". NO WARRANTIES, WHETHER |
---|
33 |
EXPRESS, IMPLIED OR STATUTORY, APPLY TO THIS SOFTWARE, INCLUDING ANY |
---|
34 |
IMPLIED WARRANTIES OF NON-INFRINGEMENT, MERCHANTABILITY, AND FITNESS |
---|
35 |
FOR A PARTICULAR PURPOSE. |
---|
36 |
|
---|
37 |
IN NO EVENT WILL MICROCHIP BE LIABLE FOR ANY INDIRECT, SPECIAL, PUNITIVE, |
---|
38 |
INCIDENTAL OR CONSEQUENTIAL LOSS, DAMAGE, COST OR EXPENSE OF ANY KIND |
---|
39 |
WHATSOEVER RELATED TO THE SOFTWARE, HOWEVER CAUSED, EVEN IF MICROCHIP |
---|
40 |
HAS BEEN ADVISED OF THE POSSIBILITY OR THE DAMAGES ARE FORESEEABLE. TO |
---|
41 |
THE FULLEST EXTENT ALLOWED BY LAW, MICROCHIP'S TOTAL LIABILITY ON ALL |
---|
42 |
CLAIMS IN ANY WAY RELATED TO THIS SOFTWARE WILL NOT EXCEED THE AMOUNT |
---|
43 |
OF FEES, IF ANY, THAT YOU HAVE PAID DIRECTLY TO MICROCHIP FOR THIS |
---|
44 |
SOFTWARE. |
---|
45 |
*/ |
---|
46 |
|
---|
47 |
#ifndef TMR0_H |
---|
48 |
#define TMR0_H |
---|
49 |
|
---|
50 |
/** |
---|
51 |
Section: Included Files |
---|
52 |
*/ |
---|
53 |
|
---|
54 |
#include <stdint.h> |
---|
55 |
#include <stdbool.h> |
---|
56 |
|
---|
57 |
#ifdef __cplusplus // Provide C++ Compatibility |
---|
58 |
|
---|
59 |
extern "C" { |
---|
60 |
|
---|
61 |
#endif |
---|
62 |
|
---|
63 |
/** |
---|
64 |
Section: TMR0 APIs |
---|
65 |
*/ |
---|
66 |
|
---|
67 |
/** |
---|
68 |
@Summary |
---|
69 |
Initializes the TMR0 module. |
---|
70 |
|
---|
71 |
@Description |
---|
72 |
This function initializes the TMR0 Registers. |
---|
73 |
This function must be called before any other TMR0 function is called. |
---|
74 |
|
---|
75 |
@Preconditions |
---|
76 |
None |
---|
77 |
|
---|
78 |
@Param |
---|
79 |
None |
---|
80 |
|
---|
81 |
@Returns |
---|
82 |
None |
---|
83 |
|
---|
84 |
@Comment |
---|
85 |
|
---|
86 |
|
---|
87 |
@Example |
---|
88 |
<code> |
---|
89 |
main() |
---|
90 |
{ |
---|
91 |
// Initialize TMR0 module |
---|
92 |
TMR0_Initialize(); |
---|
93 |
|
---|
94 |
// Do something else... |
---|
95 |
} |
---|
96 |
</code> |
---|
97 |
*/ |
---|
98 |
void TMR0_Initialize(void); |
---|
99 |
|
---|
100 |
/** |
---|
101 |
@Summary |
---|
102 |
Reads the TMR0 register. |
---|
103 |
|
---|
104 |
@Description |
---|
105 |
This function reads the TMR0 register value and return it. |
---|
106 |
|
---|
107 |
@Preconditions |
---|
108 |
Initialize the TMR0 before calling this function. |
---|
109 |
|
---|
110 |
@Param |
---|
111 |
None |
---|
112 |
|
---|
113 |
@Returns |
---|
114 |
This function returns the current value of TMR0 register. |
---|
115 |
|
---|
116 |
@Example |
---|
117 |
<code> |
---|
118 |
// Initialize TMR0 module |
---|
119 |
// Read the current value of TMR0 |
---|
120 |
if(0 == TMR0_ReadTimer()) |
---|
121 |
{ |
---|
122 |
// Do something else... |
---|
123 |
|
---|
124 |
// Reload the TMR value |
---|
125 |
TMR0_Reload(); |
---|
126 |
} |
---|
127 |
</code> |
---|
128 |
*/ |
---|
129 |
uint8_t TMR0_ReadTimer(void); |
---|
130 |
|
---|
131 |
/** |
---|
132 |
@Summary |
---|
133 |
Writes the TMR0 register. |
---|
134 |
|
---|
135 |
@Description |
---|
136 |
This function writes the TMR0 register. |
---|
137 |
This function must be called after the initialization of TMR0. |
---|
138 |
|
---|
139 |
@Preconditions |
---|
140 |
Initialize the TMR0 before calling this function. |
---|
141 |
|
---|
142 |
@Param |
---|
143 |
timerVal - Value to write into TMR0 register. |
---|
144 |
|
---|
145 |
@Returns |
---|
146 |
None |
---|
147 |
|
---|
148 |
@Example |
---|
149 |
<code> |
---|
150 |
#define PERIOD 0x80 |
---|
151 |
#define ZERO 0x00 |
---|
152 |
|
---|
153 |
while(1) |
---|
154 |
{ |
---|
155 |
// Read the TMR0 register |
---|
156 |
if(ZERO == TMR0_ReadTimer()) |
---|
157 |
{ |
---|
158 |
// Do something else... |
---|
159 |
|
---|
160 |
// Write the TMR0 register |
---|
161 |
TMR0_WriteTimer(PERIOD); |
---|
162 |
} |
---|
163 |
|
---|
164 |
// Do something else... |
---|
165 |
} |
---|
166 |
</code> |
---|
167 |
*/ |
---|
168 |
void TMR0_WriteTimer(uint8_t timerVal); |
---|
169 |
|
---|
170 |
/** |
---|
171 |
@Summary |
---|
172 |
Reload the TMR0 register. |
---|
173 |
|
---|
174 |
@Description |
---|
175 |
This function reloads the TMR0 register. |
---|
176 |
This function must be called to write initial value into TMR0 register. |
---|
177 |
|
---|
178 |
@Preconditions |
---|
179 |
Initialize the TMR0 before calling this function. |
---|
180 |
|
---|
181 |
@Param |
---|
182 |
None |
---|
183 |
|
---|
184 |
@Returns |
---|
185 |
None |
---|
186 |
|
---|
187 |
@Example |
---|
188 |
<code> |
---|
189 |
while(1) |
---|
190 |
{ |
---|
191 |
if(TMR0IF) |
---|
192 |
{ |
---|
193 |
// Do something else... |
---|
194 |
|
---|
195 |
// clear the TMR0 interrupt flag |
---|
196 |
TMR0IF = 0; |
---|
197 |
|
---|
198 |
// Reload the initial value of TMR0 |
---|
199 |
TMR0_Reload(); |
---|
200 |
} |
---|
201 |
} |
---|
202 |
</code> |
---|
203 |
*/ |
---|
204 |
void TMR0_Reload(void); |
---|
205 |
|
---|
206 |
/** |
---|
207 |
@Summary |
---|
208 |
Timer Interrupt Service Routine |
---|
209 |
|
---|
210 |
@Description |
---|
211 |
Timer Interrupt Service Routine is called by the Interrupt Manager. |
---|
212 |
|
---|
213 |
@Returns |
---|
214 |
None |
---|
215 |
|
---|
216 |
@Param |
---|
217 |
None |
---|
218 |
*/ |
---|
219 |
void TMR0_ISR(void); |
---|
220 |
|
---|
221 |
|
---|
222 |
/** |
---|
223 |
@Summary |
---|
224 |
Set Timer Interrupt Handler |
---|
225 |
|
---|
226 |
@Description |
---|
227 |
This sets the function to be called during the ISR |
---|
228 |
|
---|
229 |
@Preconditions |
---|
230 |
Initialize the TMR0 module with interrupt before calling this. |
---|
231 |
|
---|
232 |
@Param |
---|
233 |
Address of function to be set |
---|
234 |
|
---|
235 |
@Returns |
---|
236 |
None |
---|
237 |
*/ |
---|
238 |
void TMR0_SetInterruptHandler(void (* InterruptHandler)(void)); |
---|
239 |
|
---|
240 |
/** |
---|
241 |
@Summary |
---|
242 |
Timer Interrupt Handler |
---|
243 |
|
---|
244 |
@Description |
---|
245 |
This is a function pointer to the function that will be called during the ISR |
---|
246 |
|
---|
247 |
@Preconditions |
---|
248 |
Initialize the TMR0 module with interrupt before calling this isr. |
---|
249 |
|
---|
250 |
@Param |
---|
251 |
None |
---|
252 |
|
---|
253 |
@Returns |
---|
254 |
None |
---|
255 |
*/ |
---|
256 |
extern void (*TMR0_InterruptHandler)(void); |
---|
257 |
|
---|
258 |
/** |
---|
259 |
@Summary |
---|
260 |
Default Timer Interrupt Handler |
---|
261 |
|
---|
262 |
@Description |
---|
263 |
This is the default Interrupt Handler function |
---|
264 |
|
---|
265 |
@Preconditions |
---|
266 |
Initialize the TMR0 module with interrupt before calling this isr. |
---|
267 |
|
---|
268 |
@Param |
---|
269 |
None |
---|
270 |
|
---|
271 |
@Returns |
---|
272 |
None |
---|
273 |
*/ |
---|
274 |
void TMR0_DefaultInterruptHandler(void); |
---|
275 |
|
---|
276 |
#ifdef __cplusplus // Provide C++ Compatibility |
---|
277 |
|
---|
278 |
} |
---|
279 |
|
---|
280 |
#endif |
---|
281 |
|
---|
282 |
#endif // TMR0_H |
---|
283 |
/** |
---|
284 |
End of File |
---|
285 |
*/ |
---|