Commit Graph

490 Commits

Author SHA1 Message Date
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
Víctor Mayoral Vilches 5c4ae15deb HAL_Linux: Make use of GetOptLong
Use GetOptLong to process long args, support
custom terrain and log directories and update
_usage().
2015-06-30 14:36:00 +10:00
Víctor Mayoral Vilches 309511dc08 HAL_Linux: UARTDriver, const device_path
Class member set to const and set_device_path
accepts a const char* now.
2015-06-30 14:36:00 +10:00
Víctor Mayoral Vilches 790f4ec56c HAL_Linux: Util fix indentation 2015-06-30 14:35:59 +10:00
Lucas De Marchi 623c5f0713 AP_HAL_Linux: check if I2C device is chardev 2015-06-30 09:10:54 +10:00
Lucas De Marchi acc571c2c5 AP_HAL_Linux: add function to check if path is chardev
Utility function to allow checking if a certain path is a character
device.
2015-06-30 09:10:54 +10:00
Lucas De Marchi a4c1b0d75f AP_HAL_Linux: add constructor to find I2C bus reliably
The device number in /dev may not be reliable from one boot to another
due to the initialization order of each bus.

For example, in Minnow Board Max, the exposed I2C buses may be i2c-7 and
i2c-8 or i2c-8 and i2c-9 depending if the platform driver in the kernel
is initialized before or after the PCI.

It also may change with different version and configuration of the DT or
UEFI used making another kernel driver to bind to the device. This means that
for Minnow Board Max we need to use something like below to pass to the
constructor:

	static const char * const i2c_devpaths[] = {
	    /* UEFI with lpss set to ACPI */
	    "/devices/platform/80860F41:05",
	    /* UEFI with lpss set to PCI */
	    "/devices/pci0000:00/0000:00:18.6",
	     NULL
	};

The devpath here is the one returned by udev with the following command:

	udevadm info -q path /dev/<i2c-device>

In contrary to the device number in /dev/i2c-N, this path in sysfs is
stable across reboots and can only change if there's a change in the
UEFI firmware or the board's device tree.

This patch assumes the currently supported boards don't have this
problem so it's not touching them.
2015-06-30 09:10:54 +10:00
Lucas De Marchi ec5d0b6c08 AP_HAL_Linux: reorder members and methods and use C++ initializer 2015-06-30 09:10:53 +10:00
Vladislav Zakharov be4b6033e4 AP_HAL_Linux: Navio RCInput reimplemented. 2015-06-29 16:45:43 +10:00
Vladislav Zakharov e505eb2cd8 AP_HAL_Linux: Changes in Scheduler: Added defines for delays, RCIN_RERIOD changed 2015-06-29 16:45:42 +10:00
Víctor Mayoral Vilches ab5f1b3a24 BusTest: Fix compilation error with AP_ADC 2015-06-26 21:59:22 +10:00
mirkix 7c55689aad AP_HAL_Linux: Fix loading Firmware 2015-06-18 10:13:49 +10:00
Andrew Tridgell c44ab01be8 AP_HAL: use noreturn attribute on panic
should reduce coverity warnings
2015-06-08 21:09:08 +10:00
Andrew Tridgell dbff6cab43 HAL_Linux: added udp example to help 2015-06-03 21:47:01 +10:00
Andrew Tridgell dd10cbc976 AP_HAL_Linux: convert example from .pde to .cpp 2015-06-01 17:03:44 +10:00
Andrew Tridgell 7e264b44df HAL_Linux: fixed functor comparison 2015-05-26 15:14:50 +10:00
Lucas De Marchi 4c97d92982 AP_HAL_Linux: use functor macros
Functor is not yet being used but let's make is macro fallback to the
previous Delegate implementation for easy of transition between the two.
2015-05-26 13:46:53 +10:00
Andrew Tridgell 0619247992 HAL_Linux: don't advance time in delay() and delay_microseconds()
this could cause time to go backwards in Replay. Thanks to Peter for
finding this
2015-05-19 13:17:15 +10:00
Andrew Tridgell b09fcfc20e HAL_Linux: cope with systems without I2C_RDRW_IOCTL_MAX_MSGS
such as my ubuntu 14.04 laptop :-)
2015-05-05 21:42:46 +10:00
Lucas De Marchi d640bc8345 AP_HAL_Linux: use kernel's limit of msgs per I2C transaction
Instead of hardcoding 8 as the limit for I2C msgs, use whatever the
kernel exported to us.  In upstream this is 42 so it means we can group
together 21 addr/data pair instead of only 8.
2015-05-05 09:56:44 +10:00
Andrew Tridgell 179e47c618 HAL_Linux: prevent time from going backwards in Replay 2015-04-20 15:12:51 +10:00
Staroselskii Georgii dff430e136 AP_HAL_Linux: added UART port for second GPS 2015-04-14 15:59:34 +10:00
Staroselskii Georgii da6316ed4c AP_HAL_Linux: fixed TCP client connection in LinuxUARTDriver 2015-04-14 15:59:33 +10:00
Staroselskii Georgii 716fd56c62 AP_HAL_Linux: added support for dynamic speed configration in LinuxSPIUARTDriver 2015-04-14 10:45:49 +10:00
Staroselskii Georgii baf2b4da4e AP_HAL_Linux: renamed AnalogIn_Navio 2015-04-14 10:16:26 +10:00
Staroselskii Georgii 930aeaf556 AP_HAL_Linux: add RPi version runtime detection 2015-04-14 10:16:25 +10:00
Mikhail Avkhimenia c11304ba7a AP_HAL_Linux: change GPIO register address for Raspberry Pi 2 2015-04-14 10:16:25 +10:00
Staroselskii Georgii 641fa05028 AP_HAL_Linux: added buffering in RCOutput_Navio 2015-04-14 10:16:25 +10:00
Staroselskii Georgii e6c2977da2 AP_HAL_Linux: fixed style in RCOutput_Navio 2015-04-14 10:16:25 +10:00
Staroselskii Georgii 024825f95a AP_HAL_Linux: fixed PCA9685 initialization for RCOutput_Navio 2015-04-14 10:16:25 +10:00
Staroselskii Georgii 2a137b6ea9 AP_HAL_Linux: fixed RCInput initialization on NavIO 2015-04-14 10:16:24 +10:00
Andrew Tridgell 7f7d92913e HAL_Linux: allow running as non-root
this is needed for Replay, plus is very useful for debugging
2015-04-14 09:25:35 +10:00
Lucas De Marchi f049c8e4c5 AP_HAL_Linux: remove needless call to mlockall()
All threads share the same address space and have the same pages locked
into memory so it's not necessary to call mlockall() for each of them.

