This is a fork of the `events` subdirectory of https://github.com/ARMmbed/mbed-os
Dependents: HelloWorld_CCA01M1 HelloWorld_CCA02M1 CI-data-logger-server HelloWorld_CCA02M1 ... more
This is a fork of the events subdirectory of https://github.com/ARMmbed/mbed-os.
Note, you must import this library with import name: events!!!
Revision 6548:c08cb6087b0a, committed 2016-06-15
- Comitter:
- Christopher Haster
- Date:
- Wed Jun 15 20:57:25 2016 -0500
- Parent:
- 6547:5f2779e36035
- Child:
- 6549:723eda4f0297
- Commit message:
- Added config option for newline conversion
Changed in this revision
| hal/common/retarget.cpp | Show annotated file Show diff for this revision Revisions of this file |
| mbed_lib.json | Show annotated file Show diff for this revision Revisions of this file |
--- a/hal/common/retarget.cpp Tue Jun 07 10:08:07 2016 -0500
+++ b/hal/common/retarget.cpp Wed Jun 15 20:57:25 2016 -0500
@@ -88,9 +88,11 @@
#if DEVICE_SERIAL
extern int stdio_uart_inited;
extern serial_t stdio_uart;
+#ifdef MBED_CONF_CORE_STDIO_CONVERT_NEWLINES
static char stdio_in_prev;
static char stdio_out_prev;
#endif
+#endif
static void init_serial() {
#if DEVICE_SERIAL
@@ -228,6 +230,7 @@
if (fh < 3) {
#if DEVICE_SERIAL
if (!stdio_uart_inited) init_serial();
+#ifdef MBED_CONF_CORE_STDIO_CONVERT_NEWLINES
for (unsigned int i = 0; i < length; i++) {
if (buffer[i] == '\n' && stdio_out_prev != '\r') {
serial_putc(&stdio_uart, '\r');
@@ -235,6 +238,11 @@
serial_putc(&stdio_uart, buffer[i]);
stdio_out_prev = buffer[i];
}
+#else
+ for (unsigned int i = 0; i < length; i++) {
+ serial_putc(&stdio_uart, buffer[i]);
+ }
+#endif
#endif
n = length;
} else {
@@ -260,6 +268,7 @@
// only read a character at a time from stdin
#if DEVICE_SERIAL
if (!stdio_uart_inited) init_serial();
+#ifdef MBED_CONF_CORE_STDIO_CONVERT_NEWLINES
while (true) {
char c = serial_getc(&stdio_uart);
if ((c == '\r' && stdio_in_prev != '\n') ||
@@ -278,6 +287,9 @@
break;
}
}
+#else
+ *buffer = serial_getc(&stdio_uart);
+#endif
#endif
n = 1;
} else {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed_lib.json Wed Jun 15 20:57:25 2016 -0500
@@ -0,0 +1,8 @@
+{
+ "name": "core",
+ "config": {
+ "stdio-convert-newlines": {
+ "help": "Enable conversion to standard newlines on stdin/stdout"
+ }
+ }
+}