Exemplo n.º 1
0
void mwii_read_sensors(struct fc_data *data){
	data->flags = 0xffff; // all
	mpu6050_readRawAcc(&_brd.mpu, 
		&data->raw_acc.x, 
		&data->raw_acc.y, 
		&data->raw_acc.z); 
	mpu6050_convertAcc(&_brd.mpu, 
		data->raw_acc.x, 
		data->raw_acc.y, 
		data->raw_acc.z, 
		&data->acc_g.x, 
		&data->acc_g.y, 
		&data->acc_g.z
	); 
	mpu6050_readRawGyr(&_brd.mpu, 
		&data->raw_gyr.x, 
		&data->raw_gyr.y, 
		&data->raw_gyr.z
	); 
	mpu6050_convertGyr(&_brd.mpu, 
		data->raw_gyr.x, 
		data->raw_gyr.y, 
		data->raw_gyr.z, 
		&data->gyr_deg.x,
		&data->gyr_deg.y,
		&data->gyr_deg.z
	); 
	/*
	hmc5883l_readRawMag(&_brd.hmc, 
		&data->raw_mag.x, 
		&data->raw_mag.y, 
		&data->raw_mag.z
	); 
	hmc5883l_convertMag(&_brd.hmc, 
		data->raw_mag.x, 
		data->raw_mag.y, 
		data->raw_mag.z, 
		&data->mag.x, 
		&data->mag.y, 
		&data->mag.z
	); 
	*/
	int16_t sonar = hcsr04_read_distance_in_cm(&brd->hcsr); 
	data->atmospheric_altitude = bmp085_read_altitude(&brd->bmp); 
	data->sonar_altitude = (sonar > 0)?((float)sonar / 100.0):-1; 
	data->temperature = bmp085_read_temperature(&brd->bmp); 
	data->pressure = bmp085_read_pressure(&brd->bmp); 
	
	//data->vbat = (adc0_read_cached(2) / 65535.0);
}
Exemplo n.º 2
0
/// reads temperature in degrees C
float mwii_read_temperature_c(void){
	return bmp085_read_temperature(&brd->bmp); 
}
Exemplo n.º 3
0
PROCESS_THREAD(default_app_process, ev, data)
{
  PROCESS_BEGIN();
  printf("Hello, world\n");

  _delay_ms(100);

#if DEBUG
  printf("Begin initialization:\n");

  if (microSD_init() == 0) {
    printf(":microSD   OK\n");
    microSD_switchoff();
  } else {
    printf(":microSD   FAILURE\n");
  }
  if (adxl345_init() == 0) {
    printf(":ADXL345   OK\n");
  } else {
    printf(":ADXL345   FAILURE\n");
  }
  if (at45db_init() == 0) {
    printf(":AT45DBxx  OK\n");
  } else {
    printf(":AT45DBxx  FAILURE\n");
  }
//  if (bmp085_init() == 0) {
//    printf(":BMP085    OK\n");
//  } else {
//    printf(":BMP085    FAILURE\n");
//  }
//  if (l3g4200d_init() == 0) {
//    printf(":L3G4200D  OK\n");
//  } else {
//    printf(":L3G4200D  FAILURE\n");
//  }
#else
  adxl345_init();
  microSD_switchoff();
  at45db_init();
  microSD_init();
  bmp085_init();
  l3g4200d_init();
#endif

  adc_init(ADC_SINGLE_CONVERSION, ADC_REF_2560MV_INT);
  etimer_set(&timer, CLOCK_SECOND * 0.05);

  while (1) {

    PROCESS_YIELD();
    etimer_set(&timer, CLOCK_SECOND);
    int16_t tmp;
    /*############################################################*/
    //ADXL345 serial Test
    printf("X:%+6d | Y:%+6d | Z:%+6d\n",
            adxl345_get_x_acceleration(),
            adxl345_get_y_acceleration(),
            adxl345_get_z_acceleration());

    /*############################################################*/
    //L3G4200d serial Test
    printf("X:%+6d | Y:%+6d | Z:%+6d\n",
            l3g4200d_get_x_angle(),
            l3g4200d_get_y_angle(),
            l3g4200d_get_z_angle());
    printf("T1:%+3d\n", l3g4200d_get_temp());

    /*############################################################*/
    //BMP085 serial Test
    printf("P:%+6ld\n", (uint32_t) bmp085_read_pressure(BMP085_HIGH_RESOLUTION));
    printf("T2:%+3d\n", bmp085_read_temperature());

    /*############################################################*/
    //Power Monitoring
    printf("V:%d\n", adc_get_value_from(PWR_MONITOR_ICC_ADC));
    //              tmp = adc_get_value_from(PWR_MONITOR_ICC_ADC);
    //             
    //              tmp = adc_get_value_from(PWR_MONITOR_VCC_ADC);
    //             
    /*############################################################*/
    //microSD Test
    //              uint8_t buffer[512];
    //              uint16_t j;
    //              microSD_init();
    //              for (j = 0; j < 512; j++) {
    //                      buffer[j] = 'u';
    //                      buffer[j + 1] = 'e';
    //                      buffer[j + 2] = 'r';
    //                      buffer[j + 3] = '\n';
    //
    //                      j = j + 3;
    //              }
    //
    //              microSD_write_block(2, buffer);
    //
    //              microSD_read_block(2, buffer);
    //
    //              for (j = 0; j < 512; j++) {
    //                      printf(buffer[j]);
    //              }
    //              microSD_deinit();
    //
    /*############################################################*/
    //Flash Test
    //    uint8_t buffer[512];
    //    uint16_t j, i;
    //
    //    for (i = 0; i < 10; i++) {
    //      //at45db_erase_page(i);
    //      for (j = 0; j < 512; j++) {
    //        buffer[j] = i;
    //      }
    //      at45db_write_buffer(0, buffer, 512);
    //
    //      at45db_buffer_to_page(i);
    //
    //      at45db_read_page_bypassed(i, 0, buffer, 512);
    //
    //      for (j = 0; j < 512; j++) {
    //        printf("%02x", buffer[j]);
    //        if (((j + 1) % 2) == 0)
    //          printf(" ");
    //        if (((j + 1) % 32) == 0)
    //          printf("\n");
    //      }
    //    }

  }


  PROCESS_END();
}