Grepping /proc/<tid>/status gives the same VmLck for all of them, even
when only the main thread locks the memory:

    # for i in `seq 477 482`; do \
	name=$(cat /proc/$i/comm); \
	vm=$(cat /proc/$i/status |grep VmLck); \
        echo -e "$name\t$vm"; \
    done
    ArduCopter.elf  VmLck:     57868 kB
    sched-timer     VmLck:     57868 kB
    sched-uart      VmLck:     57868 kB
    sched-rcin      VmLck:     57868 kB
    sched-tonealarm VmLck:     57868 kB
    sched-io        VmLck:     57868 kB
2015-04-14 09:17:21 +10:00
Lucas De Marchi b7355dc62b AP_HAL_Linux: set thread name for ease debug
Use pthread_setname_np() to set thread name so it's easier to debug
what't going on with each of them. This is the example output of the
relevant par of "ps -Leo class,rtprio,wchan,comm":

FF      12 futex_ ArduCopter.elf
FF      15 usleep sched-timer
FF      14 hrtime sched-uart
FF      13 poll_s sched-rcin
FF      11 hrtime sched-tonealarm
FF      10 hrtime sched-io
2015-04-14 09:17:21 +10:00
Lucas De Marchi 2c48434110 AP_HAL_Linux: use a table to initialize threads
Refactor function calls into a table and pass in the name so it can be
used in error message.
2015-04-14 09:17:21 +10:00
Lucas De Marchi e3d78b8960 AP_HAL_Linux: fix passing callback to member function
It's undefined behavior to pass the callback to pthread to a class
member like we were doing. Refactor the code so the callbacks are static
members.

This fixes the following warnings:

libraries/AP_HAL_Linux/Scheduler.cpp: In member function 'virtual void Linux::LinuxScheduler::init(void*)':
/home/lucas/p/dronecode/ardupilot/libraries/AP_HAL_Linux/Scheduler.cpp:61:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_timer_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:65:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_uart_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:69:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_rcin_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:73:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_tonealarm_thread);
                                                                            ^
libraries/AP_HAL_Linux/Scheduler.cpp:77:76: warning: converting from 'void* (Linux::LinuxScheduler::*)()' to 'Linux::LinuxScheduler::pthread_startroutine_t {aka void* (*)(void*)}' [-Wpmf-conversions]
                            (pthread_startroutine_t)&Linux::LinuxScheduler::_io_thread);
