Commit Graph

58 Commits

Author SHA1 Message Date
Andrew Tridgell 81cd103073 AP_InertialSensor: probe for new v2 invensense IMUs
also suppress LSM9DS0 whoami warnings, as these will now be common
with new IMUs

and make 20602 show up as a new devtype so we can distinguish it
2019-03-11 12:40:21 +11:00
Andrew Tridgell dff3ea416c AP_InertialSensor: allow for LSM9DS0 to be used on I2C 2019-03-10 09:03:06 +11:00
Lucas De Marchi c4e8aeb105 AP_InertialSensor: remove linux-only include
We already include AP_HAL.h that includes the platform-agnostic gpio
header, which is all that this driver needs. This is an alternative
fix to #7794.
2018-03-09 11:12:31 -08:00
Lucas De Marchi caa4e3ee89 AP_InertialSensor: remove raspilot 2017-09-12 15:06:19 -07:00
Andrew Tridgell 49cc0965c0 AP_InertialSensor: separate handling of FIFO and non-FIFO sensors
FIFO sensors produce data at a well known rate, but samples come in
bunches, so we can't use the system clock to calculate deltaT.

non-FIFO sensors produce data when we sample them, but that rate is
less regular due to timing jitter.

For FIFO sensors this changes makes us use a learned sample rate,
which allows for different clock speeds on sensor and system board.

For non-FIFO sensors we use the system clock to measure deltaT

the overall effect is a fix for sensors that produce samples at other
than the claimed datasheet rate.
2017-05-01 15:06:46 +10:00
Andrew Tridgell 25cd16a275 AP_InertialSensor: fixed LSM303D registered sample rate
we are running the LSM303D at 1600Hz, and are sampling it at 1kHz. We
need to tell the AP_InertialSensor layer that samples will arrive at 1kHz
2017-05-01 15:06:46 +10:00
Andrew Tridgell 01da36295d AP_InertialSensor: support the L3GD20H gyro
this is used by the MRo Pixhawk1
2017-01-31 07:39:36 +11:00
murata 2643e7e906 AP_InertialSensor: Unify from print or println to printf. 2017-01-27 18:20:22 +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 27605b0258 AP_InertialSensor: run invensese reg checking at low speed
config register read/write should be at low bus speed.

also change to check every 20 calls to reduce checking cost
2016-11-25 20:31:40 +11:00
Andrew Tridgell f3f1f6b0b6 AP_InertialSensor: fixed gyro orientation on l3gd20H on pixhawk 2016-11-16 20:33:56 +11:00
Andrew Tridgell 49856c37f2 AP_InertialSensor: reduce checked register count
thanks to Francisco for spotting this
2016-11-11 08:08:56 +11:00
Andrew Tridgell 4be8f05ad4 AP_InertialSensor: added register checking for LSM9DS0 2016-11-11 08:08:56 +11:00
Andrew Tridgell fde80a9408 AP_InertialSensor: modify LSM303D settings to match PX4 driver
this allows existing accel calibration to be used
2016-11-09 17:08:12 +11:00
Andrew Tridgell bd84e592f8 AP_InertialSensor: check for NULL device pointer in probe()
handle missing devices
2016-11-09 17:08:10 +11:00
Andrew Tridgell aa4025bdf9 AP_InertialSensor: make INS sensor IDs match for PX4
in-tree driver IDs now match PX4Firmware driver IDs on Pixhawk2
2016-11-09 17:08:06 +11:00
Andrew Tridgell 9e7e1b2f01 AP_InertialSensor: fixed merge conflicts with patches from Lucas 2016-11-09 17:08:06 +11:00
Lucas De Marchi 469efb00f6 AP_InertialSensor: save id for gyro and accel instances
This allows each sensor to be uniquely identified in the system by using
either the index inside the backend or for those that use the Device
interface, to use the bus type, location, and device id.

