Commit Graph

686 Commits

Author SHA1 Message Date
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
Andrew Tridgell c77e3c89c5 HAL_Linux: implement new_semaphore() 2015-12-20 17:55:39 +11:00
Lucas De Marchi 2a953c4e35 AP_HAL_Linux: add missing casts
These errors were all over the VideoIn.cpp file:

libraries/AP_HAL_Linux/VideoIn.cpp: In member function 'bool Linux::VideoIn::allocate_buffers(uint32_t)':
libraries/AP_HAL_Linux/VideoIn.cpp:107:15: error: invalid conversion from 'uint32_t {aka unsigned int}' to 'v4l2_memory' [-fpermissive]
     rb.memory = _memtype;
               ^
libraries/AP_HAL_Linux/VideoIn.cpp: In member function 'bool Linux::VideoIn::set_format(uint32_t*, uint32_t*, uint32_t*, uint32_t*, uint32_t*)':
libraries/AP_HAL_Linux/VideoIn.cpp:169:14: error: invalid conversion from 'int' to 'v4l2_buf_type' [-fpermissive]
     fmt.type = V4L2_CAP_VIDEO_CAPTURE;
              ^

Add proper casts to fix the compilation.
2015-12-18 17:56:06 +11:00
Lucas De Marchi ba5dd88a0b AP_HAL_Linux: move mt9v117 patches inside class
Let it be a static const member instead of defining it in a header. The
problem with the header is that it will generate conflicting symbols
when more than 1 compilation unit includes it.
2015-12-18 17:56:06 +11:00
Julien BERAUD 6f55f3734c AP_HAL_Linux: Add optflow declaration
Add an empty driver for boards that are not bebop
2015-12-18 17:56:05 +11:00
Julien BERAUD f13cd00e59 AP_HAL_Linux: Update namespace and private
Add new interfaces for optical flow
2015-12-18 17:56:05 +11:00
Lucas De Marchi 83c50e12ca AP_HAL_Linux: OpticalFlow_Onboard: follow coding style
- Remove commented out defines
 - Sort headers
 - Remove ifdef for HAL_BOARD_SUBTYPE_LINUX_BEBOP inside the same ifdef
 - Use AP_HAL::panic() instead of perror
 - AP_HAL::panic() message doesn't take a '\n' and there's no return
   statement after a call to this function
 - Fix pointer placement
 - Use pragma once
 - Don't initialize members to 0, it's already the default behavior of
   our custom allocator
2015-12-18 17:56:05 +11:00
Julien BERAUD ea89308d90 AP_HAL_Linux: Add Onboard Optical Flow interface
Implementation of AP_HAL::OpticalFlow for an embedded camera sensor

There is the possibility to record video and also the gyro datas in order
to process the video off-board and debug possible issues.
2015-12-18 17:56:05 +11:00
Lucas De Marchi db5f49f49f AP_HAL_Linux: Flow_PX4: follow coding style
- Replace tabs with spaces
 - Sort headers
 - Fix curly braces placement
 - Use pragma once
2015-12-18 17:56:05 +11:00
Julien BERAUD 0476e698af AP_HAL_Linux: Flow_PX4 interface
Implementation of the PX4 flow algorithm for ardupilot.
Based on the original PX4 Flow code, it has diverged a lot.
I have kept the license header since it is required.
I have removed all the unused and dead code on current implementation,
modified the code to make it clearer, re-indented it and changed
the way some params are calculated. It has been tested on PC and
on board and showed results that I assumed were OK. No optical flow
Loiter tests have been undertaken since it requires a Sonar which will
be added soon.

Limitations :
Some parts were written in ARM assembly and I rewrote them very naively
to get them to be more easily portable. A simple optimisation would be
to re-introduce assembly code for ARM as a separate asm file with
methods for fixed resolutions that would reduce a lot the amount of
calculation and memory read/writes. Then writing a version in NEON
assembly would even be more optimised and then maybe an Intel version.
2015-12-18 17:56:05 +11:00
Lucas De Marchi c75704bde3 AP_HAL_Linux: VideoIn: follow coding style and minor fixes
- No need to if/else if just returning
 - Sort includes
 - Fix missing space in log message
 - When closing the fd, set it to -1. It's better to later fail the
   operation than to operate on another random file descriptor
 - Add some spaces to improve readability
 - Use pragma once
 - Do not initialize members to zero, it's already the behavior for our
   custom allocator
2015-12-18 17:56:05 +11:00
Julien BERAUD 25df4d03ff AP_HAL_Linux: Add support for Video Input
VideoIn class is created that allows to setup a v4l2 interface
and capture buffers. I is based on yavta utility by Laurent Pinchart
and has been tested only on the bebop, though yavta works on any linux
platform.
2015-12-18 17:56:04 +11:00
Lucas De Marchi 24d20f89c4 AP_HAL_Linux: make CameraSensor follow coding style
- Replace tabs with spaces
 - Sort includes
 - No need to ifdef Linux inside AP_HAL_Linux
 - Use early returns on error rather than a chain o if/else
 - Use pragma once
 - No need to initialize class members to 0, it's already our default
   behavior
