Commit Graph

20600 Commits

Author SHA1 Message Date
Lucas De Marchi d80a0e47bc AP_Common: missing: move definitions to standard headers
This way we don't create problems regarding which header to include: we
just include the normal/c++11 headers and everything works as it should.
2016-02-16 19:49:09 -02:00
Lucas De Marchi 75d58bcfb6 Global: rename HAVE_NULLPTR_T with HAVE_STD_NULLPTR_T
This makes for a more standard name for these overrides.
2016-02-16 19:49:09 -02:00
Andrew Tridgell 815d653283 mk: fixup qurt and qflight builds with HAVE_STD_MOVE=0 2016-02-16 19:49:09 -02:00
Andrew Tridgell 29100937bc AP_Common: allow for nullptr_t but not std::move replacement 2016-02-16 19:49:09 -02:00
Andrew Tridgell 52e36908ff AP_Common: fixed std::move() for qurt build
Thanks Lucas!
2016-02-16 19:49:09 -02:00
Lucas De Marchi cc4504e613 AP_Airspeed: fix coding style
- replace tabs with spaces
  - remove C-style void from function arguments
  - use pragma once
  - fix pointer alignement
  - remove unused header: AP_Airspeed_I2C_PX4 - we actually use
    AP_Airspeed_PX4
2016-02-16 19:49:09 -02:00
Lucas De Marchi 02a7fa5c2b AP_InertialSensor: MPU9250: use AP_HAL::Device abstraction
This makes MPU9250 be almost the same as MPU6000 driver. Work has been
done here to make than similar so it's easier to spot the differences.
2016-02-16 19:49:09 -02:00
Lucas De Marchi d2b267d026 AP_InertialSensor: LSM9DS0: use AP_HAL::SPIDevice abstraction 2016-02-16 19:49:09 -02:00
Lucas De Marchi 58f4624f8c AP_InertialSensor: L3G4200D: use AP_HAL::I2CDevice abstraction 2016-02-16 19:49:09 -02:00
Lucas De Marchi af846636e4 AP_InertialSensor: MPU60x0: use AP_HAL::Device abstraction 2016-02-16 19:49:09 -02: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 b05954660a AP_Baro: BMP085: use I2CDevice interface 2016-02-16 19:49:09 -02:00
Lucas De Marchi 3060c3da3c AP_HAL_Linux: Add fake device to SPIDriver
This allows us to re-use SPIDevice from SPIDeviceDriver (the
to-become-SPIDeviceProperties) while the drivers are
converted.  We create a fake device by calling the temporary
SPIDeviceManager::get_device() method passing the descriptor. The
transfer and assert logic is still using the old code.

Now we can interoperate SPIDeviceDriver with the ones based in
SPIDevice since they are going to use the same semaphore and bus.
2016-02-16 19:49:09 -02:00
Lucas De Marchi 61ef653181 AP_HAL_Linux: implement SPIDevice
The way this code is structured is a little bit different from the
SPIDriver implementation:

 - We only open the bus once, no matter how many devices we have in it

 - There's a single transfer() method which uses half-duplex mode
   instead of full duplex. The reason is that for all cases in the
   codebase we are using half-duplex transfers using the full-duplex
   API, i.e. a single SPI msg with both tx and rx buffers. This is
   cumbersome because the buffers need to be of the same size and the
   receive buffer using an offset of the same length as the actux data
   being written. This means the high level APIs need to copy buffers
   around.

   If later we have uses for a real full duplex case it's just a matter
   of adding another transfer_fullduplex() method or something like
   this.

 - The methods are implemented in the SPIDevice class instead of having
   proxy methods to SPIDeviceManager as is the case of SPIDriver

