~gabe/flashlight-firmware/anduril2

« back to all changes in this revision

Viewing changes to ToyKeeper/spaghetti-monster/fsm-main.c

  • Committer: Gabriel Hart
  • Date: 2021-08-20 14:48:04 UTC
  • Revision ID: gabe@ghart.com-20210820144804-smen7udrhuhr3658
from Tom E, support PB4 for any of the 3 PWM channels

Show diffs side-by-side

added added

removed removed

Lines of Context:
46
46
    DDRB |= (1 << PWM1_PIN);
47
47
    TCCR0B = 0x01; // pre-scaler for timer (1 => 1, 2 => 8, 3 => 64...)
48
48
    TCCR0A = PHASE;
 
49
    #if (PWM1_PIN == PB4) // Second PWM counter is ... weird
 
50
    TCCR1 = _BV (CS10);
 
51
    GTCCR = _BV (COM1B1) | _BV (PWM1B);
 
52
    OCR1C = 255;  // Set ceiling value to maximum
 
53
    #endif
49
54
    #endif
50
55
    #if PWM_CHANNELS >= 2
51
56
    DDRB |= (1 << PWM2_PIN);
 
57
    #if (PWM2_PIN == PB4) // Second PWM counter is ... weird
 
58
    TCCR1 = _BV (CS10);
 
59
    GTCCR = _BV (COM1B1) | _BV (PWM1B);
 
60
    OCR1C = 255;  // Set ceiling value to maximum
 
61
    #endif
52
62
    #endif
53
63
    #if PWM_CHANNELS >= 3
54
 
    // Second PWM counter is ... weird
55
64
    DDRB |= (1 << PWM3_PIN);
 
65
    #if (PWM3_PIN == PB4) // Second PWM counter is ... weird
56
66
    TCCR1 = _BV (CS10);
57
67
    GTCCR = _BV (COM1B1) | _BV (PWM1B);
58
68
    OCR1C = 255;  // Set ceiling value to maximum
59
69
    #endif
 
70
    #endif
60
71
    #if PWM_CHANNELS >= 4
61
72
    // 4th PWM channel is ... not actually supported in hardware  :(
62
73
    DDRB |= (1 << PWM4_PIN);