Commit Graph

331 Commits

Author SHA1 Message Date
Lucas De Marchi f69208d47d AP_HAL: 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
Lucas De Marchi a1c3912bd8 AP_HAL: remove unused AP_ADC_AnalogSource 2015-12-03 13:32:43 +11:00
Caio Marcelo de Oliveira Filho 6e7b73610d waf: add waf support 2015-12-03 07:54:30 +11:00
Lucas De Marchi 036eb21c09 AP_HAL: remove init() method with unused argument 2015-12-02 14:49:12 -02:00
Lucas De Marchi 6bc07da0ee AP_HAL: 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:42:37 -02:00
Lucas De Marchi 6b1c5e6f72 AP_HAL: add init() method without argument
The argument in init() is not used by any implementation. Add a second
method without it so the HAL implementation can used it instead. Later
the unused method will be removed.
2015-12-02 14:21:58 -02: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
Andrew Tridgell 44c280e9fb AP_HAL: fixed typo in do_transfer declaration 2015-12-01 07:18:10 +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 0fa362ff5c AP_Notify: Fix GPIO declaration for Linux boards
Currently, the default behaviour on linux boards tries to
write LED gpios with fixed values among them. There is no way
to declare that there are no LED GPIOs.
This commit moves the declaration of the LED Gpios in AP_HAL_Boards.h
and makes AP_Notify do nothing if no LED gpio was declared
2015-12-01 07:07:26 +11:00
Julien BERAUD af6bbb806e AP_HAL: add do_transfer method to I2CDriver
Needed in linux HAL
2015-12-01 07:07:26 +11:00
Caio Marcelo de Oliveira Filho c5fc0deee9 AP_HAL_Scheduler: remove unused functions
Getting the time elapsed and panic are now functions in AP_HAL, so
remove them from HAL class interface and it's implementations.
2015-11-20 12:36:00 +09:00
Caio Marcelo de Oliveira Filho 5292bc0054 AP_HAL: example uses millis/micros/panic functions 2015-11-20 12:31:48 +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
Caio Marcelo de Oliveira Filho a348424551 AP_HAL: remove unused function
This was used by APM1/2 that were removed.
2015-11-18 11:50:56 +09:00
Andrew Tridgell 8f4ce7f20b build: removed all nocore.inoflag files
these were APM2 specific
2015-11-16 08:05:17 +11:00
José Roberto de Souza 6ece4d60aa AP_HAL: HAL_COMPASS_AK8963_MPU9250_I2C to the supported list 2015-11-11 14:29:07 +11:00
José Roberto de Souza b3f030f650 AP_HAL: Add MPU9250 over I2C 2015-11-11 14:29:07 +11:00
Andrew Tridgell 8a4c0593f2 AP_HAL: make available_memory() uint32_t 2015-11-05 16:09:00 +11:00
Víctor Mayoral Vilches 90a00553cb AP_HAL: Boards, add Erle-Brain 2 2015-11-04 13:58:24 +11:00
Lucas De Marchi 255e04a841 AP_HAL: remove check for AVR CPUs
Remove the checks for HAL_CPU_CLASS > HAL_CPU_CLASS_16 and
HAL_CPU_CLASS >= HAL_CPU_CLASS_75. Corresponding dead code will be
removed on separate commits.
2015-11-04 12:14:14 +11:00
Lucas De Marchi 3142f21363 AP_InertialSensor: remove checks for HAL_BOARD_APM2 and HAL_BOARD_APM1 2015-11-04 12:14:12 +11:00
Lucas De Marchi 8e65e88d06 AP_HAL: remove checks for HAL_BOARD_APM2 and HAL_BOARD_APM1 2015-11-04 12:14:11 +11:00
Lucas De Marchi 5244559010 Minimize AP_Progmem.h includes
Most of AP_Progmem is already gone so we can stop including it in most
of the places. The only places that need it are the ones using
pgm_read_*() APIs.

