From 285cad290b826883f4c556f32d5d4fbe4d9e089c Mon Sep 17 00:00:00 2001 From: Oleg Semyonov Date: Fri, 15 Mar 2013 16:28:53 +0200 Subject: [PATCH] pios: common PIOS #ifdef guards Conflicts: flight/PiOS/Common/pios_com.c flight/PiOS/Common/pios_mpu6000.c --- flight/PiOS/Common/pios_adxl345.c | 4 ++++ flight/PiOS/Common/pios_bma180.c | 3 ++- flight/PiOS/Common/pios_bmp085.c | 10 ++++------ flight/PiOS/Common/pios_board_info.c | 1 - flight/PiOS/Common/pios_com.c | 7 +++---- flight/PiOS/Common/pios_com_msg.c | 3 +-- flight/PiOS/Common/pios_etasv3.c | 5 +---- flight/PiOS/Common/pios_flash_jedec.c | 5 +++++ flight/PiOS/Common/pios_flashfs_logfs.c | 7 +++++++ flight/PiOS/Common/pios_gcsrcvr.c | 7 +++---- flight/PiOS/Common/pios_hcsr04.c | 8 ++++---- flight/PiOS/Common/pios_hmc5843.c | 5 ++--- flight/PiOS/Common/pios_hmc5883.c | 3 +-- flight/PiOS/Common/pios_i2c_esc.c | 7 +++---- flight/PiOS/Common/pios_l3gd20.c | 5 ++--- flight/PiOS/Common/pios_mpu6000.c | 6 +++--- flight/PiOS/Common/pios_mpxv.c | 3 +-- flight/PiOS/Common/pios_ms5611.c | 11 ++++++----- flight/PiOS/Common/pios_rcvr.c | 5 ++--- flight/PiOS/Common/pios_rfm22b.c | 5 ++--- flight/PiOS/Common/pios_sbus.c | 8 ++++---- flight/PiOS/Common/pios_sdcard.c | 5 ++--- flight/PiOS/Common/pios_usb_desc_hid_cdc.c | 6 ++++++ flight/PiOS/Common/pios_usb_desc_hid_only.c | 6 ++++++ flight/PiOS/Common/pios_usb_util.c | 6 ++++++ flight/PiOS/Common/pios_video.c | 8 +++----- flight/PiOS/Common/pios_wavplay.c | 8 +++----- 27 files changed, 86 insertions(+), 71 deletions(-) diff --git a/flight/PiOS/Common/pios_adxl345.c b/flight/PiOS/Common/pios_adxl345.c index 248c985b2..3f3ba88f8 100644 --- a/flight/PiOS/Common/pios_adxl345.c +++ b/flight/PiOS/Common/pios_adxl345.c @@ -30,6 +30,8 @@ #include "pios.h" +#ifdef PIOS_INCLUDE_ADXL345 + enum pios_adxl345_dev_magic { PIOS_ADXL345_DEV_MAGIC = 0xcb55aa55, }; @@ -306,3 +308,5 @@ uint8_t PIOS_ADXL345_Read(struct pios_adxl345_data * data) return rec[8] & 0x7F; // return number of remaining entries } + +#endif /* PIOS_INCLUDE_ADXL345 */ diff --git a/flight/PiOS/Common/pios_bma180.c b/flight/PiOS/Common/pios_bma180.c index 3a2e32d95..a5f64a121 100644 --- a/flight/PiOS/Common/pios_bma180.c +++ b/flight/PiOS/Common/pios_bma180.c @@ -31,7 +31,7 @@ #include "pios.h" -#if defined(PIOS_INCLUDE_BMA180) +#ifdef PIOS_INCLUDE_BMA180 #include "fifo_buffer.h" @@ -475,6 +475,7 @@ bool PIOS_BMA180_IRQHandler(void) } #endif /* PIOS_INCLUDE_BMA180 */ + /** * @} * @} diff --git a/flight/PiOS/Common/pios_bmp085.c b/flight/PiOS/Common/pios_bmp085.c index c12174d0f..0b1201caf 100644 --- a/flight/PiOS/Common/pios_bmp085.c +++ b/flight/PiOS/Common/pios_bmp085.c @@ -28,15 +28,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_BMP085) -#if !defined(PIOS_INCLUDE_EXTI) -#error PIOS_EXTI Must be included in the project! -#endif /* PIOS_INCLUDE_EXTI */ +#ifdef PIOS_INCLUDE_BMP085 -#include +#ifndef PIOS_INCLUDE_EXTI +#error PIOS_EXTI must be included in the project +#endif /* PIOS_INCLUDE_EXTI */ /* Glocal Variables */ ConversionTypeTypeDef CurrentRead; diff --git a/flight/PiOS/Common/pios_board_info.c b/flight/PiOS/Common/pios_board_info.c index 8905a5c08..c3a5a4dfb 100644 --- a/flight/PiOS/Common/pios_board_info.c +++ b/flight/PiOS/Common/pios_board_info.c @@ -1,6 +1,5 @@ #include #include - #include "pios_board_info.h" const struct pios_board_info __attribute__((__used__)) __attribute__((__section__(".boardinfo"))) pios_board_info_blob = { diff --git a/flight/PiOS/Common/pios_com.c b/flight/PiOS/Common/pios_com.c index 422f3ecc9..b15a176ef 100644 --- a/flight/PiOS/Common/pios_com.c +++ b/flight/PiOS/Common/pios_com.c @@ -28,15 +28,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_COM) +#ifdef PIOS_INCLUDE_COM #include "fifo_buffer.h" #include -#if !defined(PIOS_INCLUDE_FREERTOS) +#ifndef PIOS_INCLUDE_FREERTOS #include "pios_delay.h" /* PIOS_DELAY_WaitmS */ #endif @@ -524,7 +523,7 @@ bool PIOS_COM_Available(uint32_t com_id) return (com_dev->driver->available)(com_dev->lower_id); } -#endif +#endif /* PIOS_INCLUDE_COM */ /** * @} diff --git a/flight/PiOS/Common/pios_com_msg.c b/flight/PiOS/Common/pios_com_msg.c index c1cebe1d9..afc68c1ec 100644 --- a/flight/PiOS/Common/pios_com_msg.c +++ b/flight/PiOS/Common/pios_com_msg.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_COM_MSG) +#ifdef PIOS_INCLUDE_COM_MSG #include "pios_com.h" diff --git a/flight/PiOS/Common/pios_etasv3.c b/flight/PiOS/Common/pios_etasv3.c index 2a0ca9b52..33090ba5e 100644 --- a/flight/PiOS/Common/pios_etasv3.c +++ b/flight/PiOS/Common/pios_etasv3.c @@ -28,12 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_ETASV3) - -#include "pios_etasv3.h" +#ifdef PIOS_INCLUDE_ETASV3 static bool PIOS_ETASV3_Read(uint8_t * buffer, uint8_t len) { diff --git a/flight/PiOS/Common/pios_flash_jedec.c b/flight/PiOS/Common/pios_flash_jedec.c index 6d382a1c1..2294b598d 100644 --- a/flight/PiOS/Common/pios_flash_jedec.c +++ b/flight/PiOS/Common/pios_flash_jedec.c @@ -28,7 +28,11 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + #include "pios.h" + +#ifdef PIOS_INCLUDE_FLASH + #include "pios_flash_jedec_priv.h" #define JEDEC_WRITE_ENABLE 0x06 @@ -562,3 +566,4 @@ const struct pios_flash_driver pios_jedec_flash_driver = { .read_data = PIOS_Flash_Jedec_ReadData, }; +#endif /* PIOS_INCLUDE_FLASH */ diff --git a/flight/PiOS/Common/pios_flashfs_logfs.c b/flight/PiOS/Common/pios_flashfs_logfs.c index 5bad06383..0873e5987 100644 --- a/flight/PiOS/Common/pios_flashfs_logfs.c +++ b/flight/PiOS/Common/pios_flashfs_logfs.c @@ -24,6 +24,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + +#include "pios.h" + +#ifdef PIOS_INCLUDE_FLASH + #include "openpilot.h" #include "pios_flashfs_logfs_priv.h" @@ -1020,6 +1025,8 @@ out_exit: return rc; } +#endif /* PIOS_INCLUDE_FLASH */ + /** * @} * @} diff --git a/flight/PiOS/Common/pios_gcsrcvr.c b/flight/PiOS/Common/pios_gcsrcvr.c index d5451157e..674a88481 100644 --- a/flight/PiOS/Common/pios_gcsrcvr.c +++ b/flight/PiOS/Common/pios_gcsrcvr.c @@ -28,12 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#include "uavobjectmanager.h" +#ifdef PIOS_INCLUDE_GCSRCVR -#if defined(PIOS_INCLUDE_GCSRCVR) +#include "uavobjectmanager.h" #include "pios_gcsrcvr_priv.h" @@ -168,7 +167,7 @@ static void PIOS_gcsrcvr_Supervisor(uint32_t gcsrcvr_id) { gcsrcvr_dev->Fresh = false; } -#endif /* PIOS_INCLUDE_GCSRCVR */ +#endif /* PIOS_INCLUDE_GCSRCVR */ /** * @} diff --git a/flight/PiOS/Common/pios_hcsr04.c b/flight/PiOS/Common/pios_hcsr04.c index cbdb31e7e..02177fac0 100644 --- a/flight/PiOS/Common/pios_hcsr04.c +++ b/flight/PiOS/Common/pios_hcsr04.c @@ -28,12 +28,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_HCSR04) +#ifdef PIOS_INCLUDE_HCSR04 + #if !(defined(PIOS_INCLUDE_DSM) || defined(PIOS_INCLUDE_SBUS)) -#error Only supported with Spektrum/JR DSM or S.Bus interface! +#error Only supported with Spektrum/JR DSM or S.Bus interface #endif /* Local Variables */ @@ -206,5 +206,5 @@ void TIM3_IRQHandler(void) } } +#endif /* PIOS_INCLUDE_HCSR04 */ -#endif diff --git a/flight/PiOS/Common/pios_hmc5843.c b/flight/PiOS/Common/pios_hmc5843.c index 4f6b562d6..83dcc07bf 100644 --- a/flight/PiOS/Common/pios_hmc5843.c +++ b/flight/PiOS/Common/pios_hmc5843.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_HMC5843) +#ifdef PIOS_INCLUDE_HMC5843 #include @@ -376,7 +375,7 @@ static bool PIOS_HMC5843_Write(uint8_t address, uint8_t buffer) return PIOS_I2C_Transfer(PIOS_I2C_MAIN_ADAPTER, txn_list, NELEMENTS(txn_list)); } -#endif +#endif /* PIOS_INCLUDE_HMC5843 */ /** * @} diff --git a/flight/PiOS/Common/pios_hmc5883.c b/flight/PiOS/Common/pios_hmc5883.c index 0eb14e28a..1e676fbcb 100644 --- a/flight/PiOS/Common/pios_hmc5883.c +++ b/flight/PiOS/Common/pios_hmc5883.c @@ -28,10 +28,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_HMC5883) +#ifdef PIOS_INCLUDE_HMC5883 /* Global Variables */ diff --git a/flight/PiOS/Common/pios_i2c_esc.c b/flight/PiOS/Common/pios_i2c_esc.c index d440bfa48..9409b9a68 100644 --- a/flight/PiOS/Common/pios_i2c_esc.c +++ b/flight/PiOS/Common/pios_i2c_esc.c @@ -29,12 +29,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_I2C_ESC) +#ifdef PIOS_INCLUDE_I2C_ESC -/* HMC5843 Addresses */ +/* Known i2c ESC addresses */ #define MK_I2C_ADDR 0x29 #define ASTEC4_I2C_ADDR 0x02 @@ -164,7 +163,7 @@ bool PIOS_SetAstec4Speed(uint8_t motornum, uint8_t speed) { return PIOS_I2C_Transfer(PIOS_I2C_ESC_ADAPTER, txn_list, NELEMENTS(txn_list)); } -#endif +#endif /* PIOS_INCLUDE_I2C_ESC */ /** * @} diff --git a/flight/PiOS/Common/pios_l3gd20.c b/flight/PiOS/Common/pios_l3gd20.c index 6876db16d..399eaa785 100644 --- a/flight/PiOS/Common/pios_l3gd20.c +++ b/flight/PiOS/Common/pios_l3gd20.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_L3GD20) +#ifdef PIOS_INCLUDE_L3GD20 #include "fifo_buffer.h" @@ -381,7 +380,7 @@ bool PIOS_L3GD20_IRQHandler(void) return xHigherPriorityTaskWoken == pdTRUE; } -#endif /* L3GD20 */ +#endif /* PIOS_INCLUDE_L3GD20 */ /** * @} diff --git a/flight/PiOS/Common/pios_mpu6000.c b/flight/PiOS/Common/pios_mpu6000.c index 973332fae..7820efe62 100644 --- a/flight/PiOS/Common/pios_mpu6000.c +++ b/flight/PiOS/Common/pios_mpu6000.c @@ -29,9 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_MPU6000) + +#ifdef PIOS_INCLUDE_MPU6000 #include "fifo_buffer.h" @@ -551,7 +551,7 @@ bool PIOS_MPU6000_IRQHandler(void) return xHigherPriorityTaskWoken == pdTRUE; } -#endif +#endif /* PIOS_INCLUDE_MPU6000 */ /** * @} diff --git a/flight/PiOS/Common/pios_mpxv.c b/flight/PiOS/Common/pios_mpxv.c index ff02a0266..80e0b648d 100644 --- a/flight/PiOS/Common/pios_mpxv.c +++ b/flight/PiOS/Common/pios_mpxv.c @@ -30,10 +30,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_MPXV) +#ifdef PIOS_INCLUDE_MPXV #define A0 340.27f //speed of sound at standard sea level in [m/s] #define P0 101.325f //static air pressure at standard sea level in kPa diff --git a/flight/PiOS/Common/pios_ms5611.c b/flight/PiOS/Common/pios_ms5611.c index 41bf7c80e..7e4358b35 100644 --- a/flight/PiOS/Common/pios_ms5611.c +++ b/flight/PiOS/Common/pios_ms5611.c @@ -28,13 +28,14 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_MS5611 + + // TODO: Clean this up. Getting around old constant. #define PIOS_MS5611_OVERSAMPLING oversampling -#include "pios.h" - -#if defined(PIOS_INCLUDE_MS5611) /* Glocal Variables */ ConversionTypeTypeDef CurrentRead; @@ -261,7 +262,7 @@ int32_t PIOS_MS5611_Test() return 0; } -#endif +#endif /* PIOS_INCLUDE_MS5611 */ /** * @} diff --git a/flight/PiOS/Common/pios_rcvr.c b/flight/PiOS/Common/pios_rcvr.c index 0f3988d7f..4533d874b 100644 --- a/flight/PiOS/Common/pios_rcvr.c +++ b/flight/PiOS/Common/pios_rcvr.c @@ -1,7 +1,6 @@ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_RCVR) +#ifdef PIOS_INCLUDE_RCVR #include @@ -108,7 +107,7 @@ int32_t PIOS_RCVR_Read(uint32_t rcvr_id, uint8_t channel) return rcvr_dev->driver->read(rcvr_dev->lower_id, channel); } -#endif +#endif /* PIOS_INCLUDE_RCVR */ /** * @} diff --git a/flight/PiOS/Common/pios_rfm22b.c b/flight/PiOS/Common/pios_rfm22b.c index 306e96062..20eecc112 100644 --- a/flight/PiOS/Common/pios_rfm22b.c +++ b/flight/PiOS/Common/pios_rfm22b.c @@ -46,10 +46,9 @@ // // ***************************************************************** -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_RFM22B) +#ifdef PIOS_INCLUDE_RFM22B #include #include @@ -2455,7 +2454,7 @@ static enum pios_rfm22b_event rfm22_fatal_error(struct pios_rfm22b_dev *rfm22b_d // ************************************ -#endif +#endif /* PIOS_INCLUDE_RFM22B */ /** * @} diff --git a/flight/PiOS/Common/pios_sbus.c b/flight/PiOS/Common/pios_sbus.c index 53730b16b..ec8daab62 100644 --- a/flight/PiOS/Common/pios_sbus.c +++ b/flight/PiOS/Common/pios_sbus.c @@ -28,11 +28,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#include "pios_sbus_priv.h" -#if defined(PIOS_INCLUDE_SBUS) +#ifdef PIOS_INCLUDE_SBUS + +#include "pios_sbus_priv.h" /* Forward Declarations */ static int32_t PIOS_SBus_Get(uint32_t rcvr_id, uint8_t channel); @@ -332,7 +332,7 @@ static void PIOS_SBus_Supervisor(uint32_t sbus_id) } } -#endif /* PIOS_INCLUDE_SBUS */ +#endif /* PIOS_INCLUDE_SBUS */ /** * @} diff --git a/flight/PiOS/Common/pios_sdcard.c b/flight/PiOS/Common/pios_sdcard.c index c404fa718..1ae2ea50e 100644 --- a/flight/PiOS/Common/pios_sdcard.c +++ b/flight/PiOS/Common/pios_sdcard.c @@ -29,10 +29,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/* Project Includes */ #include "pios.h" -#if defined(PIOS_INCLUDE_SDCARD) +#ifdef PIOS_INCLUDE_SDCARD /* Global Variables */ VOLINFO PIOS_SDCARD_VolInfo; @@ -1000,7 +999,7 @@ int32_t PIOS_SDCARD_FileDelete(char *Filename) return 0; } -#endif +#endif /* PIOS_INCLUDE_SDCARD */ /** * @} diff --git a/flight/PiOS/Common/pios_usb_desc_hid_cdc.c b/flight/PiOS/Common/pios_usb_desc_hid_cdc.c index 747eda3d4..e102aefe3 100644 --- a/flight/PiOS/Common/pios_usb_desc_hid_cdc.c +++ b/flight/PiOS/Common/pios_usb_desc_hid_cdc.c @@ -28,6 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb_desc_hid_cdc_priv.h" /* exported API */ #include "pios_usb_defs.h" /* struct usb_*, USB_* */ #include "pios_usb_board_data.h" /* PIOS_USB_BOARD_* */ @@ -324,3 +328,5 @@ int32_t PIOS_USB_DESC_HID_CDC_Init(void) return 0; } + +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/Common/pios_usb_desc_hid_only.c b/flight/PiOS/Common/pios_usb_desc_hid_only.c index b15a02b32..0757d0937 100644 --- a/flight/PiOS/Common/pios_usb_desc_hid_only.c +++ b/flight/PiOS/Common/pios_usb_desc_hid_only.c @@ -28,6 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb_desc_hid_only_priv.h" /* exported API */ #include "pios_usb_defs.h" /* struct usb_*, USB_* */ #include "pios_usb_board_data.h" /* PIOS_USB_BOARD_* */ @@ -163,3 +167,5 @@ int32_t PIOS_USB_DESC_HID_ONLY_Init(void) return 0; } + +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/Common/pios_usb_util.c b/flight/PiOS/Common/pios_usb_util.c index 4bbf98d23..9f7c8c94e 100644 --- a/flight/PiOS/Common/pios_usb_util.c +++ b/flight/PiOS/Common/pios_usb_util.c @@ -28,6 +28,10 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ +#include "pios.h" + +#ifdef PIOS_INCLUDE_USB + #include "pios_usb_util.h" uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srclen) @@ -40,3 +44,5 @@ uint8_t * PIOS_USB_UTIL_AsciiToUtf8(uint8_t * dst, uint8_t * src, uint16_t srcle return dst; } + +#endif /* PIOS_INCLUDE_USB */ diff --git a/flight/PiOS/Common/pios_video.c b/flight/PiOS/Common/pios_video.c index 22e6060ce..5d7452f9d 100644 --- a/flight/PiOS/Common/pios_video.c +++ b/flight/PiOS/Common/pios_video.c @@ -30,7 +30,8 @@ */ #include "pios.h" -#if defined(PIOS_INCLUDE_VIDEO) + +#ifdef PIOS_INCLUDE_VIDEO extern xSemaphoreHandle osdSemaphore; @@ -277,7 +278,4 @@ void PIOS_VIDEO_DMA_Handler(void) } - -#endif - - +#endif /* PIOS_INCLUDE_VIDEO */ diff --git a/flight/PiOS/Common/pios_wavplay.c b/flight/PiOS/Common/pios_wavplay.c index cc0335c07..d2b82d65a 100644 --- a/flight/PiOS/Common/pios_wavplay.c +++ b/flight/PiOS/Common/pios_wavplay.c @@ -30,7 +30,8 @@ */ #include "pios.h" -#if defined(PIOS_INCLUDE_WAVE) + +#ifdef PIOS_INCLUDE_WAVE static const struct pios_dac_cfg * dev_cfg; @@ -606,7 +607,4 @@ void DAC_DMA_Handler(void) } } - -#endif - - +#endif /* PIOS_INCLUDE_WAVE */