2015-12-18 17:56:04 +11:00
Julien BERAUD c84d9bf702 AP_HAL_Linux: Add support for mt9v117 camera
The camera sensor is connected on i2c bus for config
and on a parallel bus on the main SoC.
Currently, the i2c driver remains userland, but this is intended to
change in the future. The v4l2_subdev part is the way to go in the future
and it is the mainline way of configuring i2c camera sensors on Linux.
Currently only the max framerate is supported because it is the one that
is to be used on the bebop optical flow.
2015-12-18 17:56:04 +11:00
Andrew Tridgell 0a36503742 HAL_Linux: fixed a bug with UDP packetisation
this fixes a bug where we would send UDP MAVLink packets larger than 300 bytes
2015-12-14 18:27:11 +11:00
Julien BERAUD bbf146197c RCOutput_Bebop : Update motor order
Newer esc firmware versions on bebop 1 and all the versions on bebop 2
have a different order for the motors in the i2c frame sent to the
esc contoller. This commit adds support for both versions by reading
the firmware version of the esc, using GET_INFO frame
2015-12-09 20:48:26 +09:00
Lucas De Marchi 6011eefb55 AP_HAL_Linux: rename AP_HAL_Empty instances 2015-12-08 11:12:14 +11:00
Lucas De Marchi 27dafa8f1b AP_HAL_Linux: remove state leftover from SPIDeviceDriver
This was previously used to allow to save a state in a SPIDriver so we
could synchronize the initialization of AP_Compass and
AP_InertialSensor.

It was only used by MPU9250 and is not used anymore since the move to
AuxiliaryBus initialization and it's not used anymore since c3dae6f
("AP_InertialSensor: MPU9250: Remove methods not used anymore")
2015-12-08 11:10:23 +11:00
Caio Marcelo de Oliveira Filho 6e7b73610d waf: add waf support 2015-12-03 07:54:30 +11:00
Lucas De Marchi 2439826c19 AP_HAL_Linux: use init() method without arguments
Override the init() method from parent class that doesn't have a
parameter since it's not used here.
2015-12-02 14:49:11 -02:00
Lucas De Marchi 49abb78372 AP_HAL_Linux: fix warning due to derived PWM_Sysfs
PWM_Sysfs derives from PWM_Sysfs_Base which was not update to have a
virtual destructor. Make PWM_Sysfs_Base's constructor virtual.
2015-12-02 10:43:43 +11:00
Lucas De Marchi d19c5035b6 Global: Rename printf format attribute
As commented in 8218140 ("AP_Common: add scanf format macro"), "FORMAT"
was a bad name for this macro since there's also the scanf. Rename to
FMT_PRINTF to follow the scanf name.
2015-12-01 07:22:12 +11:00
Julien BERAUD 88236821c0 AP_HAL_Linux: Adapt Heat_Pwm to use PWM_Sysfs
Only compiled on Bebop, the constructor will need to be modified to
pass the pwm chip number and to create a PWM_Sysfs instead of a PWM_Sysfs_Bebop
in case it is used on a mainline linux board
2015-12-01 07:07:26 +11:00
Julien BERAUD 8c4803af10 AP_HAL_Linux: GPIO Sysfs for Bebop
copied from minlure implementation
2015-12-01 07:07:26 +11:00
Julien BERAUD 2136866594 AP_HAL_Linux: fix I2CDriver indentation
Tabs to spaces
2015-12-01 07:07:26 +11:00
Julien BERAUD 26163b6640 AP_HAL_Linux: Add do_transfer method to i2c driver
Method needed for mt9v117 camera sensor
2015-12-01 07:07:26 +11:00
Lucas De Marchi 04f601d42f AP_HAL_Linux: PWM_Sysfs: minor changes to Bebop/mainline integration
- Make error path in constructor shorter and earlier. It's calling
    panic() so there's no reason to do anything else

  - We don't need to check variable for NULL when calling free()

  - Change set/get_polarity to use a virtual function; this allows us
    not to fail silently if _polarity_path is NULL for PWM_Sysfs.
    PWM_Sysfs_Bebop just overrides this method and implement an empty
    version.
2015-12-01 07:07:25 +11:00
Julien BERAUD 8733f34ce1 AP_HAL_Linux: PWM_Sysfs for bebop
Modify existing class to create a PWM_Sysfs_Base class and derive it for
Bebop and Pwm_Sysfs (mainline kernel)

use asprintf for path allocation since it doesn't cost so much and is done
only at startup
Note that the constructor of the 2 classes : PWM_Sysfs and PWM_Sysfs_Bebop
allocate the paths and the constructor and desctuctor of class PWM_Sysfs_Base
frees them.
only keep in memory the paths that are needed later, i.e free _export_path,
_duty_path. The remaining path are freed in the destructor
2015-12-01 07:07:25 +11:00
Caio Marcelo de Oliveira Filho 6773e18bc4 AP_HAL_Linux: Remove unused extern declaration for HALs 2015-11-20 16:32:17 +09:00
Caio Marcelo de Oliveira Filho e0a6d83457 AP_HAL_LINUX: remove unused functions 2015-11-20 12:36:25 +09:00
Caio Marcelo de Oliveira Filho 7675913d5b AP_HAL_Linux: use millis/micros/panic functions 2015-11-20 12:31:04 +09:00
Caio Marcelo de Oliveira Filho ff016c4b5a AP_HAL_Linux: implement new AP_HAL functions
Implement the new AP_HAL functions and use them in the Scheduler when
possible.