Also from now on we refer to the SPIDriver objects as "descriptors"
because they have the parameters of each device in the
SPIDeviceManager::devices[] table. When SPIDeviceDriver is completely
replaced we can rename them to SPIDeviceProperties.
2016-02-16 19:49:09 -02:00
Lucas De Marchi 0d1bb7aa84 AP_HAL_Linux: export number of SPI devices
Save in the manager the number of devices so it can be used in other
places like the SPIDevice implementation. This is a temporary storage
while we migrate to SPIDevice.

While at it use protected rather than private.
2016-02-16 19:49:09 -02:00
Lucas De Marchi cb40444bf8 AP_HAL_Empty: implement SPIDevice 2016-02-16 19:49:09 -02:00
Lucas De Marchi 66f644c50d AP_HAL: add interface for SPIDevice devices
In order to interoperate with SPIDeviceDriver this is re-using the same
SPIDeviceManager interface.
2016-02-16 19:49:09 -02:00
Andrew Tridgell 30ce8ad311 HAL_QURT: fixed for addition of i2c manager 2016-02-16 19:49:09 -02:00
Lucas De Marchi 00249dc8bb AP_HAL_VRBRAIN: use empty I2CDevice 2016-02-16 19:49:09 -02:00
Lucas De Marchi 8de329fc81 AP_HAL_PX4: use empty I2CDevice 2016-02-16 19:49:09 -02:00
Lucas De Marchi c3d8ba3ea5 AP_HAL_SITL: use empty I2CDevice 2016-02-16 19:49:09 -02:00
Lucas De Marchi f22f4928dc AP_HAL_FLYMAPLE: fix constructor after I2CDevice 2016-02-16 19:49:09 -02:00
Lucas De Marchi e40785b002 AP_HAL_Linux: Add fake device to I2CDriver
This allows us to re-use I2CDevice from I2CDriver while the drivers are
converted.  We create a fake device with addr = 0 for each I2CDriver but
we only use the register/unregister logic. The transfer logic still uses
the methods from I2CDriver in order to use the right address.

Now we can interoperate I2CDevice drivers with the ones base in
I2CDriver since they are going to use the same semaphore and bus.

The I2CDriver constructors were changed to re-use the logic in I2CDevice
(it uses a number rather than an string) and the semaphore doesn't live
outside anymore, its embedded in the fake I2CDevice, as well as the
bus's file descritor.
2016-02-16 19:49:09 -02:00
Lucas De Marchi 5194f7e5ce AP_HAL_Linux: I2CDevice: method to read multiple times 2016-02-16 19:49:09 -02:00
Lucas De Marchi c394de31a0 AP_HAL_Linux: register I2CManager instance 2016-02-16 19:49:09 -02:00
Lucas De Marchi bc2f7f2783 AP_HAL_Linux: implement function to transfer data
This is a similar function to what we have in I2CDriver, but it can
receive a nullptr to recv or send.  It will create 2 i2c_msg structs to
send and receive data to/from the I2C slave.
2016-02-16 19:49:08 -02:00
Lucas De Marchi 2fc534d18d AP_HAL_Linux: implement methods to open the bus
These are very similar to their counterparts in I2CDriver. The changes
were:
    - Don't use fixed buffer with PATH_MAX length: allocate the string
    - Change the interface to use std::vector so we can simplify the
      implementation
