mirror of
https://bitbucket.org/librepilot/librepilot.git
synced 2024-12-01 09:24:10 +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:
parent
d55cb811ba
commit
c1f56b5d33
15
flight/doc/SDCard Files/Settings.ini
Normal file
15
flight/doc/SDCard Files/Settings.ini
Normal 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
|
@ -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 <ff.h>
|
||||
#include <diskio.h>
|
||||
|
||||
/* minIni Functions */
|
||||
#include <minIni.h>
|
||||
|
||||
/* Include Flyingfox Hardware Header Files */
|
||||
#include <pios_board.h>
|
||||
#include <pios_sys.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
|
||||
|
@ -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;
|
||||
}
|
@ -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 */
|
@ -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();
|
||||
|
||||
}
|
||||
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user