+ __pdata int16_t pyro;
+ ao_arch_critical(
+ while (sample == ao_data_head)
+ ao_sleep((void *) DATA_TO_XDATA(&ao_data_head));
+ );
+
+
+ packet = &ao_data_ring[sample];
+ sample = ao_data_ring_next(sample);
+
+ pyro = packet->adc.pyro;
+
+#define VOLTS_TO_PYRO(x) ((int16_t) ((x) * ((1.0 * AO_PYRO_R_SENSE_GND) / \
+ (1.0 * (AO_PYRO_R_SENSE_GND + AO_PYRO_R_PYRO_SENSE)) / 3.3 * AO_ADC_MAX)))
+
+
+#define VOLTS_TO_FIRE(x) ((int16_t) ((x) * ((1.0 * AO_FIRE_R_SENSE_GND) / \
+ (1.0 * (AO_FIRE_R_SENSE_GND + AO_FIRE_R_FET_SENSE)) / 3.3 * AO_ADC_MAX)))
+
+ /* convert ADC value to voltage in tenths, then add .2 for the diode drop */
+ query.battery = (packet->adc.batt + 96) / 192 + 2;
+ cur = 0;
+ if (pyro > VOLTS_TO_PYRO(10)) {
+ query.arm_status = AO_PAD_ARM_STATUS_ARMED;
+ cur |= AO_LED_ARMED;
+#if AO_FIRE_R_POWER_FET
+ } else if (pyro > VOLTS_TO_PYRO(5)) {
+ if ((ao_time() % 100) < 50)
+ cur |= AO_LED_ARMED;
+ query.arm_status = AO_PAD_ARM_STATUS_UNKNOWN;
+ arm_beep_time = 0;
+#endif
+ } else {
+ query.arm_status = AO_PAD_ARM_STATUS_DISARMED;
+ arm_beep_time = 0;
+ }
+ if ((ao_time() - ao_pad_packet_time) > AO_SEC_TO_TICKS(2))
+ cur |= AO_LED_RED;
+ else if (ao_radio_cmac_rssi < AO_PAD_RSSI_MINIMUM)
+ cur |= AO_LED_AMBER;
+ else
+ cur |= AO_LED_GREEN;
+
+ for (c = 0; c < AO_PAD_NUM; c++) {
+ int16_t sense = packet->adc.sense[c];
+ uint8_t status = AO_PAD_IGNITER_STATUS_UNKNOWN;
+
+ /*
+ * pyro is run through a divider, so pyro = v_pyro * 27 / 127 ~= v_pyro / 20
+ * v_pyro = pyro * 127 / 27
+ *
+ * v_pyro \
+ * 100k igniter
+ * output /
+ * 100k \
+ * sense relay
+ * 27k /
+ * gnd ---
+ *
+ * v_pyro \
+ * 200k igniter
+ * output /
+ * 200k \
+ * sense relay
+ * 22k /
+ * gnd ---
+ *
+ * If the relay is closed, then sense will be 0
+ * If no igniter is present, then sense will be v_pyro * 27k/227k = pyro * 127 / 227 ~= pyro/2
+ * If igniter is present, then sense will be v_pyro * 27k/127k ~= v_pyro / 20 = pyro
+ */
+
+#if AO_FIRE_R_POWER_FET
+ if (sense <= pyro / 8) {
+ status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_CLOSED;
+ if ((ao_time() % 100) < 50)
+ cur |= AO_LED_CONTINUITY(c);
+ } else
+ if (pyro / 8 * 3 <= sense && sense <= pyro / 8 * 5)
+ status = AO_PAD_IGNITER_STATUS_NO_IGNITER_RELAY_OPEN;
+ else if (pyro / 8 * 7 <= sense) {
+ status = AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN;
+ cur |= AO_LED_CONTINUITY(c);
+ }
+#else
+ if (sense >= pyro / 8 * 5) {
+ status = AO_PAD_IGNITER_STATUS_GOOD_IGNITER_RELAY_OPEN;
+ cur |= AO_LED_CONTINUITY(c);