2016-02-16 19:49:08 -02:00
Lucas De Marchi cd0e1dff82 AP_HAL_Linux: Add skeleton for I2CDevice
This adds the logic to maintain the I2CDevice's managed by I2CManager.
2016-02-16 19:49:08 -02:00
Lucas De Marchi a117c22c34 AP_HAL_Empty: add I2CDevice 2016-02-16 19:49:08 -02:00
Lucas De Marchi 2250d9d768 AP_HAL: initialize I2C manager
Add I2CManager to AP_HAL's contructor.
2016-02-16 19:49:08 -02:00
Lucas De Marchi f8e6c5b379 AP_HAL: add helper method to read registers
This just forwards to the transfer() method, avoiding the need in driver
code to have a similar method.
2016-02-16 19:49:08 -02:00
Lucas De Marchi b4ff2d7595 AP_HAL: add helper method to write register
This just forwards to the transfer() method, avoiding the need in driver
code to have a similar method.
2016-02-16 19:49:08 -02:00
Lucas De Marchi 872b255384 AP_HAL: Add interface for I2CDevice
This is a new interface to replace I2CDriver in future, when all drivers
are converted.
2016-02-16 19:49:08 -02:00
Lucas De Marchi 0eb450d379 AP_HAL: Add interface for I2C/SPI devices
These interfaces are intended to abstract I2C and SPI devices for
drivers.
2016-02-16 19:49:08 -02:00
Lucas De Marchi 2e60e1b1f2 AP_HAL: utility: Add OwnPtr implementation
This is very similar to std::unique_ptr, but doesn't require including
the <memory> header which pulls lots of c++ headers and cause problems
with nuttx headers. It's header-only. It contains an explanation on what
it solves, how to use and unit tests.
2016-02-16 19:49:08 -02:00
Lucas De Marchi ae5da864e7 mk: make PX4, QURT and QFLIGHT use wrapper cstddef 2016-02-16 19:49:08 -02:00
Lucas De Marchi e1ae79688d AP_Common: add directory to add missing C/C++ symbols
Add a cstddef header to allow using std::nullptr_t with those toolchains
that don't provide it. The idea is to make these platforms to use our
wrapper header (see https://gcc.gnu.org/onlinedocs/cpp/Wrapper-Headers.html)
and then we add the missing bits to the header.
2016-02-16 19:49:08 -02:00
Tom Pittenger 7fda3ba178 mk: fix SITL windows build
fixes https://github.com/diydrones/ardupilot/issues/3586
2016-02-15 16:42:06 -08:00
Julien Beraud c2db6bfb9d AP_Param: Fix warning
Cast to the original type to use get function.
Still a hack but better than casting a pointer to an object which
memory mapping we are not supposed to know
2016-02-15 15:48:35 -02:00
Lucas De Marchi f4bc5c60ba mk: px4: replace cp -f with cp
-f is only needed for rm because it fails when the file being removed
doesn't exist. cp doesn't need it.
2016-02-15 13:36:28 -02:00
Peter Barker 529a0166d5 mk: px4: correct manipulation of files
- remove useless file copy
 - replace rm/cp idiom with cp -f
2016-02-15 13:35:43 -02:00
Tom Pittenger 92fea608f3 Rover: add item_reached_msg to GUIDED 2016-02-14 16:12:56 -08:00
Tom Pittenger 786d14cd3c AP_RangeFinder: For LightWareSerial, write 'd' to support more devices 2016-02-14 16:05:50 -08:00
Andrew Tridgell b76aff2dcb AP_Arming: allow unconfigured GPS in SITL arming checks
the SITL GPS does not implement the needed protocol negotiation
2016-02-15 07:49:19 +11:00
Lucas De Marchi 7debd14683 AP_HAL_Linux: Scheduler: remove unused _in_io_proc 2016-02-12 23:42:34 -02:00
Lucas De Marchi fbb3bb2fd0 AP_HAL_Linux: Scheduler: remove unused _timer_event_missed 2016-02-12 23:42:34 -02:00
Lucas De Marchi f39a6745d1 Global: remove unused _timer_pending from scheduler 2016-02-12 23:42:34 -02:00
Lucas De Marchi 0ad436c337 AP_HAL_Linux: Scheduler: bring back scheduler table
Use a scheduler table to list threads' properties in a single place.
2016-02-12 23:42:34 -02:00
Lucas De Marchi a1b62b4984 AP_HAL_Linux: Scheduler: use PeriodicThread
Some tasks were not accounting for the time to execute the tasks. Now
that we are using the infra from PeriodicThread all of them are.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 48e81c8589 AP_HAL_Linux: Thread: add PeriodicThread helper
This is a helper class to run a single periodic function like the ones
used in the scheduler.
2016-02-12 23:42:34 -02:00