1 |
hedin |
15 |
/*********************************************************************
|
2 |
|
|
*
|
3 |
|
|
* General Delay rouines
|
4 |
|
|
*
|
5 |
|
|
*********************************************************************
|
6 |
|
|
* FileName: Delay.h
|
7 |
|
|
* Dependencies: Compiler.h
|
8 |
|
|
* Processor: PIC18, PIC24F, PIC24H, dsPIC30F, dsPIC33F
|
9 |
|
|
* Complier: Microchip C18 v3.02 or higher
|
10 |
|
|
* Microchip C30 v2.01 or higher
|
11 |
|
|
* Company: Microchip Technology, Inc.
|
12 |
|
|
*
|
13 |
|
|
* Software License Agreement
|
14 |
|
|
*
|
15 |
|
|
* Copyright © 2002-2007 Microchip Technology Inc. All rights
|
16 |
|
|
* reserved.
|
17 |
|
|
*
|
18 |
|
|
* Microchip licenses to you the right to use, modify, copy, and
|
19 |
|
|
* distribute:
|
20 |
|
|
* (i) the Software when embedded on a Microchip microcontroller or
|
21 |
|
|
* digital signal controller product (“Device”) which is
|
22 |
|
|
* integrated into Licensee’s product; or
|
23 |
|
|
* (ii) ONLY the Software driver source files ENC28J60.c and
|
24 |
|
|
* ENC28J60.h ported to a non-Microchip device used in
|
25 |
|
|
* conjunction with a Microchip ethernet controller for the
|
26 |
|
|
* sole purpose of interfacing with the ethernet controller.
|
27 |
|
|
*
|
28 |
|
|
* You should refer to the license agreement accompanying this
|
29 |
|
|
* Software for additional information regarding your rights and
|
30 |
|
|
* obligations.
|
31 |
|
|
*
|
32 |
|
|
* THE SOFTWARE AND DOCUMENTATION ARE PROVIDED “AS IS” WITHOUT
|
33 |
|
|
* WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT
|
34 |
|
|
* LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS FOR A
|
35 |
|
|
* PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL
|
36 |
|
|
* MICROCHIP BE LIABLE FOR ANY INCIDENTAL, SPECIAL, INDIRECT OR
|
37 |
|
|
* CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA, COST OF
|
38 |
|
|
* PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR SERVICES, ANY CLAIMS
|
39 |
|
|
* BY THIRD PARTIES (INCLUDING BUT NOT LIMITED TO ANY DEFENSE
|
40 |
|
|
* THEREOF), ANY CLAIMS FOR INDEMNITY OR CONTRIBUTION, OR OTHER
|
41 |
|
|
* SIMILAR COSTS, WHETHER ASSERTED ON THE BASIS OF CONTRACT, TORT
|
42 |
|
|
* (INCLUDING NEGLIGENCE), BREACH OF WARRANTY, OR OTHERWISE.
|
43 |
|
|
*
|
44 |
|
|
*
|
45 |
|
|
* Author Date Comment
|
46 |
|
|
*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
47 |
|
|
* Nilesh Rajbharti 5/9/02 Original (Rev 1.0)
|
48 |
|
|
* Nilesh Rajbharti 6/10/02 Fixed C18 ms and us routines
|
49 |
|
|
* Howard Schlunder 4/04/06 Changed for C30
|
50 |
|
|
********************************************************************/
|
51 |
|
|
#ifndef __DELAY_H
|
52 |
|
|
#define __DELAY_H
|
53 |
|
|
|
54 |
|
|
#include "Compiler.h"
|
55 |
|
|
#include "HardwareProfile.h"
|
56 |
|
|
#if defined(__18CXX) && !defined(HI_TECH_C)
|
57 |
|
|
#include <delays.h>
|
58 |
|
|
#endif
|
59 |
|
|
|
60 |
|
|
#ifndef INSTR_FREQ
|
61 |
|
|
#error INSTR_FREQ must be defined.
|
62 |
|
|
#endif
|
63 |
|
|
|
64 |
|
|
#if defined(__C30__) || defined(HI_TECH_C)
|
65 |
|
|
#define Delay10us(x) \
|
66 |
|
|
{ \
|
67 |
|
|
unsigned long _dcnt; \
|
68 |
|
|
_dcnt=x*((unsigned long)(0.00001/(1.0/INSTR_FREQ)/6)); \
|
69 |
|
|
while(_dcnt--); \
|
70 |
|
|
}
|
71 |
|
|
void DelayMs(unsigned int ms);
|
72 |
|
|
#elif defined(__18CXX)
|
73 |
|
|
#define Delay10us(us) Delay10TCYx(((INSTR_FREQ/1000000)*us))
|
74 |
|
|
#define DelayMs(ms) Delay1KTCYx((((INSTR_FREQ/1000)*ms)/1000))
|
75 |
|
|
#endif
|
76 |
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
|
|
#endif
|