This adds a hwdef.dat define HAL_PROBE_EXTERNAL_I2C_BAROS. When set,
we get a new parameter GND_PROBE_EXT that is a bitmask of i2c
barometers to look for.
This allows boards that have no builtin baro to work without
rebuilding
the datasheet says that if you get back zero in an ADC read that the
next value can be corrupt. I have seen this happen on the FMUv1,
leading to bad altitude readings
- reorder and document members.
- remove tentative of vertical alignement
- like was done for accumulated values, move the calibration
values to a struct
This converts MS56XX to use the thread started by SPI/I2C instead of
using the timer thread. This also fixes a possible starvation of the
main thread:
1) INS driver registers itself to be sampled on timer thread
2) MS56XX registers itself to be sampled on timer thread
3) Main thread waits for a sample from INS with
ins.wait_for_sample()
4) timer thread is waiting on update from MS56XX and consequently
the main thread is waiting on an I2C/SPI transfer
Besides this starvation there's another one due to reuse of the timer
lock in order to pump values from the timer thread to the main thread. A
call to the update() method when we have a sample available would need
to wait on any other driver holding the timer lock.
Now there's a lock just to pass the new values from the bus thread to
the main thread with a very tiny critical region, not waiting on any
bus transfers and/or syscalls.
We don't need to expose to other libraries how each backend is
implemented. AP_Baro.h is the main header, included by other libraries.
Instead of including each backend in the main header, move them to where
they are needed. Additionally standardize the order and how we include
the headers.
The advantages are:
- Internals of each backend is not exposed outside of the
library
- Faster incremental builds since we don't need to recompile
whoever includes AP_Baro.h because a backend changed
The configuration of MS5637 is different from MS5611 in 2 ways:
- The PROM is of 112 bytes rather than 128
- The CRC is located in the first MSB of the first word, not the
last one
For CRC calculation we also need to zero out the last (missing) word.
This renames _check_crc() to _read_prom(), which returns false when the
PROM doesn't contain valid data. It also makes it virtual so MS5637 can
override it. This also moves the PROM read to be all in the same place
rather than split between the CRC field and coefficient fields. Finally
calculate_crc() is renamed to crc4() to be shorter and add info on what
it does.
On MS5637 we will need to override the method to read and calculate the
PROM's crc. Thus we need a 2-phase init.
It also makes the constructor of AP_Baro_MS56XX protected since only the
derived classes should instantiate the base one.
As AVR2560 is not supported anymore and do integer operations is
usually faster than float-point the _calculate() implementation was
done using only integer operations and as more close to what
datasheet says.
This commit changes the way libraries headers are included in source files:
- If the header is in the same directory the source belongs to, so the
notation '#include ""' is used with the path relative to the directory
containing the source.
- If the header is outside the directory containing the source, then we use
the notation '#include <>' with the path relative to libraries folder.
Some of the advantages of such approach:
- Only one search path for libraries headers.
- OSs like Windows may have a better lookup time.
this changes the barometer calculations to floating point. On a MS5611
this is actually about twice as fast as the previous 64 bit
calculations, but gains us more accuracy as we are able to take
advantage of sub-bit precision when we average over 8 samples.
this allows us to use the MS5611 barometer at its full 100Hz sample
rate (80Hz for pressure, 20Hz for temperature). The pressure and
temperature values are averaged between reads without adding any
latency. Previously the driver would throw away values between
readings
This also fixes a race condition in reading from the SPI bus that
could lead to bad values from the barometer
this allows the barometer driver to calibrate and return altitude and
climb rate values. This will be used by the AHRS drift correction code
for vertical velocity
The climb rate uses a 5 point average filter