summaryrefslogtreecommitdiff
path: root/stmhal/usb.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2014-07-31 10:30:42 +0100
committerDamien George <damien.p.george@gmail.com>2014-07-31 10:30:42 +0100
commit3c4db9f91c01211aed47afe3efdd11477badc0bc (patch)
treeba4a7fbf2d13c672992966469f5bf7abf7ec1d98 /stmhal/usb.h
parent5f27a7e81135f7a7c0c75ee551fe0c6103048046 (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/usb.h')
-rw-r--r--stmhal/usb.h5
1 files changed, 3 insertions, 2 deletions
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, ?