modify the behaviour of scanf() stm32f3 discovery
Hi, this is the _read() function I used to redirect scanf to my uart input. The read function needs to read only one byte at the time.
int _read (int file, char *ptr, int len)
{
HAL_UART_Receive(&huart2,(uint8_t*)ptr++,1,0xffff);
HAL_UART_Transmit(&huart2,(uint8_t *)(ptr-1),1,10);
if (*(ptr-1)==0x0D){
HAL_UART_Transmit(&huart2,(uint8_t *)”\n”,1,10);
*(ptr-1)=’\n’;
}
return 1;
}