1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-01 09:24:10 +01:00

git-svn-id: svn://svn.openpilot.org/OpenPilot/trunk@15 ebee16cc-31ac-478f-84a7-5cbb03baadba

This commit is contained in:
dankers 2009-11-29 06:09:33 +00:00 committed by dankers
parent 9b77b473c4
commit 5efc81f6c9
8 changed files with 100 additions and 14 deletions

View File

@ -28,7 +28,7 @@
#ifndef PIOS_IRQ_H #ifndef PIOS_IRQ_H
#define PIOS_IRQ_H #define PIOS_IRQ_H
/* Function Prototypes */ /* Public Functions */
extern void UARTInit(void); extern void UARTInit(void);
extern void EnableAuxUART(void); extern void EnableAuxUART(void);
extern void DisableAuxUART(void); extern void DisableAuxUART(void);

View File

@ -31,7 +31,7 @@
/* Type Definitions */ /* Type Definitions */
typedef enum {LED1 = 0, LED2 = 1} LedTypeDef; typedef enum {LED1 = 0, LED2 = 1} LedTypeDef;
/* Exported Functions */ /* Public Functions */
extern void LED_INIT(void); extern void LED_INIT(void);
extern void LED_ON(LedTypeDef LEDNum); extern void LED_ON(LedTypeDef LEDNum);
extern void LED_OFF(LedTypeDef LEDNum); extern void LED_OFF(LedTypeDef LEDNum);

View File

@ -25,15 +25,35 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* Project Includes */ /* Project Includes */
#include "pios.h" #include "pios.h"
/* Public Function Prototypes */
void LoadSettings(void);
/* Private Function Prototypes */
/* Local Variables */ /* Local Variables */
SettingsTypeDef Settings; SettingsTypeDef Settings;
/* Loads Settings from INI file */
/*******************************************************************************
* Function Name : LoadSettings
* Description : Populate System global Vars into Structs using MinIni,
* : defaults are also set here. Only function in the file
* : and where all our system data is handled.
* : Called from the end of SysInit()
* Input : None
* Output : None
* Return : None
*******************************************************************************/
/* Value Reading: ini_getl("Section", "Key", (DefaultValue), IniFile); */ /* Value Reading: ini_getl("Section", "Key", (DefaultValue), IniFile); */
/* String Reading: ini_gets("Section", "Key", "DefaultValue", StrBuffer, sizearray(StrBuffer), IniFile); */ /* String Reading: ini_gets("Section", "Key", "DefaultValue", StrBuffer, sizearray(StrBuffer), IniFile); */
void LoadSettings(void) void LoadSettings(void)
{ {
char StrBuffer[100]; char StrBuffer[100];

View File

@ -57,10 +57,10 @@ typedef struct {
UARTSettingsTypeDef AuxUART; UARTSettingsTypeDef AuxUART;
} SettingsTypeDef; } SettingsTypeDef;
/*Global Veriables */ /*Global Variables */
extern SettingsTypeDef Settings; extern SettingsTypeDef Settings;
/* Function Prototypes */ /* Public Functions */
extern void LoadSettings(void); extern void LoadSettings(void);
#endif /* PIOS_SETTINGS_H */ #endif /* PIOS_SETTINGS_H */

View File

@ -25,12 +25,31 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* Project Includes */ /* Project Includes */
#include "pios.h" #include "pios.h"
/* Public Function Prototypes */
void SysInit(void);
/* Private Function Prototypes */
void NVIC_Configuration(void);
/* Local Variables */ /* Local Variables */
FATFS Fatfs[_DRIVES]; // File system object for each logical drive */ FATFS Fatfs[_DRIVES]; // File system object for each logical drive */
/*******************************************************************************
* Function Name : SysInit
* Description : Brings up the System and Initializes peripherals
* Input : None
* Output : None
* Return : None
*******************************************************************************/
//TODO: Get these in the right order, settings need to be loaded ASAP
void SysInit(void) void SysInit(void)
{ {
/* Setup STM32 system (RCC, clock, PLL and Flash configuration) - CMSIS Function */ /* Setup STM32 system (RCC, clock, PLL and Flash configuration) - CMSIS Function */
@ -51,13 +70,15 @@ void SysInit(void)
} }
} }
/* Call LoadSettings which populates System Vars */
LoadSettings(); LoadSettings();
} }
/******************************************************************************* /*******************************************************************************
* Function Name : GPIO_Configuration * Function Name : GPIO_Configuration
* Description : Configures the different GPIO ports. * Description : Configures base level GPIO ports.
* Input : None * Input : None
* Output : None * Output : None
* Return : None * Return : None
@ -67,9 +88,10 @@ void GPIO_Configuration(void)
} }
/******************************************************************************* /*******************************************************************************
* Function Name : NVIC_Configuration * Function Name : NVIC_Configuration
* Description : Configures Vector Table base location. * Description : Configures Vector Table base location and SysTick
* Input : None * Input : None
* Output : None * Output : None
* Return : None * Return : None
@ -78,6 +100,8 @@ void NVIC_Configuration(void)
{ {
/* Set the Vector Table base address as specified in .ld file */ /* Set the Vector Table base address as specified in .ld file */
NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0);
/* 4 bits for Interupt priorities so no sub priorities */
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
/* Configure HCLK clock as SysTick clock source. */ /* Configure HCLK clock as SysTick clock source. */

