Commit Graph

551 Commits

Author SHA1 Message Date
Lucas De Marchi 705393b30c AP_HAL_Linux: replace header guard with pragma once 2016-02-18 14:52:35 -02:00
mirkix 8da58226ae AP_HAL_Linux: Fix BBBmini IIO scaling 2016-02-18 00:00:07 -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 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 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
Lucas De Marchi 860d5aaf84 AP_HAL_Linux: Scheduler: move rpcmem initialization to setup phase
This was the only piece remaining in the timer thread that was used only
to setup the thread.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 0282ebb8ff AP_HAL_Linux: add method to check caller same as thread 2016-02-12 23:42:34 -02:00
Lucas De Marchi e3beef0f77 AP_HAL_Linux: Scheduler: remove unused parameter 2016-02-12 23:42:34 -02:00
Lucas De Marchi 2b61eaf9f2 Global: remove {begin,end}_atomic from scheduler
These are never used and largely not implemented.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 9aa49cda93 Global: remove system_initializing() from scheduler
This is not used anymore.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 9cf9fc152b AP_HAL_Linux: use pthread's barrier instead of polling
Use pthread's barrier so we don't keep waking up threads with possibly
higher priority during initialization phase.

This also synchronizes all of them to a single point. With the previous
approach it was possible (but unlikely) that a thread hadn't reach the
synchronization point when main thread signalize "system initialized".
2016-02-12 23:42:34 -02:00
Lucas De Marchi 2b0e214168 AP_HAL_Linux: Scheduler: move synchronization to common method 2016-02-12 23:42:34 -02:00
Lucas De Marchi 66e6cd60d8 AP_HAL_Linux: Thread: allow to override run method 2016-02-12 23:42:34 -02:00
Lucas De Marchi a183ff8d32 AP_HAL_Linux: Scheduler: use Thread abstraction 2016-02-12 23:42:34 -02:00
Lucas De Marchi 3e0a83ede9 AP_HAL_Linux: add Thread abstraction class 2016-02-12 23:42:34 -02:00
Lucas De Marchi 5e9b45ebc2 AP_HAL_Linux: Scheduler: make microsleep() public
This will be used outside of scheduler class.
2016-02-12 23:42:34 -02:00
Lucas De Marchi 27999b339d AP_HAL_Linux: Scheduler: include cleanups
While at it also remove some wrong whitespaces.
2016-02-08 13:28:31 -02:00
mirkix 5b8de06beb AP_HAL_Linux: Enable optical flow onboard for BBBMINI 2016-02-08 08:52:10 -02:00
Lucas De Marchi 2296139516 AP_HAL_Linux: remove unused constant 2016-02-01 14:18:51 -02:00
Lucas De Marchi 21b2d5d34c AP_HAL_Linux: AnalogIn_Raspilot: rename classes to follow other names 2016-02-01 14:18:51 -02:00
Lucas De Marchi 87e7704b1c AP_HAL_Linux: ADS1115: rename classes to follow other names
While at it, remove some dead/commented-out code.
2016-02-01 14:18:51 -02:00
Lucas De Marchi 5bb2716081 AP_HAL_Linux: add name to SPI device table
A string name allows to more easily expand the table: the board is
responsible for the name and doesn't have to declare it as a enum or
define. It's also easier to add 2 sensors of the same type.
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
mirkix c622ff1539 AP_HAL_Linux: Enable AnalogIN_IIO for BBBMINI 2016-01-28 13:44:43 -02:00
mirkix fe404c8a5d AP_HAL_Linux: AnalogIIO: Remove unused code, add scaling for BBBMINI, rework 2016-01-28 13:44:43 -02:00
Gustavo Jose de Sousa c2e3f05dbf waf: ardupilotwaf: prefix build context methods with ap_
It helps to distinguish between things from waf and things from ardupilotwaf.
2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa a2d2661765 waf: use methods from bld instead of ardupilotwaf for the remaining 2016-01-22 20:10:29 -02:00
Gustavo Jose de Sousa 3d22490397 waf: examples: use methods from bld instead of ardupilotwaf 2016-01-22 20:10:29 -02:00
mirkix 86e335b6b6 AP_HAL_Linux: Prevent buffer overflow 2016-01-19 00:14:48 -02:00
Lucas De Marchi 2d3a62eae3 AP_HAL_Linux: RCInput_RPI: revert PWM support
This reverts support for RCInput via PWM. This is causing trouble in
some RPI-based boards, receiving a SIGSEGV. Let's revert it for now and
retry this later.

