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/usb.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'stmhal/usb.h') diff --git a/stmhal/usb.h b/stmhal/usb.h index 4eb29c9de..5153cb5fa 100644 --- a/stmhal/usb.h +++ b/stmhal/usb.h @@ -41,13 +41,14 @@ typedef enum { USB_STORAGE_MEDIUM_SDCARD, } usb_storage_medium_t; +const mp_obj_type_t pyb_usb_vcp_type; + void pyb_usb_dev_init(usb_device_mode_t mode, usb_storage_medium_t medium); void pyb_usb_dev_stop(void); bool usb_vcp_is_enabled(void); bool usb_vcp_is_connected(void); void usb_vcp_set_interrupt_char(int c); -int usb_vcp_rx_num(void); -char usb_vcp_rx_get(void); +int usb_vcp_recv_byte(uint8_t *c); void usb_vcp_send_strn(const char* str, int len); void usb_vcp_send_strn_cooked(const char *str, int len); void usb_hid_send_report(uint8_t *buf); // 4 bytes for mouse: ?, x, y, ? -- cgit v1.2.3