diff --git a/flight/sys/pios_irq.h b/flight/sys/pios_irq.h index d074ecc03..dd288681b 100644 --- a/flight/sys/pios_irq.h +++ b/flight/sys/pios_irq.h @@ -28,7 +28,7 @@ #ifndef PIOS_IRQ_H #define PIOS_IRQ_H -/* Function Prototypes */ +/* Public Functions */ extern void UARTInit(void); extern void EnableAuxUART(void); extern void DisableAuxUART(void); diff --git a/flight/sys/pios_led.h b/flight/sys/pios_led.h index c8de746eb..bd3509df1 100644 --- a/flight/sys/pios_led.h +++ b/flight/sys/pios_led.h @@ -31,7 +31,7 @@ /* Type Definitions */ typedef enum {LED1 = 0, LED2 = 1} LedTypeDef; -/* Exported Functions */ +/* Public Functions */ extern void LED_INIT(void); extern void LED_ON(LedTypeDef LEDNum); extern void LED_OFF(LedTypeDef LEDNum); diff --git a/flight/sys/pios_settings.c b/flight/sys/pios_settings.c index aa240b412..e506b2034 100644 --- a/flight/sys/pios_settings.c +++ b/flight/sys/pios_settings.c @@ -25,15 +25,35 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* Project Includes */ #include "pios.h" + +/* Public Function Prototypes */ +void LoadSettings(void); + + +/* Private Function Prototypes */ + + /* Local Variables */ 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); */ /* String Reading: ini_gets("Section", "Key", "DefaultValue", StrBuffer, sizearray(StrBuffer), IniFile); */ + void LoadSettings(void) { char StrBuffer[100]; diff --git a/flight/sys/pios_settings.h b/flight/sys/pios_settings.h index 343422c8a..938dcb18a 100644 --- a/flight/sys/pios_settings.h +++ b/flight/sys/pios_settings.h @@ -57,10 +57,10 @@ typedef struct { UARTSettingsTypeDef AuxUART; } SettingsTypeDef; -/*Global Veriables */ +/*Global Variables */ extern SettingsTypeDef Settings; -/* Function Prototypes */ +/* Public Functions */ extern 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 4368aeed0..989f7e5c1 100644 --- a/flight/sys/pios_sys.c +++ b/flight/sys/pios_sys.c @@ -25,12 +25,31 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* Project Includes */ #include "pios.h" + +/* Public Function Prototypes */ +void SysInit(void); + + +/* Private Function Prototypes */ +void NVIC_Configuration(void); + + /* Local Variables */ 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) { /* 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(); } + /******************************************************************************* * Function Name : GPIO_Configuration -* Description : Configures the different GPIO ports. +* Description : Configures base level GPIO ports. * Input : None * Output : None * Return : None @@ -67,9 +88,10 @@ void GPIO_Configuration(void) } + /******************************************************************************* * Function Name : NVIC_Configuration -* Description : Configures Vector Table base location. +* Description : Configures Vector Table base location and SysTick * Input : None * Output : None * Return : None @@ -78,6 +100,8 @@ void NVIC_Configuration(void) { /* Set the Vector Table base address as specified in .ld file */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); + + /* 4 bits for Interupt priorities so no sub priorities */ NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4); /* Configure HCLK clock as SysTick clock source. */ diff --git a/flight/sys/pios_sys.h b/flight/sys/pios_sys.h index 745bbd921..f1796d1e3 100644 --- a/flight/sys/pios_sys.h +++ b/flight/sys/pios_sys.h @@ -28,9 +28,7 @@ #ifndef PIOS_SYS_H #define PIOS_SYS_H -/* Exported Functions */ +/* Public Functions */ extern void SysInit(void); -extern void GPIO_Configuration(void); -extern void NVIC_Configuration(void); #endif /* PIOS_SYS_H */ diff --git a/flight/sys/pios_uart.c b/flight/sys/pios_uart.c index e790f8917..0c00c1ff1 100644 --- a/flight/sys/pios_uart.c +++ b/flight/sys/pios_uart.c @@ -5,7 +5,7 @@ * @author The OpenPilot Team, http://www.openpilot.org, Copyright (C) 2009. * * @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) */ @@ -25,9 +25,21 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ + /* Project Includes */ #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 */ static u8 rx_buffer[UART_NUM][UART_RX_BUFFER_SIZE]; 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_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) { 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) { //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) { //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) { /* USART BRR Configuration */ @@ -171,6 +214,7 @@ void UARTChangeBaud(USART_TypeDef* USARTx, uint32_t Baud) USARTx->BRR = (uint16_t)tmpreg; } + /*----------------------------------------------------------------------------------*/ /* WORK IN PROGRESS BELOW */ /*----------------------------------------------------------------------------------*/ diff --git a/flight/sys/pios_uart.h b/flight/sys/pios_uart.h index 0fb1bfe09..e6a30232d 100644 --- a/flight/sys/pios_uart.h +++ b/flight/sys/pios_uart.h @@ -28,7 +28,7 @@ #ifndef PIOS_UART_H #define PIOS_UART_H -/* Function Prototypes */ +/* Public Functions */ extern void UARTInit(void); extern void EnableAuxUART(void); extern void DisableAuxUART(void);