/* pwm.c */
void init_pwm();
-void pwm_on(unsigned char n);
void pwm_off(unsigned char n);
void pwm_set(unsigned char n, unsigned char stride);
PORTB &= ~(_BV( PB1 ) | _BV( PB3 ) | _BV( PB5 )); // set to zero
}
-void pwm_on(unsigned char n)
-{
- switch (n) {
- case 0: DDRB |= _BV(PB1); break;
- case 1: DDRB |= _BV(PB3); break;
- case 2: DDRB |= _BV(PB5); break;
- }
-}
-
void pwm_off(unsigned char n)
{
switch (n) {
{
TC1H = 0x00;
switch (n) {
- case 0: OCR1A = stride; break;
- case 1: OCR1B = stride; break;
+ case 0:
+ OCR1A = stride;
+ DDRB |= _BV(PB1);
+ break;
+ case 1: OCR1B = stride;
+ DDRB |= _BV(PB3);
+ break;
case 2: {
uint16_t s16 = PWM_MAX - (uint16_t)stride;
volatile unsigned char hi, lo;
lo = s16 & 0xFF;
TC1H = hi;
OCR1D = lo;
+ DDRB |= _BV(PB5);
}
break;
}