This reverts commit 5629f38b2c.
This reverts commit 51fd0b3d55.
This reverts commit 79d56073f7.
2016-01-18 20:07:42 -02:00
Lucas De Marchi c8947c3e9c AP_HAL_Linux: RCInput_RPI: provide signal information
Otherwise it's difficult to know what signal is causing the program to
exit.
2016-01-18 19:20:44 -02:00
Lucas De Marchi 5629f38b2c AP_HAL_Linux: RCInput_RPI: fix use of uninitiliazed value
../../libraries/AP_HAL_Linux/RCInput_RPI.cpp: In member function ‘virtual void Linux::RCInput_RPI::_timer_tick()’:
../../libraries/AP_HAL_Linux/RCInput_RPI.cpp:489:127: warning: ‘x’ may be used uninitialized in this function [-Wmaybe-uninitialized]
     counter = circle_buffer->bytes_available(curr_pointer, circle_buffer->get_offset(circle_buffer->_virt_pages, (uintptr_t)x));
                                                                                                                               ^
2016-01-18 19:19:36 -02:00
Julien BERAUD 4acc121bd6 AP_HAL_Linux: support for timesliced timers
In order for lower frequency timers not to be called at the same iteration
of the main timer loop. This improves scheduling.
2016-01-18 16:57:48 -02:00
Gustavo Jose de Sousa d281067bcc waf: make example binaries be placed in 'examples' dir
This commit makes examples' wscripts use ardupilotwaf.example() instead of
ardupilot.program().
2016-01-15 16:46:41 -02:00
Ricardo de Almeida Gonzaga 4c60dd5e44 AP_HAL_Linux: improve yuyv_to_grey() performance
Based on gbenchmark metrics.

Before:
Benchmark             Time(ns)    CPU(ns) Iterations
----------------------------------------------------
BM_YuyvToGrey/4k          3109       3114     233334
BM_YuyvToGrey/75k        55777      55857      12353
BM_YuyvToGrey/300k      231829     232227       3043

After:
Benchmark             Time(ns)    CPU(ns) Iterations
----------------------------------------------------
BM_YuyvToGrey/4k          1713       1716     411765
BM_YuyvToGrey/75k        32124      32152      21875
BM_YuyvToGrey/300k      128530     128753       5385
2016-01-15 16:43:52 -02:00
Ricardo de Almeida Gonzaga 3748760ead AP_HAL_Linux: improve crop_8bpp() performance
Based on gbenchmark metrics.

Before:
Benchmark             Time(ns)    CPU(ns) Iterations
----------------------------------------------------
BM_Crop8bpp/64/64         3206       3197     198113
BM_Crop8bpp/240/240      38166      38181      18421
BM_Crop8bpp/640/480     193589     193317       3621

After:
Benchmark             Time(ns)    CPU(ns) Iterations
----------------------------------------------------
BM_Crop8bpp/64/64         2652       2657     232103
BM_Crop8bpp/240/240      33532      33506      20792
BM_Crop8bpp/640/480     187848     188201       3684
2016-01-15 16:43:52 -02:00
Ricardo de Almeida Gonzaga 210c90e784 AP_HAL_Linux: add benchmark for crop_8bpp() and yuyv_to_grey()
We had to check for board subtypes in the benchmark since VideoIn.cpp
does these checks.
2016-01-15 16:43:52 -02:00
Julien BERAUD 43307d95c8 OpticalFlow_Onboard: fix body rate calculation
The correct integral of the body rate is (rate + last_rate)/2*dt
and not rate * dt
2016-01-15 16:11:19 -02:00
Ricardo de Almeida Gonzaga 753f7d864a AP_HAL_Linux: add a shrink by software option in OpticalFlow
This shrink must be used when the output camera sizes doesn't fit
the expected output.

