Пример #1
0
Файл: pu-test.c Проект: gke/UAVP
void BaroTest(void)
{
	uint8 r;

	TxString("\r\nBarometer test\r\n");
	if ( !_UseBaro ) goto BAerror;

	if ( BaroType == BARO_ID_BMP085 )
		TxString("Type:\tBMP085\r\n");
	else
		TxString("Type:\tSMD500\r\n");
	
	if( !StartBaroADC(BARO_PRESS) ) goto BAerror;
	Delay1mS(BARO_PRESS_TIME);
	r = ReadValueFromBaro();
	TxString("Press: \t");	
	TxVal32((int32)BaroVal, 0, 0);
		
	if( !StartBaroADC(BaroTemp) ) goto BAerror;
	Delay1mS(BARO_TEMP_TIME);
	r = ReadValueFromBaro();
	TxString("\tTemp: ");
	TxVal32((int32)BaroVal, 0, 0);	
	TxNextLine();

	TxNextLine();

	return;
BAerror:
	I2CStop();
	TxString("FAIL\r\n");
} // BaroTest
Пример #2
0
// initialize compass sensor
void InitAltimeter(void)
{
#ifdef NOT_PORTED_FOR18F  // use gregs code when ready
// read temperature once to get base value
// set SMD500 device to start temperature conversion
	if( !StartBaroADC(0xee) ) goto BAerror;
// wait 40ms
	for( Vtmp=40; Vtmp!=0; Vtmp--)
	{
		T0IF=0;
		while(T0IF == 0);
	}
	ReadValueFromBaro();

	BaseTemp = niltemp;	// save start value

// read pressure once to get base value
// set SMD500 device to start pressure conversion
	if( !StartBaroADC(0xf4) ) goto BAerror;

// wait 40ms
	for( Vtmp=40; Vtmp!=0; Vtmp--)
	{
		T0IF=0;
		while(T0IF == 0);
	}
	ReadValueFromBaro();
 	
	BasePressure = niltemp;

	_UseBaro = 1;
// prepare for next run
//	if( !StartBaroADC(0xf4) ) goto BAerror;

	return;
BAerror:
	I2CStop();
#endif
	_UseBaro = 0;

}