The '_sketch_start_time' was renamed and moved as a detail of
implementation of the functions code. It allows the code to return time
starting from zero.

The 'stopped_clock_usec' was renamed to follow convention in the file
and add a getter so that AP_HAL functions can reach it. It's not a
problem this getter is public because in practice, regular code
shouldn't even access the Linux::Scheduler directly -- only code that
should is from Linux implementation.
2015-11-20 12:25:39 +09:00
Caio Marcelo de Oliveira Filho efbc7648b1 AP_HAL: create AP_HAL namespace and use for some HAL functionality
For certain basic functionality, there aren't much benefit to be able to
vary the implementation easily at runtime. So instead of using virtual
functions, use regular functions that are "resolved" at link time. The
implementation of such functions is provided per board/platform.

Examples of functions that fit this include: getting the current
time (since boot), panic'ing, getting system information, rebooting.

These functions are less likely to benefit from the indirection provided
by virtual interfaces. For more complex hardware access APIs the
indirection makes more sense and ease the testing (when we have it!).

The idea is that instead of calling

    hal.scheduler->panic("on the streets of london");

now use

    AP_HAL::panic("on the streets of london");

A less important side-effect is that call-site code gets
smaller. Currently the compiler needs to get the hal, get the scheduler
pointer, get the right function pointer in the vtable for that
scheduler. And the call must include an extra parameter ("this"). Now it
will be just a function call, with the address resolved at link time.

This patch introduces the first functions that will be in the namespace,
further patches will implementations for each board and then switch the
call-sites. The extra init() function allow any initial setup needed for
the functions to work.
2015-11-20 12:25:24 +09:00
Andrew Tridgell 9ea99cba29 HAL_Linux: fixed example build 2015-11-16 08:04:35 +11:00
Andrew Tridgell 1a033f3b73 HAL_Linux: don't flood the link with errors on uninitialised perf counter
that could bring down the vehicle
2015-11-14 14:44:29 +11:00
Julien BERAUD 2f610a400a AP_HAL_Linux: fix perf
Fix warning (warning: declaration of 'perf_count' shadows a member of 'this')
and check that perf is not NULL before indirection
2015-11-14 14:44:29 +11:00
Julien BERAUD f8f2833c88 AP_HAL_Linux: use I2C_SLAVE_FORCE in case of error
When there is already a driver registered on an i2c bus, the I2C_SLAVE ioctl
returns an error.
When it happens, it is better to display a warning and try to force the address.
It is especially useful on the bebop when killing the regular autopilot that uses
iio drivers to access the imu because else we would need to manually unbind the
driver in an init procedure.

I have added a warning because this error can also be resulting of another cause.
If the error is not EBUSY, then panic

If the I2C_SLAVE_FORCE ioctl fails then we panic because one of the i2c devices
won't be working properly.
2015-11-13 21:20:13 +11:00
José Roberto de Souza 5ff67a41a1 AP_HAL_Linux: Implement perf API
Initial implementation of perf API on Linux, for now just saving
perf data, in a further patch this data will be exported.
2015-11-13 12:16:19 +11:00
mirkix f00d4f0b3e AP_HAL_Linux: Improve loading firmware 2015-11-12 21:25:17 +01:00
Lucas De Marchi 1d51e60571 AP_HAL_Linux: move Util instantiation
The util object may be used by all other objects so we need to
instantiate it as earlier as possible.
2015-11-11 08:02:41 +11:00
José Roberto de Souza 01766e7069 AP_HAL_Linux: RCOutput: Add LinuxRCOutput_Sysfs
This RCOutput works over Linux PWM sysfs interface.
2015-11-10 17:05:34 +11:00
Lucas De Marchi 392879112e AP_HAL_Linux: document functions to write file
Document function and add attributes to mark then as printf- and
scanf-like functions.
2015-11-10 17:05:34 +11:00
Lucas De Marchi c66c61180a AP_HAL_Linux: rework PWM_Sysfs
This include some minor changes on all methods of PWM_Sysfs:

  - Sort headers
  - Add code inside Linux namespace rather than just use the namespace
  - Declare a union pwm_params, that's only used to calculate at compile
    time the maximum stack space we need in our methods: this is a bit
    safer for future extensions
  - Standardize error messages to include the useful params first and
    then the error message
  - Remove log message from hot path
  - Don't abuse macros for checking error - convert the SNPRINTF_CHECK
    macro into proper code, ignoring errors for not enough space since
    they can't happen
  - Fix call to read_file() passing uint8_t for "%u" in get_period()
  - Fix passing char** instead of char* to write_file() in set_polarity()
  - Use strncmp() instead of strncasecmp() since the kernel API uses
    lowercase.
  - Add comments on the 2 main methods of this class
2015-11-10 17:05:34 +11:00
José Roberto de Souza 39bd5fa80e AP_HAL_Linux: Add PWM_Sysfs
This class makes easy to use Linux PWM sysfs interface, available since
Linux 3.10.

