www.pudn.com > stm32f103c8t6Pucos_ii(v2.91).rar > app.c, change:2015-04-01,size:2221b


#include "pbdata.h" 
 
int fputc(int ch,FILE* f) 
{ 
	USART_SendData(USART1,(u8)ch); 
	while(USART_GetFlagStatus(USART1,USART_FLAG_TXE)==RESET);	  //???????? 
	return ch; 
} 
 
void RCC_Config(void) 
{ 
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_GPIOA,ENABLE); 
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1,ENABLE); 
	RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO,ENABLE); 
} 
 
void GPIO_Config(void) 
{ 
	GPIO_InitTypeDef GPIO_Struct; 
 
	GPIO_Struct.GPIO_Pin=GPIO_Pin_9; 
	GPIO_Struct.GPIO_Speed=GPIO_Speed_50MHz; 
	GPIO_Struct.GPIO_Mode=GPIO_Mode_AF_PP;	   //?????? 
 
	GPIO_Init(GPIOA,&GPIO_Struct); 
 
	GPIO_Struct.GPIO_Pin=GPIO_Pin_10; 
	GPIO_Struct.GPIO_Mode=GPIO_Mode_IN_FLOATING;	 //???? 
 
	GPIO_Init(GPIOA,&GPIO_Struct); 
} 
 
void USART_Config(void) 
{ 
	USART_InitTypeDef USART_Struct; 
 
	USART_Struct.USART_BaudRate=9600; 
	USART_Struct.USART_WordLength=USART_WordLength_8b; 
	USART_Struct.USART_StopBits=USART_StopBits_1; 
	USART_Struct.USART_Parity=USART_Parity_No; 
	USART_Struct.USART_HardwareFlowControl=USART_HardwareFlowControl_None;  //????? 
	USART_Struct.USART_Mode=USART_Mode_Rx|USART_Mode_Tx; 
 
	USART_Init(USART1,&USART_Struct); 
 
	USART_ITConfig(USART1,USART_IT_RXNE,ENABLE);	  //????????? 
	USART_Cmd(USART1,ENABLE); 
	USART_ClearFlag(USART1,USART_FLAG_TC);	  //????????? 
} 
 
void NVIC_Config(void) 
{ 
	NVIC_InitTypeDef NVIC_Struct; 
 
	NVIC_PriorityGroupConfig(NVIC_PriorityGroup_0); 
 
	NVIC_Struct.NVIC_IRQChannel=USART1_IRQn; 
  NVIC_Struct.NVIC_IRQChannelPreemptionPriority = 0; 
	NVIC_Struct.NVIC_IRQChannelSubPriority = 2;  
	NVIC_Struct.NVIC_IRQChannelCmd = ENABLE; 
 
	NVIC_Init(&NVIC_Struct); 
} 
 
 
/***************************************************** 
 *任务一 
*****************************************************/ 
void Task_1(void *p_arg) 
{ 
	(void)p_arg; 
	 
	RCC_Config(); 
	GPIO_Config(); 
	USART_Config(); 
	NVIC_Config(); 
	 
	while(1) 
	{ 
			printf("Task_1 is runing!\r\n"); 
			OSTimeDly(1000); 
	} 
} 
 
/****************************************************** 
 *任务二 
******************************************************/ 
void Task_2(void *p_arg) 
{	 
	(void)p_arg; 
	 
	while(1) 
	{ 
			printf("Task_2 is runing!\r\n"); 
			OSTimeDly(1000); 
	} 
}