We don't need to crop it even when the camera sizes aren't squared since
the shrink_8bpp() function shrinks a selected area.
2016-01-15 16:05:47 -02:00
Ricardo de Almeida Gonzaga 553d36c860 AP_HAL_Linux: add shrink_8bpp() to VideoIn
This function shrinks a selected area on a 8bpp image.

The focus in this function was the performance, so this may not be the
clearer or the most understandable way to write it. The performance
was measured using GoogleBenchmark[1].

[1] - https://github.com/google/benchmark.git
2016-01-15 16:05:47 -02:00
Lucas De Marchi 51fd0b3d55 AP_HAL_Linux: RCInput_RPI: fix coding style
- Remove trailing whitespaces
 - Remove some uneeded comments
 - Fix indentation
 - Replace some breaks inside the loop by checking in the loop itself
2016-01-15 00:16:14 -02:00
Aaron Wang Shi 79d56073f7 AP_HAL_Linux: support PWM input for BH hat 2016-01-15 00:16:14 -02:00
Julien BERAUD f449107563 AP_HAL_Linux: Add Perf Lttng
Support for perf api using lttng.
Some additional build tricks needed for bebop because lttng uses dl_open
which is not compatible with a static link on a different libc as used
on the bebop
2016-01-14 19:13:35 -02:00
Lucas De Marchi a3cac102cd AP_HAL_Linux: AnalogIn_Raspilot: rename misleading variables
We are not doing any dma here, it's just an SPI transaction. Name them
only rx/tx (although io_packet_tx/io_packet_rx could be another option).
This also zero-initialize the struct to keep valgrind happy about not
calling ioctl() with uninitialized variables.
2016-01-11 16:03:28 -02:00
Lucas De Marchi 0cff40ed7b AP_HAL_Linux: AnalogIn_Raspilot: remove unused debug 2016-01-11 15:58:49 -02:00
Pritam Ghanghas 60636c1653 AP_HAL_Linux: rename RaspilotAnalogIn.cpp to AnalogIn_Raspilot.cpp 2016-01-11 15:56:20 -02:00
Lucas De Marchi 1fde473afc AP_HAL_Linux: AnalogIn_IIO: normalize names
Use same name for file and classes, preferring AnalogIn_IIO over
IIOAnalogIn.
2016-01-11 15:44:24 -02:00
Lucas De Marchi be2af0877c AP_HAL_Linux: AnalogIn_IIO: formatting fixes
- remove trailing whitespaces
  - use pragma 0 for header guard
2016-01-11 15:44:24 -02:00
Víctor Mayoral Vilches 8195631fac HAL_Linux: AnalogIn_IIO update reopen_pin 2016-01-11 15:44:24 -02:00
Víctor Mayoral Vilches b9c83da8c6 HAL_Linux: AnalogIn_IIO, replace reopen by select
A new select_pin method has been implemented and
set that changes solely the file descriptor (avoids
reopening the file every time we call set_pin).
2016-01-11 15:44:24 -02:00
Víctor Mayoral Vilches da1b529415 HAL_Linux: AnalogIn_IIO add init_pins
initializes all the available analog
sources and stores the corresponding file descriptors
in fd_analog_sources.
2016-01-11 15:44:24 -02:00
Víctor Mayoral Vilches 546fbd1f25 HAL_Linux: mv AnalogIn_PXF to AnalogIn_IIO
Initial implementation used for the PXF moved for
a wider use. The implementation uses the Linux Industrial
I/O Subsystem (IIO) to get Analog Input.
2016-01-11 15:44:24 -02:00
Víctor Mayoral Vilches 4820e0b2c7 HAL_Linux: AnalogIn_PXF changes in AnalogIn
Recent changes in AP_HAL::AnalogIn have made the previous
code not valid anymore. This commit fixes the init()
method and adds common headers.
2016-01-11 15:44:24 -02:00
pkancir 506db4eaf5 AP_HAL_Linux: add ADC support for PXF cape 2016-01-11 15:44:24 -02:00
Lucas De Marchi 0817fe6033 AP_HAL_Linux: default USE_FRAM to 0 for all boards
This disables FRAM usage in PXF and erleboard. The reason is it's
failing and not being used. Right now we get this on startup:

	root@beaglebone:~# ./ArduCopter.elf
	FRAM: Online
	Storage: FRAM is getting reset to default values
	Failed to read FRAM

