예제 #1
0
// *************************************************************************************************
// @fn          start_altitude_measurement
// @brief       Start altitude measurement
// @param       none
// @return      none
// *************************************************************************************************
void start_altitude_measurement(void)
{
    // Show warning if pressure sensor was not initialised properly
    if (!ps_ok)
    {
        display_chars(LCD_SEG_L1_2_0, (u8*)"ERR", SEG_ON);
        return;
    }

    // Start altitude measurement if timeout has elapsed
    if (sAlt.timeout == 0)
    {
        // Enable DRDY IRQ on rising edge
        PS_INT_IFG &= ~PS_INT_PIN;
        PS_INT_IE |= PS_INT_PIN;

        // Start pressure sensor
        ps_start();

        // Set timeout counter only if sensor status was OK
        sAlt.timeout = ALTITUDE_MEASUREMENT_TIMEOUT;

        // Get updated altitude
        while((PS_INT_IN & PS_INT_PIN) == 0);
        do_altitude_measurement(FILTER_OFF);
    }
}
예제 #2
0
파일: altitude.c 프로젝트: alkin/tidecc
// *************************************************************************************************
// @fn          start_altitude_measurement
// @brief       Start altitude measurement
// @param       none
// @return      none
// *************************************************************************************************
void start_altitude_measurement(void)
{
   u8 timeout = 15;

   // Already on?
   if (sAlt.on)
      return;

   // Show warning if pressure sensor was not initialised properly
   if (!ps_ok)
   {
      display_chars(LCD_SEG_L1_2_0, (u8 *) "ERR", SEG_ON);
      return;
   }

   // Enable DRDY IRQ on rising edge
   PS_INT_IFG &= ~PS_INT_PIN;
   PS_INT_IE |= PS_INT_PIN;

   // Start pressure sensor
   ps_start();

   // Set altitude measurement flag
   sAlt.on = 1;

   // Get updated altitude
   while (((PS_INT_IN & PS_INT_PIN) == 0) && (timeout > 0))
   {
      Timer0_A4_Delay(CONV_MS_TO_TICKS(100));
      timeout--;
   }

   // Failed to start?
   if (timeout == 0)
   {
      sAlt.on = 0;
   }

   do_altitude_measurement(FILTER_OFF);
}