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