diff options
| author | Damien George <damien.p.george@gmail.com> | 2014-07-31 10:30:42 +0100 | 
|---|---|---|
| committer | Damien George <damien.p.george@gmail.com> | 2014-07-31 10:30:42 +0100 | 
| commit | 3c4db9f91c01211aed47afe3efdd11477badc0bc (patch) | |
| tree | ba4a7fbf2d13c672992966469f5bf7abf7ec1d98 /stmhal/pybstdio.c | |
| parent | 5f27a7e81135f7a7c0c75ee551fe0c6103048046 (diff) | |
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.
Diffstat (limited to 'stmhal/pybstdio.c')
| -rw-r--r-- | stmhal/pybstdio.c | 6 | 
1 files changed, 4 insertions, 2 deletions
| 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);          } | 
