Remote Access Control


timer.h File Reference


Detailed Description

Header file for timer public functions.

This file contains the prototypes for the timer functions. The implementation is found in the timer.c file. The timer functions use Timer/Counter1 Compare Match A and B and interrupts to implement the timing functionality. The timeout delays are configured using macros in the timer.c file. A short and a long timeout delay is implemented. The short is used for detecting timeouts when receiving data from the RF receiver. The long timeout is used for user interaction when the application is in learn mode.

Author:
Atmel Corporation: http://www.atmel.com
Support email: avr@atmel.com
Name
Revision
1193
Date
2006-10-31 14:21:08 +0100 (ti, 31 okt 2006)

Copyright (c) 2006, Atmel Corporation All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

3. The name of ATMEL may not be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY ATMEL ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Definition in file timer.h.

#include "common.h"
#include "config.h"
#include "memory.h"

Include dependency graph for timer.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void startLongTimeout (void)
void startShortTimeout (void)
void stopTimer (void)

Variables

volatile bool longTimeout
volatile bool shortTimeout


Function Documentation

void startLongTimeout ( void   ) 

Clear flag and restart long timeout delay.

Definition at line 117 of file timer.c.

References LONG_TIMEOUT_HI_VALUE, longTimeout, longTimeoutHighCounter, and TIMER_PRESCALER_VALUE.

Referenced by learnMode().

00118 {
00119         // Clear timeout flag.
00120         longTimeout = false;
00121         // Initialize countdown value.
00122         longTimeoutHighCounter = LONG_TIMEOUT_HI_VALUE;
00123         // Initialize compare value to one less than
00124         // current counter value, so that we do not get
00125         // an interrupt immediately.
00126         OCR1B = TCNT1 - 1;
00127         // Clear pending interrupt flag.
00128         TIFR1 |= (1<<OCF1B);
00129         // Enable interrupt.
00130         TIMSK1 |= (1<<OCIE1B);
00131         // Start timer/counter if not started yet.
00132         TCCR1B = TIMER_PRESCALER_VALUE;
00133 }

void startShortTimeout ( void   ) 

Clear flag and restart short timeout delay.

Definition at line 100 of file timer.c.

References SHORT_TIMEOUT_VALUE, shortTimeout, and TIMER_PRESCALER_VALUE.

Referenced by rxClockLineHandler().

00101 {
00102         // Clear timeout flag.
00103         shortTimeout = false;
00104         // Initialize compare value relative
00105         // to current timer value.
00106         OCR1A = TCNT1 + SHORT_TIMEOUT_VALUE;
00107         // Clear pending interrupt flag.
00108         TIFR1 |= (1<<OCF1A);
00109         // Enable interrupt.
00110         TIMSK1 |= (1<<OCIE1A);
00111         // Start timer/counter if not started yet.
00112         TCCR1B = TIMER_PRESCALER_VALUE;
00113 }

void stopTimer ( void   ) 

Stop both timers and clear flags.

Definition at line 137 of file timer.c.

References longTimeout, and shortTimeout.

Referenced by learnMode(), and main().

00138 {
00139         TCCR1B = 0x00;
00140         shortTimeout = false;
00141         longTimeout = false;
00142 }


Variable Documentation

volatile bool longTimeout

Timeout flag set if long timeout occurs.

Definition at line 62 of file timer.c.

Referenced by learnMode(), longTimeoutHandler(), startLongTimeout(), and stopTimer().

volatile bool shortTimeout

Timeout flag set if short timeout occurs.

Definition at line 61 of file timer.c.

Referenced by receiverTimedOut(), shortTimeoutHandler(), startShortTimeout(), and stopTimer().

@DOC_TITLE@
Generated on Fri Aug 8 11:04:08 2008 for AVR411 Secure Rolling Code Algorithm (Receiver) by doxygen 1.4.7