From 551ff0c8b831d0b710f3799d0dee5eb0c3ab64ee Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Thu, 13 Dec 2012 09:01:40 +1100 Subject: [PATCH] AP_HAL_AVR: prevent build of AVR code on non-AVR platforms --- libraries/AP_HAL_AVR/AnalogIn_ADC.cpp | 3 +++ libraries/AP_HAL_AVR/AnalogIn_Common.cpp | 3 +++ libraries/AP_HAL_AVR/GPIO.cpp | 3 +++ libraries/AP_HAL_AVR/I2CDriver.cpp | 4 ++++ libraries/AP_HAL_AVR/RCInput_APM1.cpp | 4 ++++ libraries/AP_HAL_AVR/RCInput_APM2.cpp | 4 ++++ libraries/AP_HAL_AVR/RCOutput_APM1.cpp | 3 +++ libraries/AP_HAL_AVR/RCOutput_APM2.cpp | 4 ++++ libraries/AP_HAL_AVR/SPIDeviceManager_APM1.cpp | 3 +++ libraries/AP_HAL_AVR/SPIDeviceManager_APM2.cpp | 3 +++ libraries/AP_HAL_AVR/SPIDevice_SPI0.cpp | 3 +++ libraries/AP_HAL_AVR/SPIDevice_SPI2.cpp | 4 +++- libraries/AP_HAL_AVR/SPIDevice_SPI3.cpp | 3 +++ libraries/AP_HAL_AVR/Scheduler_Timer.cpp | 4 ++++ libraries/AP_HAL_AVR/Storage.cpp | 3 +++ libraries/AP_HAL_AVR/UARTDriver.cpp | 3 +++ libraries/AP_HAL_AVR/UARTDriver.h | 3 ++- 17 files changed, 55 insertions(+), 2 deletions(-) diff --git a/libraries/AP_HAL_AVR/AnalogIn_ADC.cpp b/libraries/AP_HAL_AVR/AnalogIn_ADC.cpp index 1594904d39..d5a35ccdbb 100644 --- a/libraries/AP_HAL_AVR/AnalogIn_ADC.cpp +++ b/libraries/AP_HAL_AVR/AnalogIn_ADC.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -88,3 +90,4 @@ void ADCSource::new_sample(uint16_t sample) { _sum_count++; } } +#endif diff --git a/libraries/AP_HAL_AVR/AnalogIn_Common.cpp b/libraries/AP_HAL_AVR/AnalogIn_Common.cpp index e42aaf8b47..92b10258d5 100644 --- a/libraries/AP_HAL_AVR/AnalogIn_Common.cpp +++ b/libraries/AP_HAL_AVR/AnalogIn_Common.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -123,3 +125,4 @@ AP_HAL::AnalogSource* AVRAnalogIn::channel(int16_t ch, float scale) { } } +#endif diff --git a/libraries/AP_HAL_AVR/GPIO.cpp b/libraries/AP_HAL_AVR/GPIO.cpp index f183b55b61..e40e1fdd62 100644 --- a/libraries/AP_HAL_AVR/GPIO.cpp +++ b/libraries/AP_HAL_AVR/GPIO.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -158,3 +160,4 @@ void AVRDigitalSource::write(uint8_t value) { } +#endif diff --git a/libraries/AP_HAL_AVR/I2CDriver.cpp b/libraries/AP_HAL_AVR/I2CDriver.cpp index 34a54cf410..f289074fd1 100644 --- a/libraries/AP_HAL_AVR/I2CDriver.cpp +++ b/libraries/AP_HAL_AVR/I2CDriver.cpp @@ -31,6 +31,9 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) + #include #include @@ -314,3 +317,4 @@ SIGNAL(TWI_vect) } +#endif diff --git a/libraries/AP_HAL_AVR/RCInput_APM1.cpp b/libraries/AP_HAL_AVR/RCInput_APM1.cpp index 5a6689851c..c95a0e25ab 100644 --- a/libraries/AP_HAL_AVR/RCInput_APM1.cpp +++ b/libraries/AP_HAL_AVR/RCInput_APM1.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -146,3 +148,5 @@ void APM1RCInput::clear_overrides() { _override[i] = 0; } } + +#endif diff --git a/libraries/AP_HAL_AVR/RCInput_APM2.cpp b/libraries/AP_HAL_AVR/RCInput_APM2.cpp index 0e4d883f8c..a7813fc799 100644 --- a/libraries/AP_HAL_AVR/RCInput_APM2.cpp +++ b/libraries/AP_HAL_AVR/RCInput_APM2.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -146,3 +148,5 @@ void APM2RCInput::clear_overrides() { _override[i] = 0; } } + +#endif diff --git a/libraries/AP_HAL_AVR/RCOutput_APM1.cpp b/libraries/AP_HAL_AVR/RCOutput_APM1.cpp index 880dd67a9c..8cff3b3307 100644 --- a/libraries/AP_HAL_AVR/RCOutput_APM1.cpp +++ b/libraries/AP_HAL_AVR/RCOutput_APM1.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include @@ -225,3 +227,4 @@ void APM1RCOutput::read(uint16_t* period_us, uint8_t len) { uint16_t APM1RCOutput::_timer_period(uint16_t speed_hz) { return 2000000UL / speed_hz; } +#endif diff --git a/libraries/AP_HAL_AVR/RCOutput_APM2.cpp b/libraries/AP_HAL_AVR/RCOutput_APM2.cpp index 78c89a3afc..b1ff94f603 100644 --- a/libraries/AP_HAL_AVR/RCOutput_APM2.cpp +++ b/libraries/AP_HAL_AVR/RCOutput_APM2.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include @@ -217,3 +219,5 @@ void APM2RCOutput::read(uint16_t* period_us, uint8_t len) { uint16_t APM2RCOutput::_timer_period(uint16_t speed_hz) { return 2000000UL / speed_hz; } + +#endif diff --git a/libraries/AP_HAL_AVR/SPIDeviceManager_APM1.cpp b/libraries/AP_HAL_AVR/SPIDeviceManager_APM1.cpp index 1919216f53..449ceecaa2 100644 --- a/libraries/AP_HAL_AVR/SPIDeviceManager_APM1.cpp +++ b/libraries/AP_HAL_AVR/SPIDeviceManager_APM1.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -47,3 +49,4 @@ AP_HAL::SPIDeviceDriver* APM1SPIDeviceManager::device(enum AP_HAL::SPIDevice d) }; } +#endif diff --git a/libraries/AP_HAL_AVR/SPIDeviceManager_APM2.cpp b/libraries/AP_HAL_AVR/SPIDeviceManager_APM2.cpp index 27e0516f6c..869f2ad283 100644 --- a/libraries/AP_HAL_AVR/SPIDeviceManager_APM2.cpp +++ b/libraries/AP_HAL_AVR/SPIDeviceManager_APM2.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -62,3 +64,4 @@ AP_HAL::SPIDeviceDriver* APM2SPIDeviceManager::device(enum AP_HAL::SPIDevice d) }; } +#endif diff --git a/libraries/AP_HAL_AVR/SPIDevice_SPI0.cpp b/libraries/AP_HAL_AVR/SPIDevice_SPI0.cpp index 42b5b0f557..56f533a67a 100644 --- a/libraries/AP_HAL_AVR/SPIDevice_SPI0.cpp +++ b/libraries/AP_HAL_AVR/SPIDevice_SPI0.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include @@ -67,3 +69,4 @@ uint8_t AVRSPI0DeviceDriver::transfer(uint8_t data) { return read_spdr; } +#endif diff --git a/libraries/AP_HAL_AVR/SPIDevice_SPI2.cpp b/libraries/AP_HAL_AVR/SPIDevice_SPI2.cpp index 6f92410c91..8ee0d9887c 100644 --- a/libraries/AP_HAL_AVR/SPIDevice_SPI2.cpp +++ b/libraries/AP_HAL_AVR/SPIDevice_SPI2.cpp @@ -1,4 +1,5 @@ - +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include @@ -67,3 +68,4 @@ uint8_t AVRSPI2DeviceDriver::transfer(uint8_t data) { return UDR2; } +#endif diff --git a/libraries/AP_HAL_AVR/SPIDevice_SPI3.cpp b/libraries/AP_HAL_AVR/SPIDevice_SPI3.cpp index 128413eb24..126b90d53c 100644 --- a/libraries/AP_HAL_AVR/SPIDevice_SPI3.cpp +++ b/libraries/AP_HAL_AVR/SPIDevice_SPI3.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include @@ -71,3 +73,4 @@ uint8_t AVRSPI3DeviceDriver::transfer(uint8_t data) { return UDR3; } +#endif diff --git a/libraries/AP_HAL_AVR/Scheduler_Timer.cpp b/libraries/AP_HAL_AVR/Scheduler_Timer.cpp index 957361697e..4f3eae6e69 100644 --- a/libraries/AP_HAL_AVR/Scheduler_Timer.cpp +++ b/libraries/AP_HAL_AVR/Scheduler_Timer.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -159,3 +161,5 @@ void AVRTimer::delay_microseconds(uint16_t us) "brne 1b" : "=w" (us) : "0" (us) // 2 cycles ); } + +#endif diff --git a/libraries/AP_HAL_AVR/Storage.cpp b/libraries/AP_HAL_AVR/Storage.cpp index 208d4a0ea7..8f630ddff8 100644 --- a/libraries/AP_HAL_AVR/Storage.cpp +++ b/libraries/AP_HAL_AVR/Storage.cpp @@ -1,3 +1,5 @@ +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -36,3 +38,4 @@ void AVREEPROMStorage::write_block(uint16_t dst, void *src, size_t n) { eeprom_write_block(src,(void*)dst,n); } +#endif diff --git a/libraries/AP_HAL_AVR/UARTDriver.cpp b/libraries/AP_HAL_AVR/UARTDriver.cpp index ebcee1aad6..18eada7c48 100644 --- a/libraries/AP_HAL_AVR/UARTDriver.cpp +++ b/libraries/AP_HAL_AVR/UARTDriver.cpp @@ -7,6 +7,8 @@ // Free Software Foundation; either version 2.1 of the License, or (at // your option) any later version. // +#include +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -279,3 +281,4 @@ void AVRUARTDriver::_printf_P(const prog_char *fmt, ...) { vprintf((AP_HAL::Print*)this, 1, fmt, ap); va_end(ap); } +#endif diff --git a/libraries/AP_HAL_AVR/UARTDriver.h b/libraries/AP_HAL_AVR/UARTDriver.h index 5808c5af76..4f75c1bf6a 100644 --- a/libraries/AP_HAL_AVR/UARTDriver.h +++ b/libraries/AP_HAL_AVR/UARTDriver.h @@ -1,6 +1,7 @@ #ifndef __AP_HAL_AVR_UART_DRIVER_H__ #define __AP_HAL_AVR_UART_DRIVER_H__ +#if (CONFIG_HAL_BOARD == HAL_BOARD_APM1 || CONFIG_HAL_BOARD == HAL_BOARD_APM2) #include #include @@ -212,6 +213,6 @@ struct hack UCSR##_num##B, \ _BV(UDRIE##_num)) - +#endif #endif // __AP_HAL_AVR_UART_DRIVER_H__