[LIBC IAR]Implement the _write_r function in libc_iar
Alios need this function implemented in IAR, to support standard
printf function. This function not implemented in libc files for IAR.
@@ -79,9 +79,28 @@ void __assert_func(const char * a, int b, const char * c, const char *d)
}
/*TO DO*/
-void __write()
+#pragma weak __write
+size_t __write(int handle, const unsigned char *buffer, size_t size)
{
+ if (buffer == 0)
+ {
+ /*
+ * This means that we should flush internal buffers. Since we don't we just return.
+ * (Remember, "handle" == -1 means that all handles should be flushed.)
+ */
+ return 0;
+ }
+
+ /* This function only writes to "standard out" and "standard err" for all other file handles it returns failure. */
+ if ((handle != 1) && (handle != 2))
+ {
+ return ((size_t)-1);
+ }
+
+ /* Send data. */
+ aos_uart_send(buffer, size, 1000);
+ return size;
}
void bzero()