More information https://www.kernel.org/doc/Documentation/pwm.txt
2015-11-10 17:05:34 +11:00
Andrew Tridgell 883ac59e4a HAL_Linux: always report 256k of available memory 2015-11-05 16:09:00 +11:00
Víctor Mayoral Vilches d5d1bfae8c AP_HAL_Linux: Adapt code to common RPI layer 2015-11-04 13:58:25 +11:00
Víctor Mayoral Vilches b1a53c383c AP_HAL_Linux: Add AnalogIn_ADS1115, common code
This commit provides a single abstraction for both
Erle-Brain 2 and Navio boards.
2015-11-04 13:58:24 +11:00
Víctor Mayoral Vilches 47d43c64ef AP_HAL_Linux: Add RCInput_RPI, merge common code 2015-11-04 13:58:24 +11:00
Víctor Mayoral Vilches 739fc0df35 AP_HAL_Linux: UtilRPI, add Erle-Brain 2 2015-11-04 13:58:24 +11:00
Víctor Mayoral Vilches 30153b6eac AP_HAL_Linux: Scheduler, add Erle-Brain 2 2015-11-04 13:58:24 +11:00
Víctor Mayoral Vilches 8ae8f47538 AP_HAL_Linux: SPIDriver, add Erle-Brain 2 2015-11-04 13:58:24 +11:00
Víctor Mayoral Vilches 68c92eab25 AP_HAL_Linux: GPIO, add Erle-Brain 2 2015-11-04 13:58:24 +11:00
Lucas De Marchi 6984168a45 AP_HAL_Linux: don't log on failed semaphore
With commit 24f4153 ("AP_HAL_Linux: RCOutput_PCA9685: group writes") a
log was introduced when we can't get the bus semaphore. However since we
are calling the non blocking method, failing there is not that unlikely
if the bus is shared. Return back to the previous behavior of not
logging.
2015-11-03 11:08:00 +11:00
Lucas De Marchi 1b07dabeb7 Replace prog_char and prog_char_t with char
prog_char and prog_char_t are now the same as char on supported
platforms. So, just change all places that use them and prefer char
instead.

AVR-specific places were not changed.
2015-10-30 14:35:30 +09:00
Lucas De Marchi 6f4904189b Replace use of println_P() with println() 2015-10-30 14:35:22 +09:00
Lucas De Marchi 831d8acca5 Remove use of PROGMEM
Now variables don't have to be declared with PROGMEM anymore, so remove
them. This was automated with:

    git grep -l -z PROGMEM | xargs -0 sed -i 's/ PROGMEM / /g'
    git grep -l -z PROGMEM | xargs -0 sed -i 's/PROGMEM//g'

The 2 commands were done so we don't leave behind spurious spaces.

