diff --git a/flight/doc/SDCard Files/Settings.ini b/flight/doc/SDCard Files/Settings.ini new file mode 100644 index 000000000..bfcdbe7fa --- /dev/null +++ b/flight/doc/SDCard Files/Settings.ini @@ -0,0 +1,15 @@ +# +# Basic Settings File for Open Pilot +# The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. +# + +[GPS] +Baudrate = 57600 + +[Telemetry] +Baudrate = 19200 + +[Auxillary_UART] +# !!WARNING!! Enabling this will DISABLE RC input 5 and 6 +Enabled = 0 +Baudrate = 19200 diff --git a/flight/sys/pios.h b/flight/sys/pios.h index ad190160f..6e60c0dee 100644 --- a/flight/sys/pios.h +++ b/flight/sys/pios.h @@ -8,9 +8,6 @@ * PiOS header. Central header for the project * * @see The GNU Public License (GPL) - -* - * @see The GNU Public License (GPL) */ /* * This program is free software; you can redistribute it and/or modify @@ -45,6 +42,9 @@ #include #include +/* minIni Functions */ +#include + /* Include Flyingfox Hardware Header Files */ #include #include diff --git a/flight/sys/pios_board.h b/flight/sys/pios_board.h index 3d6ce71fe..9569df446 100644 --- a/flight/sys/pios_board.h +++ b/flight/sys/pios_board.h @@ -29,6 +29,11 @@ #ifndef PIOS_BOARD_H #define PIOS_BOARD_H +//------------------------ +// Default File Settings +//------------------------ +#define SETTINGS_FILE "Settings.ini" + //------------------------ // DMA Channels Used //------------------------ @@ -199,7 +204,7 @@ #define PERIPHERAL_CLOCK (MASTER_CLOCK/2) //------------------------- -// USB +// Interrupt Priorities //------------------------- #define IRQ_PRIO_LOW 12 // lower than RTOS #define IRQ_PRIO_MID 8 // higher than RTOS diff --git a/flight/sys/pios_settings.c b/flight/sys/pios_settings.c index 5b9e29a9b..b3f7c791e 100644 --- a/flight/sys/pios_settings.c +++ b/flight/sys/pios_settings.c @@ -29,4 +29,28 @@ #include "pios.h" /* Local Variables */ +SettingsTypeDef Settings; +/* Loads Settings from INI file */ +/* Value Reading: ini_getl("Section", "Key", (DefaultValue), IniFile); */ +/* String Reading: ini_gets("Section", "Key", "DefaultValue", StrBuffer, sizearray(StrBuffer), IniFile); */ +void LoadSettings(void) +{ + char StrBuffer[100]; + long Result; + + /* Section: GPS */ + Settings.GPSUART.Baudrate = ini_getl("GPS", "Baudrate", GPS_BAUDRATE, SETTINGS_FILE); + + /* Section: Telemetry */ + Settings.GPSUART.Baudrate = ini_getl("Telemetry", "Baudrate", TELEM_BAUDRATE, SETTINGS_FILE); + + /* Section: Auxillary_UART */ + Settings.AuxUART.Enabled = ini_getl("Auxillary_UART", "Enabled", AUXUART_ENABLED, SETTINGS_FILE); + Settings.AuxUART.Baudrate = ini_getl("Auxillary_UART", "Baudrate", AUXUART_BAUDRATE, SETTINGS_FILE); +} + +int foo(void) +{ + return 0; +} \ No newline at end of file diff --git a/flight/sys/pios_settings.h b/flight/sys/pios_settings.h index 90c489cf2..69ea84389 100644 --- a/flight/sys/pios_settings.h +++ b/flight/sys/pios_settings.h @@ -28,23 +28,39 @@ #ifndef PIOS_SETTINGS_H #define PIOS_SETTINGS_H -/* Global Defines */ +/* Default Values */ +/* GPSUART Default Values */ +#define GPS_BAUDRATE 19200 + +#define TELEM_BAUDRATE 19200 + +#define AUXUART_ENABLED 1 +#define AUXUART_BAUDRATE 19200 /* Global types */ +typedef struct { + uint32_t Baudrate; +} GPSSettingsTypeDef; + +typedef struct { + uint32_t Baudrate; +} TelemSettingsTypeDef; + typedef struct { bool Enabled; - uint32_t Baud; + uint32_t Baudrate; } UARTSettingsTypeDef; typedef struct { - UARTSettingsTypeDef GPSUART; - UARTSettingsTypeDef TELEMUART; - UARTSettingsTypeDef AUXUART; + GPSSettingsTypeDef GPS; + TelemSettingsTypeDef Telem; + UARTSettingsTypeDef AuxUART; } SettingsTypeDef; /*Global Veriables */ extern SettingsTypeDef Settings; /* Function Prototypes */ +void LoadSettings(void); #endif /* PIOS_SETTINGS_H */ \ No newline at end of file diff --git a/flight/sys/pios_sys.c b/flight/sys/pios_sys.c index 56c3790f1..083d355e7 100644 --- a/flight/sys/pios_sys.c +++ b/flight/sys/pios_sys.c @@ -28,32 +28,27 @@ /* Project Includes */ #include "pios.h" -/*Global Variables */ -SettingsTypeDef Settings; - /* Local Variables */ FATFS Fatfs[_DRIVES]; // File system object for each logical drive */ void SysInit(void) { - /* Setup STM32 system (clock, PLL and Flash configuration) - CMSIS Function */ + /* Setup STM32 system (RCC, clock, PLL and Flash configuration) - CMSIS Function */ SystemInit(); - /* RRC Init??? */ - - /* Initialize LEDs */ - LED_INIT(); - /* Initialize NVIC */ NVIC_Configuration(); + /* Initialize LEDs */ + LED_INIT(); + /* Initialize FatFS disk */ if(f_mount(0, &Fatfs[0]) != FR_OK) { //Failed to mount MicroSD filesystem, should we do something? } - //InitSettings(&Settings); + LoadSettings(); } diff --git a/flight/sys/pios_uart.c b/flight/sys/pios_uart.c index 902f95cfb..2c74477b4 100644 --- a/flight/sys/pios_uart.c +++ b/flight/sys/pios_uart.c @@ -81,10 +81,10 @@ void UARTInit(void) USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; - USART_InitStructure.USART_BaudRate = GPS_BAUD; + USART_InitStructure.USART_BaudRate = Settings.GPS.Baudrate; USART_Init(GPS_UART, &USART_InitStructure); - USART_InitStructure.USART_BaudRate = TELEM_BAUD; + USART_InitStructure.USART_BaudRate = Settings.Telem.Baudrate; USART_Init(TELEM_UART, &USART_InitStructure); /* Enable UART Receive and Transmit interrupts */