char bmp180_get_druck(bmp180_calc_t cal, long *druck, unsigned char oss, long *temperatur, int *temp, long *press)
{
char ret = 1;
long p;
int t;
long UT, X1, X2, X3, B3, B5, B6, T;
long AC1, AC2, AC3, AC4, AC5, AC6, MB, MC, MD, B1, B2;
unsigned long B4, B7, UP;
AC1 = cal.AC1;
AC2 = cal.AC2;
AC3 = cal.AC3;
AC4 = cal.AC4;
AC5 = cal.AC5;
AC6 = cal.AC6;
MB = cal.MB;
MC = cal.MC;
MD = cal.MD;
B1 = cal.B1;
B2 = cal.B2;
ret &= bmp180_start_temp(&t);
UT = (long)t;
*temp = t;
ret &= bmp180_start_druck(&p, oss);
UP = (long)p;
*press = p;
X1 = (((UT - AC6) * AC5)>>15);
X2 = (MC<<11) / (X1 + MD);
B5 = X1 + X2;
T = ((B5 + 8L)>>4);
*temperatur = T;
/* Musterwerte laut Datenblatt */
oss = 0;
AC1 = 408;
AC2 = -72;
AC3 = -14383;
AC4 = 32741;
AC5 = 32757;
AC6 = 23153;
B1 = 6190;
B2 = 4;
MB = -32768;
MC = -8711;
MD = 2868;
UP = 23843;
B5 = 2399;
#define SCROLL_CAL_VALUE 20
char Buffer[20];
// strcpy(Buffer, "AC1 : ");
// sprintf(Buffer+strlen(Buffer), "%i", AC1);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "AC2 : ");
// sprintf(Buffer+strlen(Buffer), "%i", AC2);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "AC3 : ");
// sprintf(Buffer+strlen(Buffer), "%i", AC3);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "AC4 : ");
// sprintf(Buffer+strlen(Buffer), "%i", AC4);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "AC5 : ");
// sprintf(Buffer+strlen(Buffer), "%i", AC5);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "AC6 : ");
// sprintf(Buffer+strlen(Buffer), "%i", AC6);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "MB : ");
// sprintf(Buffer+strlen(Buffer), "%i", MB);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "MC : ");
// sprintf(Buffer+strlen(Buffer), "%i", MC);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "MD : ");
// sprintf(Buffer+strlen(Buffer), "%i", MD);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "B1 : ");
// sprintf(Buffer+strlen(Buffer), "%i", B1);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
//
// strcpy(Buffer, "B2 : ");
// sprintf(Buffer+strlen(Buffer), "%i", B2);
// scroll_display(Buffer,SCROLL_CAL_VALUE);
B6 = B5 - 4000;
X1 = (B2 * (B6 * B6 >> 12)) >> 11;
X2 = AC2 * B6 >> 11;
X3 = X1 + X2;
B3 = (((AC1 * 4 + X3) << oss) + 2) >> 2;
X1 = AC3 * B6 / 8192;
X2 = (B1 * (B6 * B6 >> 12)) >> 16;
X3 = ((X1 + X2) + 2) >> 2;
B4 = AC4 * (unsigned long)(X3 + 3276
>> 15;
B7 = ((unsigned long)UP - B3) * (50000 >> oss);
if (B7 < 0x80000000)
p = (B7 * 2) / B4;
else
p = (B7 / B4) * 2;
X1 = (p >>
* (p >>
;
X1 = (X1 * 303
>> 16;
X2 = (-7357 * p) >> 16;
long temp_1;
temp_1 = p + ((X1 + X2 + 3791) >> 4);
strcpy(Buffer, "Druck : ");
sprintf(Buffer+strlen(Buffer), "%ld", temp_1);
scroll_display(Buffer,SCROLL_CAL_VALUE);
return ret;
}
Bekomme ich den Wert laut Musterrechnung (Datenblatt)
Lesezeichen