We leave 16-bit for each sensor to be able to change its own
identification in future, which allows them to be changed in an
incompatible manner forcing a re-calibration.
2016-11-09 17:08:05 +11:00
Lucas De Marchi ace61087a1 AP_InertialSensor: remove product_id
We only leave the parameter there for backward-compatibility. However
product id on the inertial sensor is not much useful since it's only
kept for the first instance.

A better implementation per-gyro and per-accel is needed in order to
avoid problems with sensors taking the offsets configured for another
sensor.
2016-11-09 17:08:05 +11:00
Andrew Tridgell a5c5e033d2 AP_InertialSensor: fixed threading and locking in remaining backends
use a backend semaphore for shared data and use thread per bus where
available
2016-11-09 17:08:01 +11:00
Andrew Tridgell b92c48548a AP_InertialSensor: added per-instance rotation for LSM9DS0 2016-11-09 17:08:00 +11:00
Andrew Tridgell ac2572384d AP_InertialSensor: added start() method for LSM9DS0
needed to get sensor ordering right on multi-sensor boards
2016-11-09 17:08:00 +11:00
Andrew Tridgell 2b66df68a1 AP_InertialSensor: use thread-per-bus for lsm303d and mpu6000 2016-11-09 17:07:56 +11:00
raspilot 1d1d224c18 AP_InertialSensor: Enable dual IMU for raspilot 2016-03-18 21:51:37 -03:00
Lucas De Marchi f75c12f57c AP_InertialSensor: LSM9DS0: change mode of drdy pins to input 2016-03-18 21:51:37 -03:00
raspilot c83e4df002 AP_InertialSensor: LSM9DS0: Disable I2C at init to avoid SDA hanging by slave. 2016-03-18 21:51:37 -03:00
raspilot 557beb4bb1 AP_InertialSensor: LSM9DS0: Fixed wrong call to _register_read_xm() 2016-03-18 21:51:37 -03:00
Lucas De Marchi d2b267d026 AP_InertialSensor: LSM9DS0: use AP_HAL::SPIDevice abstraction 2016-02-16 19:49:09 -02:00
Lucas De Marchi c1d19fa4dc AP_InertialSensor: LSM9DS0: sanitize whitespaces 2016-02-01 14:18:51 -02:00
Caio Marcelo de Oliveira Filho d7601095fa AP_InertialSensor: use millis/micros/panic functions 2015-11-20 12:31:41 +09:00
Andrew Tridgell 75ea8f3dc0 AP_InertialSensor: removed "have sample" logic from drivers
the frontend has all the information it needs, so we can simplify the
drivers some more
2015-11-16 17:57:35 +11:00
Andrew Tridgell 0e4bab74ba AP_InertialSensor: simplify sensor backends
use common code for filtering and update, allowing each sensor driver
to be simpler and more consistent
2015-11-16 17:57:35 +11:00
Lucas De Marchi 20c6ffc5e3 Replace use of UARTDriver::printf_P() with UARTDriver::printf()
This also starts to show warnings on places that were already using
wrong printf format strings.
2015-10-30 14:35:25 +09:00
Lucas De Marchi 6f4904189b Replace use of println_P() with println() 2015-10-30 14:35:22 +09:00
Lucas De Marchi 2c38e31c93 Remove use of PSTR
The PSTR is already define as a NOP for all supported platforms. It's
only needed for AVR so here we remove all the uses throughout the
codebase.

This was automated with a simple python script so it also converts
places which spans to multiple lines, removing the matching parentheses.

AVR-specific places were not changed.
2015-10-30 14:35:04 +09:00
Gustavo Jose de Sousa dfd671c54e AP_InertialSensor: Backend: add hook for new gyro sample arrival
That hook will do common tasks for when new gyro raw sample is available.
2015-10-22 16:53:10 +11:00
Gustavo Jose de Sousa e06627dfcb AP_InertialSensor: Backend: add hook for new raw accel samples
That hook will eventually do necessary things when a new accelerometer raw
sample arrives (like calculating vibration levels).
2015-09-07 11:14:42 +10:00
Gustavo Jose de Sousa ac3a677626 AP_InertialSensor: remove param rotate_and_correct from publish functions
Once that parameter is always false.
2015-09-07 11:14:42 +10:00
Gustavo Jose de Sousa f946f48dce AP_InertialSensor: LSM9DS0: apply correction on each new sample
These changes are for enabling unified accelerometer vibration and clipping
calculation. For that, we need the values "rotated and corrected" before they
are filtered and the calculation must be called as soon as a new sample arrives
as it takes the sample rate into account.

