Commit Graph

53 Commits

Author SHA1 Message Date
Peter Barker ee07789383 AP_Baro: add override keyword 2018-11-08 11:30:12 +11:00
Randy Mackay 758331612f AP_Baro: probe for MS5611 on I2C addr 0x76 2018-09-07 08:36:02 +10:00
Andrew Tridgell 1439b1a730 AP_Baro: added option to probe any i2c baro using GND_PROBE_EXT
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
2018-08-23 13:29:59 +10:00
Peter Barker c56486a39e AP_Baro: remove pointless destructor overrides 2018-02-08 17:36:33 +11:00
Jacob Walser 613bc46592 AP_Baro: Add support for water pressure and Sub 2017-02-21 11:26:14 +11:00
Lucas De Marchi 5472bc4de1 Global: change Device::PeriodicCb signature
Remove bool return as it's never being used and not supported on PX4.
2017-01-14 10:03:54 +11:00
Andrew Tridgell f2246326bb AP_Baro: added MS5611 probing, and support 3 baros on Pixhawk2
this adds sensor probing for barometers, simplifies the MS5611 driver,
and adds support for the I2C external barometers on Pixhawk2
2016-11-25 21:40:11 +11:00
Andrew Tridgell b16226dddf AP_Baro: fixed a bug with corrupted conversions in MS5611 driver
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
2016-11-13 17:08:06 +11:00
Andrew Tridgell 4df9b093c3 AP_Baro: fixed missed samples in ms5611 driver 2016-11-09 17:08:03 +11:00
Andrew Tridgell bedee31f61 AP_Baro: fixed semaphore and thread usage in baro drivers 2016-11-09 17:08:02 +11:00
Mathieu OTHACEHE 152edf7189 Global: remove mode line from headers
Using a global .dir-locals.el file is a better alternative than
reincluding the same emacs header in every file of the project.
2016-10-24 09:42:01 -02:00
Lucas De Marchi e217faacab AP_Baro: MS56XX: cosmetic changes to members
- reorder and document members.
    - remove tentative of vertical alignement
    - like was done for accumulated values, move the calibration
      values to a struct
