Main Page | File List | Globals

purge.c

Go to the documentation of this file.
00001 // This file has been prepared for Doxygen automatic documentation generation.
00025 #include "xmodem.h"
00026 
00027 extern struct global
00028 {
00029   volatile unsigned char *recv_ptr;
00030   volatile unsigned char buffer_status;
00031   volatile unsigned char recv_error;
00032   volatile unsigned char t1_timed_out;
00033 } gl;
00034 
00035 unsigned char flush; // dummy value declared as global to eliminate compiler warning
00036 
00037 // wait 1 second for sender to empty its transmit buffer
00038 void purge(void)
00039 {
00040     gl.t1_timed_out = FALSE;
00041 
00042     // 1 second timeout
00043     // 8MHz / 1024 = 7813 Hz
00044     // 7813 Hz = 128 us
00045     // 1 seconds / 128 us = 7813
00046     // 65536 - 7813 = 57723 = e17b
00047     // interrupt on ffff to 0000 transition
00048     TCNT1 = 0xE17B;
00049     TCCR1B = 0x05; // timer/counter 1 clock / 1024
00050 
00051     while (gl.t1_timed_out != TRUE) // read uart until done
00052     {
00053         flush = UDR0;
00054     }
00055     TCCR1B = 0x00; // disable timer/counter 1 clock
00056 }

Generated on Tue Aug 23 13:47:52 2005 for Atmel AVR Application Note by  doxygen 1.4.4