Commit Graph

289 Commits

Author SHA1 Message Date
Lucas De Marchi 8240e5ae65 AP_Compass: AK8963: reduce bytes read
We are not using INFO and ST1 registers, so there's no need to read
extra 2 bytes for each transaction.
2015-07-23 17:44:36 +10:00
Lucas De Marchi 2b9c46e1ff AP_Compass: AK8963: don't oversample AK8963
Reduce the frequency with which MPU9250 reads AK8963 to reduce the
chance of errors.
2015-07-23 17:44:36 +10:00
Lucas De Marchi 6c2ceea165 AP_Compass: AK8963: remove author and connection comment
Authorship and how sensor is connected get outdated (as it already is).
Our code is on git so let it track who wrote each line.
2015-07-23 17:44:36 +10:00
Staroselskii Georgii 8ab33c46ce AP_Compass: revisited AK8963 code
Reduced duplication a bit and revisited the update method which is now
split into several logical hunks.
2015-07-23 17:44:36 +10:00
Lucas De Marchi fffedae3e0 AP_Compass: AK8963: reduce stack usage and zero out buffers
Since we are not using MPU9250's fifo to get samples from AK8963 we will
always read only 1 sample (+ control registers).
2015-07-23 17:44:35 +10:00
Lucas De Marchi 37734886a5 AP_Compass: AK8963: remove repeated comments
No need to repeat the same comments on 3 different places. Instead add a
single comment to explain how start_measurements() and read_raw() are
related.
2015-07-23 17:44:35 +10:00
Lucas De Marchi 27d95b67a8 AP_Compass: AK8963: remove state machine
Don't use a state machine in AK8963: the start_measurements() method
should be called only once.  Even if there's a magnetic sensor overflow
the only thing we should do is to discard the new data.

This also moves the _collect_samples() method to be inside _update()
since it's the only place it should be called from, the one running on
the timer thread.
2015-07-23 17:44:35 +10:00
Lucas De Marchi e232543fca AP_Compass: AK8963: change initialization and rename methods
We need to check the AK8963's id before anything else Here we are
reordering the calls to _calibrate() and _check_id(). After that we
don't need to read and write again the AK8963_CNTL1 register.

While at it do some renames as well:
	- _configure() -> _setup_mode(): since now there's a
 	  _bus->configure() it became confusing what actually it's
	  doing.
	- make error messages say what we were actually trying to do but
	  couldn't. Also remove PSTR since this is linux-only.
	- start_conversion() -> start_measurements():  We are instructing the
          bus to start to get the samples, not to tell the chip to start an
          analog->digital conversion like in other sensors.
2015-07-23 17:44:35 +10:00
Lucas De Marchi ae5d9baddb AP_Compass: AK8963: remove defines not used anymore
The MPUREG_PWR_MGMT_1 defines were used when we cared about the MPU9250
initialization code. Now all initialization is done by the MPU9250 class
itself, so remove these defines.

