clean up main.c

master barebones
q3k 2013-11-18 09:17:45 +01:00
parent 4c34d2643c
commit 5936abb874
1 changed files with 20 additions and 44 deletions

View File

@ -1,48 +1,31 @@
/* Standard includes. */
#include <string.h>
/* Scheduler includes. */
#include "FreeRTOS.h"
#include "task.h"
#include "queue.h"
#include <FreeRTOS.h>
#include <task.h>
#include <queue.h>
/* Library includes. */
#include <stm32f10x.h>
#include <stm32f10x_gpio.h>
#include <stm32f10x_rcc.h>
#include <stm32f10x_it.h>
#include <misc.h>
#include "stm32f10x_it.h"
/* Task priorities. */
#define mainECHO_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define BLINK_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
/* COM port and baud rate used by the echo task. */
#define mainCOM0 ( 0 )
#define mainBAUD_RATE ( 115200 )
static void prvUSARTEchoTask( void *pvParameters );
static void prvSetupHardware(void);
/*-----------------------------------------------------------*/
static void BlinkTask(void *Parameters);
static void SetupHardware(void);
int main(void)
{
prvSetupHardware();
SetupHardware();
/* Create the 'echo' task, which is also defined within this file. */
xTaskCreate( prvUSARTEchoTask, ( signed char * ) "Echo", configMINIMAL_STACK_SIZE, NULL, mainECHO_TASK_PRIORITY, NULL );
xTaskCreate(BlinkTask, "blnk", configMINIMAL_STACK_SIZE, NULL, BLINK_TASK_PRIORITY, NULL);
/* Start the scheduler. */
vTaskStartScheduler();
/* Will only get here if there was insufficient memory to create the idle
task. The idle task is created within vTaskStartScheduler(). */
for( ;; );
}
/*-----------------------------------------------------------*/
/* Described at the top of this file. */
void prvUSARTEchoTask( void *pvParameters )
static void BlinkTask(void *Parameters)
{
for (;;)
{
@ -52,11 +35,9 @@ void prvUSARTEchoTask( void *pvParameters )
vTaskDelay(1000);
}
}
/*-----------------------------------------------------------*/
GPIO_InitTypeDef GPIO_InitStructure;
extern void SystemInit(void);
static void prvSetupHardware( void )
static void SetupHardware(void)
{
// For FreeRTOS interrupt priority
NVIC_PriorityGroupConfig(NVIC_PriorityGroup_4);
@ -68,20 +49,15 @@ static void prvSetupHardware( void )
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP;
GPIO_Init(GPIOB, &GPIO_InitStructure);
}
/*-----------------------------------------------------------*/
void vApplicationStackOverflowHook(xTaskHandle pxTask, signed char *pcTaskName)
{
/* This function will get called if a task overflows its stack. If the
parameters are corrupt then inspect pxCurrentTCB to find which was the
offending task. */
// Use these for debugging
(void) pxTask;
(void) pcTaskName;
for( ;; );
}
/*-----------------------------------------------------------*/
void assert_failed(unsigned char *pucFile, unsigned long ulLine)
{