Gert van der Knokke
/
C1541III
C1541-III mbed edition
delay.c
- Committer:
- gertk
- Date:
- 2011-08-22
- Revision:
- 1:0cbbb66a6100
- Parent:
- 0:28557a4d2215
File content as of revision 1:0cbbb66a6100:
/*----------------------------------------------------------------------------------*/ /* 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