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