summaryrefslogtreecommitdiffstatshomepage
path: root/ports/stm32/usbd_hid_interface.h
diff options
context:
space:
mode:
authorDamien George <damien.p.george@gmail.com>2017-09-05 14:07:16 +1000
committerDamien George <damien.p.george@gmail.com>2017-09-21 21:50:37 +1000
commit77e1da40e2fdcef736d05f2646fbaa8abf844543 (patch)
treee05f8c78fed2fa8f0c0611ead1b66671e42436c8 /ports/stm32/usbd_hid_interface.h
parent980b33177bbb99f4bc6472c24a0cc67bf7760679 (diff)
downloadmicropython-77e1da40e2fdcef736d05f2646fbaa8abf844543.tar.gz
micropython-77e1da40e2fdcef736d05f2646fbaa8abf844543.zip
stm32/usbdev: Put all HID state in a struct.
Diffstat (limited to 'ports/stm32/usbd_hid_interface.h')
-rw-r--r--ports/stm32/usbd_hid_interface.h35
1 files changed, 21 insertions, 14 deletions
diff --git a/ports/stm32/usbd_hid_interface.h b/ports/stm32/usbd_hid_interface.h
index b2ff75fa13..3dc87de6bf 100644
--- a/ports/stm32/usbd_hid_interface.h
+++ b/ports/stm32/usbd_hid_interface.h
@@ -1,14 +1,21 @@
-/*
- * This file is part of the MicroPython project, http://micropython.org/
- */
-#ifndef MICROPY_INCLUDED_STMHAL_USBD_HID_INTERFACE_H
-#define MICROPY_INCLUDED_STMHAL_USBD_HID_INTERFACE_H
-
-#include "usbd_cdc_msc_hid.h"
-
-extern const USBD_HID_ItfTypeDef USBD_HID_fops;
-
-int USBD_HID_RxNum(void);
-int USBD_HID_Rx(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len, uint32_t timeout);
-
-#endif // MICROPY_INCLUDED_STMHAL_USBD_HID_INTERFACE_H
+/*
+ * This file is part of the MicroPython project, http://micropython.org/
+ */
+#ifndef MICROPY_INCLUDED_STMHAL_USBD_HID_INTERFACE_H
+#define MICROPY_INCLUDED_STMHAL_USBD_HID_INTERFACE_H
+
+#include "usbd_cdc_msc_hid.h"
+
+typedef struct _usbd_hid_itf_t {
+ USBD_HandleTypeDef *usb; // the parent USB device
+
+ uint8_t buffer[2][HID_DATA_FS_MAX_PACKET_SIZE]; // pair of buffers to read individual packets into
+ int8_t current_read_buffer; // which buffer to read from
+ uint32_t last_read_len; // length of last read
+ int8_t current_write_buffer; // which buffer to write to
+} usbd_hid_itf_t;
+
+int usbd_hid_rx_num(usbd_hid_itf_t *hid);
+int usbd_hid_rx(usbd_hid_itf_t *hid, size_t len, uint8_t *buf, uint32_t timeout);
+
+#endif // MICROPY_INCLUDED_STMHAL_USBD_HID_INTERFACE_H