Testing with valgrind also reveals some invalid memory reads. Let's
disable it for now to be common with other boards.
2016-01-11 15:44:24 -02:00
Lucas De Marchi 2a33b6bf33 AP_HAL_Linux: OpticalFlow: remove unneeded panic
There's already a panic() below.
2016-01-11 15:34:14 -02:00
Ricardo de Almeida Gonzaga 7adbccac9a AP_HAL_Linux: add support for OpticalFlow to MinnowBoardMax
This commit adds support for OpticalFlow to MinnowBoardMax trying to
leave the OpticalFlow implementation as generic as it already is.

We had to add some format conversion and software crop to the cameras that
do not have this features.
2016-01-11 15:31:27 -02:00
Ricardo de Almeida Gonzaga 8aded390e7 AP_HAL_Linux: add yuyv_to_grey() and crop_8bpp() to VideoIn
Most cameras do not support NV12 or GREY formats, we are adding in this commit
a conversion from YUYV format, that seems pretty common in cameras, to GREY
format (since we do not use Cb and Cr data on OpticalFlow).

Also we are adding a software crop for 8bpp images, such as GREY format. For
the same reason, most cameras do not have support for overlaying (crop, resize
and so on).

These functions are being added in order to be used in the next commits,
where we will add support for OpticalFlow on MinnowBoardMax.
2016-01-11 15:31:27 -02:00
Ricardo de Almeida Gonzaga 27f909319e AP_HAL_Linux: add get_pixel_formats() to VideoIn
This function is being added in order to be used in the next commits,
where we will add support for OpticalFlow on MinnowBoardMax.
2016-01-11 15:31:26 -02:00
Julien BERAUD 979184607d OpticalFlow_Onboard: fix comment
Copy-paste mistake
2016-01-11 14:54:51 -02:00
Lucas De Marchi a803cfd1e8 AP_HAL_Linux: RCInput: use GPIO5 for PPMSUM in bhat 2016-01-07 10:28:16 -02:00
Lucas De Marchi 321803919c Revert "AP_HAL_Linux: support PWM input for BH hat"
This reverts commit 8cca0beba9.

The PWM input using the RPI DMA is causing trouble with RPI boards using
PPMSUM. Let's revert it until the solution is found. We still leave the
ifdef in RCInput for BH hat.
2016-01-07 10:27:07 -02:00
Víctor Mayoral Vilches fa3dad928b HAL_Linux: Add PXFmini to Linux_Class 2016-01-05 15:35:56 -02:00
Víctor Mayoral Vilches e1de1f5f80 HAL_Linux: Util, add PXFmini support 2016-01-05 15:35:56 -02:00
Víctor Mayoral Vilches a0b9181198 HAL_Linux: Scheduler add PXFmini support 2016-01-05 15:35:55 -02:00
Víctor Mayoral Vilches 1c49b086eb HAL_Linux: SPIDriver add PXFmini support 2016-01-05 15:35:55 -02:00
Lucas De Marchi e0d19dc87d AP_HAL_Linux: RCInput_RPI: fix coding style 2016-01-05 15:35:34 -02:00
Víctor Mayoral Vilches fdf490dad1 HAL_Linux: RCInput support for PXFmini 2016-01-05 15:34:50 -02:00
Lucas De Marchi 4e883e033f AP_HAL_Linux: GPIO: remove ifdef comment
It just clutters the source code and review process when a new similar
board is added.
2016-01-05 15:34:49 -02:00
Víctor Mayoral Vilches 8ce8045033 HAL_Linux: GPIO, add support for PXFmini 2016-01-05 15:31:43 -02:00
Lucas De Marchi 47f25a0aa0 AP_HAL_Linux: remove _export_pins() method
The initial idea was to export all pins to be used at once, so we
created _export_pins() to take all of them and a wrapper method,
_export_pin() to export a single one. However we never export more than
one pin at once.
2016-01-04 15:12:49 -02:00
José Roberto de Souza ba0ed84039 AP_HAL_Linux: Refactor GPIO_Sysfs
- Replaced PATH_MAX by the maximum stack memory it will use for GPIO
  paths
