D:/DRISSI/arduino-0022/arduino-0022/libraries/TimerOne/TimerOne.h
00001 /*
00002  *  Interrupt and PWM utilities for 16 bit Timer1 on ATmega168/328
00003  *  Original code by Jesse Tane for http://labs.ideo.com August 2008
00004  *  Modified March 2009 by Jérôme Despatis and Jesse Tane for ATmega328 support
00005  *  Modified June 2009 by Michael Polli and Jesse Tane to fix a bug in setPeriod() which caused the timer to stop
00006  *
00007  *  This is free software. You can redistribute it and/or modify it under
00008  *  the terms of Creative Commons Attribution 3.0 United States License. 
00009  *  To view a copy of this license, visit http://creativecommons.org/licenses/by/3.0/us/ 
00010  *  or send a letter to Creative Commons, 171 Second Street, Suite 300, San Francisco, California, 94105, USA.
00011  *
00012  */
00013 
00014 #include <avr/io.h>
00015 #include <avr/interrupt.h>
00016 
00017 #define RESOLUTION 65536    // Timer1 is 16 bit
00018 
00019 class TimerOne
00020 {
00021   public:
00022   
00023     // properties
00024     unsigned int pwmPeriod;
00025     unsigned char clockSelectBits;
00026 
00027     // methods
00028     void initialize(long microseconds=1000000);
00029     void start();
00030     void stop();
00031     void restart();
00032     void pwm(char pin, int duty, long microseconds=-1);
00033     void disablePwm(char pin);
00034     void attachInterrupt(void (*isr)(), long microseconds=-1);
00035     void detachInterrupt();
00036     void setPeriod(long microseconds);
00037     void setPwmDuty(char pin, int duty);
00038     void (*isrCallback)();
00039 };
00040 
00041 extern TimerOne Timer1;