View File

@ -28,9 +28,7 @@
#ifndef PIOS_SYS_H #ifndef PIOS_SYS_H
#define PIOS_SYS_H #define PIOS_SYS_H
/* Exported Functions */ /* Public Functions */
extern void SysInit(void); extern void SysInit(void);
extern void GPIO_Configuration(void);
extern void NVIC_Configuration(void);
#endif /* PIOS_SYS_H */ #endif /* PIOS_SYS_H */

View File

@ -5,7 +5,7 @@
* @author The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. * @author The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009.
* *
* @file pios_uart.c * @file pios_uart.c
* UART commands, Inits UARTS, controls & talks to UARTS * UART commands. Inits USARTs, controls UARTs & Interupt handlers
* *
* @see The GNU Public License (GPL) * @see The GNU Public License (GPL)
*/ */
@ -25,9 +25,21 @@
* 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/ */
/* Project Includes */ /* Project Includes */
#include "pios.h" #include "pios.h"
/* Public Function Prototypes */
void UARTInit(void);
void EnableAuxUART(void);
void DisableAuxUART(void);
void UARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud);
/* Private Function Prototypes */
/* Local Variables */ /* Local Variables */
static u8 rx_buffer[UART_NUM][UART_RX_BUFFER_SIZE]; static u8 rx_buffer[UART_NUM][UART_RX_BUFFER_SIZE];
static volatile u8 rx_buffer_tail[UART_NUM]; static volatile u8 rx_buffer_tail[UART_NUM];
@ -39,7 +51,14 @@ static volatile u8 tx_buffer_tail[UART_NUM];
static volatile u8 tx_buffer_head[UART_NUM]; static volatile u8 tx_buffer_head[UART_NUM];
static volatile u8 tx_buffer_size[UART_NUM]; static volatile u8 tx_buffer_size[UART_NUM];
/* Initialise the GPS and TELEM onboard UARTs */
/*******************************************************************************
* Function Name : UARTInit
* Description : Initialise the GPS and TELEM onboard UARTs
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void UARTInit(void) void UARTInit(void)
{ {
GPIO_InitTypeDef GPIO_InitStructure; GPIO_InitTypeDef GPIO_InitStructure;
@ -129,17 +148,41 @@ void UARTInit(void)
} }
} }
/*******************************************************************************
* Function Name : EnableAuxUART
* Description : Enables AUX UART at the expense of servo inputs
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void EnableAuxUART(void) void EnableAuxUART(void)
{ {
//Implement after servo inputs are implemented //Implement after servo inputs are implemented
} }
/*******************************************************************************
* Function Name : DisableAuxUART
* Description : Disables AUX UART reclaims two servo inputs
* Input : None
* Output : None
* Return : None
*******************************************************************************/
void DisableAuxUART(void) void DisableAuxUART(void)
{ {
//Implement after servo inputs are implemented //Implement after servo inputs are implemented
} }
/* Changes the baud rate of the USART peripherial without re-initialising */
/*******************************************************************************
* Function Name : UARTInit
* Description : Changes the baud rate of the USART peripherial without
* : re-initialising.
* Input : USART to change, new baud rate
* Output : None
* Return : None
*******************************************************************************/
void UARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud) void UARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud)
{ {
/* USART BRR Configuration */ /* USART BRR Configuration */
@ -171,6 +214,7 @@ void UARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud)
USARTx->BRR = (uint16_t)tmpreg; USARTx->BRR = (uint16_t)tmpreg;
} }
/*----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------*/
/* WORK IN PROGRESS BELOW */ /* WORK IN PROGRESS BELOW */
/*----------------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------------*/

View File

@ -28,7 +28,7 @@
#ifndef PIOS_UART_H #ifndef PIOS_UART_H
#define PIOS_UART_H #define PIOS_UART_H
/* Function Prototypes */ /* Public Functions */
extern void UARTInit(void); extern void UARTInit(void);
extern void EnableAuxUART(void); extern void EnableAuxUART(void);
extern void DisableAuxUART(void); extern void DisableAuxUART(void);