Add a 6th PWM input
Change-Id: I668a870c3ab26dd5804df8e2e1c7482f9fa1b588
diff --git a/motors/simple_receiver.cc b/motors/simple_receiver.cc
index 322cc06..910d2ae 100644
--- a/motors/simple_receiver.cc
+++ b/motors/simple_receiver.cc
@@ -63,9 +63,9 @@
::std::atomic<Spring *> global_spring{nullptr};
// Last width we received on each channel.
-uint16_t pwm_input_widths[5];
+uint16_t pwm_input_widths[6];
// When we received a pulse on each channel in milliseconds.
-uint32_t pwm_input_times[5];
+uint32_t pwm_input_times[6];
constexpr int kChannelTimeout = 100;
@@ -440,6 +440,12 @@
pwm_input_widths[3] = (end - start) & 0xFFFF;
pwm_input_times[3] = millis();
}
+ if (status & (1 << 7)) {
+ const uint32_t start = FTM3->C6V;
+ const uint32_t end = FTM3->C7V;
+ pwm_input_widths[5] = (end - start) & 0xFFFF;
+ pwm_input_times[5] = millis();
+ }
FTM3->STATUS = 0;
}
@@ -666,6 +672,10 @@
// FTM0_CH2
PORTC_PCR3 = PORT_PCR_MUX(4);
+ // PWM_IN5
+ // FTM3_CH6
+ PORTC_PCR10 = PORT_PCR_MUX(3);
+
// SPI0
// ACC_CS PCS0
PORTA_PCR14 = PORT_PCR_DSE | PORT_PCR_MUX(2);