download dpicco.c
Language: C
LOC: 33
Project Info
paparazzi
Server: Savannah NonGNU
Type: cvs
...zzi\paparazzi3\sw\airborne\
   3dmg.c
   3dmg.h
   actuators.c
   actuators.h
   adc.h
   adc_generic.c
   adc_generic.h
   ahrs.c
   ahrs.h
   ahrs_new.c
   ahrs_new.h
   anemotaxis.c
   anemotaxis.h
   ap_downlink.h
   autopilot.h
   bomb.c
   bomb.h
   cam.c
   cam.h
   cam_roll.c
   cam_roll.h
   chemo_detect.c
   chemo_detect.h
   chemotaxis.c
   chemotaxis.h
   commands.c
   commands.h
   control_grz.c
   control_grz.h
   datalink.c
   datalink.h
   dc.c
   dc.h
   discsurvey.c
   discsurvey.h
   downlink.c
   downlink.h
   dpicco.c
   dpicco.h
   enose.c
   enose.h
   estimator.c
   estimator.h
   fbw_downlink.h
   frames.h
   fw_h_ctl.c
   fw_h_ctl.h
   fw_v_ctl.c
   fw_v_ctl.h
   gps.c
   gps.h
   gps_ubx.c
   gps_ubx.h
   gyro.c
   gyro.h
   i2c.c
   i2c.h
   imu.c
   imu.h
   imu_v3.c
   imu_v3.h
   infrared.c
   infrared.h
   inter_mcu.c
   inter_mcu.h
   latlong.c
   latlong.h
   led.h
   link_imu.c
   link_imu.h
   link_mcu.c
   link_mcu.h
   main.c
   main_antenna.c
   main_ap.c
   main_ap.h
   main_demo1.c
   main_demo2.c
   main_demo3.c
   main_demo4.c
   main_demo5.c
   main_demo6.c
   main_fbw.c
   main_fbw.h
   main_grz.c
   main_imu.c
   main_motor_bench.c
   modem.h
   nav.c
   nav.h
   nav_line.c
   nav_line.h
   nav_survey_rectangle.c
   nav_survey_rectangle.h
   paparazzi.h
   point.c
   point.h
   ppm.h
   pprz_transport.c
   pprz_transport.h
   print.h
   radio_control.c
   radio_control.h
   rc_settings.c
   rc_settings.h
   setup_actuators.c
   spi.c
   spi.h
   srf08.c
   srf08.h
   sys_time.c
   sys_time.h
   test_adcs.c
   traffic_info.c
   traffic_info.h
   uart.h
   usb_serial.h
   wavecard.c
   wavecard.h
   xbee.c
   xbee.h

/** \file dpicco.c
 *  \brief DigiPicco I2C sensor interface
 *
 *   This reads the values for humidity and temperature from the IST DigiPicco sensor through I2C.
 */


#include "dpicco.h"

#include "i2c.h"
#include "led.h"

#include <string.h>

uint8_t dpicco_status;

uint16_t dpicco_val[DPICCO_NB_SENSOR];

#define DPICCO_SLAVE_ADDR 0xF0


volatile bool_t dpicco_i2c_done;

void dpicco_init( void ) {
  uint8_t i;
  for (i=0; i< DPICCO_NB_SENSOR; i++) {
    dpicco_val[i] = 0;
  }
  dpicco_status = DPICCO_IDLE;
  dpicco_i2c_done = TRUE;
}

void dpicco_periodic( void ) {
  if (dpicco_i2c_done) {
    if (dpicco_status == DPICCO_IDLE) {
      /* init first read */
      dpicco_status = DPICCO_MEASURING_RD;
      dpicco_i2c_done = FALSE;
      i2c_receive(DPICCO_SLAVE_ADDR, 4, &dpicco_i2c_done);
      
      LED_ON(2);
    }
    else if (dpicco_status == DPICCO_MEASURING_RD) {
      /* get data */
      dpicco_val[0] = (i2c_buf[0]<<8) | i2c_buf[1];
      dpicco_val[1] = (i2c_buf[2]<<8) | i2c_buf[3];
      
      /* start next one right away */
      dpicco_i2c_done = FALSE;
      i2c_receive(DPICCO_SLAVE_ADDR, 4, &dpicco_i2c_done);
      
      LED_TOGGLE(2);
    }
  }
}

About Koders | Resources | Downloads | Support | Black Duck | Submit Project | Terms of Service | DMCA | Privacy Policy | Site Map| Contact Us