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.
Fork of DipCortex-USB-CDC by
Revision 0:8c4eea221dcf, committed 2013-10-30
- Comitter:
- yihui
- Date:
- Wed Oct 30 02:01:50 2013 +0000
- Child:
- 1:b9eededaba19
- Commit message:
- a USB to UART bridge
Changed in this revision
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/USBDevice.lib Wed Oct 30 02:01:50 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/yihui/code/USBDevice/#01040319e35c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Wed Oct 30 02:01:50 2013 +0000
@@ -0,0 +1,37 @@
+/**
+ * USB to UART Bridge
+ */
+
+#include "mbed.h"
+#include "USBSerial.h"
+
+Serial uart(USBTX, USBRX);
+USBSerial pc;
+
+// Called by ISR
+void settingsChanged(int baud, int bits, int parity, int stop)
+{
+ const Serial::Parity parityTable[] = {Serial::None, Serial::Odd, Serial::Even, Serial::Forced0, Serial::Forced1};
+
+ if (stop != 2) {
+ stop = 1; // stop bit(s) = 1 or 1.5
+ }
+
+ uart.baud(baud);
+ uart.format(bits, parityTable[parity], stop);
+}
+
+int main()
+{
+ pc.attach(settingsChanged);
+
+ while (1) {
+ while (uart.readable()) {
+ pc.putc(uart.getc());
+ }
+
+ while (pc.readable()) {
+ uart.putc(pc.getc());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.lib Wed Oct 30 02:01:50 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/#f37f3b9c9f0b