Thus, move code that applies "corrections" to be executed as soon as accel data
arrive and call _publish_accel() passing rotate_and_correct parameter as false.
Also, do the same for gyro so we can keep it consistent.
2015-09-07 11:14:41 +10:00
Lucas De Marchi 2c44f3e313 AP_HAL_InertialSensor: standardize inclusion of libaries headers
Do the missing header changes due to changing the code before the pr
getting accepted.
2015-08-18 17:12:52 +10:00
Gustavo Jose de Sousa 7789aec85b AP_InertialSensor: 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:43 +10:00
Andrew Tridgell ac3200fd32 AP_InertialSensor: make max_abs_offsets a single float, not a vector 2015-06-30 10:51:43 +10:00
Gustavo Jose de Sousa c168e19e73 AP_InertialSensor: fix coding style with uncrustify on LSM9DS0
This commit makes backend source code for LSM9DS0 comply with the configuration
files "uncrustify_cpp.cfg" and "uncrustify_headers.cfg".
2015-06-30 10:28:02 +10:00
Gustavo Jose de Sousa 2f2a627002 AP_InertialSensor: use runtime GPIO drdy pins numbers instead C constant macros
As we intend to eventually get board related parameters from a configuration
file, this commit makes the GPIO numbers for data-ready pins be instance
variables instead of from C constant macros.

Another advantage of using instance variables in this context is the
possibility of using more than one LSM9DS0.
2015-06-30 10:27:59 +10:00
Gustavo Jose de Sousa 0ef914adac AP_InertialSensor: don't take SPI semaphore if not necessary on LSM9DS0
If the data-ready polling is done entirely on GPIO pins, it isn't necessary to
hold the semaphore before we now we have data to consume. In that case, only
take the SPI semaphore if there's new data available.

On the other hand, if at least one SPI transaction is done in order to check
for new data, then it makes sense to take the semaphore beforehand.
2015-06-30 10:27:57 +10:00
Gustavo Jose de Sousa a82ab25ed3 AP_InertialSensor: use bitfield macros instead of literal values on LSM9DS0
This commit makes accel and gyro initialization routines use bitfield macros
instead of hardcoding the literal value when wrinting on registers. That is
less prone to typos and a lot of times self-explanatory. Also, due to the
latter, the long comments explaining each register field were removed (any
detail can be checked on the datasheet).
2015-06-30 10:27:54 +10:00
Gustavo Jose de Sousa 1572324315 AP_InertialSensor: add macros for LSM9DS0 registers' bitfields 2015-06-30 10:27:51 +10:00
Gustavo Jose de Sousa 033409c629 AP_InertialSensor: set max abs calibration offset for LSM9DS0 2015-06-30 10:27:48 +10:00
Gustavo Jose de Sousa 42eb73a1d1 AP_InertialSensor: add LSM9DS0 backend
This adds the backend driver for LSM9DS0. This implementation is based on the
legacy driver coded by Víctor Mayoral Vilches (under folder LSM9DS0) and makes
some necessary adaptations and fixes in order to work properly. The legacy
driver folder was removed.
2015-06-30 10:27:46 +10:00
Víctor Mayoral Vilches bfacf08c30 HAL_Linux: LSM9DS0 legacy driver moved to AP_InertialSensor/LSM9DS0/
The new LSM9DS0 driver will consist of the AP_InertialSensor_L3GD20 and
the AP_InertialSensor_LSM303D. For that reason the old LSM9DS0
(consisting of gyro and accel+mag implemented on a single class) has
been moved to a folder.

Legacy LSM9DS0 didn't probe to receive "correct" data.
2014-08-19 10:08:15 +10:00