2016-07-30 00:55:28 -03:00
Lucas De Marchi f7b453359d AP_Baro: MS56XX: convert to threaded bus
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.
2016-07-30 00:55:28 -03:00
Lucas De Marchi 929348ff75 AP_Baro: MS5611: always use timer thread
Remove support to run MS5611 on main thread since we shouldn't be doing
I2C transactions there and we are moving to "thread per bus"
nonetheless.
2016-07-30 00:55:28 -03:00
Lucas De Marchi f1ade970a3 AP_Baro: MS5611: Use AP_HAL::Device abstraction
This allows to share almost all the I2C/SPI code and remove the
AP_Serial abstraction since that is now handled by AP_HAL itself.
2016-02-16 19:49:09 -02:00
Lucas De Marchi 56e4de0bdd AP_Baro: MS56XX: remove initialization to 0 from constructor 2016-02-01 14:18:50 -02:00
Lucas De Marchi 9d5fb97819 Global: rename enum SPIDevice to SPIDeviceType
Free the SPIDevice name so to have a consistent name for I2C/SPI device
classes.
2016-02-01 14:18:50 -02:00
Julien BERAUD d15097f3fc AP_Baro_MS5611: Support for timesliced timers
fallback if current scheduler doesn't support it
2016-01-18 16:57:48 -02:00
Andrew Tridgell ef83f39029 AP_Baro: renamed _C* vars to avoid conflict with qurt 2015-12-20 17:55:39 +11:00
Lucas De Marchi 81a298c9c8 AP_Baro: reduce header scope
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
2015-12-02 10:40:50 +11:00
Lucas De Marchi 30f631de8f AP_Baro: MS5637: fix CRC check
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.
2015-12-02 10:38:09 +11:00
José Roberto de Souza 7457588d7c AP_Baro: Move initialisation code from MS56XX constructor to init()
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.
2015-12-02 10:38:09 +11:00
José Roberto de Souza d9931b5f34 AP_Baro: Add support to MS5637
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.
2015-10-16 10:05:03 +11:00
Gustavo Jose de Sousa 1f29e18375 AP_Baro: make AP_SerialBus::write() return success or failure for MS56XX 2015-09-01 20:26:05 +10:00
Gustavo Jose de Sousa f18802bc46 AP_Baro: standardize inclusion of libaries headers
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.
2015-08-11 16:28:42 +10:00
Julien BERAUD d407737434 AP_Baro: added MS5607 support 2015-07-10 16:46:29 +10:00
Tom Pittenger 4191c44bbd Baro: fix compile warning re member init order 2015-04-24 14:15:11 +09:00
Andrew Tridgell 8359c082ca AP_Baro: fixed baro on NavIO
don't use the 1kHz timer as it conflicts with other I2C devices
2015-01-09 11:51:51 +11:00
Andrew Tridgell 5bb57a31f7 AP_Baro: split into frontend/backend
this allows for support of multiple sensors on a board
2015-01-09 11:50:54 +11:00
Andrew Tridgell 8b794602d1 AP_Baro: make get_temperature() a const function 2014-11-12 13:36:01 +11:00
Andrew Tridgell 6ebff35fe2 AP_Baro: don't include I2C MS5611 on APM1 either 2014-08-03 17:17:20 +10:00
Andrew Tridgell f73ec95c39 AP_Baro_MS5611: added PROM CRC checking
disabled on APM2 to save flash space
2014-07-14 09:44:35 +10:00
Andrew Tridgell e118984c26 AP_Baro: save some flash and memory on APM2
we don't need the I2C MS5611 driver
2014-07-08 14:21:42 +10:00
Andrew Tridgell 6964529124 AP_Baro: _calculate can be private 2014-02-15 05:48:24 +11:00
Andrew Tridgell 20b1131059 AP_Baro: use new scheduler API 2013-09-28 21:24:03 +10:00
Andrew Tridgell fc119d9b80 AP_Baro: cleaned up temperature and pressure units
thanks to Mike McCauley for pointing this out
2013-09-21 21:30:41 +10:00
James Bielman eca1417858 AP_HAL: Add semaphores to I2C driver.
- Guard I2C transactions with this semaphore in the MS5611 and
  HMC5843 drivers.
2013-01-04 15:43:43 -08:00
Pat Hickey 5d91f342bb AP_Baro_MS5611: uses new semaphore lib 2013-01-03 13:48:07 -08:00
James Bielman 5753ae5692 AP_Baro: Add I2C support to MS5611 driver. 2013-01-03 13:48:06 -08:00
Pat Hickey c1114168e4 AP_Baro tests rebase fixups 2012-12-20 14:51:29 +11:00
Pat Hickey 5d40074e4e AP_Baro: port to AP_HAL 2012-12-20 14:51:26 +11:00
uncrustify 1196285266 uncrustify libraries/AP_Baro/AP_Baro_MS5611.h 2012-08-21 19:00:50 -07:00
Andrew Tridgell f501503eb0 AP_Baro: improved barometer averaging
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.
2012-07-06 15:11:30 +10:00
Andrew Tridgell 057eb5e6f6 Baro: average over all pressure/temperature samples on MS5611
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
2012-07-02 13:44:53 +10:00
Andrew Tridgell c387edd74c Baro: added get_altitude() and get_climb_rate() interfaces
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
2012-06-27 16:01:50 +10:00
Andrew Tridgell 804332c340 AP_Baro: fixed some signed/unsigned warnings
and a potential bug on timer wrap
2012-02-13 21:39:18 +11:00
Andrew Tridgell 7ba744a11a I2C: convert barometer library to new I2C library
this also adds a healthy attribute and error checking
2011-12-28 20:41:53 +11:00
Andrew Tridgell e7720254dd AP_Baro: update MS5611 driver for new ap_proceduce prototype
this saves calling millis() quite so often
2011-12-21 23:31:38 +11:00
Pat Hickey f4aaa56b16 AP_Baro_MS5611: Asynchronous operation, plus c++ style changes.
Yeah, I know this was a big change to make all at once.
2011-12-11 15:21:10 -08:00
Pat Hickey a41b6da263 AP_Baro_MS5611: conform to AP_Baro interface 2011-12-11 15:21:09 -08:00