|
34 | 34 | #define POW2(x) (1 << x) |
35 | 35 |
|
36 | 36 | // Command addresses |
37 | | -#define MS56XX_RESET 0x1E |
38 | | -#define MS56XX_CALIB_ADDR 0xA2 /* First sample is factory stuff */ |
39 | | -#define MS56XX_CALIB_LEN 16 |
40 | | -#define MS56XX_ADC_READ 0x00 |
41 | | -#define MS56XX_PRES_ADDR 0x40 |
42 | | -#define MS56XX_TEMP_ADDR 0x50 |
| 37 | +#define MS56XX_RESET 0x1E |
| 38 | +#define MS56XX_CALIB_ADDR 0xA2 /* First sample is factory stuff */ |
| 39 | +#define MS56XX_CALIB_LEN 16 |
| 40 | +#define MS56XX_ADC_READ 0x00 |
| 41 | +#define MS56XX_PRES_ADDR 0x40 |
| 42 | +#define MS56XX_TEMP_ADDR 0x50 |
43 | 43 |
|
44 | 44 | // Option to change the interleave between Temp and Pressure conversions |
45 | 45 | // Undef for normal operation |
@@ -128,7 +128,7 @@ const PIOS_SENSORS_Driver PIOS_MS56xx_Driver = { |
128 | 128 | */ |
129 | 129 | void PIOS_MS56xx_Init(const struct pios_ms56xx_cfg *cfg, int32_t i2c_device) |
130 | 130 | { |
131 | | - i2c_id = i2c_device; |
| 131 | + i2c_id = i2c_device; |
132 | 132 |
|
133 | 133 | ms56xx_address = cfg->address; |
134 | 134 | version = cfg->version; |
@@ -262,14 +262,14 @@ int32_t PIOS_MS56xx_ReadADC(void) |
262 | 262 | // Offset and sensitivity at actual temperature |
263 | 263 | if (version == MS56XX_VERSION_5611) { |
264 | 264 | // OFF = OFFT1 + TCO * dT = C2 * 2^16 + (C4 * dT) / 2^7 |
265 | | - Offset = ((int64_t)CalibData.C[1]) * POW2(16) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(7) - Offset2; |
| 265 | + Offset = ((int64_t)CalibData.C[1]) * POW2(16) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(7) - Offset2; |
266 | 266 | // SENS = SENST1 + TCS * dT = C1 * 2^15 + (C3 * dT) / 2^8 |
267 | | - Sens = ((int64_t)CalibData.C[0]) * POW2(15) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(8) - Sens2; |
| 267 | + Sens = ((int64_t)CalibData.C[0]) * POW2(15) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(8) - Sens2; |
268 | 268 | } else { |
269 | 269 | // OFF = OFFT1 + TCO * dT = C2 * 2^17 + (C4 * dT) / 2^6 |
270 | | - Offset = ((int64_t)CalibData.C[1]) * POW2(17) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(6) - Offset2; |
| 270 | + Offset = ((int64_t)CalibData.C[1]) * POW2(17) + (((int64_t)CalibData.C[3]) * deltaTemp) / POW2(6) - Offset2; |
271 | 271 | // SENS = SENST1 + TCS * dT = C1 * 2^16 + (C3 * dT) / 2^7 |
272 | | - Sens = ((int64_t)CalibData.C[0]) * POW2(16) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(7) - Sens2; |
| 272 | + Sens = ((int64_t)CalibData.C[0]) * POW2(16) + (((int64_t)CalibData.C[2]) * deltaTemp) / POW2(7) - Sens2; |
273 | 273 | } |
274 | 274 |
|
275 | 275 | // Temperature compensated pressure (10…1200mbar with 0.01mbar resolution) |
@@ -516,10 +516,11 @@ bool PIOS_MS56xx_driver_poll(__attribute__((unused)) uintptr_t context) |
516 | 516 | } |
517 | 517 |
|
518 | 518 | /* Poll the pressure sensor and return the temperature and pressure. */ |
519 | | -bool PIOS_MS56xx_Read(float *temperature, float *pressure) { |
| 519 | +bool PIOS_MS56xx_Read(float *temperature, float *pressure) |
| 520 | +{ |
520 | 521 | if (PIOS_MS56xx_driver_poll(0)) { |
521 | 522 | *temperature = results.temperature; |
522 | | - *pressure = results.sample; |
| 523 | + *pressure = results.sample; |
523 | 524 | return true; |
524 | 525 | } |
525 | 526 | return false; |
|
0 commit comments