AVR-specific places were not changed.
2015-10-30 14:35:16 +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
Lucas De Marchi 9eaf7c5660 AP_HAL: add format attribute to panic() 2015-10-24 14:26:36 +11:00
Lucas De Marchi 4b54bcbfad AP_HAL_Linux: use variadic panic()
While at it also add a prefix with the name of the driver.
2015-10-24 14:26:36 +11:00
Lucas De Marchi 2af4244854 AP_HAL_Linux: Scheduler: implement variadic version of panic() 2015-10-24 14:26:36 +11:00
Lucas De Marchi ad61a93c14 AP_HAL: turn panic() into a variadic method
Change the declaration on all HAL implementations so panic() in future
may implement a printf-like interface.
2015-10-24 14:26:35 +11:00
Lucas De Marchi b326856635 AP_HAL_Linux: fix warning due to limited storage
ardupilot/libraries/AP_HAL_Linux/Storage_FRAM.cpp: In member
function 'int32_t Linux::Storage_FRAM::read(uint16_t, uint8_t*, uint16_t)':
/home/lucas/p/dronecode/ardupilot/libraries/AP_HAL_Linux/Storage_FRAM.cpp:183:24: war
ning: comparison is always false due to limited range of data type [-Wtype-limits]
         if(Buff[i-fptr]==-1){
                        ^
2015-10-23 07:47:19 +11:00
Lucas De Marchi cdaf67b749 AP_HAL_Linux: use PCA9685 for output in minlure 2015-10-22 12:04:53 +11:00
Lucas De Marchi b75524a152 AP_HAL_Linux: use UART RC input for minlure 2015-10-22 12:04:53 +11:00
Lucas De Marchi f72a5614d5 AP_HAL_Linux: add I2C buses for minlure 2015-10-22 12:04:53 +11:00
Lucas De Marchi 959e061514 AP_HAL_Linux: add spi device for minlure 2015-10-22 12:04:53 +11:00
Lucas De Marchi 4992375bab AP_HAL_Linux: add GPIO definitions for minlure 2015-10-22 12:04:52 +11:00
Gustavo Jose de Sousa 7daa3201fd AP_HAL_Linux: add test for GPIO 2015-10-22 12:04:52 +11:00
Gustavo Jose de Sousa cdf70f6fe5 AP_HAL_Linux: add GPIO_Sysfs
This commit adds the class Linux::GPIO_Sysfs. This class provides a generic
implementation of AP_HAL::GPIO on Linux by using GPIO Sysfs Interface
(https://www.kernel.org/doc/Documentation/gpio/sysfs.txt).

The channel() interface should be preferred in places that need to be
fast. Since it maintains the file descriptor open this is much faster
than opening and closing it.
2015-10-22 12:04:52 +11:00
Gustavo Jose de Sousa 88146f1f02 AP_HAL_Linux: make board specific GPIO inclusions last
Board specific inclusions should be the last inclusions so that any
eventual dependency may be fulfilled.
2015-10-22 12:04:52 +11:00
Fabio Mello 20e209120f AP_HAL_Linux: add support for RCInput through UART
We are using a microcontroller to read the PWM input from RC. The read
values are sent to our board using a simple serial protocol through the
UART interface.

This patch interprets these values and passes them forward to the APM.
2015-10-22 12:04:52 +11:00
Lucas De Marchi f21ee7694a AP_HAL_Linux: don't use relative includes
Use brackets to include from AP_HAL and reorder headers.
2015-10-21 15:54:27 -02:00
Lucas De Marchi 2ac96b942c AP_HAL_Linux: remove prefix from AP_HAL_Linux classes
We have already a Linux namespace, so there's no need to prefix Linux on
all names.
2015-10-21 10:11:19 +11:00
Caio Marcelo de Oliveira Filho c95a89411c AP_HAL_Linux: remove unnecessary includes in example 2015-10-21 09:16:09 +11:00
Caio Marcelo de Oliveira Filho 19b4ca60c4 AP_HAL: provide AP_HAL_MAIN()
Move the macros to a single place and reduce the variations not based on
board, but based on

- The name of the entry-point function, specified by AP_MAIN;
- Whether it contains argc/argv arguments or not.

The goal here is that programs (vehicles and examples) don't need to
include all possible boards to define a main function. Further patches
will change the programs.
2015-10-21 09:16:09 +11:00
Caio Marcelo de Oliveira Filho 3c22564307 AP_HAL_Linux: merge init() and run() 2015-10-21 09:16:08 +11:00
Caio Marcelo de Oliveira Filho 32dc822470 AP_HAL_Linux: implement HAL::run()
Added a note about the different ordering between setup callback and
scheduler initialized call.
2015-10-21 09:16:07 +11:00
Caio Marcelo de Oliveira Filho ec52df991c build: compile only the HAL files needed by the board
Instead of requiring every program to specify the HAL related modules,
let the build system do it (in practice everything we compiled depended
on HAL anyway). This allow including only the necessary files in the
compilation.
2015-10-21 09:16:07 +11:00
Caio Marcelo de Oliveira Filho 2e464a53c2 AP_HAL: make code not depend on concrete HAL implementations
The switching between different AP_HAL was happening by giving different
definitions of AP_HAL_BOARD_DRIVER, and the programs would use it to
instantiate.

A program or library code would have to explicitly include (and depend)
on the concrete implementation of the HAL, even when using it only via
interface.

The proposed change move this dependency to be link time. There is a
AP_HAL::get_HAL() function that is used by the client code. Each
implementation of HAL provides its own definition of this function,
returning the appropriate concrete instance.

Since this replaces the job of AP_HAL_BOARD_DRIVER, the definition was
removed.

The static variables for PX4 and VRBRAIN were named differently to avoid
shadowing the extern symbol 'hal'.
2015-10-21 09:16:07 +11:00
José Roberto de Souza 9889f826b3 AP_HAL_Linux: RCInput_UDP: Fix compiling warning
This warning happens because of the difference of datatypes between
32 and 64 bits processors.

%% libraries/AP_HAL_Linux/RCInput_UDP.o
/home/zehortigoza/dev/ardupilot/libraries/AP_HAL_Linux/RCInput_UDP.cpp: In member function 'virtual void Linux::LinuxRCInput_UDP::_timer_tick()':
/home/zehortigoza/dev/ardupilot/libraries/AP_HAL_Linux/RCInput_UDP.cpp:42:72: warning: format '%llu' expects argument of type 'long long unsigned int', but argument 3 has type 'uint64_t {aka long unsigned int}' [-Wformat=]
             hal.console->printf("no rc cmds received for %llu\n", delay);
2015-10-16 10:28:07 +11:00
José Roberto de Souza e6f0ba6c8b AP_HAL_Linux: Compile RCInput_UDP in all Linux boards
This RCInput is generic enough to be used on every Linux board.
2015-10-16 10:28:06 +11:00
Julien BERAUD ffbb892a01 AP_HAL_Linux: add support for a pwm heater
It uses a heating resistor controlled by a pwm.
By changing the duty cycle of the pwm, we can control the temperature.
A simple PI algorithm is used in order to get to the correct temperature
fast enough and without too much overshoot
It is implemented as a member of the Util class in order not to make to much
modification to the current codebase
2015-10-06 15:21:39 +11:00
Lucas De Marchi 0dad58ae8b AP_HAL_Linux: RCOutput_Bebop: group writes
This allows to remove the hard limit of 4 motors in Bebop, allowing to
execute the motor test.
2015-10-06 11:03:30 +11:00
Lucas De Marchi 24f41538cb AP_HAL_Linux: RCOutput_PCA9685: group writes 2015-10-06 11:03:30 +11:00
Julien BERAUD 1c46205c2b AP_HAL_Linux: fix warning
Fix warning and use htole16 instead of trying to implement it.
The current code does nothing on little endian platforms.
Moreover, the status variable was unused.
2015-10-06 10:34:59 +11:00
raspilot aa4d16622e HAL_Linux_Class: Init spi before rcin & rcout, because raspilot rcin & rcout use spi. 2015-10-02 09:54:55 +10:00
raspilot 5dc18b9a54 HAL_Linux_Class: Fix the broken declare of "LinuxUtilRPI utilInstance" at building raspilot. 2015-10-02 09:47:18 +10:00
Lucas De Marchi 191ec10554 AP_HAL_Linux: remove unused write method 2015-09-29 11:53:46 +09:00
Lucas De Marchi fc2a1d27b4 AP_HAL_Linux: fix build for raspilot after Util change
Make sure raspilot also builds after making the Util class common for
RPI-based boards.
2015-09-24 15:31:32 +10:00
Lucas De Marchi 55e1d60b54 AP_HAL_Linux: Use from() method for downcast in Util class 2015-09-24 15:31:32 +10:00
dgrat 15b3717d89 AP_HAL_Linux: Move RPi version check to util class
- Moved the version check functions to util.
 - Removed a redundant version check.
 - Removed redundant version check functions from RCInput.
2015-09-24 13:04:18 +10:00
dgrat 2590db378a AP_HAL_Linux: remove extra spaces in RCInput_Navio 2015-09-24 13:04:18 +10:00
dgrat e96a1bae8a AP_HAL_Linux: cleanup pointer casts in RCInput_Navio
Although RPi is 32 bits, use uintptr_t and friends for casts.
2015-09-24 13:04:18 +10:00
Lucas De Marchi 54c2c5f682 AP_HAL_Linux: use method for downcast
Instead of just doing a static cast to the desired class, use a method
named "from". Pros:

  - When we have data shared on the parent class, the code is cleaner in
    child class when it needs to access this data. Almost all the data
    we use in AP_HAL benefits from this

  - There's a minimal type checking because now we are using a method
    that can only receive the type of the parent class
2015-09-23 09:01:29 +10:00
mirkix 93941c3349 AP_HAL_Linux: Add support for using SPI devices of the same type. 2015-09-18 09:15:09 +10:00
Andrew Tridgell 61441ab35d HAL_Linux: fixed apm2 build 2015-09-14 14:22:16 +10:00
Andrew Tridgell bf001f19ff HAL_Linux: don't panic on runtime failures 2015-09-14 14:22:16 +10:00
raspilot 9f91eb020e AP_HAL_Linux: new files for raspilot 2015-09-14 14:22:16 +10:00
raspilot 30a2fe0857 AP_HAL_Linux: added scheduler hooks for raspilot 2015-09-14 14:22:16 +10:00
raspilot 25cddbcbaa AP_HAL_Linux: added SPI support for raspilot 2015-09-14 14:22:16 +10:00
raspilot 7d329205ec AP_HAL_Linux: added tonealarm support for raspilot 2015-09-14 14:22:16 +10:00
raspilot a6736d8e61 AP_HAL_Linux: fixed ublox debug message 2015-09-14 14:22:16 +10:00
raspilot 444081d38d AP_HAL_Linux: added support for raspilot objects 2015-09-14 14:22:16 +10:00
raspilot f057fe3d02 AP_HAL_Linux: added support for raspilot GPIO 2015-09-14 14:22:15 +10:00
raspilot 9a73df1bea AP_HAL_Linux: added support for raspilot RCInput 2015-09-14 14:22:15 +10:00
Víctor Mayoral Vilches 728921f7c5 AP_HAL_Linux: ERLEBOARD legacy support
This config referred to the legacy Erle-Board
https://erlerobotics.com/blog/product/erle-board/
The configuration is preserved to support the
existing boards.
2015-09-09 10:31:55 +10:00
Fredrik Hedberg d9a4b6b089 AP_HAL_Linux: Allow PCA9685 to be used on non-default I2C addresses. 2015-09-09 08:43:22 +10:00
Fredrik Hedberg 9d9e6d0b34 AP_HAL_Linux: Only use enable pin for PCA9685 if we need to. 2015-09-09 08:43:22 +10:00
Fredrik Hedberg 21b9f96ce3 AP_HAL_Linux: Enable use of all 16 channels for non-Navio PCA9685. 2015-09-09 08:43:22 +10:00
Julien BERAUD a057a8a009 AP_HAL_Linux: Add Support for RCInput_UDP
very simple protocol to receive RC cmds via UDP
Add support for it on the bebop
2015-09-07 12:10:08 +10:00
Lucas De Marchi 0000ff45cb AP_HAL_Linux: RCOutput_PCA9685: remove trailing whitespace 2015-09-03 18:43:21 +10:00
Lucas De Marchi 18321a77c4 AP_HAL_Linux: rename RCOutput_Navio to RCOutput_PCA9685
The RCOutput_Navio is now generic enough to be used by other boards.
Rename it to use the name of the chip, PCA9685.
2015-09-03 18:43:21 +10:00
Lucas De Marchi e1f0284df2 AP_HAL_Linux: PCA9685: build on all Linux boards 2015-09-03 18:43:21 +10:00
Fabio Mello c0caed1b64 AP_HAL_Linux: RCOutput_Navio: allow to use internal clock
It's possible to use the internal clock in PCA96895 if we account for
the drift it contains. This is a bit different from solutions in other
projects like the Adafruit library and the PX4 firmware: instead of
applying a correction to the final frequency we apply the correction to
the clock since this is the source of the error.

With this fix we arrived to much better results across different lots of
sensors.

The Navio board continues to use the external clock and should have no
difference behavior.
2015-09-03 18:43:21 +10:00
Lucas De Marchi 6c042b6666 AP_HAL_Linux: RCOutput_Navio: allow to have other offset 2015-09-03 18:43:21 +10:00
Lucas De Marchi 3beaf34aa1 AP_HAL_Linux: RCOutput_Navio: allow to have other OE pin
While at it also rename enable_pin to follow the convention of starting
with underscore for private members.
2015-09-03 18:43:21 +10:00
Gustavo Jose de Sousa 4af2a9a9cc AP_HAL_Linux: SPI: adapt to the new signature of transaction() 2015-09-01 20:26:05 +10:00
Lucas De Marchi dabfeff440 AP_HAL_Linux: 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 124b750c10 AP_HAL_Linux: 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 45a7c37734 HAL_Linux: added bcast flag for udp broadcast 2015-07-29 16:46:53 +10:00
Andrew Tridgell b99740cb93 HAL_Linux: sped up UDP transfers by about 25x
allow more than 1 packetised transfer per tick
2015-07-29 14:19:46 +10:00
Andrew Tridgell a5c7aa1b19 HAL_Linux: allow startup before network bringup
this makes it possible to bootup ardupilot before the desired network
interface is available. This is very useful for when using 3G dongles
in aircraft
2015-07-29 09:55:47 +10:00
Andrew Tridgell 55fc66ec65 HAL_Linux: implemented TCP server as a single driver
the wait flag just changes startup behaviour. The TCP server should
always be a server with listen and accept. We don't need two drivers
2015-07-29 09:37:57 +10:00
Andrew Tridgell f72d9c6393 HAL_Linux: replace recvfrom with recv 2015-07-29 08:39:29 +10:00
Andrew Tridgell 3f3aaa3c50 HAL_Linux: removed 0 timeout from sendto call 2015-07-29 08:36:50 +10:00
Staroselskii Georgii aa3efecef3 AP_HAL_Linux: fixed _parseDevicePath() in LinuxUARTDRiver
The current implementation doesn't throw an error on a malformed path string.

i.e. udp:192.168.1.1.14550 instead of udp:192.168.1.1:14550 may result in a memory leak or whatsoever.

The commit fixes the issue and outputs a nice error message if anything's wrong.
2015-07-29 08:36:09 +10:00
Staroselskii Georgii 0362128265 AP_HAL_Linux: renamed TCPClientDevice 2015-07-29 08:36:09 +10:00
Staroselskii Georgii 211acbec9c AP_HAL_Linux: renamed TCPServerDevice
A more appropriate name for the class.
2015-07-29 08:36:08 +10:00
Staroselskii Georgii a3f47878a2 AP_HAL_Linux: made UARTDriver use TCPServerDevice 2015-07-29 08:36:08 +10:00
Staroselskii Georgii 56f760f022 AP_HAL_Linux: added TCPServerDevice 2015-07-29 08:36:08 +10:00
Staroselskii Georgii eacc085289 AP_HAL_Linux: made UARTDriver use TCPClientDevice 2015-07-29 08:36:07 +10:00
Staroselskii Georgii a5ef931f5c AP_HAL_Linux: added TCPClientDevice 2015-07-29 08:36:07 +10:00
Staroselskii Georgii 6e34dd9669 AP_HAL_Linux: got rid of TCP connection 2015-07-29 08:36:07 +10:00
Staroselskii Georgii de6b2b4bce AP_HAL_Linux: made UARTDriver use ConsoleDevice 2015-07-29 08:36:07 +10:00
Staroselskii Georgii a9c9d91f09 AP_HAL_Linux: added ConsoleDevice 2015-07-29 08:36:06 +10:00
Staroselskii Georgii 6ec67a9bfd AP_HAL_Linux: made UARTDriver use UDPDevice 2015-07-29 08:36:06 +10:00
Staroselskii Georgii 1881878c3a AP_HAL_Linux: added UDPDevice 2015-07-29 08:36:06 +10:00
Staroselskii Georgii 656399541f AP_HAL_Linux: encapsulated LinuxUARTDriver::_deallocate_buffers 2015-07-29 08:36:06 +10:00
Staroselskii Georgii f117134443 AP_HAL_Linux: made UARTDriver use UARTDevice 2015-07-29 08:36:05 +10:00
Staroselskii Georgii acd180ae96 AP_HAL_Linux: added UARTDevice 2015-07-29 08:36:05 +10:00
Staroselskii Georgii 6b94fd7603 AP_HAL_Linux: added SerialDevice interface
Adds the interface that will be used for encapsulating various mediums
that can be used in the Linux port.
2015-07-29 08:36:05 +10:00
Staroselskii Georgii dacbdb57c4 AP_HAL_Linux: added _serial_start_connection 2015-07-29 08:36:05 +10:00
Staroselskii Georgii 44198bd4eb AP_HAL_Linux: encapsulated LinuxUARTDriver::allocate_buffers 2015-07-29 08:36:04 +10:00
Staroselskii Georgii 94de9416fe AP_HAL_Linux: use defines instead of hardcoding fd numbers in UARTDriver 2015-07-29 08:36:04 +10:00
Jean-Baptiste Dubois f6aba6c952 HAL_Linux: add read_obs_data to RCOutput_Bebop 2015-07-23 21:49:28 +09:00
Staroselskii Georgii d7ac725a64 AP_HAL_Linux: fixed signal handler in RCInput_Navio
DMA is getting stopped in the separate method now. This is the best we
can get at the current time. It does yield slightly better experience
and works in the majority of cases.

The patch is a no bulletproof solution, though.

There's a possibility of corruption in case of e.g. a SIGKILL. There's
no signal framework at the time and the commit doesn't add one. That's
why all signals are handled in the same erroneous way. This is not a
good nor a final solution to the issue.

For the issue at hand a better fix might be porting the code to kernel
space but it's a rather tediuos task that we cannot undertake in the
couple of weeks.
2015-07-23 08:51:38 +10:00
Staroselskii Georgii 8528a7d159 AP_HAL_Linux: added deinit logic for RCInput_Navio
DMA needs to be stopped if a panic occurs.
2015-07-23 08:51:37 +10:00
Staroselskii Georgii f4d14f73ba AP_HAL_Linux: extended panic handling with RCInput deinitialization
The issue has already come up. There's no deinitialization mechanisms at the moment. As APM is rather software than firmware on Linux, there're some clean-up work that needs to be done. This commit triggers deinitialization of RCInput on a panic.
2015-07-23 08:51:37 +10:00
Lucas De Marchi cfc2972e51 AP_HAL_Linux: use ARRAY_SIZE macro 2015-07-21 14:24:58 +09:00
Jean-Baptiste Dubois 7dcfe1c667 RCOutput_Bebop: group channels write 2015-07-20 09:23:13 +10:00
Jean-Baptiste Dubois 9e5d13c1de RCOutput_Bebop: use CLOCK_MONOTONIC instead of CLOCK_REALTIME
CLOCK_MONOTONIC is not affected by discontinuous jumps in the system time.
2015-07-15 12:08:44 +02:00
Staroselskii Georgii 72820303d4 AP_HAL_Linux: set higher SPI speed for Navio
We can set a higher speed on newer Linux kernels since
52469b2a38.
The older ones will just floor the value.
2015-07-10 18:59:18 +10:00
Julien BERAUD 954ec71630 HAL_Linux: added rcout implementation for bebop 2015-07-10 16:46:30 +10:00
Julien BERAUD 7275e33e79 AP_HAL: add the possibility to have more than 1 i2c
Bebop drone has 3 i2c
2015-07-10 14:23:17 +10:00
Daniel Frenzel c49e44d02c HAL_LInux: RCInput for Navio
Cleaned the code a bit

Signed-off-by: Daniel Frenzel <dgdanielf@gmail.com>
2015-07-06 11:19:33 +10:00
Lucas De Marchi fde43a77b3 AP_HAL_Linux: allow to change spi device state
Allowing to change the SPI device state allows us to save the
information whether the device was already initialized and avoid 2
separate drivers to initialize it.
2015-07-06 10:48:06 +10:00
mirkix e6363ea95d AP_HAL_Linux: BBBMINI uses /dev/i2c-2 2015-07-06 10:09:21 +10:00
Lucas De Marchi b211b86204 AP_HAL_Linux: don't manually define number of spi devices
It's error-prone, let's make the compiler define it for us.
2015-07-06 10:07:22 +10:00
Andrew Tridgell 5f0302ed9f HAL_Linux: fixed chaining of getopt calls 2015-07-01 20:44:07 +10:00
Andrew Tridgell 355575f793 HAL_Linux: fixed chaining of getopt instances 2015-07-01 15:42:07 +10:00
Andrew Tridgell c8a6a02be1 HAL_Linux: don't do chardev test on subtype NONE
otherwise replay is broken
2015-07-01 15:36:34 +10:00
Andrew Tridgell 281f6d9caa HAL_Linux: cope with expansion of storage from 4096 to 16k 2015-06-30 16:45:49 +10:00
Gustavo Jose de Sousa 87776d8a4b Storage: define LINUX_STORAGE_SIZE correctly
The value for LINUX_STORAGE_SIZE was defined inconsistently against the one
defined for Linux boards in HAL_STORAGE_SIZE. That led to some values not
being written to the storage when running the test binary built at
libraries/StorageManager/examples/StorageTest.
2015-06-30 16:37:08 +10:00
Andrew Tridgell 761b39be03 HAL_Linux: removed extra include 2015-06-30 15:09:52 +10:00
Andrew Tridgell a3c7297d8e HAL_Linux: fixed setting of custom directories 2015-06-30 15:08:10 +10:00
Víctor Mayoral Vilches 2e7a4aa1e6 HAL_Linux: Implement custom dir. methods 2015-06-30 14:36:42 +10:00