From e18884a328a19f2c8b65fcb5129caca9a4c2558c Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Mon, 19 Oct 2015 13:59:47 -0200 Subject: [PATCH] AP_HAL_AVR: merge init() and run() --- libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.cpp | 13 ++++--------- libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.h | 1 - libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.cpp | 13 ++++--------- libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.h | 1 - 4 files changed, 8 insertions(+), 20 deletions(-) diff --git a/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.cpp b/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.cpp index be5e8cd56e..953d936da0 100644 --- a/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.cpp +++ b/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.cpp @@ -58,10 +58,12 @@ HAL_AVR_APM1::HAL_AVR_APM1() : &avrUtil ) {} -void HAL_AVR_APM1::init(int argc, char * const argv[]) const { +void HAL_AVR_APM1::run(int argc, char* const argv[], Callbacks* callbacks) const +{ + assert(callbacks); scheduler->init((void*)&isrRegistry); - + /* uartA is the serial port used for the console, so lets make sure * it is initialized at boot */ uartA->begin(115200); @@ -86,13 +88,6 @@ void HAL_AVR_APM1::init(int argc, char * const argv[]) const { PORTE |= _BV(0); PORTD |= _BV(2); PORTJ |= _BV(0); -}; - -void HAL_AVR_APM1::run(int argc, char* const argv[], Callbacks* callbacks) const -{ - assert(callbacks); - - init(argc, argv); callbacks->setup(); scheduler->system_initialized(); diff --git a/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.h b/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.h index edff329c10..9e05585433 100644 --- a/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.h +++ b/libraries/AP_HAL_AVR/HAL_AVR_APM1_Class.h @@ -20,7 +20,6 @@ class HAL_AVR_APM1 : public AP_HAL::HAL { public: HAL_AVR_APM1(); - void init(int argc, char * const argv[]) const; void run(int argc, char* const argv[], Callbacks* callbacks) const override; }; diff --git a/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.cpp b/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.cpp index 1520403c78..c4131e4494 100644 --- a/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.cpp +++ b/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.cpp @@ -57,10 +57,12 @@ HAL_AVR_APM2::HAL_AVR_APM2() : &avrUtil ) {} -void HAL_AVR_APM2::init(int argc, char * const argv[]) const { +void HAL_AVR_APM2::run(int argc, char* const argv[], Callbacks* callbacks) const +{ + assert(callbacks); scheduler->init((void*)&isrRegistry); - + /* uartA is the serial port used for the console, so lets make sure * it is initialized at boot */ uartA->begin(115200, 128, 128); @@ -85,13 +87,6 @@ void HAL_AVR_APM2::init(int argc, char * const argv[]) const { PORTE |= _BV(0); PORTD |= _BV(2); PORTH |= _BV(0); -}; - -void HAL_AVR_APM2::run(int argc, char* const argv[], Callbacks* callbacks) const -{ - assert(callbacks); - - init(argc, argv); callbacks->setup(); scheduler->system_initialized(); diff --git a/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.h b/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.h index b8cc539d3d..7ec081779e 100644 --- a/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.h +++ b/libraries/AP_HAL_AVR/HAL_AVR_APM2_Class.h @@ -20,7 +20,6 @@ class HAL_AVR_APM2 : public AP_HAL::HAL { public: HAL_AVR_APM2(); - void init(int argc, char * const argv[]) const; void run(int argc, char* const argv[], Callbacks* callbacks) const override; };