2015-04-14 09:17:20 +10:00
Lucas De Marchi 62c2f737d5 AP_HAL_Linux: fix setting RT priorities
LinuxScheduler::init() was not really working as it should. This was the
result of "ps -Leo class,rtprio,wchan,comm | grep ArduCopter":

FF      12 futex_ ArduCopter.elf
FF      12 usleep ArduCopter.elf
FF      12 hrtime ArduCopter.elf
FF      12 poll_s ArduCopter.elf
FF      12 hrtime ArduCopter.elf
FF      12 hrtime ArduCopter.elf

As can be seen all the threads run with the same priority, the one of the main
thread. There were basically 2 mistakes:

	1) pthread_attr_setschedpolicy() needs to be called before
	   pthread_attr_setschedparam(). Otherwise the latter will just return
	   an error and not set the priority

	2) pthread_create() defaults to ignore the priority and inherit the
	   it from the parent thread. pthread_attr_setinheritsched() needs to
	   be called to change the behavior to PTHREAD_EXPLICIT_SCHED. See
	   pthread_attr_setinheritsched(3) for an example program to test the
	   behaviors.

Also, it's undefined behavior to call pthread_attr_init() several times on the
same pthread_attr_t. Although we could reutilize the same attribute without
calling  pthread_attr_init() again, lets refactor the code a little bit, so all
the pthread calls are in a single place. Then also call pthread_attr_destroy()
when we are done.
2015-04-14 09:17:20 +10:00
Lucas De Marchi 29b667efdf AP_HAL_Linux: remove useless mlock of stack
In Linux the default stack size is always greater than 32k, either 2MB
or 8MB depending on the architecture. There's no point in creating a
function to lock 32k.
2015-04-14 09:17:20 +10:00
mirkix 445f358839 AP_HAL_Linux: Fix compiler warning of MAX_PWMS redefinition (previously defined) 2015-04-06 15:34:50 -07:00
mirkix d4d42599b0 AP_HAL_Linux: Add RcInput and RcOutput with only one PRU when using a BBB. BBBMINI use the RC AIO PRU firmware already 2015-03-16 09:33:54 +11:00
mirkix a6b018eab9 AP_HAL_Linux: BBBMINI use kernel CS now 2015-03-16 09:15:06 +11:00
Staroselskii Georgii 75cd41a7c1 AP_HAL_Linux: added NavioAnalogIn 2015-02-12 12:57:45 +11:00
Staroselskii Georgii 195aa5fc6b AP_HAL_Linux: take the semaphore in SPIUARTDriver for shorter periods of time 2015-02-12 12:52:56 +11:00
Staroselskii Georgii 64da7f0360 AP_HAL_Linux: fix macro that defines number of I/O callbacks 2015-02-12 12:52:56 +11:00
Staroselskii Georgii 5b21bd2f1d AP_HAL_Linux: make Ublox transactions shorter 2015-02-12 12:52:56 +11:00
Staroselskii Georgii 4034004194 AP_HAL_Linux: switch NavIO to kernel CS handling 2015-02-12 12:52:56 +11:00
Andrew Tridgell 33a3254d8b HAL_Linux: accept a smaller sync pulse width 2015-02-08 21:47:28 +11:00
Andrew Tridgell 61be4ce2d2 HAL_Linux: fixed #if for linux builds 2015-01-22 15:58:20 +11:00
Víctor Mayoral Vilches 2b74d018fe HAL_Linux: Adjust set_system_clock
Do nothing for HAL_BOARD_SUBTYPE_NONE.
2015-01-22 15:43:16 +11:00
Víctor Mayoral Vilches 974f243c7e HAL_Linux: Add set_system_clock 2015-01-22 15:43:16 +11:00
mirkix c58a022111 AP_HAL_Linux: add support for BBBMINI, simple ArduPilot DIY Cape for the BeagleBone Black 2015-01-12 21:36:40 +13:00
Mikhail Avkhimenia 954b0795d4 HAL_Linux: Enable PCA9685 output after its setup 2015-01-09 06:38:21 +11:00
Andrew Tridgell 4da0a24887 HAL_Linux: use common RingBuffer.h 2015-01-07 08:41:14 +11:00
Staroselskii Georgii e4a21f291d AP_HAL_Linux: added LinuxSPIUARTDriver that can handle SPI-driven Ublox 2015-01-07 08:41:12 +11:00
Staroselskii Georgii 2b589d4604 AP_HAL_Linux: enable output for PCA9685 PWM in NavioRCOuput 2015-01-07 08:41:12 +11:00
Andrew Tridgell 193bda068c HAL_Linux: run IO processes when we do a stop_clock()
this has the effect of allowing logging to progress in Replay where we
are running at much more than realtime speeds
2014-12-08 11:24:39 +11:00
John Williams d0e467aea0 AP_HAL_Linux: Bypass manual CS assertion for SPI_CS_KERNEL mode
Missed from initial patch series

