From f4c4b1371a03c9a3245684d56e12b63096778505 Mon Sep 17 00:00:00 2001 From: vassilis Date: Sat, 10 Apr 2010 01:35:13 +0000 Subject: [PATCH] Flight/Settings: Remove old settings implementation (replaced with binary settings as UAVObjects) git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@465 ebee16cc-31ac-478f-84a7-5cbb03baadba --- flight/OpenPilot/Makefile | 5 - flight/OpenPilot/Settings/inc/settings.h | 0 flight/OpenPilot/Settings/settings.c | 0 flight/OpenPilot/System/openpilot.c | 5 +- flight/PiOS/Common/pios_settings.c | 116 ----------------------- flight/PiOS/STM32F10x/pios_servo.c | 8 +- flight/PiOS/STM32F10x/pios_usart.c | 1 - flight/PiOS/inc/pios_settings.h | 64 ------------- flight/PiOS/pios.h | 1 - 9 files changed, 5 insertions(+), 195 deletions(-) delete mode 100644 flight/OpenPilot/Settings/inc/settings.h delete mode 100644 flight/OpenPilot/Settings/settings.c delete mode 100644 flight/PiOS/Common/pios_settings.c delete mode 100644 flight/PiOS/inc/pios_settings.h diff --git a/flight/OpenPilot/Makefile b/flight/OpenPilot/Makefile index 0bcb55c08..101701f84 100644 --- a/flight/OpenPilot/Makefile +++ b/flight/OpenPilot/Makefile @@ -71,8 +71,6 @@ OPUAVTALK = ./UAVTalk OPUAVTALKINC = $(OPUAVTALK)/inc OPUAVOBJ = ./UAVObjects OPUAVOBJINC = $(OPUAVOBJ)/inc -OPSETTINGS = ./Settings -OPSETTINGSINC = $(OPSETTINGS)/inc OPTESTS = ./Tests OPMODULEDIR = ./Modules MODEXAMPLE = $(OPMODULEDIR)/Example @@ -153,7 +151,6 @@ SRC += $(PIOSSTM32F10X)/pios_exti.c ## PIOS Hardware (Common) SRC += $(PIOSCOMMON)/pios_sdcard.c -SRC += $(PIOSCOMMON)/pios_settings.c SRC += $(PIOSCOMMON)/pios_com.c SRC += $(PIOSCOMMON)/pios_bmp085.c SRC += $(PIOSCOMMON)/printf-stdarg.c @@ -246,8 +243,6 @@ EXTRAINCDIRS += $(OPUAVTALK) EXTRAINCDIRS += $(OPUAVTALKINC) EXTRAINCDIRS += $(OPUAVOBJ) EXTRAINCDIRS += $(OPUAVOBJINC) -EXTRAINCDIRS += $(OPSETTINGS) -EXTRAINCDIRS += $(OPSETTINGSINC) EXTRAINCDIRS += $(MODEXAMPLE) EXTRAINCDIRS += $(MODEXAMPLEINC) EXTRAINCDIRS += $(MODTELEMETRY) diff --git a/flight/OpenPilot/Settings/inc/settings.h b/flight/OpenPilot/Settings/inc/settings.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/flight/OpenPilot/Settings/settings.c b/flight/OpenPilot/Settings/settings.c deleted file mode 100644 index e69de29bb..000000000 diff --git a/flight/OpenPilot/System/openpilot.c b/flight/OpenPilot/System/openpilot.c index 46e5d9ca0..d16316da0 100644 --- a/flight/OpenPilot/System/openpilot.c +++ b/flight/OpenPilot/System/openpilot.c @@ -69,7 +69,7 @@ int main() for(;;) { /* Check if we have an SD Card with the correct settings files on it */ - if(!PIOS_SDCARD_MountFS(STARTUP_LOG_ENABLED) && !PIOS_Settings_CheckForFiles()) { + if(!PIOS_SDCARD_MountFS(STARTUP_LOG_ENABLED)) { /* Found one without errors */ break; } @@ -88,9 +88,6 @@ int main() UAVObjInitialize(); UAVObjectsInitializeAll(); - /* Call LoadSettings which populates global variables so the rest of the hardware can be configured. */ - PIOS_Settings_Load(); - /* Com ports init */ PIOS_COM_Init(); diff --git a/flight/PiOS/Common/pios_settings.c b/flight/PiOS/Common/pios_settings.c deleted file mode 100644 index b5dc860f0..000000000 --- a/flight/PiOS/Common/pios_settings.c +++ /dev/null @@ -1,116 +0,0 @@ -/** - ****************************************************************************** - * - * @file pios_settings.c - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Gets and sets PiOS settings, normally from SDCard. - * @see The GNU Public License (GPL) Version 3 - * @defgroup PIOS_SETTINGS Settings Functions - * @{ - * - *****************************************************************************/ -/* - * 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" - -#if defined(PIOS_INCLUDE_SETTINGS) - - -/* Private Function Prototypes */ - - -/* Local Variables */ -SettingsTypeDef Settings; - - -/** -* Populate System global Settings into Structs using MinIni, defaults are also set here via macros from pios_config.h -*/ -/* Value Reading: ini_getl("Section", "Key", (DefaultValue), IniFile); */ -/* String Reading: ini_gets("Section", "Key", "DefaultValue", StrBuffer, sizearray(StrBuffer), IniFile); */ -void PIOS_Settings_Load(void) -{ - /* Unused yet, until we load strings - char StrBuffer[100]; - long Result; - */ - - /* Section: GPS */ - Settings.GPS.Baudrate = (uint32_t) ini_getl("GPS", "Baudrate", GPS_BAUDRATE, SETTINGS_FILE); - - /* Section: Telemetry */ - Settings.Telem.Baudrate = (uint32_t) ini_getl("Telemetry", "Baudrate", TELEM_BAUDRATE, SETTINGS_FILE); - - /* Section: Auxillary_USART */ - Settings.AuxUSART.Enabled = (bool) ini_getl("Auxillary_USART", "Enabled", AUXUART_ENABLED, SETTINGS_FILE); - Settings.AuxUSART.Baudrate = (uint32_t) ini_getl("Auxillary_USART", "Baudrate", AUXUART_BAUDRATE, SETTINGS_FILE); - - /* Section: Servos */ - Settings.Servos.PositionMin = (uint16_t) ini_getl("Servos", "PositionMin", SERVOS_POSITION_MIN, SETTINGS_FILE); - Settings.Servos.PositionMax = (uint16_t) ini_getl("Servos", "PositionMax", SERVOS_POSITION_MAX, SETTINGS_FILE); -} - -/** -* Dump Settings struct contents to UART -* \param[in] USARTx USART name (GPS, TELEM, AUX) -*/ -void PIOS_Settings_Dump(USART_TypeDef* USARTx) -{ - /* Implement once UART is fully implemented */ -} - -/** -* Check if settings files exist on the drive -* \return 0 All files found -* \return >0 Number of files missing -*/ -int32_t PIOS_Settings_CheckForFiles(void) -{ - DIRINFO di; - DIRENT de; - int FoundCount = 0; - - di.scratch = PIOS_SDCARD_Sector; - - /* Open the root directory */ - DFS_OpenDir(&PIOS_SDCARD_VolInfo, (uint8_t *)"", &di); - - /* Scan the directory for all files */ - while(!DFS_GetNext(&PIOS_SDCARD_VolInfo, &di, &de)) { - if(de.name[0]) { - uint8_t file_name[13]; - DFS_DirToCanonical((char *)file_name, (char *)de.name); - - if(strcmp((char *)file_name, SETTINGS_FILE) == 0) { - FoundCount++; - } - } - } - - /* If one or more files are missing, return the number of missing files */ - if(FoundCount != 1) - { - return FoundCount; - } - - /* All files found */ - return 0; -} - -#endif diff --git a/flight/PiOS/STM32F10x/pios_servo.c b/flight/PiOS/STM32F10x/pios_servo.c index 4befb23e7..e6ac83d1b 100644 --- a/flight/PiOS/STM32F10x/pios_servo.c +++ b/flight/PiOS/STM32F10x/pios_servo.c @@ -160,11 +160,11 @@ void PIOS_Servo_Set(uint8_t Servo, uint16_t Position) if (Servo < PIOS_SERVO_NUM_OUTPUTS && Servo >= 0) { /* Clip servo position */ - if(Position < Settings.Servos.PositionMin) { - Position = Settings.Servos.PositionMin; + if(Position < SERVOS_POSITION_MIN) { + Position = SERVOS_POSITION_MIN; } - if(Position > Settings.Servos.PositionMax) { - Position = Settings.Servos.PositionMax; + if(Position > SERVOS_POSITION_MAX) { + Position = SERVOS_POSITION_MAX; } /* Update the position */ diff --git a/flight/PiOS/STM32F10x/pios_usart.c b/flight/PiOS/STM32F10x/pios_usart.c index 5b4622074..204a8e6bc 100644 --- a/flight/PiOS/STM32F10x/pios_usart.c +++ b/flight/PiOS/STM32F10x/pios_usart.c @@ -34,7 +34,6 @@ /* Global Variables */ -extern SettingsTypeDef Settings; xSemaphoreHandle PIOS_USART1_Buffer; xSemaphoreHandle PIOS_USART2_Buffer; xSemaphoreHandle PIOS_USART3_Buffer; diff --git a/flight/PiOS/inc/pios_settings.h b/flight/PiOS/inc/pios_settings.h deleted file mode 100644 index 286809576..000000000 --- a/flight/PiOS/inc/pios_settings.h +++ /dev/null @@ -1,64 +0,0 @@ -/** - ****************************************************************************** - * - * @file pios_settings.h - * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010. - * @brief Settings 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_SETTINGS_H -#define PIOS_SETTINGS_H - - -/* Global types */ -typedef struct { - uint32_t Baudrate; -} GPSSettingsTypeDef; - -typedef struct { - uint32_t Baudrate; -} TelemSettingsTypeDef; - -typedef struct { - bool Enabled; - uint32_t Baudrate; -} USARTSettingsTypeDef; - -typedef struct { - uint16_t PositionMin; - uint16_t PositionMax; -} ServosSettingsTypeDef; - -typedef struct { - GPSSettingsTypeDef GPS; - TelemSettingsTypeDef Telem; - USARTSettingsTypeDef AuxUSART; - ServosSettingsTypeDef Servos; -} SettingsTypeDef; - -/*Global Variables */ -extern SettingsTypeDef Settings; - -/* Public Functions */ -extern void PIOS_Settings_Load(void); -extern void PIOS_Settings_Dump(USART_TypeDef* USARTx); -extern int32_t PIOS_Settings_CheckForFiles(void); - -#endif /* PIOS_SETTINGS_H */ diff --git a/flight/PiOS/pios.h b/flight/PiOS/pios.h index 7134ad479..b3eda9faf 100644 --- a/flight/PiOS/pios.h +++ b/flight/PiOS/pios.h @@ -84,7 +84,6 @@ #endif /* PIOS Hardware Includes (Common) */ -#include #include #include #if defined(PIOS_INCLUDE_BMP085)