2011-10-17 09:59 AM
Hi guys,
I am trying to retarget scanf for USART1 of STM32 using Atollic. I think the utilized toolchain makes use of _read_r for the scanf (please verify if possible). So I need a new definition of _read_r. Any ideas?I have looked at IAR's _read for keyboard I/O and tried to modify for Atollic (_read_r redirected to USART1) but no luck until now. Thanks!2011-10-17 11:59 AM
http://mcu.cz/print.php?news.2265
int
_read_r
(
void
*reent, uint16_t fd,char
*ptr, uint32_t len)
{
uint32_t counter = len;
USART_TypeDef *Usart;
if
(
fd == STDIN_FILENO)
{
// stdin from UARTx
Usart = USART1;
}
else
{
return
len;
}
while
(
counter-- >0
)
{
// Read the character to the buffer from UART
while
(
USART_GetFlagStatus(
Usart, USART_FLAG_RXNE)
== RESET)
;*ptr = USART_ReceiveData
(
Usart)
;ptr++;
}
return
len;}
2011-10-18 12:59 AM