| 17 |
#include <inttypes.h> |
#include <inttypes.h> |
| 18 |
#include <avr/io.h> |
#include <avr/io.h> |
| 19 |
#include <avr/interrupt.h> |
#include <avr/interrupt.h> |
|
#include <avr/signal.h> |
|
| 20 |
|
|
| 21 |
#if defined(__AVR_AT90S2313__) |
#if defined(__AVR_AT90S2313__) |
| 22 |
# define OC1 PB3 |
# define OC1 PB3 |
| 67 |
volatile uint16_t pwm; /* Note [1] */ |
volatile uint16_t pwm; /* Note [1] */ |
| 68 |
volatile uint8_t direction; |
volatile uint8_t direction; |
| 69 |
|
|
| 70 |
SIGNAL (SIG_OVERFLOW1) /* Note [2] */ |
ISR (TIMER1_OVF_vect) /* Note [2] */ |
| 71 |
{ |
{ |
| 72 |
switch (direction) /* Note [3] */ |
switch (direction) /* Note [3] */ |
| 73 |
{ |
{ |
| 100 |
/* enable OC1 and PB2 as output */ |
/* enable OC1 and PB2 as output */ |
| 101 |
DDROC = _BV (OC1); |
DDROC = _BV (OC1); |
| 102 |
|
|
|
timer_enable_int (_BV (TOIE1)); |
|
|
|
|
| 103 |
/* enable interrupts */ |
/* enable interrupts */ |
| 104 |
|
TIMSK = _BV (TOIE1); |
| 105 |
sei (); |
sei (); |
| 106 |
} |
} |
| 107 |
|
|