From dc03b1190ffa783f6088189b9cc2da1516d4585f Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Mon, 20 Aug 2012 11:37:46 -0700 Subject: [PATCH] AP_HAL: Stub implementations of pure virtual AP_HAL classes --- libraries/AP_HAL/AP_HAL.h | 23 ++++++++++ libraries/AP_HAL/AP_HAL_Namespace.h | 40 +++++++++++++++++ libraries/AP_HAL/AnalogIn.h | 14 ++++++ libraries/AP_HAL/Console.h | 14 ++++++ libraries/AP_HAL/GPIO.h | 13 ++++++ libraries/AP_HAL/HAL.h | 66 +++++++++++++++++++++++++++++ libraries/AP_HAL/I2CDriver.h | 14 ++++++ libraries/AP_HAL/Log.h | 14 ++++++ libraries/AP_HAL/PPMInput.h | 14 ++++++ libraries/AP_HAL/PWMOutput.h | 14 ++++++ libraries/AP_HAL/SPIDriver.h | 14 ++++++ libraries/AP_HAL/Storage.h | 14 ++++++ libraries/AP_HAL/UARTDriver.h | 19 +++++++++ 13 files changed, 273 insertions(+) create mode 100644 libraries/AP_HAL/AP_HAL.h create mode 100644 libraries/AP_HAL/AP_HAL_Namespace.h create mode 100644 libraries/AP_HAL/AnalogIn.h create mode 100644 libraries/AP_HAL/Console.h create mode 100644 libraries/AP_HAL/GPIO.h create mode 100644 libraries/AP_HAL/HAL.h create mode 100644 libraries/AP_HAL/I2CDriver.h create mode 100644 libraries/AP_HAL/Log.h create mode 100644 libraries/AP_HAL/PPMInput.h create mode 100644 libraries/AP_HAL/PWMOutput.h create mode 100644 libraries/AP_HAL/SPIDriver.h create mode 100644 libraries/AP_HAL/Storage.h create mode 100644 libraries/AP_HAL/UARTDriver.h diff --git a/libraries/AP_HAL/AP_HAL.h b/libraries/AP_HAL/AP_HAL.h new file mode 100644 index 0000000000..014e046095 --- /dev/null +++ b/libraries/AP_HAL/AP_HAL.h @@ -0,0 +1,23 @@ + +#ifndef __AP_HAL_H__ +#define __AP_HAL_H__ + +#include "AP_HAL_Namespace.h" + +/* HAL Module Classes (all pure virtual) */ +#include "UARTDriver.h" +#include "I2CDriver.h" +#include "SPIDriver.h" +#include "AnalogIn.h" +#include "Storage.h" +#include "Log.h" +#include "Console.h" +#include "GPIO.h" +#include "PPMInput.h" +#include "PWMOutput.h" + +/* HAL Class definition */ +#include "HAL.h" + +#endif // __AP_HAL_H__ + diff --git a/libraries/AP_HAL/AP_HAL_Namespace.h b/libraries/AP_HAL/AP_HAL_Namespace.h new file mode 100644 index 0000000000..65cc87860f --- /dev/null +++ b/libraries/AP_HAL/AP_HAL_Namespace.h @@ -0,0 +1,40 @@ + +#ifndef __AP_HAL_NAMESPACE_H__ +#define __AP_HAL_NAMESPACE_H__ + +namespace AP_HAL { + + /* Toplevel pure virtual class Hal.*/ + class HAL; + + /* Toplevel class names for drivers: */ + class UARTDriver; + class I2CDriver; + class SPIDriver; + class AnalogIn; + class Storage; + class Log; + class Console; + class GPIO; + class PPMInput; + class PWMOutput; + + /* AVR / Arduino Implementations for APM1 and APM2 */ + + class AVRUARTDriver; + class AVRI2CDriver; + class ArduinoSPIDriver; + class ArduinoAnalogIn; + class AVREEPROMStorage; + class DataFlashAPM1Log; + class DataFlashAPM2Log; + class AVRUARTConsole; + class ArduinoGPIO; + class APM1PPMInput; + class APM2PPMInput; + class APM1PWMOutput; + class APM2PWMOutput; +} + + +#endif // __AP_HAL_NAMESPACE_H__ diff --git a/libraries/AP_HAL/AnalogIn.h b/libraries/AP_HAL/AnalogIn.h new file mode 100644 index 0000000000..0a089b3cfb --- /dev/null +++ b/libraries/AP_HAL/AnalogIn.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_ANALOG_IN_H__ +#define __AP_HAL_ANALOG_IN_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::AnalogIn { +public: + AnalogIn() {} + virtual void init(int machtnicht) = 0; +}; + +#endif // __AP_HAL_ANALOG_IN_H__ + diff --git a/libraries/AP_HAL/Console.h b/libraries/AP_HAL/Console.h new file mode 100644 index 0000000000..22617e5ea2 --- /dev/null +++ b/libraries/AP_HAL/Console.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_CONSOLE_H__ +#define __AP_HAL_CONSOLE_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::Console { +public: + Console() {} + virtual void init(int machtnicht) = 0; +}; + +#endif // __AP_HAL_CONSOLE_H__ + diff --git a/libraries/AP_HAL/GPIO.h b/libraries/AP_HAL/GPIO.h new file mode 100644 index 0000000000..3fb5410490 --- /dev/null +++ b/libraries/AP_HAL/GPIO.h @@ -0,0 +1,13 @@ + +#ifndef __AP_HAL_GPIO_H__ +#define __AP_HAL_GPIO_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::GPIO { +public: + GPIO() {} + virtual void init(int machtnicht) = 0; +}; + +#endif // __AP_HAL_GPIO_H__ diff --git a/libraries/AP_HAL/HAL.h b/libraries/AP_HAL/HAL.h new file mode 100644 index 0000000000..020bf391c9 --- /dev/null +++ b/libraries/AP_HAL/HAL.h @@ -0,0 +1,66 @@ + +#ifndef __AP_HAL_HAL_H__ +#define __AP_HAL_HAL_H__ + +#include "AP_HAL_Namespace.h" + +#include "../AP_HAL/UARTDriver.h" +#include "../AP_HAL/SPIDriver.h" +#include "../AP_HAL/AnalogIn.h" +#include "../AP_HAL/Storage.h" +#include "../AP_HAL/Log.h" +#include "../AP_HAL/Console.h" +#include "../AP_HAL/GPIO.h" +#include "../AP_HAL/PPMInput.h" +#include "../AP_HAL/PWMOutput.h" + +class AP_HAL::HAL { +public: + HAL(AP_HAL::UARTDriver* _uart0, + AP_HAL::UARTDriver* _uart1, + AP_HAL::UARTDriver* _uart2, + AP_HAL::UARTDriver* _uart3, + AP_HAL::I2CDriver* _i2c, + AP_HAL::SPIDriver* _spi, + AP_HAL::AnalogIn* _analogIn, + AP_HAL::Storage* _storage, + AP_HAL::Log* _log, + AP_HAL::Console* _console, + AP_HAL::GPIO* _gpio, + AP_HAL::PPMInput* _ppmin, + AP_HAL::PWMOutput* _pwmout) + : + uart0(_uart0), + uart1(_uart1), + uart2(_uart2), + uart3(_uart3), + i2c(_i2c), + spi(_spi), + analogIn(_analogIn), + storage(_storage), + log(_log), + console(_console), + gpio(_gpio), + ppmin(_ppmin), + pwmout(_pwmout) + {} + + AP_HAL::UARTDriver* uart0; + AP_HAL::UARTDriver* uart1; + AP_HAL::UARTDriver* uart2; + AP_HAL::UARTDriver* uart3; + + AP_HAL::I2CDriver* i2c; + AP_HAL::SPIDriver* spi; + AP_HAL::AnalogIn* analogIn; + + AP_HAL::Storage* storage; + AP_HAL::Log* log; + AP_HAL::Console* console; + AP_HAL::GPIO* gpio; + AP_HAL::PPMInput* ppmin; + AP_HAL::PWMOutput* pwmout; +}; + +#endif // __AP_HAL_HAL_H__ + diff --git a/libraries/AP_HAL/I2CDriver.h b/libraries/AP_HAL/I2CDriver.h new file mode 100644 index 0000000000..d5c23bd71c --- /dev/null +++ b/libraries/AP_HAL/I2CDriver.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_I2C_DRIVER_H__ +#define __AP_HAL_I2C_DRIVER_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::I2CDriver { +public: + I2CDriver() {} + virtual void init() = 0; +}; + +#endif // __AP_HAL_I2C_DRIVER_H__ + diff --git a/libraries/AP_HAL/Log.h b/libraries/AP_HAL/Log.h new file mode 100644 index 0000000000..01e8c7bd30 --- /dev/null +++ b/libraries/AP_HAL/Log.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_LOG_H__ +#define __AP_HAL_LOG_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::Log{ +public: + Log() {} + virtual void init(int machtnicht) = 0; +}; + +#endif // __AP_HAL_LOG_H__ + diff --git a/libraries/AP_HAL/PPMInput.h b/libraries/AP_HAL/PPMInput.h new file mode 100644 index 0000000000..58bc01afaa --- /dev/null +++ b/libraries/AP_HAL/PPMInput.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_PPM_INPUT_H__ +#define __AP_HAL_PPM_INPUT_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::PPMInput { +public: + PPMInput() {} + virtual void init(int machtnicht) = 0; +}; + +#endif // __AP_HAL_PPM_INPUT_H__ + diff --git a/libraries/AP_HAL/PWMOutput.h b/libraries/AP_HAL/PWMOutput.h new file mode 100644 index 0000000000..c427e47994 --- /dev/null +++ b/libraries/AP_HAL/PWMOutput.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_PWM_OUTPUT_H__ +#define __AP_HAL_PWM_OUTPUT_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::PWMOutput { +public: + PWMOutput() {} + virtual void init(int machtnicht) = 0; +}; + +#endif // __AP_HAL_PWM_OUTPUT_H__ + diff --git a/libraries/AP_HAL/SPIDriver.h b/libraries/AP_HAL/SPIDriver.h new file mode 100644 index 0000000000..3c850a686c --- /dev/null +++ b/libraries/AP_HAL/SPIDriver.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_SPI_DRIVER_H__ +#define __AP_HAL_SPI_DRIVER_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::SPIDriver { +public: + SPIDriver() {} + virtual void init() = 0; +}; + +#endif // __AP_HAL_SPI_DRIVER_H__ + diff --git a/libraries/AP_HAL/Storage.h b/libraries/AP_HAL/Storage.h new file mode 100644 index 0000000000..caff2df4ad --- /dev/null +++ b/libraries/AP_HAL/Storage.h @@ -0,0 +1,14 @@ + +#ifndef __AP_HAL_STORAGE_H__ +#define __AP_HAL_STORAGE_H__ + +#include "AP_HAL_Namespace.h" + +class AP_HAL::Storage { +public: + Storage() {} + virtual void init(int machtnicht) = 0; +}; + +#endif // __AP_HAL_STORAGE_H__ + diff --git a/libraries/AP_HAL/UARTDriver.h b/libraries/AP_HAL/UARTDriver.h new file mode 100644 index 0000000000..8e4f6cb8e7 --- /dev/null +++ b/libraries/AP_HAL/UARTDriver.h @@ -0,0 +1,19 @@ + +#ifndef __AP_HAL_UART_DRIVER_H__ +#define __AP_HAL_UART_DRIVER_H__ + +#include + +#include "AP_HAL_Namespace.h" + +/* Pure virtual UARTDriver class */ + +class AP_HAL::UARTDriver { +public: + UARTDriver() {} + virtual void init(uint16_t baud) = 0; + /* XXX stub */ +}; + +#endif // __AP_HAL_UART_DRIVER_H__ +