Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Nucleo_F103RB_RTC_battery_bkup_pwr_off_okay
Fork of mbed-dev by
Diff: platform/mbed_board.c
- Revision:
- 160:d5399cc887bb
- Parent:
- 149:156823d33999
- Child:
- 163:74e0ce7f98e8
diff -r 612c381a210f -r d5399cc887bb platform/mbed_board.c
--- a/platform/mbed_board.c Tue Feb 28 17:13:35 2017 +0000
+++ b/platform/mbed_board.c Tue Mar 14 16:40:56 2017 +0000
@@ -15,10 +15,10 @@
*/
#include <stdio.h>
#include "hal/gpio_api.h"
-#include "platform/wait_api.h"
-#include "platform/toolchain.h"
+#include "platform/mbed_wait_api.h"
+#include "platform/mbed_toolchain.h"
#include "platform/mbed_interface.h"
-#include "platform/critical.h"
+#include "platform/mbed_critical.h"
#include "hal/serial_api.h"
#if DEVICE_SERIAL
@@ -75,16 +75,31 @@
void mbed_error_vfprintf(const char * format, va_list arg) {
#if DEVICE_SERIAL
+
+#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
+ char stdio_out_prev;
+#endif
+
core_util_critical_section_enter();
char buffer[128];
int size = vsprintf(buffer, format, arg);
if (size > 0) {
if (!stdio_uart_inited) {
- serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
+ serial_init(&stdio_uart, STDIO_UART_TX, STDIO_UART_RX);
}
- for (int i = 0; i < size; i++) {
+#if MBED_CONF_PLATFORM_STDIO_CONVERT_NEWLINES
+ for (unsigned int i = 0; i < size; i++) {
+ if (buffer[i] == '\n' && stdio_out_prev != '\r') {
+ serial_putc(&stdio_uart, '\r');
+ }
+ serial_putc(&stdio_uart, buffer[i]);
+ stdio_out_prev = buffer[i];
+ }
+#else
+ for (unsigned int i = 0; i < size; i++) {
serial_putc(&stdio_uart, buffer[i]);
}
+#endif
}
core_util_critical_section_exit();
#endif
