验证中...
gistfile1.txt
Raw Copy
#include <stdio.h>
#include <errno.h>
#include <sys/unistd.h> // STDOUT_FILENO, STDERR_FILENO
int _write(int file, char *ptr, int len)
{
switch (file)
{
case STDOUT_FILENO: //stdout
// Send the string somewhere
HAL_UART_Transmit(&huart1, (uint8_t*)ptr, len, 100);
break;
case STDERR_FILENO: // stderr
// Send the string somewhere
break;
default:
return -1;
}
return len;
/*if ((file != STDOUT_FILENO) && (file != STDERR_FILENO))
{
//errno = EBADF;
return -1;
}
// arbitrary timeout 1000
HAL_StatusTypeDef status =
HAL_UART_Transmit(&huart1, (uint8_t *)ptr, len, 1000);
// return # of bytes written - as best we can tell
return (status == HAL_OK ? len : 0);*/
}

Comment list( 0 )

You need to Sign in for post a comment

Help Search