AP_HAL: expose argc/argv in hal.init()

used for SITL port
This commit is contained in:
Andrew Tridgell 2012-12-13 09:31:50 +11:00
parent ddafd4ffbb
commit 18824c7ef5
11 changed files with 23 additions and 11 deletions

View File

@ -42,7 +42,7 @@ public:
scheduler(_scheduler)
{}
virtual void init(void* opts) const = 0;
virtual void init(int argc, const char *argv[]) const = 0;
AP_HAL::UARTDriver* uartA;
AP_HAL::UARTDriver* uartB;

View File

@ -13,15 +13,16 @@
* and not expose implementation details.
*/
#if CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2
#define AP_HAL_MAIN() extern "C" {\
int main (void) {\
hal.init(NULL);\
hal.init(0, NULL); \
setup();\
for(;;) loop();\
return 0;\
}\
}
#endif
#endif // __AP_HAL_AVR_H__

View File

@ -2,7 +2,7 @@
#include "HAL_AVR.h"
using namespace AP_HAL_AVR;
void HAL_AVR::init(void* opts) const {
void HAL_AVR::init(int argc, const char *argv[]) const {
scheduler->init((void*)&isr_registry);

View File

@ -31,7 +31,7 @@ public:
_console, _gpio, _rcin,
_rcout, _scheduler) {}
void init(void* opts) const;
void init(int argc, const char *argv[]) const;
AP_HAL_AVR::ISRRegistry isr_registry;
};
#endif // __AP_HAL_AVR_HAL_AVR_H__

View File

@ -50,7 +50,7 @@ HAL_AVR_APM1::HAL_AVR_APM1() :
&avrScheduler )
{}
void HAL_AVR_APM1::init(void* opts) const {
void HAL_AVR_APM1::init(int argc, const char *argv[]) const {
scheduler->init((void*)&isrRegistry);

View File

@ -20,7 +20,7 @@
class HAL_AVR_APM1 : public AP_HAL::HAL {
public:
HAL_AVR_APM1();
void init(void* opts) const;
void init(int argc, const char *argv[]) const;
};
/**

View File

@ -49,7 +49,7 @@ HAL_AVR_APM2::HAL_AVR_APM2() :
&avrScheduler )
{}
void HAL_AVR_APM2::init(void* opts) const {
void HAL_AVR_APM2::init(int argc, const char *argv[]) const {
scheduler->init((void*)&isrRegistry);

View File

@ -20,7 +20,7 @@
class HAL_AVR_APM2 : public AP_HAL::HAL {
public:
HAL_AVR_APM2();
void init(void* opts) const;
void init(int argc, const char *argv[]) const;
};
/**

View File

@ -5,5 +5,16 @@
#include "AP_HAL_AVR_SITL_Namespace.h"
#include "HAL_AVR_SITL_Class.h"
#if CONFIG_HAL_BOARD == HAL_BOARD_AVR_SITL
#define AP_HAL_MAIN() extern "C" {\
int main (int argc, const char *argv[]) { \
hal.init(argc, argv); \
setup();\
for(;;) loop();\
return 0;\
}\
}
#endif
#endif // __AP_HAL_AVR_SITL_H__

View File

@ -38,7 +38,7 @@ HAL_AVR_SITL::HAL_AVR_SITL() :
&sitlScheduler) /* scheduler */
{}
void HAL_AVR_SITL::init(void* machtnichts) const {
void HAL_AVR_SITL::init(int argc, const char *argv[]) const {
scheduler->init(NULL);
uartA->begin(115200);

View File

@ -12,7 +12,7 @@
class HAL_AVR_SITL : public AP_HAL::HAL {
public:
HAL_AVR_SITL();
void init(void*) const;
void init(int argc, const char *argv[]) const;
};
extern const HAL_AVR_SITL AP_HAL_AVR_SITL;