From 52f560a4c277fa1021ba0350c21389f626659d90 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Mon, 21 Jan 2013 13:56:57 +1100 Subject: [PATCH] HAL_PX4: enabled AnalogIn driver --- libraries/AP_HAL_PX4/AP_HAL_PX4_Namespace.h | 2 ++ libraries/AP_HAL_PX4/HAL_PX4_Class.cpp | 18 +++++++++++------- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/libraries/AP_HAL_PX4/AP_HAL_PX4_Namespace.h b/libraries/AP_HAL_PX4/AP_HAL_PX4_Namespace.h index 2a71997214..fb3f865b85 100644 --- a/libraries/AP_HAL_PX4/AP_HAL_PX4_Namespace.h +++ b/libraries/AP_HAL_PX4/AP_HAL_PX4_Namespace.h @@ -9,6 +9,8 @@ namespace PX4 { class PX4EEPROMStorage; class PX4RCInput; class PX4RCOutput; + class PX4AnalogIn; + class PX4AnalogSource; } #endif //__AP_HAL_PX4_NAMESPACE_H__ diff --git a/libraries/AP_HAL_PX4/HAL_PX4_Class.cpp b/libraries/AP_HAL_PX4/HAL_PX4_Class.cpp index 3e00469670..18dda4fb83 100644 --- a/libraries/AP_HAL_PX4/HAL_PX4_Class.cpp +++ b/libraries/AP_HAL_PX4/HAL_PX4_Class.cpp @@ -13,6 +13,7 @@ #include "Storage.h" #include "RCInput.h" #include "RCOutput.h" +#include "AnalogIn.h" #include #include @@ -29,7 +30,6 @@ using namespace PX4; static Empty::EmptySemaphore i2cSemaphore; static Empty::EmptyI2CDriver i2cDriver(&i2cSemaphore); static Empty::EmptySPIDeviceManager spiDeviceManager; -static Empty::EmptyAnalogIn analogIn; static Empty::EmptyGPIO gpioDriver; static Empty::EmptyUtil utilInstance; @@ -38,6 +38,7 @@ static PX4Scheduler schedulerInstance; static PX4EEPROMStorage storageDriver; static PX4RCInput rcinDriver; static PX4RCOutput rcoutDriver; +static PX4AnalogIn analogIn; #define UARTA_DEFAULT_DEVICE "/dev/ttyS0" #define UARTB_DEFAULT_DEVICE "/dev/ttyS3" @@ -64,7 +65,7 @@ HAL_PX4::HAL_PX4() : &utilInstance) /* util */ {} -static bool thread_should_exit = false; /**< Daemon exit flag */ +bool _px4_thread_should_exit = false; /**< Daemon exit flag */ static bool thread_running = false; /**< Daemon status flag */ static int daemon_task; /**< Handle of daemon task / thread */ @@ -75,17 +76,18 @@ static int main_loop(int argc, char **argv) extern void setup(void); extern void loop(void); - hal.uartA->begin(115200); + hal.uartA->begin(57600); hal.console->init((void*) hal.uartA); hal.scheduler->init(NULL); hal.rcin->init(NULL); hal.rcout->init(NULL); + hal.analogin->init(NULL); setup(); hal.scheduler->system_initialized(); thread_running = true; - while (!thread_should_exit) { + while (!_px4_thread_should_exit) { loop(); // yield the CPU for 1ms between loops to let other apps @@ -128,7 +130,7 @@ void HAL_PX4::init(int argc, char * const argv[]) const uartADriver.set_device_path(device); printf("Starting %s on %s\n", SKETCHNAME, device); - thread_should_exit = false; + _px4_thread_should_exit = false; daemon_task = task_spawn(SKETCHNAME, SCHED_RR, SCHED_PRIORITY_DEFAULT, @@ -139,12 +141,14 @@ void HAL_PX4::init(int argc, char * const argv[]) const } if (strcmp(argv[i], "stop") == 0) { - thread_should_exit = true; + _px4_thread_should_exit = true; exit(0); } if (strcmp(argv[i], "status") == 0) { - if (thread_running) { + if (_px4_thread_should_exit && thread_running) { + printf("\t%s is exiting\n", SKETCHNAME); + } else if (thread_running) { printf("\t%s is running\n", SKETCHNAME); } else { printf("\t%s is not started\n", SKETCHNAME);