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.
Diff: USBDevice/USBSERIAL/.svn/text-base/USBSerial.cpp.svn-base
- Revision:
- 0:505207de8566
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/USBDevice/USBSERIAL/.svn/text-base/USBSerial.cpp.svn-base Tue Nov 29 21:26:20 2011 +0000
@@ -0,0 +1,45 @@
+// USBSerial.c
+// USB device example: virtual serial port
+// Copyright (c) 2011 ARM Limited. All rights reserved
+
+#include "stdint.h"
+#include "USBSerial.h"
+#include "USBBusInterface.h"
+
+
+int USBSerial::_putc(int c) {
+ send(EPBULK_IN, (uint8_t *)&c, 1);
+ return 1;
+}
+
+int USBSerial::_getc() {
+ uint16_t size = 0;
+ uint8_t c[65];
+ if (!USBCDC::read(EPBULK_OUT, c, &size, 1))
+ return -1;
+ return c[0];
+}
+
+
+void USBSerial::attach(void (*ptr)(void))
+{
+ handler = true;
+ proc = true;
+ fn = ptr;
+}
+
+bool USBSerial::EPBULK_OUT_callback()
+{
+ if(handler)
+ {
+ if(proc)
+ (*fn)();
+ else
+ rx.call();
+
+ // We reactivate the endpoint to receive next characters
+ readStart(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK);
+ return true;
+ }
+ return false;
+}