diff --git a/flight/sys/pios.c b/flight/sys/pios.c index 3ad952918..ad7436435 100644 --- a/flight/sys/pios.c +++ b/flight/sys/pios.c @@ -65,13 +65,13 @@ int main() } -/******************************************************************************* +/** * Function Name : PiosMainTask * Description : PIOS * Input : None * Output : None * Return : None -*******************************************************************************/ +*/ void PiosMainTask( void *pvParameters ) { @@ -80,13 +80,13 @@ void PiosMainTask( void *pvParameters ) } } -/******************************************************************************* +/** * Function Name : SensorTask * Description : PIOS * Input : None * Output : None * Return : None -*******************************************************************************/ +*/ void SensorTask( void *pvParameters ) { diff --git a/flight/sys/pios.h b/flight/sys/pios.h index 21c2747ef..fdd268be9 100644 --- a/flight/sys/pios.h +++ b/flight/sys/pios.h @@ -30,7 +30,7 @@ #define PIOS_H -/* C Header Files */ +/* C Lib Includes */ #include #include @@ -38,14 +38,14 @@ #include #include -/* FatFS Functions */ +/* FatFS Includes */ #include #include -/* minIni Functions */ +/* minIni Includes */ #include -/* Include PIOS Hardware Header Files */ +/* PIOS Hardware Includes */ #include #include #include diff --git a/flight/sys/pios_board.h b/flight/sys/pios_board.h index 82d951b79..8c33f5065 100644 --- a/flight/sys/pios_board.h +++ b/flight/sys/pios_board.h @@ -44,7 +44,8 @@ /* Channel 5 - */ /* Channel 6 - */ /* Channel 7 - */ -/* Channel 8 - */ +/* Channel 8 - */ + /* Channel 9 - */ /* Channel 10 - */ /* Channel 11 - */ @@ -53,18 +54,18 @@ //------------------------ // Leds Definition //------------------------ -#define LED1_GPIO_PORT GPIOC -#define LED1_GPIO_PIN GPIO_Pin_12 -#define LED1_GPIO_CLK RCC_APB2Periph_GPIOC -#define LED2_GPIO_PORT GPIOC -#define LED2_GPIO_PIN GPIO_Pin_13 -#define LED2_GPIO_CLK RCC_APB2Periph_GPIOC +#define LED1_GPIO_PORT GPIOC +#define LED1_GPIO_PIN GPIO_Pin_12 +#define LED1_GPIO_CLK RCC_APB2Periph_GPIOC +#define LED2_GPIO_PORT GPIOC +#define LED2_GPIO_PIN GPIO_Pin_13 +#define LED2_GPIO_CLK RCC_APB2Periph_GPIOC #define NUM_LED 2 //------------------------ // I2C //------------------------ -#define I2C_GPIO_PORT GPIOB +#define I2C_GPIO_PORT GPIOB #define I2C_SDA_PIN GPIO_Pin_11 #define I2C_SCL_PIN GPIO_Pin_10 @@ -72,143 +73,143 @@ // Onboard Pressure sensor //------------------------ #define HP03D_XCLR_GPIO_PORT GPIOC -#define HP03D_XCLR_GPIO_PIN GPIO_Pin_15 +#define HP03D_XCLR_GPIO_PIN GPIO_Pin_15 #define HP03D_MCLK_GPIO_PORT GPIOA -#define HP03D_MCLK_GPIO_PIN GPIO_Pin_1 +#define HP03D_MCLK_GPIO_PIN GPIO_Pin_1 //------------------------- // GPS UART //------------------------- -#define GPS_UART USART2 -#define GPS_BAUD 57600 -#define GPS_GPIO_PORT GPIOA -#define GPS_RX_PIN GPIO_Pin_3 -#define GPS_TX_PIN GPIO_Pin_2 -#define GPS_REMAP_FUNC { } -#define GPS_IRQ_CHANNEL USART2_IRQn -#define GPS_IRQHANDLER_FUNC void USART2_IRQHandler(void) -#define GPS_CLK_FUNC RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE) -#define GPS_NVIC_PRIO IRQ_PRIO_HIGHEST +#define GPS_UART USART2 +#define GPS_BAUD 57600 +#define GPS_GPIO_PORT GPIOA +#define GPS_RX_PIN GPIO_Pin_3 +#define GPS_TX_PIN GPIO_Pin_2 +#define GPS_REMAP_FUNC { } +#define GPS_IRQ_CHANNEL USART2_IRQn +#define GPS_IRQHANDLER_FUNC void USART2_IRQHandler(void) +#define GPS_CLK_FUNC RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE) +#define GPS_NVIC_PRIO IRQ_PRIO_HIGHEST //------------------------- // Telemetry radio UART //------------------------- -#define TELEM_UART USART3 -#define TELEM_BAUD 115200 +#define TELEM_UART USART3 +#define TELEM_BAUD 115200 #define TELEM_GPIO_PORT GPIOC -#define TELEM_RX_PIN GPIO_Pin_11 -#define TELEM_TX_PIN GPIO_Pin_10 -#define TELEM_REMAP_FUNC { GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE); } -#define TELEM_IRQ_CHANNEL USART3_IRQn +#define TELEM_RX_PIN GPIO_Pin_11 +#define TELEM_TX_PIN GPIO_Pin_10 +#define TELEM_REMAP_FUNC { GPIO_PinRemapConfig(GPIO_PartialRemap_USART3, ENABLE); } +#define TELEM_IRQ_CHANNEL USART3_IRQn #define TELEM_IRQHANDLER_FUNC void USART3_IRQHandler(void) -#define TELEM_CLK_FUNC RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE) -#define TELEM_NVIC_PRIO IRQ_PRIO_HIGHEST +#define TELEM_CLK_FUNC RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART3, ENABLE) +#define TELEM_NVIC_PRIO IRQ_PRIO_HIGHEST //------------------------- // AUXSER USART (available instead of RX5/RX6) //------------------------- -#define AUX_UART_BAUD 19200 -#define AUX_UART_UART USART1 -#define AUX_UART_GPIO_PORT GPIOA -#define AUX_UART_RX_PIN GPIO_Pin_10 -#define AUX_UART_TX_PIN GPIO_Pin_9 -#define AUX_UART_REMAP_FUNC { } +#define AUX_UART_BAUD 19200 +#define AUX_UART_UART USART1 +#define AUX_UART_GPIO_PORT GPIOA +#define AUX_UART_RX_PIN GPIO_Pin_10 +#define AUX_UART_TX_PIN GPIO_Pin_9 +#define AUX_UART_REMAP_FUNC { } #define AUX_UART_IRQ_CHANNEL USART1_IRQn #define AUX_UART_IRQHANDLER_FUNC void USART1_IRQHandler(void) -#define AUX_UART_CLK_FUNC RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE) -#define AUX_UART_NVIC_PRIO IRQ_PRIO_HIGH +#define AUX_UART_CLK_FUNC RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1, ENABLE) +#define AUX_UART_NVIC_PRIO IRQ_PRIO_HIGH //------------------------- // USART Serial Ports //------------------------- -#define UART_NUM 3 -#define UART_RX_BUFFER_SIZE 128 -#define UART_TX_BUFFER_SIZE 128 +#define UART_NUM 3 +#define UART_RX_BUFFER_SIZE 128 +#define UART_TX_BUFFER_SIZE 128 //------------------------- // Receiver PWM inputs //------------------------- -#define RECEIVER1_GPIO_PORT GPIOB -#define RECEIVER1_PIN GPIO_Pin_2 // PB2 -#define RECEIVER1_TIM_PORT TIM3 -#define RECEIVER1_CH TIM_Channel_3 // TIM3_CH3 -#define RECEIVER2_GPIO_PORT GPIOB -#define RECEIVER2_PIN GPIO_Pin_1 // PB1 -#define RECEIVER2_TIM_PORT TIM3 -#define RECEIVER2_CH TIM_Channel_4 // TIM3_CH4 -#define RECEIVER3_GPIO_PORT GPIOA -#define RECEIVER3_PIN GPIO_Pin_8 // PA8 -#define RECEIVER3_TIM_PORT TIM1 -#define RECEIVER3_CH TIM_Channel_1 // TIM1_CH1 -#define RECEIVER4_GPIO_PORT GPIOA -#define RECEIVER4_PIN GPIO_Pin_0 // PA0 -#define RECEIVER4_TIM_PORT TIM5 -#define RECEIVER4_CH TIM_Channel_1 // TIM5_CH1 -#define RECEIVER5_GPIO_PORT GPIOA -#define RECEIVER5_PIN GPIO_Pin_10 // PA10 -#define RECEIVER5_TIM_PORT TIM1 -#define RECEIVER5_CH TIM_Channel_3 // TIM1_CH3 -#define RECEIVER6_GPIO_PORT GPIOA -#define RECEIVER6_PIN GPIO_Pin_9 // PA9 -#define RECEIVER6_TIM_PORT TIM1 -#define RECEIVER6_CH TIM_Channel_2 // TIM1_CH2 +#define RECEIVER1_GPIO_PORT GPIOB +#define RECEIVER1_PIN GPIO_Pin_2 // PB2 +#define RECEIVER1_TIM_PORT TIM3 +#define RECEIVER1_CH TIM_Channel_3 // TIM3_CH3 +#define RECEIVER2_GPIO_PORT GPIOB +#define RECEIVER2_PIN GPIO_Pin_1 // PB1 +#define RECEIVER2_TIM_PORT TIM3 +#define RECEIVER2_CH TIM_Channel_4 // TIM3_CH4 +#define RECEIVER3_GPIO_PORT GPIOA +#define RECEIVER3_PIN GPIO_Pin_8 // PA8 +#define RECEIVER3_TIM_PORT TIM1 +#define RECEIVER3_CH TIM_Channel_1 // TIM1_CH1 +#define RECEIVER4_GPIO_PORT GPIOA +#define RECEIVER4_PIN GPIO_Pin_0 // PA0 +#define RECEIVER4_TIM_PORT TIM5 +#define RECEIVER4_CH TIM_Channel_1 // TIM5_CH1 +#define RECEIVER5_GPIO_PORT GPIOA +#define RECEIVER5_PIN GPIO_Pin_10 // PA10 +#define RECEIVER5_TIM_PORT TIM1 +#define RECEIVER5_CH TIM_Channel_3 // TIM1_CH3 +#define RECEIVER6_GPIO_PORT GPIOA +#define RECEIVER6_PIN GPIO_Pin_9 // PA9 +#define RECEIVER6_TIM_PORT TIM1 +#define RECEIVER6_CH TIM_Channel_2 // TIM1_CH2 /* Not used in v1.2 HW -#define RECEIVER7_GPIO_PORT GPIOB -#define RECEIVER7_PIN GPIO_Pin_4 // PB4 -#define RECEIVER7_TIM_PORT TIM3 -#define RECEIVER7_CH TIM_Channel_1 // TIM3_CH1 -#define RECEIVER8_GPIO_PORT GPIOB -#define RECEIVER8_PIN GPIO_Pin_5 // PB5 -#define RECEIVER8_TIM_PORT TIM3 -#define RECEIVER8_CH TIM_Channel_2 // TIM3_CH2 +#define RECEIVER7_GPIO_PORT GPIOB +#define RECEIVER7_PIN GPIO_Pin_4 // PB4 +#define RECEIVER7_TIM_PORT TIM3 +#define RECEIVER7_CH TIM_Channel_1 // TIM3_CH1 +#define RECEIVER8_GPIO_PORT GPIOB +#define RECEIVER8_PIN GPIO_Pin_5 // PB5 +#define RECEIVER8_TIM_PORT TIM3 +#define RECEIVER8_CH TIM_Channel_2 // TIM3_CH2 */ -#define NUM_RECEIVER_INPUTS 6 +#define NUM_RECEIVER_INPUTS 6 //------------------------- // Servo outputs //------------------------- -#define SERVO1_4_PORT GPIOB -#define SERVO1_PIN GPIO_Pin_6 -#define SERVO2_PIN GPIO_Pin_7 -#define SERVO3_PIN GPIO_Pin_8 -#define SERVO4_PIN GPIO_Pin_9 -#define SERVO5_8_PORT GPIOC -#define SERVO5_PIN GPIO_Pin_6 -#define SERVO6_PIN GPIO_Pin_7 -#define SERVO7_PIN GPIO_Pin_8 -#define SERVO8_PIN GPIO_Pin_9 +#define SERVO1_4_PORT GPIOB +#define SERVO1_PIN GPIO_Pin_6 +#define SERVO2_PIN GPIO_Pin_7 +#define SERVO3_PIN GPIO_Pin_8 +#define SERVO4_PIN GPIO_Pin_9 +#define SERVO5_8_PORT GPIOC +#define SERVO5_PIN GPIO_Pin_6 +#define SERVO6_PIN GPIO_Pin_7 +#define SERVO7_PIN GPIO_Pin_8 +#define SERVO8_PIN GPIO_Pin_9 -#define NUM_SERVO_OUTPUTS 8 +#define NUM_SERVO_OUTPUTS 8 //------------------------- // Leveler (analog inputs) //------------------------- -#define LEVELER_GPIO_PORT GPIOC -#define LEVELER_Z_PIN GPIO_Pin_0 // ADC123_IN10 -#define LEVELER_A_PIN GPIO_Pin_1 // ADC123_IN11 -#define LEVELER_B_PIN GPIO_Pin_2 // ADC123_IN12 +#define LEVELER_GPIO_PORT GPIOC +#define LEVELER_Z_PIN GPIO_Pin_0 // ADC123_IN10 +#define LEVELER_A_PIN GPIO_Pin_1 // ADC123_IN11 +#define LEVELER_B_PIN GPIO_Pin_2 // ADC123_IN12 //------------------------- // USB //------------------------- -#define USB_ACC_GPIO_PORT GPIOC -#define USB_DETECT_PIN GPIO_Pin_4 -#define USB_PULLUP_PIN GPIO_Pin_14 +#define USB_ACC_GPIO_PORT GPIOC +#define USB_DETECT_PIN GPIO_Pin_4 +#define USB_PULLUP_PIN GPIO_Pin_14 //------------------------- // Master Clock //------------------------- -#define MASTER_CLOCK 72000000 -#define PERIPHERAL_CLOCK (MASTER_CLOCK/2) +#define MASTER_CLOCK 72000000 +#define PERIPHERAL_CLOCK (MASTER_CLOCK/2) //------------------------- // Interrupt Priorities //------------------------- -#define IRQ_PRIO_LOW 12 // lower than RTOS -#define IRQ_PRIO_MID 8 // higher than RTOS -#define IRQ_PRIO_HIGH 5 // for like SPI, AIN, I2C etc... -#define IRQ_PRIO_HIGHEST 4 // for UART etc... +#define IRQ_PRIO_LOW 12 // lower than RTOS +#define IRQ_PRIO_MID 8 // higher than RTOS +#define IRQ_PRIO_HIGH 5 // for like SPI, AIN, I2C etc... +#define IRQ_PRIO_HIGHEST 4 // for UART etc... #endif /* PIOS_BOARD_H */ diff --git a/flight/sys/pios_irq.c b/flight/sys/pios_irq.c index b2fb68fbe..6f2a9edf3 100644 --- a/flight/sys/pios_irq.c +++ b/flight/sys/pios_irq.c @@ -30,11 +30,6 @@ #include "pios.h" -/* Public Function Prototypes */ -int IRQDisable(void); -int IRQEnable(void); - - /* Private Function Prototypes */ @@ -46,13 +41,13 @@ static unsigned int nested_ctr; static unsigned int prev_primask; -/******************************************************************************* +/** * Function Name : IRQDisable * Description : Disables all interrupts (nested) * Input : None * Output : None * Return : Zero on no error -*******************************************************************************/ +*/ int IRQDisable(void) { /* Get current priority if nested level == 0 */ @@ -77,13 +72,13 @@ int IRQDisable(void) } -/******************************************************************************* +/** * Function Name : IRQEnable * Description : Enables all interrupts (nested) * Input : None * Output : None * Return : Zero on no error, -1 on nesting error -*******************************************************************************/ +*/ int IRQEnable(void) { /* Check for nesting error */ diff --git a/flight/sys/pios_led.c b/flight/sys/pios_led.c index 22c4434a5..a4439aca9 100644 --- a/flight/sys/pios_led.c +++ b/flight/sys/pios_led.c @@ -30,13 +30,6 @@ #include "pios.h" -/* Public Function Prototypes */ -void LED_INIT(void); -void LED_ON(LedTypeDef LEDNum); -void LED_OFF(LedTypeDef LEDNum); -void LED_TOGGLE(LedTypeDef LEDNum); - - /* Private Function Prototypes */ @@ -46,13 +39,13 @@ const uint16_t LED_GPIO_PIN[NUM_LED] = {LED1_GPIO_PIN, LED2_GPIO_PIN}; const uint32_t LED_GPIO_CLK[NUM_LED] = {LED1_GPIO_CLK, LED2_GPIO_CLK}; -/******************************************************************************* +/** * Function Name : LED_INIT * Description : Initialises all the LED's * Input : None * Output : None * Return : None -*******************************************************************************/ +*/ void LED_INIT(void) { GPIO_InitTypeDef GPIO_InitStructure; @@ -67,39 +60,39 @@ void LED_INIT(void) } -/******************************************************************************* +/** * Function Name : LED_ON * Description : Turn on LED * Input : LED Number * Output : None * Return : None -*******************************************************************************/ +*/ void LED_ON(LedTypeDef LEDNum) { LED_GPIO_PORT[LEDNum]->BSRR = LED_GPIO_PIN[LEDNum]; } -/******************************************************************************* +/** * Function Name : LED_OFF * Description : Turn off LED * Input : LED Number * Output : None * Return : None -*******************************************************************************/ +*/ void LED_OFF(LedTypeDef LEDNum) { LED_GPIO_PORT[LEDNum]->BRR = LED_GPIO_PIN[LEDNum]; } -/******************************************************************************* +/** * Function Name : LED_TOGGLE * Description : Turn on/off LED * Input : LED Number * Output : None * Return : None -*******************************************************************************/ +*/ void LED_TOGGLE(LedTypeDef LEDNum) { LED_GPIO_PORT[LEDNum]->ODR ^= LED_GPIO_PIN[LEDNum]; diff --git a/flight/sys/pios_settings.c b/flight/sys/pios_settings.c index e506b2034..770e54a95 100644 --- a/flight/sys/pios_settings.c +++ b/flight/sys/pios_settings.c @@ -30,10 +30,6 @@ #include "pios.h" -/* Public Function Prototypes */ -void LoadSettings(void); - - /* Private Function Prototypes */ @@ -41,7 +37,7 @@ void LoadSettings(void); SettingsTypeDef Settings; -/******************************************************************************* +/** * Function Name : LoadSettings * Description : Populate System global Vars into Structs using MinIni, * : defaults are also set here. Only function in the file @@ -50,7 +46,7 @@ SettingsTypeDef Settings; * 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); */ diff --git a/flight/sys/pios_sys.c b/flight/sys/pios_sys.c index 989f7e5c1..7fff442d3 100644 --- a/flight/sys/pios_sys.c +++ b/flight/sys/pios_sys.c @@ -30,10 +30,6 @@ #include "pios.h" -/* Public Function Prototypes */ -void SysInit(void); - - /* Private Function Prototypes */ void NVIC_Configuration(void); @@ -42,13 +38,13 @@ void NVIC_Configuration(void); 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) { @@ -76,26 +72,26 @@ void SysInit(void) } -/******************************************************************************* +/** * Function Name : GPIO_Configuration * Description : Configures base level GPIO ports. * Input : None * Output : None * Return : None -*******************************************************************************/ +*/ void GPIO_Configuration(void) { } -/******************************************************************************* +/** * Function Name : NVIC_Configuration * Description : Configures Vector Table base location and SysTick * Input : None * Output : None * Return : None -*******************************************************************************/ +*/ void NVIC_Configuration(void) { /* Set the Vector Table base address as specified in .ld file */ diff --git a/flight/sys/pios_uart.c b/flight/sys/pios_uart.c index 0c00c1ff1..402b607db 100644 --- a/flight/sys/pios_uart.c +++ b/flight/sys/pios_uart.c @@ -30,13 +30,6 @@ #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 */ @@ -52,13 +45,13 @@ static volatile u8 tx_buffer_head[UART_NUM]; static volatile u8 tx_buffer_size[UART_NUM]; -/******************************************************************************* +/** * Function Name : UARTInit * Description : Initialise the GPS and TELEM onboard UARTs * Input : None * Output : None * Return : None -*******************************************************************************/ +*/ void UARTInit(void) { GPIO_InitTypeDef GPIO_InitStructure; @@ -149,40 +142,40 @@ 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 } -/******************************************************************************* +/** * 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 */