#include "stm32f10x_lib.h"
#include "stdio.h"
ErrorStatus HSEStartUpStatus;//errorstatus是一种数据类型,在固件库里面有,是布尔0/1
void RCC_Configuration(void);
void NVIC_Configuration(void);
void GPIO_Configuration(void);
void USART_Configuration(void);
int main(void)
{
u16 i=0;
#ifdef DEBUG
debug();
#endif
RCC_Configuration();
NVIC_Configuration();
GPIO_Configuration();
USART_Configuration();
printf("please input charter from keyboard\n") ;//printf可直接从串口输出
while(1)
{
if(USART_GetFlagStatus(USART1,USART_IT_RXNE)==SET)//SET表示1的意思,RESET表示0.即RXNE不为空时,可以取数据 IT_RXNE还是FLAG_RXNE?
{
i=USART_ReceiveData(USART1);
printf("%c",i&0xFF);//???
}
}
}
//=========================RCC_Configuration=================
void RCC_Configuration(void)
{
RCC_APB2PeriphClockCmd(RCC_APB2Periph_USART1 | RCC_APB2Periph_GPIOA,ENABLE);
}
//=======================NVIC_Configuration===================
void NVIC_Configuration(void)
{
#ifdef VECT_TAB_RAM
NVIC_SetVectorTable(NVIC_VcetTab_RAM,0x0);
#else
NVIC_SetVectorTable(NVIC_VectTab_FLASH,0x0);
#endif
}
//=======================GPIO_Configuration===================
void GPIO_Configuration(void)
{
GPIO_InitTypeDef GPIO_InitStructure;
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_10;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_AF_PP;
GPIO_InitStructure.GPIO_Speed=GPIO_Speed_50MHz;
GPIO_Init(GPIOA,&GPIO_InitStructure);
GPIO_InitStructure.GPIO_Pin=GPIO_Pin_9;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN_FLOATING;
GPIO_Init(GPIOA,&GPIO_InitStructure);
}
//========================USART_Configuration=======================
void USART_Configuration(void)
{
USART_InitTypeDef USART_InitStructure;
USART_InitStructure.USART_BaudRate=115200;
USART_InitStructure.USART_WordLength=USART_WordLength_8b;
USART_InitStructure.USART_StopBits=USART_StopBits_1;
USART_InitStructure.USART_Parity=USART_Parity_No;
USART_InitStructure.USART_HardwareFlowControl=USART_HardwareFlowControl_None;
USART_InitStructure.USART_Mode=USART_Mode_Rx|USART_Mode_Tx ;
USART_InitStructure.USART_Clock=USART_Clock_Disable;
USART_InitStructure.USART_CPOL=USART_CPOL_Low;
USART_InitStructure.USART_CPHA=USART_CPHA_2Edge;
USART_InitStructure.USART_LastBit=USART_LastBit_Disable;
USART_Init(USART1,&USART_InitStructure);
USART_Cmd(USART1,ENABLE);
}
int fputc(int ch,FILE *f)
{
USART_SendData(USART1,(u8)ch);
while(USART_GetFlagStatus(USART1,USART_FLAG_TC)==RESET)
{
}
return ch;
}
#ifdef DEBUG
void assert_failed(u8* file,u32 line)
{
}
#endif
程序如上了。我在编译的时候出现了usart.axf: Error: L6218E: Undefined symbol assert_failed (referred from stm32f10x_gpio.o).,怎么解决呀,请各位大侠指教
|