![](/media/cache/profiles/f93486bfff38ca69d76d85c089569a09.50x50_q85.jpg)
C1541-III mbed edition
Diff: delay.c
- Revision:
- 0:28557a4d2215
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/delay.c Mon Aug 22 05:48:51 2011 +0000 @@ -0,0 +1,110 @@ +/*----------------------------------------------------------------------------------*/ +/* +high level delay routines - see delay.h for more info. + +Designed by Shane Tolmie of KeyGhost corporation. Freely distributable. +Questions and comments to shane@keyghost.com +PICuWEB - Program PIC micros with C. Site has FAQ and sample source code. http://www.workingtex.com/htpic + +For Microchip PIC18xxxxx and Hi-Tech C + +*/ +/*----------------------------------------------------------------------------------*/ + +/* History: + -------- + 2006-02-02 -improvements in code layout... i.o.w. making it more readable + +*/ + +/* TO DO: + ------ +*/ + +/*----------------------------------------------------------------------------------*/ + +#ifndef __DELAY_C +#define __DELAY_C + +/*--------------------------------------------------------*/ +/* includes */ +/*--------------------------------------------------------*/ +#include <mbed.h> +#include <delay.h> +#include <main.h> + +/*--------------------------------------------------------*/ +/* globals */ +/*--------------------------------------------------------*/ +unsigned char delayus_variable; + +void CLRWDT(){}; + +/*****************************************************************************************************************/ +/*****************************************************************************************************************/ + +void DelayBigUs(unsigned int cnt) +{ + unsigned char i; + + i = (unsigned char)(cnt>>8); + while(i>=1) + { + i--; + DelayUs(253); + CLRWDT(); + } + DelayUs((unsigned char)(cnt & 0xFF)); +} + +void DelayMs(unsigned char cnt) +{ + unsigned char i; + do { + i = 4; + do { + DelayUs(250); + CLRWDT(); + } while(--i); + } while(--cnt); +} + +//this copy is for the interrupt function +void DelayMs_interrupt(unsigned char cnt) +{ + unsigned char i; + do { + i = 4; + do { + DelayUs(250); + } while(--i); + } while(--cnt); +} + +void DelayBigMs(unsigned int cnt) +{ + unsigned char i; + do { + i = 4; + do { + DelayUs(250); + CLRWDT(); + } while(--i); + } while(--cnt); +} + +void DelayS(unsigned char cnt) +{ + unsigned char i; + do { + i = 4; + do { + DelayMs(250); + CLRWDT(); + } while(--i); + } while(--cnt); +} + +#endif + +