/*******************************************************************************
* Function Name : main
* Description : Main program
* Input : None
* Output : None
* Return : None
*******************************************************************************/
int main(void) //主函数
{
#ifdef DEBUG
debug();
#endif
//int Tx_Data;
int i;
u8 RxCounter = 0;
u8 RxBuffer[RxBufferSize];
/* System Clocks Configuration */
RCC_Configuration();
/* NVIC configuration */
// NVIC_Configuration();
/* Configure the GPIO ports */
GPIO_Configuration();
/* USART1 configuration ------------------------------------------------------*/
/* USART1 configured as follow:
- BaudRate = 9600 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
- USART Clock disabled
- USART CPOL: Clock is active low
- USART CPHA: Data is captured on the second edge
- USART LastBit: The clock pulse of the last data bit is not output to
the SCLK pin
*/
USART_InitStructure.USART_BaudRate = 115200; //设置USART传输波特率
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时钟低电平活动
USART_InitStructure.USART_CPOL = USART_CPOL_Low; //指定了下SLCK引脚上时钟输出的极性
USART_InitStructure.USART_CPHA = USART_CPHA_2Edge;//指定了下SLCK引脚上时钟输出的相位
/******控制是否在同步模式下,在SCLK引脚上输出最后发送的哪个数据字对应的时钟脉冲
最后一位数据的时钟脉冲不从SCLK输出***/
USART_InitStructure.USART_LastBit = USART_LastBit_Disable;
/* Configure the USART1 */
USART_Init(USART1, &USART_InitStructure); //初始化外设USARTx寄存器
/* Enable the USART Receive interrupt: this interrupt is generated when the
USART1 receive data register is not empty */
USART_ITConfig(USART1, USART_IT_RXNE, ENABLE); //使能接收中断
USART_ITConfig(USART1, USART_IT_TXE, ENABLE); //使能发送中断
/* Enable USART1 */
USART_Cmd(USART1, ENABLE);//使能或者失能USART外设
// Tx_Data=0x30;
/*Configure PB11 as output for LD3*/
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_1; //IO端口的第1位
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz; //翻转速度为50M
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_Out_PP; //端口模式为推拉输出方式
GPIO_Init(GPIOA, &GPIO_InitStructure); //用以上几个参数初始化PA口
/*Configure PB10 as output for LD4*/
GPIO_InitStructure.GPIO_Pin =GPIO_Pin_4; //IO端口的第4位
GPIO_Init(GPIOA, &GPIO_InitStructure); //用以上几个参数初始化PA口
}
#ifdef DEBUG
/*******************************************************************************
* Function Name : assert_failed
* Description : Reports the name of the source file and the source line number
* where the assert error has occurred.
* Input : - file: pointer to the source file name
* - line: assert error line source number
* Output : None
* Return : None
*******************************************************************************/
void assert_failed(u8* file, u32 line)
{
/* User can add his own implementation to report the file name and line number,
ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
/* Infinite loop */
while (1)
{
}
}
#endif
/******************* (C) COPYRIGHT 2007 STMicroelectronics *****END OF FILE****/