예제 #1
0
void temod_event(void)
{

  if (tmd_trans.status == I2CTransSuccess) {

    uint16_t tmd_temperature;

    /* read two byte temperature */
    tmd_temperature  = tmd_trans.buf[0] << 8;
    tmd_temperature |= tmd_trans.buf[1];

    ftmd_temperature = (tmd_temperature / TEMOD_TYPE) - 32.;

    DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &tmd_temperature, &ftmd_temperature);
    tmd_trans.status = I2CTransDone;


#if TEMP_TEMOD_SDLOG
  if (pprzLogFile != -1) {
    if (!log_temod_started) {
      sdLogWriteLog(pprzLogFile, "TEMOD: Temp(degC) GPS_fix TOW(ms) Week Lat(1e7deg) Lon(1e7deg) HMSL(mm) gspeed(cm/s) course(1e7deg) climb(cm/s)\n");
      log_temod_started = true;
    }
    else {
      sdLogWriteLog(pprzLogFile, "temod: %9.4f    %d %d %d   %d %d %d   %d %d %d\n",
          ftmd_temperature,
          gps.fix, gps.tow, gps.week,
          gps.lla_pos.lat, gps.lla_pos.lon, gps.hmsl,
          gps.gspeed, gps.course, -gps.ned_vel.z);
    }
  }
#endif

  }
}
예제 #2
0
파일: temp_temod.c 프로젝트: AxSt/paparazzi
void temod_event( void ) {

  if (tmd_trans.status == I2CTransSuccess) {

      uint16_t tmd_temperature;

      /* read two byte temperature */
      tmd_temperature  = tmd_trans.buf[0] << 8;
      tmd_temperature |= tmd_trans.buf[1];

      ftmd_temperature = (tmd_temperature / TEMOD_TYPE) - 32.;

      DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &tmd_temperature, &ftmd_temperature);
      tmd_trans.status = I2CTransDone;
  }
}
예제 #3
0
파일: temp_lm75.c 프로젝트: AshuLara/lisa
void lm75_event( void ) {
  if (lm75_trans.status == I2CTransSuccess) {
    uint16_t lm75_temperature;
    float flm75_temperature;

    /* read two byte temperature */
    lm75_temperature  = lm75_trans.buf[0] << 8;
    lm75_temperature |= lm75_trans.buf[1];
    lm75_temperature >>= 7;
    if (lm75_temperature & 0x0100)
      lm75_temperature |= 0xFE00;

    flm75_temperature = ((int16_t) lm75_temperature) / 2.;

    DOWNLINK_SEND_TMP_STATUS(DefaultChannel, &lm75_temperature, &flm75_temperature);
    lm75_trans.status = I2CTransDone;
  }
예제 #4
0
void tmp102_event( void ) {

  if ((tmp_trans.status == I2CTransSuccess) && (tmp_meas_started == TRUE)) {

      uint16_t tmp_temperature;

      /* read two byte temperature */
      tmp_temperature  = tmp_trans.buf[0] << 8;
      tmp_temperature |= tmp_trans.buf[1];
      tmp_temperature >>= 3;
      if (tmp_temperature & 0x1000)
        tmp_temperature |= 0xE000;

      ftmp_temperature = ((int16_t) tmp_temperature) / 16.;

      DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &tmp_temperature, &ftmp_temperature);
      tmp_trans.status = I2CTransDone;
  }
예제 #5
0
void wind_gfi_event( void ) {
    if (pcf_trans.status == I2CTransSuccess) {

        if (pcf_status == PCF_SET_OE_LSB) {
            pcf_status = PCF_READ_LSB;
            I2CReceive(PCF_I2C_DEV, pcf_trans, PCF_SLAVE_ADDR, 2);
        }
        else if (pcf_status == PCF_READ_LSB) {
            /* read lower byte direction info */
            pcf_direction = pcf_trans.buf[0];

            /* OE low, SEL low (for high data) */
            pcf_trans.buf[0] = 0xFF;
            pcf_trans.buf[1] = 0x3F;
            pcf_status = PCF_SET_OE_MSB;
            I2CTransmit(PCF_I2C_DEV, pcf_trans, PCF_SLAVE_ADDR, 2);
        }
        else if (pcf_status == PCF_SET_OE_MSB) {
            pcf_status = PCF_READ_MSB;
            I2CReceive(PCF_I2C_DEV, pcf_trans, PCF_SLAVE_ADDR, 2);
        }
        else if (pcf_status == PCF_READ_MSB) {
            float fpcf_direction;

            /* read higher byte direction info */
            pcf_direction |= pcf_trans.buf[0] << 8;

            /* OE high, SEL high */
            pcf_trans.buf[0] = 0xFF;
            pcf_trans.buf[1] = 0xFF;
            pcf_status = PCF_IDLE;
            I2CTransmit(PCF_I2C_DEV, pcf_trans, PCF_SLAVE_ADDR, 2);

            /* 2048 digits per 360 degrees */
            fpcf_direction = fmod((pcf_direction * (360./2048.)) + ZERO_OFFSET_DEGREES, 360.);

            DOWNLINK_SEND_TMP_STATUS(DefaultChannel, DefaultDevice, &pcf_direction, &fpcf_direction);
        }
        else if (pcf_status == PCF_IDLE) {
            pcf_trans.status = I2CTransDone;
        }
    }
}