altos/easymotor: Move pressure conversion code to ao_motor_flight.c
[fw/altos] / src / easymotor-v3 / ao_pins.h
index 5cc95eb93b0eb0da5b1ff0edc6efee355673bac0..a0e40bd7ba5d326a7591d4da75bd13dfef5fed79 100644 (file)
 
 typedef int16_t        motor_pressure_t;
 
-/* want about 50psi, or 344kPa */
+/* want about 50psi, or 344kPa for boost and 30psi for coast */
 
 #define AO_FULL_SCALE_PRESSURE         11031612        /* 1600psi */
 #define AO_BOOST_DETECT_PRESSURE       344000          /* 50psi */
 #define AO_QUIET_DETECT_PRESSURE       207000          /* 30psi */
 
-static inline int16_t ao_delta_pressure_to_adc(uint32_t pressure)
-{
-       static const double volts_base = 0.5;
-       static const double volts_max = 4.5;
-
-       double  volts = (double) pressure / AO_FULL_SCALE_PRESSURE * (volts_max - volts_base);
-       double  adc_volts = volts * 10.0/15.6;  /* voltage divider in front of the ADC input */
-       if (adc_volts > 1.0)
-               adc_volts = 1.0;
-       double  adc = adc_volts * 32767.0;
-
-       if (adc < 0)
-               adc = 0;
-       return (int16_t) adc;
-}
-
-#define AO_BOOST_DETECT                        ao_delta_pressure_to_adc(AO_BOOST_DETECT_PRESSURE)
-#define AO_QUIET_DETECT                        ao_delta_pressure_to_adc(AO_QUIET_DETECT_PRESSURE)
+#define AO_PRESSURE_VOLTS_BASE 0.5
+#define AO_PRESSURE_VOLTS_MAX  4.5
 
 struct ao_adc {
        int16_t                 v_batt;