/* Configure the com port */
/* USARTx configuration ------------------------------------------------------*/
/* USARTx configured as follow:
- BaudRate = 115200 baud
- Word Length = 8 Bits
- One Stop Bit
- No parity
- Hardware flow control disabled">led (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;
STM_EVAL_COMInit(COM1, &USART_InitStructure);
}
/**
* @brief Retargets the C library printf function to the USART.
* @param None
* @retval : None
*/
int fputc(int ch, FILE *f)
{
/* Write a character to the USART */
USART_SendData(USART2, (uint8_t) ch);
/* Loop until the end of transmission */
while(USART_GetFlagStatus(USART2, USART_FLAG_TXE) == RESET)
{
}
return ch;
}
/**
* @brief Get a key from the HyperTerminal
* @param None
* @retval : The Key Pressed
*/
int fgetc(FILE *f)
{
/* Waiting for user input */
while ( USART_GetFlagStatus(USART2, USART_FLAG_RXNE) == RESET);
return (uint8_t)USART2->DR;