Commit Graph

44 Commits

Author SHA1 Message Date
Lucas De Marchi d5f57fdd93 AP_Compass: AK8963: remove fallback to timer thread
Now that the bus thread from the AuxiliaryBus is implemented we can
remove the fallback.
2017-09-11 09:52:41 -07:00
Lucas De Marchi 6bab28397a AP_Compass: remove user of timesliced logic 2017-08-02 08:00:53 -07: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 4ba00720aa AP_Compass: make init() private
not called from frontend
2016-11-10 11:44:52 +11:00
Andrew Tridgell 05769640d1 AP_Compass: support rotations on AK8963 2016-11-09 17:08:08 +11:00
Andrew Tridgell de7913e8e9 AP_Compass: implement device IDs for compass drivers 2016-11-09 17:08:04 +11:00
Andrew Tridgell 1c631ea037 AP_Compass: cleanup use of backend semaphores
fixed drivers that didn't protect accumulation counters
2016-11-09 17:08:01 +11:00
Andrew Tridgell 9afd51350e AP_Compass: use thread per bus in more drivers
and removed use of timer suspend
2016-11-09 17:08:01 +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 1ddbafabdd AP_Compass: add name field to internal compass drivers 2016-05-18 18:24:14 -03:00
Randy Mackay 4aba25d2ef AP_Compass_AK8963: remove unused _bus_sem, _last_accum_time
Resolves a compiler warning
2016-04-23 23:06:21 -07:00
Lucas De Marchi e6059f5197 AP_Compass: rename files to follow other libraries
AP_Compass.h is the main header to be exported and AP_Compass.cpp its
implementation. There's no need for an additional header.
2016-03-23 17:50:38 -03:00
Lucas De Marchi d3831dbb98 AP_Compass: AK8963: use AP_HAL::I2CDevice abstraction
We still need the BusDriver (in some places called SerialBus) interface
since this driver can also be used on an AuxiliaryBus and that has a
different interface.
2016-03-23 17:50:38 -03:00
Lucas De Marchi 1a71c169fe AP_Compass: replace header guard with pragma once 2016-02-18 14:52:34 -02:00
Lucas De Marchi b55294920b AP_Compass: AK8963: remove logging on fail to get semaphore
This is the only driver doing this, using the system_initializing() from
scheduler to log selectively. Remove the check together with removal of
unused wrapper methods to semaphore.
2016-02-08 13:28:32 -02:00
Julien BERAUD 45d668df47 AP_Compass_AK8963: support for timesliced timers
fallback in case the current scheduler doesn't support it
2016-01-18 16:57:48 -02:00
José Roberto de Souza bdc36349b4 AP_Compass: AK8963: Add support to use a AK8963 behind of a MPU9250 over I2C
To be able to use AK8963 connected to the auxiliary I2C bus of a
MPU9250 we need first initialize it.
2015-11-11 14:29:07 +11:00
José Roberto de Souza 1fc29a2654 AP_Compass: AK8963: Use MPU9250 auxiliary bus 2015-11-11 14:29:06 +11:00
mirkix ddb8e67954 AP_Compass: Add support for more then one AK8963 2015-10-06 10:38:21 +11:00
José Roberto de Souza 1a2b5ff677 AP_Compass: AK8963: Remove unused AP_HAL::Semaphore attributes 2015-10-01 10:42:51 -03:00
José Roberto de Souza a9d34ac3bd AP_Compass: AK8963: Rename some SPI/I2C method parameters
On read/write operations the argument is the register that will be read or
write not the address, SPI don't even have the concept of device address.
2015-10-01 10:42:40 -03:00
Andrew Tridgell c59bdc12df AP_Compass: fix the milligauss handling
the previous approach assumed a 1:1 mapping between compass backends
and compass instances, which isn't true on PX4.

It also only setup milligauss offsets on a set_and_save call, which is
not the only way offsets change

this adds a milligauss_ratio per instance, which is considerably
simpler
2015-09-09 14:53:11 +10:00
Staroselskii Georgii 693613aa0f AP_Compass: convert AK8963 measurements to uT
AK8963 is configured in 16-bit ADC mode which implies sensitivity of 0.15 uT/LSb. Knowing this fact we can convert the measurements to the proper units. The change will make users recalibrate their compasses.
2015-09-09 10:38:16 +10:00
Staroselskii Georgii c207d8c6a8 AP_Compass: add milligauss counterparts to get_field() and get_offsets()
From now on there's a pair get_field_milligauss() and
get_offsets_milligauss() that can make the transition to the common
units across all compasses easier.
2015-09-09 10:38:16 +10:00
Lucas De Marchi 868d0bf3c3 AP_Compass: AK8963: refactor constructors
Declare a common constructor that others can call.
2015-08-28 12:39:08 +10:00
Lucas De Marchi a5df93bf10 AP_Compass: AK8963: be agnostic to I2C bus/address
This decision is better made by the caller rather than polluting the
driver with board-specific details.
2015-08-28 12:39:08 +10:00
Lucas De Marchi 7e997564bf AP_Compass: 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:51 +10:00
Gustavo Jose de Sousa 58f300e78e AP_Compass: 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
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
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 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 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
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 7dd0b5fae6 AP_Compass: removed _spi_sem and _spi 2015-07-10 16:46:29 +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
Andrew Tridgell be3d6c924e AP_Compass: rename enum values to avoid header conflicts for 'ERROR' 2015-05-05 09:45:53 +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 a871c87cad AP_Compass: use state array for compass variables 2015-03-13 18:46:15 +11:00
Víctor Mayoral Vilches d3b76cd8d3 AP_Compass: split compass into frontend/backend 2015-03-13 18:46:15 +11:00
Staroselskii Georgii 0d1cf347c7 AP_Compass: added AK8963 support 2015-01-07 08:41:12 +11:00