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