main.c

来自「1 本程序是我自己移植」· C语言 代码 · 共 110 行

C
110
字号
/******************** (C) COPYRIGHT 2007 STMicroelectronics ********************
* File Name          : main.c
* Author             : Jun Yao
* Email							 : nter@tom.com
* Version            : V1.0
* Date               : 07/22/2008
* Description        : Main program body
********************************************************************************/

/* Includes ------------------------------------------------------------------*/
#include "config.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
#define TASK_STK_SIZE	128

/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
INT32U STK_TASK_MAIN[TASK_STK_SIZE];
INT32U STK_TASK_LED[TASK_STK_SIZE];

/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

/*******************************************************************************
* Function Name  : InitSysTick
* Description    : 
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void InitSysTick(void)
{
	/* SysTick end of count event each 1ms with input clock equal to 9MHz (HCLK/8, default) */
  SysTick_SetReload(9000);

  /* Enable SysTick interrupt */
  SysTick_ITConfig(ENABLE);
	
	/* Enable the SysTick Counter */
  SysTick_CounterCmd(SysTick_Counter_Enable);
}

/*******************************************************************************
* Function Name  : MainTask
* Description    : Main Task
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void LedTask(void *pd)
{
	while(1)
	{
		OSTimeDly(500);
		led_on(LED_1);
		led_off(LED_2);
		OSTimeDly(500);
		led_on(LED_2);
		led_off(LED_1);
	}
}

/*******************************************************************************
* Function Name  : MainTask
* Description    : Main Task
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
void MainTask(void *pd)
{
#ifdef DEBUG
  debug();
#endif

  /* System Clocks Configuration */
  RCC_Configuration();
       
  /* NVIC configuration */
  NVIC_Configuration();

  /* Configure the GPIO ports */
  GPIO_Configuration();

	InitSysTick();
	
	OSStatInit();

	OSTaskCreate(LedTask,    (void *)0,(OS_STK *)&STK_TASK_LED[TASK_STK_SIZE-1],  19);
	
	while(1)
	{
		OSTimeDly(100);
	}
}
/*******************************************************************************
* Function Name  : main
* Description    : Main program
* Input          : None
* Output         : None
* Return         : None
*******************************************************************************/
int main(void)
{
	OSInit();
	OSTaskCreate(MainTask,    (void *)0,(OS_STK *)&STK_TASK_MAIN[TASK_STK_SIZE-1],  20);
	OSStart();
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?