From 59dd0637a39308cda29585e32068d7f26797d6e9 Mon Sep 17 00:00:00 2001 From: Corvus Corax Date: Thu, 5 May 2011 10:23:40 +0200 Subject: [PATCH] PiOS_posix: Add support for pios_debug API, to allow building of GPS module in x86 environment --- flight/OpenPilot/Makefile.posix | 3 +- .../OpenPilot/System/inc/pios_config_posix.h | 3 + flight/PiOS.posix/inc/pios_debug.h | 56 ++++++++++++ flight/PiOS.posix/pios.h | 1 + flight/PiOS.posix/posix/pios_debug.c | 89 +++++++++++++++++++ 5 files changed, 151 insertions(+), 1 deletion(-) create mode 100644 flight/PiOS.posix/inc/pios_debug.h create mode 100644 flight/PiOS.posix/posix/pios_debug.c diff --git a/flight/OpenPilot/Makefile.posix b/flight/OpenPilot/Makefile.posix index f2eb90753..2eff6f933 100644 --- a/flight/OpenPilot/Makefile.posix +++ b/flight/OpenPilot/Makefile.posix @@ -53,7 +53,7 @@ FLASH_TOOL = OPENOCD USE_THUMB_MODE = YES # List of modules to include -MODULES = Telemetry Actuator Stabilization Guidance ManualControl FlightPlan +MODULES = Telemetry Actuator Stabilization Guidance ManualControl FlightPlan GPS #MODULES = Telemetry ManualControl Actuator Attitude Stabilization #MODULES = Telemetry Example #MODULES = Telemetry MK/MKSerial @@ -170,6 +170,7 @@ SRC += $(PIOSPOSIX)/pios_udp.c SRC += $(PIOSPOSIX)/pios_com.c SRC += $(PIOSPOSIX)/pios_servo.c SRC += $(PIOSPOSIX)/pios_wdg.c +SRC += $(PIOSPOSIX)/pios_debug.c ## Libraries for flight calculations #SRC += $(FLIGHTLIB)/fifo_buffer.c diff --git a/flight/OpenPilot/System/inc/pios_config_posix.h b/flight/OpenPilot/System/inc/pios_config_posix.h index 26521928a..136e264c3 100644 --- a/flight/OpenPilot/System/inc/pios_config_posix.h +++ b/flight/OpenPilot/System/inc/pios_config_posix.h @@ -56,4 +56,7 @@ /* Stabilization options */ #define PIOS_QUATERNION_STABILIZATION +/* GPS options */ +#define PIOS_GPS_SETS_HOMELOCATION + #endif /* PIOS_CONFIG_POSIX_H */ diff --git a/flight/PiOS.posix/inc/pios_debug.h b/flight/PiOS.posix/inc/pios_debug.h new file mode 100644 index 000000000..e663d224e --- /dev/null +++ b/flight/PiOS.posix/inc/pios_debug.h @@ -0,0 +1,56 @@ +/** + ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @defgroup PIOS_DEBUG Debugging Functions + * @brief Debugging functionality + * @{ + * + * @file pios_i2c.h + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Debug helper functions header. + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef PIOS_DEBUG_H +#define PIOS_DEBUG_H + +extern const char *PIOS_DEBUG_AssertMsg; + +void PIOS_DEBUG_Init(void); +void PIOS_DEBUG_PinHigh(uint8_t pin); +void PIOS_DEBUG_PinLow(uint8_t pin); +void PIOS_DEBUG_PinValue8Bit(uint8_t value); +void PIOS_DEBUG_PinValue4BitL(uint8_t value); +void PIOS_DEBUG_Panic(const char *msg); + +#ifdef DEBUG +#define PIOS_DEBUG_Assert(test) if (!(test)) PIOS_DEBUG_Panic(PIOS_DEBUG_AssertMsg); +#define PIOS_Assert(test) PIOS_DEBUG_Assert(test) +#else +#define PIOS_DEBUG_Assert(test) +#define PIOS_Assert(test) if (!(test)) while (1); +#endif + +#endif /* PIOS_DEBUG_H */ + +/** + * @} + * @} + */ diff --git a/flight/PiOS.posix/pios.h b/flight/PiOS.posix/pios.h index 679296891..4f6266aca 100644 --- a/flight/PiOS.posix/pios.h +++ b/flight/PiOS.posix/pios.h @@ -63,6 +63,7 @@ #include #include #include +#include #define NELEMENTS(x) (sizeof(x) / sizeof(*(x))) diff --git a/flight/PiOS.posix/posix/pios_debug.c b/flight/PiOS.posix/posix/pios_debug.c new file mode 100644 index 000000000..f79f2e730 --- /dev/null +++ b/flight/PiOS.posix/posix/pios_debug.c @@ -0,0 +1,89 @@ +/** + ****************************************************************************** + * @addtogroup PIOS PIOS Core hardware abstraction layer + * @{ + * @defgroup PIOS_DEBUG Debugging Functions + * @brief Debugging functionality + * @{ + * + * @file pios_debug.c + * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. + * @brief Debugging Functions + * @see The GNU Public License (GPL) Version 3 + * + *****************************************************************************/ +/* + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +/* Project Includes */ +#include "pios.h" + +// Global variables +const char *PIOS_DEBUG_AssertMsg = "ASSERT FAILED"; + +/* Private Function Prototypes */ + +/** +* Initialise Debug-features +*/ +void PIOS_DEBUG_Init(void) +{ +} + +/** +* Set debug-pin high +* \param pin 0 for S1 output +*/ +void PIOS_DEBUG_PinHigh(uint8_t Pin) +{ +} + +/** +* Set debug-pin low +* \param pin 0 for S1 output +*/ +void PIOS_DEBUG_PinLow(uint8_t Pin) +{ +} + + +void PIOS_DEBUG_PinValue8Bit(uint8_t value) +{ +} + +void PIOS_DEBUG_PinValue4BitL(uint8_t value) +{ +} + + +/** + * Report a serious error and halt + */ +void PIOS_DEBUG_Panic(const char *msg) +{ +#ifdef PIOS_COM_DEBUG + register int *lr asm("lr"); // Link-register holds the PC of the caller + PIOS_COM_SendFormattedStringNonBlocking(PIOS_COM_DEBUG, "\r%s @0x%x\r", msg, lr); +#endif + + // Stay put + while (1) ; +} + +/** + * @} + * @} + */