~toykeeper/flashlight-firmware/trunk

« back to all changes in this revision

Viewing changes to ToyKeeper/hwdef-noctigon-m44.h

  • Committer: Selene ToyKeeper
  • Date: 2023-10-29 19:05:38 UTC
  • mto: (188.22.175 anduril2)
  • mto: This revision was merged to the branch mainline in revision 250.
  • Revision ID: bzr@toykeeper.net-20231029190538-8u28ea5apb4hkgi2
converted noctigon-dm11-boost to use PWM+DSM, and recalibrated timing for delays + smooth steps

Anduril has gradually gotten faster over the years, apparently, so it
needed longer delays to get accurate-ish timing for beacon and other modes.
Adding DSM also changes the timing perceptibly, so I made it possible to
calibrate the delay fudge factor on a per-build basis.

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
65
 
66
66
#define PWM_CHANNELS  1  // old, remove this
67
67
 
68
 
#define PWM_BITS      16     // 0 to 32640 (0 to 255 PWM + 0 to 127 DSM) at constant kHz
 
68
#define PWM_BITS      16        // 0 to 32640 (0 to 255 PWM + 0 to 127 DSM) at constant kHz
69
69
#define PWM_GET       PWM_GET16
70
70
#define PWM_DATATYPE  uint16_t
71
71
#define PWM_DATATYPE2 uint32_t  // only needs 32-bit if ramp values go over 255
105
105
// e-switch
106
106
#define SWITCH_PIN   PA7     // pin 20
107
107
#define SWITCH_PCINT PCINT7  // pin 20 pin change interrupt
108
 
#define SWITCH_PCIE  PCIE0   // PCIE1 is for PCINT[7:0]
109
 
#define SWITCH_PCMSK PCMSK0  // PCMSK1 is for PCINT[7:0]
 
108
#define SWITCH_PCIE  PCIE0   // PCIE0 is for PCINT[7:0]
 
109
#define SWITCH_PCMSK PCMSK0  // PCMSK0 is for PCINT[7:0]
110
110
#define SWITCH_PORT  PINA    // PINA or PINB or PINC
111
111
#define SWITCH_PUE   PUEA    // pullup group A
112
112
#define PCINT_vect   PCINT0_vect  // ISR for PCINT[7:0]
178
178
    // CS1[2:0]:    0,0,1: clk/1 (No prescaling) (DS table 12-6)
179
179
    // COM1A[1:0]:    1,0: PWM OC1A in the normal direction (DS table 12-4)
180
180
    // COM1B[1:0]:    1,0: PWM OC1B in the normal direction (DS table 12-4)
181
 
    TCCR1A  = (1<<WGM11)  | (0<<WGM10)   // adjustable PWM (TOP=ICR1) (DS table 12-5)
182
 
            | (1<<COM1A1) | (0<<COM1A0)  // PWM 1A in normal direction (DS table 12-4)
183
 
            | (1<<COM1B1) | (0<<COM1B0)  // PWM 1B in normal direction (DS table 12-4)
184
 
            ;
185
 
    TCCR1B  = (0<<CS12)   | (0<<CS11) | (1<<CS10)  // clk/1 (no prescaling) (DS table 12-6)
186
 
            //| (1<<WGM13)  | (1<<WGM12)  // fast adjustable PWM (DS table 12-5)
187
 
            | (1<<WGM13)  | (0<<WGM12)  // phase-correct adjustable PWM (DS table 12-5)
188
 
            ;
 
181
    TCCR1A = (1<<WGM11)  | (0<<WGM10)   // adjustable PWM (TOP=ICR1) (DS table 12-5)
 
182
           | (1<<COM1A1) | (0<<COM1A0)  // PWM 1A in normal direction (DS table 12-4)
 
183
           | (1<<COM1B1) | (0<<COM1B0)  // PWM 1B in normal direction (DS table 12-4)
 
184
           ;
 
185
    TCCR1B = (0<<CS12)   | (0<<CS11) | (1<<CS10)  // clk/1 (no prescaling) (DS table 12-6)
 
186
           //| (1<<WGM13)  | (1<<WGM12)  // fast adjustable PWM (DS table 12-5)
 
187
           | (1<<WGM13)  | (0<<WGM12)  // phase-correct adjustable PWM (DS table 12-5)
 
188
           ;
189
189
 
190
190
    // set PWM resolution
191
191
    PWM_TOP = PWM_TOP_INIT;