1 |
/*********************************************************************
|
2 |
*
|
3 |
* Tick Manager for PIC18
|
4 |
*
|
5 |
*********************************************************************
|
6 |
* FileName: Tick.h
|
7 |
* Dependencies: None
|
8 |
* Processor: PIC18
|
9 |
* Complier: MCC18 v1.00.50 or higher
|
10 |
* HITECH PICC-18 V8.10PL1 or higher
|
11 |
* Company: Microchip Technology, Inc.
|
12 |
*
|
13 |
* Software License Agreement
|
14 |
*
|
15 |
* The software supplied herewith by Microchip Technology Incorporated
|
16 |
* (the “Company”) for its PICmicro® Microcontroller is intended and
|
17 |
* supplied to you, the Company’s customer, for use solely and
|
18 |
* exclusively on Microchip PICmicro Microcontroller products. The
|
19 |
* software is owned by the Company and/or its supplier, and is
|
20 |
* protected under applicable copyright laws. All rights are reserved.
|
21 |
* Any use in violation of the foregoing restrictions may subject the
|
22 |
* user to criminal sanctions under applicable laws, as well as to
|
23 |
* civil liability for the breach of the terms and conditions of this
|
24 |
* license.
|
25 |
*
|
26 |
* THIS SOFTWARE IS PROVIDED IN AN “AS IS” CONDITION. NO WARRANTIES,
|
27 |
* WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT NOT LIMITED
|
28 |
* TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
|
29 |
* PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. THE COMPANY SHALL NOT,
|
30 |
* IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL OR
|
31 |
* CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
|
32 |
*
|
33 |
* Author Date Comment
|
34 |
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
35 |
* Nilesh Rajbharti 6/28/01 Original (Rev 1.0)
|
36 |
* Nilesh Rajbharti 2/9/02 Cleanup
|
37 |
* Nilesh Rajbharti 5/22/02 Rev 2.0 (See version.log for detail)
|
38 |
********************************************************************/
|
39 |
|
40 |
#ifndef TICK_H
|
41 |
#define TICK_H
|
42 |
|
43 |
typedef unsigned long TICK;
|
44 |
|
45 |
#if !defined(TICKS_PER_SECOND)
|
46 |
#error TICKS_PER_SECOND must be defined.
|
47 |
#endif
|
48 |
|
49 |
#if !defined(TICK_PRESCALE_VALUE)
|
50 |
#error TICK_PRESCALE_VALUE must be defined.
|
51 |
#endif
|
52 |
|
53 |
#define TICK_SECOND ((TICK)TICKS_PER_SECOND)
|
54 |
|
55 |
#define TickGetDiff(a, b) (a-b)
|
56 |
//#define TickGetDiff(a, b) (TICK)(a < b) ? (((TICK)0xffff - b) + a) : (a - b)
|
57 |
|
58 |
/*
|
59 |
* Only Tick.c defines TICK_INCLUDE and thus defines Seconds
|
60 |
* and TickValue storage.
|
61 |
*/
|
62 |
#ifndef TICK_INCLUDE
|
63 |
extern TICK TickCount;
|
64 |
#endif
|
65 |
|
66 |
/*********************************************************************
|
67 |
* Function: void TickInit(void)
|
68 |
*
|
69 |
* PreCondition: None
|
70 |
*
|
71 |
* Input: None
|
72 |
*
|
73 |
* Output: Tick manager is initialized.
|
74 |
*
|
75 |
* Side Effects: None
|
76 |
*
|
77 |
* Overview: Initializes Timer0 as a tick counter.
|
78 |
*
|
79 |
* Note: None
|
80 |
********************************************************************/
|
81 |
void TickInit(void);
|
82 |
|
83 |
|
84 |
|
85 |
/*********************************************************************
|
86 |
* Function: TICK TickGet(void)
|
87 |
*
|
88 |
* PreCondition: None
|
89 |
*
|
90 |
* Input: None
|
91 |
*
|
92 |
* Output: Current second value is given
|
93 |
*
|
94 |
* Side Effects: None
|
95 |
*
|
96 |
* Overview: None
|
97 |
*
|
98 |
* Note: None
|
99 |
********************************************************************/
|
100 |
TICK TickGet(void);
|
101 |
|
102 |
|
103 |
/*********************************************************************
|
104 |
* Function: void TickUpdate(void)
|
105 |
*
|
106 |
* PreCondition: None
|
107 |
*
|
108 |
* Input: None
|
109 |
*
|
110 |
* Output: None
|
111 |
*
|
112 |
* Side Effects: None
|
113 |
*
|
114 |
* Overview: Internal Tick and Seconds count are updated.
|
115 |
*
|
116 |
* Note: None
|
117 |
********************************************************************/
|
118 |
void TickUpdate(void);
|
119 |
|
120 |
#endif
|