2012-09-10 23:05:22 -03:00
|
|
|
|
|
|
|
#include <AP_Common.h>
|
2012-12-11 20:23:02 -04:00
|
|
|
#include <AP_Math.h>
|
|
|
|
#include <AP_Param.h>
|
2012-10-27 00:55:17 -03:00
|
|
|
#include <AP_Progmem.h>
|
2012-12-11 20:23:02 -04:00
|
|
|
|
2012-09-10 23:05:22 -03:00
|
|
|
#include <AP_HAL.h>
|
|
|
|
#include <AP_HAL_AVR.h>
|
2015-05-04 03:15:12 -03:00
|
|
|
#include <AP_HAL_SITL.h>
|
2013-02-21 21:48:29 -04:00
|
|
|
#include <AP_HAL_PX4.h>
|
|
|
|
#include <AP_HAL_Empty.h>
|
2015-01-28 04:10:34 -04:00
|
|
|
#include <StorageManager.h>
|
2012-09-10 23:05:22 -03:00
|
|
|
|
2013-02-21 21:48:29 -04:00
|
|
|
const AP_HAL::HAL& hal = AP_HAL_BOARD_DRIVER;
|
2012-09-10 23:05:22 -03:00
|
|
|
|
2013-05-02 08:31:55 -03:00
|
|
|
AP_HAL::AnalogSource* ch;
|
2012-09-10 23:05:22 -03:00
|
|
|
|
|
|
|
void setup (void) {
|
2013-02-21 21:50:47 -04:00
|
|
|
hal.console->printf_P(PSTR("Starting AP_HAL::AnalogIn test\r\n"));
|
2013-05-02 08:31:55 -03:00
|
|
|
ch = hal.analogin->channel(0);
|
2012-09-10 23:05:22 -03:00
|
|
|
}
|
|
|
|
|
2013-05-02 08:31:55 -03:00
|
|
|
static int8_t pin;
|
|
|
|
|
|
|
|
void loop (void)
|
|
|
|
{
|
|
|
|
float v = ch->voltage_average();
|
|
|
|
if (pin == 0) {
|
|
|
|
hal.console->println();
|
|
|
|
}
|
|
|
|
hal.console->printf_P(PSTR("[%u %.3f] "),
|
|
|
|
(unsigned)pin, v);
|
|
|
|
pin = (pin+1) % 16;
|
|
|
|
ch->set_pin(pin);
|
|
|
|
hal.scheduler->delay(100);
|
2012-09-10 23:05:22 -03:00
|
|
|
}
|
|
|
|
|
2012-12-03 20:25:11 -04:00
|
|
|
AP_HAL_MAIN();
|