Also remove AK8983_SELFTEST_MAGNETIC_FIELD_ON that is never used and let
the defines always with 2 bytes to improve readability.
2015-07-23 17:44:34 +10:00
Lucas De Marchi cae895bfdf AP_Compass: AK8963: group members together
Besides being semantically related, this removes the hole due to
alignment. The size is the same since the hole is actually turned into
padding.
2015-07-23 17:44:34 +10:00
Lucas De Marchi 28d3d775a4 AP_Compass: AK8963: remove resolution member
We only use the highest one and there's no intention to support the
14bits one. Just use the define rather than saving it as a member.
2015-07-23 17:44:34 +10:00
Lucas De Marchi 86b3312112 AP_Compass: AK8963: factor out common code of read_raw()
Similar code was added in the read_raw() implementation for each bus.
Add a new POD struct read_raw to contain the registers from the AK8963
and use it instead as argument.
2015-07-23 17:44:33 +10:00
dgrat d941174978 AP_Compass: AK8963: enhance the readability
Reduce the deepness of indentation and fix coding style.
2015-07-23 17:44:33 +10:00
Lucas De Marchi fd5d25b1d5 AP_Compass: use ARRAY_SIZE macro 2015-07-21 14:25:17 +09:00
Randy Mackay cedc9a8670 Compass: add last_update_usec per instance 2015-07-17 10:02:41 +09:00
Julien BERAUD 51c3c499e2 AP_Compass: support AK8963 on I2C 2015-07-10 16:46:30 +10:00
Julien BERAUD 0b41da0dea AP_Compass: rework to make the bus generic for AK8963
Supporting only MPU9250, prepare to implement another bus, i.e i2c on the
bebop
2015-07-10 16:46:29 +10:00
Julien BERAUD 0cd584c293 AP_Compass: fix rotation for bebop AK8963
Set the correct rotation for bebop
2015-07-10 16:46:29 +10:00
Julien BERAUD 7dd0b5fae6 AP_Compass: removed _spi_sem and _spi 2015-07-10 16:46:29 +10:00
Andrew Tridgell c83d5b1f08 AP_Compass: only build AK8963 driver on Linux
must match MPU9250 build
2015-07-09 11:57:27 +10:00
Randy Mackay d192b3ccea Compass: set device id for ak8963 and hmc5843 2015-07-06 21:04:46 +09:00
dgrat f56f584233 Compass: Improved field rounding in learning
Signed-off-by: Daniel Frenzel <dgdanielf@gmail.com>
2015-07-06 11:31:58 +10:00
Lucas De Marchi 1deb837e70 AP_Compass: Use common function in MPU9250 for initialization 2015-07-06 10:48:07 +10:00
Staroselskii Georgii 26c8007c96 AP_Compass: updated backend detect method
Uses reimplemented AK8963 driver. There's also no need trying to detect this
compass twice. Actually, it might even be bad, because the current code can
allocate an AK8963 object twice.
2015-07-06 10:48:06 +10:00
Staroselskii Georgii 7a417d1151 AP_Compass: AK8963 rework
Got rid of extra abstraction layer. There is no need for that now.
2015-07-06 10:48:06 +10:00
Randy Mackay 43b1694c76 Compass: add third compass to PRIMARY param description 2015-07-02 14:19:30 +09:00
Andrew Tridgell 5b0394eb05 AP_Compass: start MPU9250 driver at low speed
this raises the chances of successful init of the MPU9250
2015-07-02 08:48:06 +10:00
Andrew Tridgell d6a1bd98e6 AP_Compass: convert example from .pde to .cpp 2015-06-01 16:58:11 +10:00
Andrew Tridgell edc21cfa38 AP_Compass: make having no compass backends non-fatal
thanks to Daniel for spotting this
2015-05-26 14:23:40 +10:00
Lucas De Marchi 95627cf412 AP_Compass: use functor macros
Functor is not yet being used but let's make is macro fallback to the
previous Delegate implementation for easy of transition between the two.
2015-05-26 13:46:52 +10:00
Andrew Tridgell 2475ee9630 AP_Compass: setup HIL/SITL for two compasses 2015-05-16 07:06:04 +10:00
Andrew Tridgell 91b4ba3588 AP_Compass: allow for more than one compass in HIL/SITL 2015-05-15 14:25:44 +10:00
Randy Mackay ade4f81c77 Compass: fix example sketch 2015-05-15 11:53:28 +09:00
Andrew Tridgell 015fce5183 AP_Compass: revert AP_Math class change 2015-05-05 13:27:06 +10:00
Tom Pittenger d09ef4783d AP_Compass: compiler warnings: reorder constructors 2015-05-05 13:26:52 +10:00
Tom Pittenger ad11a57f57 AP_Compass: compiler warnings: apply is_zero(float) or is_equal(float) 2015-05-05 13:26:51 +10:00
Andrew Tridgell be3d6c924e AP_Compass: rename enum values to avoid header conflicts for 'ERROR' 2015-05-05 09:45:53 +10:00
Tom Pittenger 16e71ec1ce Compass: fix compile warning re member init order 2015-04-24 14:15:00 +09:00
Tom Pittenger bf1d128d70 Compass: fix compile warnings re float constants
Also fix example sketch
2015-04-24 12:29:07 +09:00
Andrew Tridgell dcb25632fb AP_Compass: removed old setHIL compass offset 2015-04-21 08:30:05 +10:00
Andrew Tridgell d7000c4105 AP_Compass: fixed compass timestamps in Replay 2015-04-20 15:12:51 +10:00
Lucas De Marchi 996739df12 AP_Compass: Do not panic if compass is not found
Copter uses 2 compasses for linux configuration, but one of them may not
be available. Do not panic if a AK8963 isn't found.
2015-04-14 09:29:12 +10:00
Andrew Tridgell c8b0970e61 AP_Compass: show compass count in example 2015-03-14 20:00:29 +11:00
Andrew Tridgell f4455d063e AP_Compass: fixed example 2015-03-14 17:07:39 +11:00
Andrew Tridgell 1962706a33 AP_Compass: fixed last_update, using last_update_usec()
this broke use of compass in the EKF
2015-03-14 12:31:23 +11:00
Andrew Tridgell 86fc90f54c AP_Compass: removed spurious rotation in PX4 backend
and cleanup rotation macros
2015-03-14 08:52:37 +11:00
Andrew Tridgell d7bac39539 AP_Compass: removed two unused functions 2015-03-14 08:52:37 +11:00
Andrew Tridgell fec2025469 AP_Compass: added set_hil_mode() 2015-03-13 22:52:55 +11:00
Andrew Tridgell 8f6982860f AP_Compass: fixed devid for 2nd compass 2015-03-13 20:46:32 +11:00
Andrew Tridgell 7b51c907f5 AP_Compass: zero some more variables in constructor and init 2015-03-13 19:22:11 +11:00