Main Page | File List | Globals

recv_wait.c

Go to the documentation of this file.
00001 // This file has been prepared for Doxygen automatic documentation generation.
00024 #include "xmodem.h"
00025 
00026 extern struct global
00027 {
00028   volatile unsigned char *recv_ptr;
00029   volatile unsigned char buffer_status;
00030   volatile unsigned char recv_error;
00031   volatile unsigned char t1_timed_out;
00032 } gl;
00033 
00034 
00035 void recv_wait(void)
00036 {
00037     gl.t1_timed_out = FALSE;                    // set in timer counter 0 overflow interrupt routine
00038 
00039     // 1 second timeout
00040     // 8MHz / 1024 = 7813 Hz
00041     // 7813 Hz = 128 us
00042     // 1 seconds / 128 us = 7813
00043     // 65536 - 7813 = 57723 = e17b
00044     // interrupt on ffff to 0000 transition
00045     TCNT1 = 0xE17B;
00046     TCCR1B = 0x05;                            // timer/counter 1 clock / 1024
00047 
00048                                             // wait for packet, error, or timeout
00049     while (!gl.buffer_status && !gl.t1_timed_out);
00050                                             // turn off timer - no more time outs needed
00051     TCCR1B = 0x00;                          // disable timer/counter 1 clock
00052 
00053 }

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