From 3c4db9f91c01211aed47afe3efdd11477badc0bc Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 31 Jul 2014 10:30:42 +0100 Subject: stmhal: Add USB_VCP class/object, for direct USB VCP control. Before, pyb.stdin/pyb.stdout allowed some kind of access to the USB VCP device, but it was basic access. This patch adds a proper USB_VCP class and object with much more control over the USB VCP device. Create an object with pyb.USB_VCP(), then use this object as if it were a UART object. It has send, recv, read, write, and other methods. send and recv allow a timeout to be specified. Addresses issue 774. --- stmhal/pybstdio.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'stmhal/pybstdio.c') diff --git a/stmhal/pybstdio.c b/stmhal/pybstdio.c index 88f47d1b4..2121a6cbb 100644 --- a/stmhal/pybstdio.c +++ b/stmhal/pybstdio.c @@ -84,8 +84,10 @@ int stdin_rx_chr(void) { } #endif #endif - if (usb_vcp_rx_num() != 0) { - return usb_vcp_rx_get(); + + byte c; + if (usb_vcp_recv_byte(&c) != 0) { + return c; } else if (pyb_stdio_uart != PYB_UART_NONE && uart_rx_any(pyb_stdio_uart)) { return uart_rx_char(pyb_stdio_uart); } -- cgit v1.2.3