int main()
{
if (SysTick_Config(SystemCoreClock / 1000))
{
/* Capture error */
while (1);
}
USART_Config();//´®¿Ú2¶ÔÍâÊäÈëÊä³ö
Senddata('a');
//USART_SendData(USART2, 0x55);
// printf("\n\rUSART is OK! \n\r");
// GPIO_Contrl();//¿ØÖÆÐźŶ¨Òå;
// printf("\n\rGPIO is OK! \n\r");
// EXTI13_Config();//PA13Ϊ´¥ÃþÆÁ´¥ÃþÖжÏ
// printf("\n\rEXIT is OK! \n\r");
//// USBD_Init(&USB_Device_dev,
//// &USR_desc,
//// &USBD_HID_cb,
//// &USR_cb);
// printf("\n\rUSB is OK! \n\r");
// printf("\n\rInitialization is OK! \n\r");
while (1)
{
for(index_xx=65536;index_xx>0;index_xx--){;}
Senddata('a');
}
}
static void USART_Config(void)
{
/* Enable GPIO clock */
RCC_AHBPeriphClockCmd(RCC_AHBPeriph_GPIOA, ENABLE);
/* Enable USART clock */
RCC_APB1PeriphClockCmd(RCC_APB1Periph_USART2, ENABLE);
/* Connect PXx to USARTx_Tx */
GPIO_PinAFConfig(GPIOA, GPIO_PinSource2, GPIO_AF_0);
/* Connect PXx to USARTx_Rx */
GPIO_PinAFConfig(GPIOA, GPIO_PinSource3, GPIO_AF_0);
/* Configure USART Tx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_2;
GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT;
GPIO_InitStructure.GPIO_Speed = GPIO_Speed_50MHz;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* Configure USART Rx as alternate function push-pull */
GPIO_InitStructure.GPIO_Pin = GPIO_Pin_3;
GPIO_InitStructure.GPIO_Mode=GPIO_Mode_IN;
GPIO_Init(GPIOA, &GPIO_InitStructure);
/* USARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- Stop Bit = 1 Stop Bit
- Parity = No Parity
- Hardware flow control disabled (RTS and CTS signals)
- Receive and transmit enabled
*/
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 configuration */
USART_Init(USART2, &USART_InitStructure);
/* Enable USART */
USART_Cmd(USART2, ENABLE);
}
|