- Added more information to error logs
- Removed the '/n' when writing to GPIO sysfs files
- Using Linux Util write_file() on _pinMode()
2016-01-04 15:12:49 -02:00
José Roberto de Souza 0c0d595b55 AP_HAL_Linux: Export GPIO pin inside of pinMode()
Make sure pinMode() method exports the pin before using it. Otherwise
the export method would need to be called, differently from other GPIO
implementations.

Since now export_pin and export_pins are called only internally, reduce
their visibility to protected.
2016-01-04 15:12:49 -02:00
Ricardo de Almeida Gonzaga 7033e4d8ed AP_HAL_Linux: OpticalFlow swap crop and scale order
In order to be easier to understand the image manipulation for the ones
who read this part, since the order makes no difference in this stage.
2016-01-04 09:24:01 -02:00
Ricardo de Almeida Gonzaga cbb313ec2c AP_HAL_Linux: Fix OpticalFlow crop calculation
'left' value should be the lateral edges size
2016-01-04 09:24:01 -02:00
Julien BERAUD e46f23f538 RCOutput_Bebop: Increase max_rpm on Bebop 2
Bebop 2 can go as high as 12200 rpm. Use get_hw_arm32 method to see
if we are on a bebop or bebop 2
2015-12-27 16:11:36 -02:00
Julien BERAUD b6f51233db AP_HAL_Linux: Make RPI get_hw method public
Valid also on Bebop
2015-12-27 16:11:36 -02:00
Julien BERAUD cadef09542 AP_HAL_Linux: Fix comment and panic on Bebop 2015-12-27 16:11:36 -02:00
Lucas De Marchi a096703b06 Global: don't link with AP_Progmem
AP_Progmem is not used anymore.
2015-12-27 15:58:12 -02:00
Andrew Tridgell 0bbf4362e0 HAL_Linux: added qflight README.md 2015-12-27 16:12:27 +11:00
Andrew Tridgell dc8a3bbf92 HAL_Linux: added qflight board subtype 2015-12-27 16:12:27 +11:00
Andrew Tridgell cfd54c5683 AP_HAL: moved dsm implementation into AP_HAL/utility 2015-12-27 16:12:27 +11:00
Aaron Wang Shi ac08eece84 AP_HAL_Linux: instantiate BH hat objects 2015-12-21 15:54:31 +11:00
Aaron Wang Shi 4d7db9bba3 AP_HAL_Linux: add ifdefs for BH hat like other RPI-based boards 2015-12-21 15:54:31 +11:00
Aaron Wang Shi a712e9572f AP_HAL_Linux: instatiate SPI device for BH hat 2015-12-21 15:54:31 +11:00
Aaron Wang Shi 5d5e75c8ad AP_HAL_Linux: RCOutput_PCA9685 add new address for BH hat 2015-12-21 15:54:31 +11:00
Aaron Wang Shi f437e7a67c AP_HAL_Linux: add GPIO definitions for BH hat 2015-12-21 15:54:31 +11:00
Aaron Wang Shi 8cca0beba9 AP_HAL_Linux: support PWM input for BH hat
Support 8 PWM channels as RCInput.
2015-12-21 15:54:31 +11:00