Signed-off-by: John Williams <john@whelanwilliams.net>
2014-11-27 15:57:12 +11:00
Mikhail Avkhimenia 955753f3f0 HAL_Linux: Optimize bandwidth for RCOutput_Navio
40% less bytes in I2C transactions for PCA9685.
2014-11-26 11:14:44 +11:00
Mikhail Avkhimenia 50459bdca0 HAL_Linux: Enable external clk for RCOutput_Navio
That should fix PWM value drifts.
2014-11-26 11:14:44 +11:00
Andrew Tridgell 22cb1c8525 HAL_Linux: tidy up SPI debugging a bit 2014-11-26 10:16:39 +11:00
John Williams 0fe3959d7e AP_HAL_Linux: Add support for in-kernel SPI CS handling
Add support for /dev/spidev<bus>.<cs> in-kernel SPI CS handling, and convert
existing SPI devices over.

 * Add a new member _subdev to the LinuxSPIDeviceDriver class, and initialiser
   in LinuxSPIDevice constructor.  Use subdev 0 for GPIO-managed CS
 * Extend the _cs_pin to signed 16 bits and define SPI_CS_KERNEL (-1) for
   kernel-managed CS
 * Move to per-device file descriptors (required for in-kernel CS)
 * Extend spidev filenames to include bus and subdevice numbers, possibly
   longer than 1 digit each
 * Allow support for platforms enumerating /dev/spidevNNN from non-zero bases
 * Convert existing users over to the new API

Signed-off-by: John Williams <john@whelanwilliams.net>
2014-11-26 09:55:09 +11:00
Andrew Tridgell 7497b4dfb1 HAL_Linux: fixed Replay with new AP_InertialSensor library 2014-11-16 12:30:50 +11:00
bugobliterator 9d39c0407e HAL_Linux: added ToneAlarmDriver.h 2014-11-15 21:25:55 +11:00
bugobliterator 329c1f5190 HAL_Linux:create ToneAlarmDriver as a separate class
ToneAlarm is now declared as a separate class instance of which is added as a private member of LinuxUtil
Some minor fixes in this patch include changing return type of tonealarm_init() to bool and use dprintf
2014-11-15 16:59:06 +11:00
bugobliterator f058131140 HAL_Linux Scheduler: reduce the delay inside tonealarm thread
Since the tonealarm is now passthrough the delay inside the thread needs to be reduced for precise tune generation
2014-11-15 16:59:06 +11:00
bugobliterator 3b94cb3072 HAL_Linux: make tonealarm generation a passthrough operation
get rid of all delays and while loops(that may turn into infinite loop)
2014-11-15 16:59:06 +11:00
bugobliterator e254b406d0 HAL_Linux: make rtttl tune and tune repeat flag list static members
instead of initialising them inside constructor
2014-11-15 16:59:06 +11:00
Andrew Tridgell c8c822422a HAL_Linux: give error msg on failure to start toneAlarm 2014-11-15 16:58:58 +11:00
John Williams 57d2fc1dd5 HAL_Linux: RCInput support for Zynq 2014-11-14 14:10:35 +11:00
Staroselskii Georgii a55db1c25d AP_HAL_Linux: fixed LinuxGPIO_RPI::read() 2014-11-14 10:28:34 +11:00
Mikhail Avkhimenia 49d3035ee5 HAL_Linux: fix types, remove printfs in GPIO_RPI 2014-11-14 10:28:34 +11:00
Mikhail Avkhimenia 6f993fe64a HAL_Linux: add prototype RCInput code for Navio 2014-11-14 10:28:34 +11:00
Staroselskii Georgii ef420a2544 AP_HAL_Linux: changed SPI mode for MPU9250 2014-11-14 10:28:34 +11:00
Staroselskii Georgii bf860ee41f AP_HAL_Linux: Ublox SPI stub 2014-11-14 10:28:34 +11:00
Víctor Mayoral Vilches ce4c4c43dc AP_HAL_Linux: Scheduler reboot fix
exit from the autpilot when reboot is commanded.
The software assumes that the code is being
launched in an infinite loop thereby an exit
will make it reboot.
2014-11-14 10:27:19 +11:00
John Williams ae87399919 HAL_Linux: Basic Zynq Linux platform support
Preliminary support for Zynq/Linux on the 'ZyboPilot' HW platform.

