00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
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
00024 unsigned int pwmPeriod;
00025 unsigned char clockSelectBits;
00026
00027
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;