1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-11-29 07:24:13 +01:00

Added basic settings functionality in pios_settings.

Updated pios_uart to use settings.
Added basic Settings.ini file for reference.

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@7 ebee16cc-31ac-478f-84a7-5cbb03baadba
This commit is contained in:
gussy 2009-11-28 14:16:50 +00:00 committed by gussy
parent d55cb811ba
commit c1f56b5d33
7 changed files with 76 additions and 21 deletions

View File

@ -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

View File

@ -6,9 +6,6 @@
* *
* @file pios.h * @file pios.h
* PiOS header. Central header for the project * PiOS header. Central header for the project
*
* @see The GNU Public License (GPL)
* *
* @see The GNU Public License (GPL) * @see The GNU Public License (GPL)
*/ */
@ -45,6 +42,9 @@
#include <ff.h> #include <ff.h>
#include <diskio.h> #include <diskio.h>
/* minIni Functions */
#include <minIni.h>
/* Include Flyingfox Hardware Header Files */ /* Include Flyingfox Hardware Header Files */
#include <pios_board.h> #include <pios_board.h>
#include <pios_sys.h> #include <pios_sys.h>

View File

@ -29,6 +29,11 @@
#ifndef PIOS_BOARD_H #ifndef PIOS_BOARD_H
#define PIOS_BOARD_H #define PIOS_BOARD_H
//------------------------
// Default File Settings
//------------------------
#define SETTINGS_FILE "Settings.ini"
//------------------------ //------------------------
// DMA Channels Used // DMA Channels Used
//------------------------ //------------------------
@ -199,7 +204,7 @@
#define PERIPHERAL_CLOCK (MASTER_CLOCK/2) #define PERIPHERAL_CLOCK (MASTER_CLOCK/2)
//------------------------- //-------------------------
// USB // Interrupt Priorities
//------------------------- //-------------------------
#define IRQ_PRIO_LOW 12 // lower than RTOS #define IRQ_PRIO_LOW 12 // lower than RTOS
#define IRQ_PRIO_MID 8 // higher than RTOS #define IRQ_PRIO_MID 8 // higher than RTOS

View File

@ -29,4 +29,28 @@
#include "pios.h" #include "pios.h"
/* Local Variables */ /* 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;
}

View File

@ -28,23 +28,39 @@
#ifndef PIOS_SETTINGS_H #ifndef PIOS_SETTINGS_H
#define 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 */ /* Global types */
typedef struct {
uint32_t Baudrate;
} GPSSettingsTypeDef;
typedef struct {
uint32_t Baudrate;
} TelemSettingsTypeDef;
typedef struct { typedef struct {
bool Enabled; bool Enabled;
uint32_t Baud; uint32_t Baudrate;
} UARTSettingsTypeDef; } UARTSettingsTypeDef;
typedef struct { typedef struct {
UARTSettingsTypeDef GPSUART; GPSSettingsTypeDef GPS;
UARTSettingsTypeDef TELEMUART; TelemSettingsTypeDef Telem;
UARTSettingsTypeDef AUXUART; UARTSettingsTypeDef AuxUART;
} SettingsTypeDef; } SettingsTypeDef;
/*Global Veriables */ /*Global Veriables */
extern SettingsTypeDef Settings; extern SettingsTypeDef Settings;
/* Function Prototypes */ /* Function Prototypes */
void LoadSettings(void);
#endif /* PIOS_SETTINGS_H */ #endif /* PIOS_SETTINGS_H */

View File

@ -28,32 +28,27 @@
/* Project Includes */ /* Project Includes */
#include "pios.h" #include "pios.h"
/*Global Variables */
SettingsTypeDef Settings;
/* Local Variables */ /* Local Variables */
FATFS Fatfs[_DRIVES]; // File system object for each logical drive */ FATFS Fatfs[_DRIVES]; // File system object for each logical drive */
void SysInit(void) 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(); SystemInit();
/* RRC Init??? */
/* Initialize LEDs */
LED_INIT();
/* Initialize NVIC */ /* Initialize NVIC */
NVIC_Configuration(); NVIC_Configuration();
/* Initialize LEDs */
LED_INIT();
/* Initialize FatFS disk */ /* Initialize FatFS disk */
if(f_mount(0, &Fatfs[0]) != FR_OK) if(f_mount(0, &Fatfs[0]) != FR_OK)
{ {
//Failed to mount MicroSD filesystem, should we do something? //Failed to mount MicroSD filesystem, should we do something?
} }
//InitSettings(&Settings); LoadSettings();
} }

View File

@ -81,10 +81,10 @@ void UARTInit(void)
USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None; USART_InitStructure.USART_HardwareFlowControl = USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode = USART_Mode_Rx | USART_Mode_Tx; 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_Init(GPS_UART, &USART_InitStructure);
USART_InitStructure.USART_BaudRate = TELEM_BAUD; USART_InitStructure.USART_BaudRate = Settings.Telem.Baudrate;
USART_Init(TELEM_UART, &USART_InitStructure); USART_Init(TELEM_UART, &USART_InitStructure);
/* Enable UART Receive and Transmit interrupts */ /* Enable UART Receive and Transmit interrupts */