Main Page   Modules   Data Structures   File List   Data Fields   Globals  

pulse.h

Go to the documentation of this file.
00001 /*! \file pulse.h \brief Pulse/frequency generation function library. */
00002 //*****************************************************************************
00003 //
00004 // File Name    : 'pulse.h'
00005 // Title        : Pulse/frequency generation function library
00006 // Author       : Pascal Stang - Copyright (C) 2000-2002
00007 // Created      : 2002-08-19
00008 // Revised      : 2003-05-29
00009 // Version      : 0.7
00010 // Target MCU   : Atmel AVR Series
00011 // Editor Tabs  : 4
00012 //
00013 // Description  : This library is designed to facilitate the output of square
00014 //      wave pulses at a frequency determined by the user.  The library uses
00015 //      the AVR processor built-in timers and the output is on the timer Output
00016 //      Compare (OC) pins.
00017 //
00018 //      The allowable range of frequencies which can be generated is governed
00019 //      by the tic rate of the timer (therefore the CPU clock rate and the
00020 //      timer prescaler), and the computing speed of the processor itself. See
00021 //      the SetFreq commands for more details.
00022 //
00023 //      NOTE: in order for the pulse library to work, pulseInit() will attach
00024 //      the pulse service routines to the timer interrupts using the
00025 //      timerAttach function. You must not detach the service routines during
00026 //      pulse library operation.
00027 //
00028 // This code is distributed under the GNU Public License
00029 //      which can be found at http://www.gnu.org/licenses/gpl.txt
00030 //
00031 //*****************************************************************************
00032 
00033 #ifndef PULSE_H
00034 #define PULSE_H
00035 
00036 #include "global.h"
00037 
00038 // constants/macros/typdefs
00039 
00040 // functions
00041 
00042 // Master Pulse Commands
00043 // pulseInit()
00044 //      Initializes the pulse system/library.
00045 void pulseInit(void);
00046 
00047 // Pulse commands for timer1
00048 // pulseT1Init()
00049 //      configures the timer1 hardware to produce pulses on pins OC1A and OC1B.
00050 //      A "pulse" is considered to be one high and low period of a square wave.
00051 void pulseT1Init(void);
00052 
00053 // pulseT1Off()
00054 //      Turns pulse output off immediately (cancels running pulse operations).
00055 //      Unconfigures hardware and interrupts.
00056 void pulseT1Off(void);
00057 
00058 //  pulseT1ASetFreq() and pulseT1BSetFreq()
00059 //      sets the frequency in hertz for each channel of square-wave pulse output
00060 //      Note1: the freqency <freqHz> must always be greater than zero
00061 //      Note2: both channels share the same frequency range which is governed
00062 //      by the timer1 prescaler setting.  A prescaler setting of DIV/8 allows
00063 //      frequencies of a few hertz through a few kilohertz.
00064 //
00065 //      Lower frequency bound = overflow rate of timer1 at current prescaling
00066 //      Upper frequency bound = the tics rate of timer1 at current prescaling,
00067 //                              or approx. the (clock rate of the processor)/50,
00068 //                              whichever is smaller
00069 void pulseT1ASetFreq(u16 freqHz);
00070 void pulseT1BSetFreq(u16 freqHz);
00071 
00072 // pulseT1ARun() and pulseT1BRun();
00073 //      Sets the number of square-wave pulses to be output on the given channel.
00074 //      For continuous (unlimited) pulse output, use nPulses = 0.  Pulses begin
00075 //      coming out immediately.
00076 //      Note: <nPulses> must be between 0 and 32767
00077 void pulseT1ARun(u16 nPulses);
00078 void pulseT1BRun(u16 nPulses);
00079 
00080 // pulseT1AStop() and pulseT1BStop();
00081 //      Stop pulse output at the next cycle (regardless of the number of
00082 //      remaining pulses).
00083 void pulseT1AStop(void);
00084 void pulseT1BStop(void);
00085 
00086 // pulseT1ARemaining() and pulseT1BRemaining()
00087 //      Returns the number of pulses remaining to be output for each channel.
00088 //      This function is useful for figuring out if the pulses are done.
00089 u16  pulseT1ARemaining(void);
00090 u16  pulseT1BRemaining(void);
00091 
00092 // pulseT1AService() and pulseT1BService()
00093 //      Interrupt service routines for pulse output (do not call these functions directly)
00094 void pulseT1AService(void);
00095 void pulseT1BService(void);
00096 
00097 
00098 #endif

Generated on Sun Feb 22 19:12:31 2004 for Procyon AVRlib by doxygen1.3-rc2