Exemplo n.º 1
0
/**
 * @ Opis  				Wykonuje pomiar cisnienia i odczytuje wynik.
 * @ Parametry  		Brak.
 * @ Zwracana wartosc 	Cisnienie w Pa.
 */
int32_t getPressure() {
	int32_t pressure;
	BMP180_StartTemperature();
	_delay_ms(30);
	BMP180_GetTemperature();
	_delay_ms(10);
	BMP180_StartPressure();
	_delay_ms(30);
	pressure = BMP180_GetPressure();

	return pressure;
}
Exemplo n.º 2
0
void sensor_timerfunc(void *arg)
{
    int32_t temperature;
    int32_t pressure;
	char buff[20];
    ets_uart_printf("Get temperature and pressure...\r\n");
    temperature = BMP180_GetTemperature();
    pressure = BMP180_GetPressure(OSS_0);
    console_printf("Temperature: %s *C\r\n", BMP180_Int2String(buff, temperature));
    console_printf("Temperature: %d.%d *F\r\n", (int)(9 * temperature / 50 + 32), (int)(9 * temperature / 5 % 10));
    console_printf("Pressure: %d mm rt.st.\r\n", (int)(pressure/133.322368));
    console_printf("Pressure: %d m water.st.\r\n", (int)(pressure/9806.65));
    console_printf("Pressure: %d.%d mbar\r\n", (int)(pressure), (int)(pressure%100));
    console_printf("Pressure: %d.%d mmHg\r\n", (int)(pressure * 75 / 10000), (int)((pressure * 75 % 10000) / 1000));
    console_printf("Altitude: %d\r\n", BMP180_CalcAltitude(pressure));
}
Exemplo n.º 3
0
int main () {

	CHIP_Init();				//Initialize Chip

	initMCU();
	initGPIO();				//Initialize GPIO
	sdi2c_Init();				//Initialize I2C
	initTimer();		//initialize timer for timer interuprt

	/* Setup SysTick Timer for 10 msec interrupts  */
	if (SysTick_Config(CMU_ClockFreqGet(cmuClock_CORE) / 1000)) {
	while (1) ;
	}

	/*Enable all sensors and GPS */
	GPIO_PinOutSet(GPS_PORT, ENABLE);			//Enable GPS Sensor board
	BMP180_GetCalData();		//Enable and get calibration data from BMP180
	initLSM303_LowPower();		//Enable Accel in low power mode
	initL3GD20H_Normal();			//Enable Gyro in normal mode
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/* Acceleromter Data */
	Delay(10);
	LSM303_GetAccelData();
	LSM303_PowerOff();
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/*Gyroscope Data */
	Delay(10);
	L3GD20H_GetGyroData();
	L3GD20H_PowerOff();
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/*Temperature/Barometric Pressure */
	Delay(10);
	BMP180_GetTemp();
	BMP180_GetPressure();
	BMP180_CalcRealTemperature();
	BMP180_CalcRealPressure();
	GPIO_PinOutToggle(EXT_LED, YEL_LED);

	/*Power Sensor*/
	INA219_GetVoltage();
	GPIO_PinOutClear(EXT_LED, YEL_LED);

	GPIO_PinOutToggle(EXT_LED, GRE_LED);
	Delay(100);
	GPIO_PinOutToggle(EXT_LED, GRE_LED);


	/* GPS Information */
	timeout = 0;		//reset timeout
	initGPS();		//Initialize GPS UART
	coldrestart();		//Send cold restart command
	while(fullread == 0) {		//while not a full read, do the following
		if(satfix == 1) {			//if there is a satellite fix, then...
			GPIO_PinOutSet(EXT_LED, YEL_LED);		//toggle LED for debug
			readdata();		//readdata
			timeout = 0;
		}
		if(timeout > 20) {
			GPIO_PinOutClear(EXT_LED, YEL_LED);
			GPStimeout();
			break;
		}
	}

	GPIO_PinOutSet(EXT_LED, GRE_LED);
	Delay(500);

	printGPS(0);		//Print GPS to screen for debug

	concact();


	/* Infinite loop */
	while(1) {
	  if(GPIO_PinInGet(BUT_PORT, RIGHT_BUT) == 0) {
		  r = r + 1;
		  if(r > 2) {		//wrap around to beginning
			  r = 0;
		  }
		  printGPS(r);
	  }
	  if(GPIO_PinInGet(BUT_PORT, LEFT_BUT) == 0) {
			  r = r - 1;
			  if(r < 0) {		//wrap around to beginning
				  r = 2;
			  }
			  printSENSORS();
		  }
//	  if(GPIO_PinInGet(GPS_PORT, FIX) == 1) {
//		  GPIO_PinOutToggle(EXT_LED, RED_LED);
//	  }
	}
}