1 |
/** |
---|
2 |
TMR1 Generated Driver API Header File |
---|
3 |
|
---|
4 |
@Company |
---|
5 |
Microchip Technology Inc. |
---|
6 |
|
---|
7 |
@File Name |
---|
8 |
tmr1.h |
---|
9 |
|
---|
10 |
@Summary |
---|
11 |
This is the generated header file for the TMR1 driver using PIC10 / PIC12 / PIC16 / PIC18 MCUs |
---|
12 |
|
---|
13 |
@Description |
---|
14 |
This header file provides APIs for driver for TMR1. |
---|
15 |
Generation Information : |
---|
16 |
Product Revision : PIC10 / PIC12 / PIC16 / PIC18 MCUs - 1.65.2 |
---|
17 |
Device : PIC16F1579 |
---|
18 |
Driver Version : 2.11 |
---|
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 TMR1_H |
---|
48 |
#define TMR1_H |
---|
49 |
|
---|
50 |
/** |
---|
51 |
Section: Included Files |
---|
52 |
*/ |
---|
53 |
|
---|
54 |
#include <stdbool.h> |
---|
55 |
#include <stdint.h> |
---|
56 |
|
---|
57 |
#ifdef __cplusplus // Provide C++ Compatibility |
---|
58 |
|
---|
59 |
extern "C" { |
---|
60 |
|
---|
61 |
#endif |
---|
62 |
|
---|
63 |
|
---|
64 |
/** |
---|
65 |
Section: TMR1 APIs |
---|
66 |
*/ |
---|
67 |
|
---|
68 |
/** |
---|
69 |
@Summary |
---|
70 |
Initializes the TMR1 |
---|
71 |
|
---|
72 |
@Description |
---|
73 |
This routine initializes the TMR1. |
---|
74 |
This routine must be called before any other TMR1 routine is called. |
---|
75 |
This routine should only be called once during system initialization. |
---|
76 |
|
---|
77 |
@Preconditions |
---|
78 |
None |
---|
79 |
|
---|
80 |
@Param |
---|
81 |
None |
---|
82 |
|
---|
83 |
@Returns |
---|
84 |
None |
---|
85 |
|
---|
86 |
@Comment |
---|
87 |
|
---|
88 |
|
---|
89 |
@Example |
---|
90 |
<code> |
---|
91 |
main() |
---|
92 |
{ |
---|
93 |
// Initialize TMR1 module |
---|
94 |
TMR1_Initialize(); |
---|
95 |
|
---|
96 |
// Do something else... |
---|
97 |
} |
---|
98 |
</code> |
---|
99 |
*/ |
---|
100 |
void TMR1_Initialize(void); |
---|
101 |
|
---|
102 |
/** |
---|
103 |
@Summary |
---|
104 |
This function starts the TMR1. |
---|
105 |
|
---|
106 |
@Description |
---|
107 |
This function starts the TMR1 operation. |
---|
108 |
This function must be called after the initialization of TMR1. |
---|
109 |
|
---|
110 |
@Preconditions |
---|
111 |
Initialize the TMR1 before calling this function. |
---|
112 |
|
---|
113 |
@Param |
---|
114 |
None |
---|
115 |
|
---|
116 |
@Returns |
---|
117 |
None |
---|
118 |
|
---|
119 |
@Example |
---|
120 |
<code> |
---|
121 |
// Initialize TMR1 module |
---|
122 |
|
---|
123 |
// Start TMR1 |
---|
124 |
TMR1_StartTimer(); |
---|
125 |
|
---|
126 |
// Do something else... |
---|
127 |
</code> |
---|
128 |
*/ |
---|
129 |
void TMR1_StartTimer(void); |
---|
130 |
|
---|
131 |
/** |
---|
132 |
@Summary |
---|
133 |
This function stops the TMR1. |
---|
134 |
|
---|
135 |
@Description |
---|
136 |
This function stops the TMR1 operation. |
---|
137 |
This function must be called after the start of TMR1. |
---|
138 |
|
---|
139 |
@Preconditions |
---|
140 |
Initialize the TMR1 before calling this function. |
---|
141 |
|
---|
142 |
@Param |
---|
143 |
None |
---|
144 |
|
---|
145 |
@Returns |
---|
146 |
None |
---|
147 |
|
---|
148 |
@Example |
---|
149 |
<code> |
---|
150 |
// Initialize TMR1 module |
---|
151 |
|
---|
152 |
// Start TMR1 |
---|
153 |
TMR1_StartTimer(); |
---|
154 |
|
---|
155 |
// Do something else... |
---|
156 |
|
---|
157 |
// Stop TMR1; |
---|
158 |
TMR1_StopTimer(); |
---|
159 |
</code> |
---|
160 |
*/ |
---|
161 |
void TMR1_StopTimer(void); |
---|
162 |
|
---|
163 |
/** |
---|
164 |
@Summary |
---|
165 |
Reads the TMR1 register. |
---|
166 |
|
---|
167 |
@Description |
---|
168 |
This function reads the TMR1 register value and return it. |
---|
169 |
|
---|
170 |
@Preconditions |
---|
171 |
Initialize the TMR1 before calling this function. |
---|
172 |
|
---|
173 |
@Param |
---|
174 |
None |
---|
175 |
|
---|
176 |
@Returns |
---|
177 |
This function returns the current value of TMR1 register. |
---|
178 |
|
---|
179 |
@Example |
---|
180 |
<code> |
---|
181 |
// Initialize TMR1 module |
---|
182 |
|
---|
183 |
// Start TMR1 |
---|
184 |
TMR1_StartTimer(); |
---|
185 |
|
---|
186 |
// Read the current value of TMR1 |
---|
187 |
if(0 == TMR1_ReadTimer()) |
---|
188 |
{ |
---|
189 |
// Do something else... |
---|
190 |
|
---|
191 |
// Reload the TMR value |
---|
192 |
TMR1_Reload(); |
---|
193 |
} |
---|
194 |
</code> |
---|
195 |
*/ |
---|
196 |
uint16_t TMR1_ReadTimer(void); |
---|
197 |
|
---|
198 |
/** |
---|
199 |
@Summary |
---|
200 |
Writes the TMR1 register. |
---|
201 |
|
---|
202 |
@Description |
---|
203 |
This function writes the TMR1 register. |
---|
204 |
This function must be called after the initialization of TMR1. |
---|
205 |
|
---|
206 |
@Preconditions |
---|
207 |
Initialize the TMR1 before calling this function. |
---|
208 |
|
---|
209 |
@Param |
---|
210 |
timerVal - Value to write into TMR1 register. |
---|
211 |
|
---|
212 |
@Returns |
---|
213 |
None |
---|
214 |
|
---|
215 |
@Example |
---|
216 |
<code> |
---|
217 |
#define PERIOD 0x80 |
---|
218 |
#define ZERO 0x00 |
---|
219 |
|
---|
220 |
while(1) |
---|
221 |
{ |
---|
222 |
// Read the TMR1 register |
---|
223 |
if(ZERO == TMR1_ReadTimer()) |
---|
224 |
{ |
---|
225 |
// Do something else... |
---|
226 |
|
---|
227 |
// Write the TMR1 register |
---|
228 |
TMR1_WriteTimer(PERIOD); |
---|
229 |
} |
---|
230 |
|
---|
231 |
// Do something else... |
---|
232 |
} |
---|
233 |
</code> |
---|
234 |
*/ |
---|
235 |
void TMR1_WriteTimer(uint16_t timerVal); |
---|
236 |
|
---|
237 |
/** |
---|
238 |
@Summary |
---|
239 |
Reload the TMR1 register. |
---|
240 |
|
---|
241 |
@Description |
---|
242 |
This function reloads the TMR1 register. |
---|
243 |
This function must be called to write initial value into TMR1 register. |
---|
244 |
|
---|
245 |
@Preconditions |
---|
246 |
Initialize the TMR1 before calling this function. |
---|
247 |
|
---|
248 |
@Param |
---|
249 |
None |
---|
250 |
|
---|
251 |
@Returns |
---|
252 |
None |
---|
253 |
|
---|
254 |
@Example |
---|
255 |
<code> |
---|
256 |
while(1) |
---|
257 |
{ |
---|
258 |
if(TMR1IF) |
---|
259 |
{ |
---|
260 |
// Do something else... |
---|
261 |
|
---|
262 |
// clear the TMR1 interrupt flag |
---|
263 |
TMR1IF = 0; |
---|
264 |
|
---|
265 |
// Reload the initial value of TMR1 |
---|
266 |
TMR1_Reload(); |
---|
267 |
} |
---|
268 |
} |
---|
269 |
</code> |
---|
270 |
*/ |
---|
271 |
void TMR1_Reload(void); |
---|
272 |
|
---|
273 |
/** |
---|
274 |
@Summary |
---|
275 |
Starts the single pulse acquisition in TMR1 gate operation. |
---|
276 |
|
---|
277 |
@Description |
---|
278 |
This function starts the single pulse acquisition in TMR1 gate operation. |
---|
279 |
This function must be used when the TMR1 gate is enabled. |
---|
280 |
|
---|
281 |
@Preconditions |
---|
282 |
Initialize the TMR1 with gate enable before calling this function. |
---|
283 |
|
---|
284 |
@Param |
---|
285 |
None |
---|
286 |
|
---|
287 |
@Returns |
---|
288 |
None |
---|
289 |
|
---|
290 |
@Example |
---|
291 |
<code> |
---|
292 |
uint16_t xVal; |
---|
293 |
uint16_t yVal; |
---|
294 |
|
---|
295 |
// enable TMR1 singlepulse mode |
---|
296 |
TMR1_StartSinglePulseAcquistion(); |
---|
297 |
|
---|
298 |
// check TMR1 gate status |
---|
299 |
if(TMR1_CheckGateValueStatus()== 0) |
---|
300 |
xVal = TMR1_ReadTimer(); |
---|
301 |
|
---|
302 |
// wait untill gate interrupt occured |
---|
303 |
while(TMR1GIF == 0) |
---|
304 |
{ |
---|
305 |
} |
---|
306 |
|
---|
307 |
yVal = TMR1_ReadTimer(); |
---|
308 |
</code> |
---|
309 |
*/ |
---|
310 |
void TMR1_StartSinglePulseAcquisition(void); |
---|
311 |
|
---|
312 |
/** |
---|
313 |
@Summary |
---|
314 |
Check the current state of Timer1 gate. |
---|
315 |
|
---|
316 |
@Description |
---|
317 |
This function reads the TMR1 gate value and return it. |
---|
318 |
This function must be used when the TMR1 gate is enabled. |
---|
319 |
|
---|
320 |
@Preconditions |
---|
321 |
Initialize the TMR1 with gate enable before calling this function. |
---|
322 |
|
---|
323 |
@Param |
---|
324 |
None |
---|
325 |
|
---|
326 |
@Returns |
---|
327 |
None |
---|
328 |
|
---|
329 |
@Example |
---|
330 |
<code> |
---|
331 |
uint16_t xVal; |
---|
332 |
uint16_t yVal; |
---|
333 |
|
---|
334 |
// enable TMR1 singlepulse mode |
---|
335 |
TMR1_StartSinglePulseAcquistion(); |
---|
336 |
|
---|
337 |
// check TMR1 gate status |
---|
338 |
if(TMR1_CheckGateValueStatus()== 0) |
---|
339 |
xVal = TMR1_ReadTimer(); |
---|
340 |
|
---|
341 |
// wait untill gate interrupt occured |
---|
342 |
while(TMR1IF == 0) |
---|
343 |
{ |
---|
344 |
} |
---|
345 |
|
---|
346 |
yVal = TMR1_ReadTimer(); |
---|
347 |
</code> |
---|
348 |
*/ |
---|
349 |
uint8_t TMR1_CheckGateValueStatus(void); |
---|
350 |
|
---|
351 |
/** |
---|
352 |
@Summary |
---|
353 |
Timer Interrupt Service Routine |
---|
354 |
|
---|
355 |
@Description |
---|
356 |
Timer Interrupt Service Routine is called by the Interrupt Manager. |
---|
357 |
|
---|
358 |
@Preconditions |
---|
359 |
Initialize the TMR1 module with interrupt before calling this ISR. |
---|
360 |
|
---|
361 |
@Param |
---|
362 |
None |
---|
363 |
|
---|
364 |
@Returns |
---|
365 |
None |
---|
366 |
*/ |
---|
367 |
void TMR1_ISR(void); |
---|
368 |
|
---|
369 |
/** |
---|
370 |
@Summary |
---|
371 |
Set Timer Interrupt Handler |
---|
372 |
|
---|
373 |
@Description |
---|
374 |
This sets the function to be called during the ISR |
---|
375 |
|
---|
376 |
@Preconditions |
---|
377 |
Initialize the TMR1 module with interrupt before calling this. |
---|
378 |
|
---|
379 |
@Param |
---|
380 |
Address of function to be set |
---|
381 |
|
---|
382 |
@Returns |
---|
383 |
None |
---|
384 |
*/ |
---|
385 |
void TMR1_SetInterruptHandler(void (* InterruptHandler)(void)); |
---|
386 |
void TMR1G_SetInterruptHandler(void (* InterruptHandler)(void)); |
---|
387 |
|
---|
388 |
/** |
---|
389 |
@Summary |
---|
390 |
Timer Interrupt Handler |
---|
391 |
|
---|
392 |
@Description |
---|
393 |
This is a function pointer to the function that will be called during the ISR |
---|
394 |
|
---|
395 |
@Preconditions |
---|
396 |
Initialize the TMR1 module with interrupt before calling this isr. |
---|
397 |
|
---|
398 |
@Param |
---|
399 |
None |
---|
400 |
|
---|
401 |
@Returns |
---|
402 |
None |
---|
403 |
*/ |
---|
404 |
extern void (*TMR1_InterruptHandler)(void); |
---|
405 |
|
---|
406 |
/** |
---|
407 |
@Summary |
---|
408 |
Default Timer Interrupt Handler |
---|
409 |
|
---|
410 |
@Description |
---|
411 |
This is the default Interrupt Handler function |
---|
412 |
|
---|
413 |
@Preconditions |
---|
414 |
Initialize the TMR1 module with interrupt before calling this isr. |
---|
415 |
|
---|
416 |
@Param |
---|
417 |
None |
---|
418 |
|
---|
419 |
@Returns |
---|
420 |
None |
---|
421 |
*/ |
---|
422 |
void TMR1_DefaultInterruptHandler(void); |
---|
423 |
void TMR1G_DefaultInterruptHandler(void); |
---|
424 |
/** |
---|
425 |
@Summary |
---|
426 |
Timer Gate Interrupt Service Routine |
---|
427 |
|
---|
428 |
@Description |
---|
429 |
Timer Gate Interrupt Service Routine is called by the Interrupt Manager. |
---|
430 |
User can write the code in this function. |
---|
431 |
|
---|
432 |
@Preconditions |
---|
433 |
Initialize the TMR1 module with gate interrupt before calling this isr. |
---|
434 |
|
---|
435 |
@Param |
---|
436 |
None |
---|
437 |
|
---|
438 |
@Returns |
---|
439 |
None |
---|
440 |
|
---|
441 |
@Example |
---|
442 |
None |
---|
443 |
*/ |
---|
444 |
void TMR1_GATE_ISR(void); |
---|
445 |
|
---|
446 |
//Sets polarity of the gate pin |
---|
447 |
void TMR1G_Polarity(uint8_t pol); |
---|
448 |
|
---|
449 |
#ifdef __cplusplus // Provide C++ Compatibility |
---|
450 |
|
---|
451 |
} |
---|
452 |
|
---|
453 |
#endif |
---|
454 |
|
---|
455 |
#endif // TMR1_H |
---|
456 |
/** |
---|
457 |
End of File |
---|
458 |
*/ |
---|