#include "stm32f10x_rcc.h" // Keil:evice:StdPeriph Drivers:RCC
#include "stm32f10x_gpio.h" // Keil:evice:StdPeriph Drivers:GPIO
#include "stm32f10x_usart.h" // Keil:evice:StdPeriph Drivers:USART
#include "stdio.h"
int fputc(int ch, FILE *f)
{
USART_SendData(USART1, (uint8_t) ch);
while (USART_GetFlagStatus(USART1, USART_FLAG_TC) == RESET);
return (ch);
}
int main(void)
{
USART_InitTypeDef us;
GPIO_InitTypeDef io;
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1|
RCC_APB2Periph_GPIOA,ENABLE);
io.GPIO_Mode = GPIO_Mode_AF_PP;
io.GPIO_Pin = GPIO_Pin_9;
io.GPIO_Speed= GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&io);
us.USART_BaudRate = 115200;
us.USART_HardwareFlowControl =USART_HardwareFlowControl_None;
us.USART_Mode = USART_Mode_Tx | USART_Mode_Rx;
us.USART_Parity = USART_Parity_No;
us.USART_StopBits = USART_StopBits_1;
us.USART_WordLength = USART_WordLength_8b;
USART_Init(USART1,&us);
USART_Cmd(USART1,ENABLE);
printf("ddsdfasdf");
while(1){}
return 0;
}
|
|