Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
delay.c
00001 /*----------------------------------------------------------------------------------*/ 00002 /* 00003 high level delay routines - see delay.h for more info. 00004 00005 Designed by Shane Tolmie of KeyGhost corporation. Freely distributable. 00006 Questions and comments to shane@keyghost.com 00007 PICuWEB - Program PIC micros with C. Site has FAQ and sample source code. http://www.workingtex.com/htpic 00008 00009 For Microchip PIC18xxxxx and Hi-Tech C 00010 00011 */ 00012 /*----------------------------------------------------------------------------------*/ 00013 00014 /* History: 00015 -------- 00016 2006-02-02 -improvements in code layout... i.o.w. making it more readable 00017 00018 */ 00019 00020 /* TO DO: 00021 ------ 00022 */ 00023 00024 /*----------------------------------------------------------------------------------*/ 00025 00026 #ifndef __DELAY_C 00027 #define __DELAY_C 00028 00029 /*--------------------------------------------------------*/ 00030 /* includes */ 00031 /*--------------------------------------------------------*/ 00032 #include <mbed.h> 00033 #include <delay.h> 00034 #include <main.h> 00035 00036 /*--------------------------------------------------------*/ 00037 /* globals */ 00038 /*--------------------------------------------------------*/ 00039 unsigned char delayus_variable; 00040 00041 void CLRWDT(){}; 00042 00043 /*****************************************************************************************************************/ 00044 /*****************************************************************************************************************/ 00045 00046 void DelayBigUs(unsigned int cnt) 00047 { 00048 unsigned char i; 00049 00050 i = (unsigned char)(cnt>>8); 00051 while(i>=1) 00052 { 00053 i--; 00054 DelayUs(253); 00055 CLRWDT(); 00056 } 00057 DelayUs((unsigned char)(cnt & 0xFF)); 00058 } 00059 00060 void DelayMs(unsigned char cnt) 00061 { 00062 unsigned char i; 00063 do { 00064 i = 4; 00065 do { 00066 DelayUs(250); 00067 CLRWDT(); 00068 } while(--i); 00069 } while(--cnt); 00070 } 00071 00072 //this copy is for the interrupt function 00073 void DelayMs_interrupt(unsigned char cnt) 00074 { 00075 unsigned char i; 00076 do { 00077 i = 4; 00078 do { 00079 DelayUs(250); 00080 } while(--i); 00081 } while(--cnt); 00082 } 00083 00084 void DelayBigMs(unsigned int cnt) 00085 { 00086 unsigned char i; 00087 do { 00088 i = 4; 00089 do { 00090 DelayUs(250); 00091 CLRWDT(); 00092 } while(--i); 00093 } while(--cnt); 00094 } 00095 00096 void DelayS(unsigned char cnt) 00097 { 00098 unsigned char i; 00099 do { 00100 i = 4; 00101 do { 00102 DelayMs(250); 00103 CLRWDT(); 00104 } while(--i); 00105 } while(--cnt); 00106 } 00107 00108 #endif 00109 00110
Generated on Tue Jul 26 2022 04:14:07 by
1.7.2