see https://github.com/trjw/ZyboPilot-bsp for the PetaLinux / Vivado project
files.

At this stage CPPM/Pulse in and PWM out work, and in CLI mode the passthru
test works correctly.

The platform has passed minimal smoke testing in HIL mode.

ZYNQ IS NOT FLIGHT TESTED YET!  FLY THIS PLATFORM AT YOUR OWN RISK!

Signed-off-by: John Williams <john@whelanwilliams.net>
2014-11-14 10:21:04 +11:00
Andrew Tridgell 00526359b0 HAL_Linux: use dprintf() instead of sprintf and write 2014-11-10 06:51:53 +11:00
bugobliterator af203760bd HAL_Linux: change the return type of AP_HAL::Util::tonealarm_init() to signed int8_t.
This is a part of a set of fixes for the bugs and typos tridge discovered and shared inside earlier commits for setting up tonealarm.
2014-11-10 06:27:48 +11:00
bugobliterator 298b27444a HAL_Linux: Add ToneAlarm Driver to Linux_HAL
ToneAlarm is setup for Beaglebone Black using pwm, toneAlarm thread runs on second last priority.
2014-11-10 06:27:48 +11:00
Andrew Tridgell 02581f4c05 HAL_Linux: re-fix dirty mask bug in Storage
when conversion to a single parent class was done it re-introduced a
bug that was fixed a while ago

See commit d238ff7c5d
2014-11-08 11:55:55 +11:00
Andrew Tridgell 330dab2fe3 HAL_Linux: fixed some warnings 2014-11-08 11:49:09 +11:00
bugobliterator 4908e335d2 HAL_Linux: Add Storage.cpp containing common storage class member definitions 2014-11-08 11:36:12 +11:00
bugobliterator dd6d520385 HAL_Linux:Create subclass to handle FRAM Storage under main Storage Class 2014-11-08 11:36:09 +11:00
Andrew Tridgell 14a6878bcd HAL_Linux: fixed termios settings on BBB initial boot
this should fix the problem of losing the GPS in flight
2014-11-07 22:15:28 +11:00
Andrew Tridgell 8506e8b5fb HAL_Linux: fixed linux build 2014-10-30 17:47:18 +11:00
John Williams b9f0310b82 hal_ap_linux: Make PRU constants private to reduce #define namespace pollution.
Forthcoming Zynq port AP_HAL_Linux uses similar constants with different
values - move these as private member constants to avoid collisions.

Signed-off-by: John Williams <john@whelanwilliams.net>
2014-10-30 13:51:41 +11:00
Mikhail Avkhimenia 81de994fef HAL_Linux: separate RCInput for PRU and Navio 2014-10-30 13:30:07 +11:00
Mikhail Avkhimenia e05151f0e0 HAL_Linux: Initialize i2c before rcoutput (required by i2c pwm chips for initialization) 2014-10-30 13:30:07 +11:00
Mikhail Avkhimenia 2f0900b0a8 HAL_Linux: add GPIO driver for Raspberry Pi 2014-10-30 13:30:07 +11:00
Mikhail Avkhimenia 07ed93cea0 HAL_Linux: add PCA9685 based RCOutput for Navio 2014-10-30 13:30:07 +11:00
Alexander Mergel 14c401c0f4 AP_HAL_Linux: [Bugfix] prevent memory acces violation in process_dsm_pulse
When a S.Bus signal is fed into the rcin-Pin AruPlane on the BBB get's a
Segmentation fault. This patch prevents the memory acces to dsm_state.bytes[16] outside
of the array bounds. The patch should be reviewed by sombody who knows the DSM protocol,
as i don't.
2014-10-30 11:57:35 +11:00
Andrew Tridgell 39fadad7d6 HAL_Linux: fixed build warnings 2014-10-09 16:49:23 +11:00
Andrew Tridgell c834589daa HAL_Linux: reduce the number of times we split up UART reads 2014-10-09 12:29:25 +11:00
Andrew Tridgell 076bb1294e HAL_Linux: improved UDP packetisation and add flow control reporting
report we have flow control on UDP and TCP
2014-10-09 12:29:25 +11:00
Andrew Tridgell cebfef3ead HAL_Linux: don't accept less than 5 input channels 2014-10-09 09:19:35 +11:00
Andrew Tridgell a3fee16604 HAL_Linux: added DSM/Spektrum RCInput support
this decodes DSM using the RCIN pulses from the PRU
2014-10-08 12:50:50 +11:00
Andrew Tridgell 3e3f87188b HAL_Linux: enable DSM power pin 2014-10-08 12:50:50 +11:00