In some cases the header needed to be added in the .cpp since it was
removed from the .h to reduce scope. In those cases the headers were
also reordered.
2015-10-30 14:35:32 +09:00
Lucas De Marchi a65c98485c AP_HAL: UARTDriver: remove _P() variants
They aren't used anymore so remove.
2015-10-30 14:35:31 +09: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 2556fc8dbe BetterStream: use common macro for printf formatting
Since this needs an additional header, also put them in correct order.
2015-10-30 14:35:26 +09:00
Lucas De Marchi 20c6ffc5e3 Replace use of UARTDriver::printf_P() with UARTDriver::printf()
This also starts to show warnings on places that were already using
wrong printf format strings.
2015-10-30 14:35:25 +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 0aa117f65d Replace use of strnlen_P() with strnlen() 2015-10-30 14:35:13 +09:00
Lucas De Marchi a8455aa4e3 AP_HAL: Remove Util::{v,}snprintf_P() 2015-10-30 14:35:06 +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 2322b8014d AP_HAL: use common macro for printf formatting 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 0b4aa5ac85 AP_HAL: Scheduler: reorder includes
Follow the following order for includes:

   - Corresponding header file (if exists)
   - System headers
   - Other ArduPilot library headers
   - "Local" headers (from the same library)
2015-10-24 14:26:35 +11:00
Lucas De Marchi 79dee5aaa9 AP_HAL: fix warning due to missing prototype after HAL rework
This was introduced with the HAL rework:

In file included from /p/ardupilot/libraries/AP_HAL/AP_HAL.h:11:0,
                 from /p/ardupilot/ArduCopter/Copter.h:35,
                 from /p/ardupilot/ArduCopter/ArduCopter.cpp:76:
/p/ardupilot/ArduCopter/ArduCopter.cpp: In function 'int ArduPilot_main(int, char* const*)':
/p/ardupilot/libraries/AP_HAL/AP_HAL_Main.h:11:26: warning: no previous declaration for 'int ArduPilot_main(int, char* const*)' [-Wmissing-declarations]
 #define AP_MAIN __EXPORT ArduPilot_main
                          ^

It's due to PX4 using that warning as opposed to Linux. Since it harmless, add
the prototype for everybody.
2015-10-23 07:47:19 +11:00
Lucas De Marchi 8153f57f06 AP_HAL: add board definitions for minlure 2015-10-22 12:04:52 +11:00
Lucas De Marchi eef4d5819f AP_HAL: HAL: don't use relative includes
Includes in the same dir should not be relative. Also sort them
alphabetically.
2015-10-21 15:54:27 -02:00
Lucas De Marchi 74ccbdb6f7 AP_HAL: AnalogIn: add missing include
Since we are using uint8_t and uint16_t types we need to include the
correspondent system header. Otherwise it would depend on the include
order of who is including this particular header, causing failures as we
move headers around.
2015-10-21 15:54:27 -02:00
Caio Marcelo de Oliveira Filho b98bf2a65e AP_HAL: remove unnecessary includes from examples 2015-10-21 09:16:10 +11:00
Caio Marcelo de Oliveira Filho b29d6eff5d AP_HAL: add an AP_HAL_MAIN_CALLBACKS() macro
This is going to be used by vehicles that already have an object with
setup/loop functions. The vehicle object will just implement the
HAL::Callbacks interface.
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 6fc60e2d5e AP_HAL: remove unused init() from the interface
And make run() pure virtual to ensure future implementations provide it.
2015-10-21 09:16:08 +11:00
Caio Marcelo de Oliveira Filho 72cd5ef185 AP_HAL: add run() method
Add run method, that encapsulate any mainloop logic on behalf of the
client code. The setup/loop functions are passed via a HAL::Callbacks
interface. The AP_HAL_MAIN() macro should be kept as trivial as
possible.

This interface should be implemented by the existing vehicle objects. To
make easy for the examples (that don't have the equivalent of vehicle
objects), a FunCallbacks was added to bridge to the functions directly.
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
Andrew Tridgell 28fa05c965 AP_HAL: added generic perf counter
simple wrapper around PX4 API, but ready for use by other HALs
2015-10-20 18:09:57 +11:00
José Roberto de Souza 6215a3d224 AP_HAL: Add MS5637 over I2C to the supported barometers list 2015-10-16 10:05:03 +11:00