8000 stmhal/usb: Make state for USB device private to top-level USB driver. · DFRobot/micropython@f86c57f · GitHub
[go: up one dir, main page]

Skip to content

Commit f86c57f

Browse files
committed
stmhal/usb: Make state for USB device private to top-level USB driver.
1 parent 3bb69f6 commit f86c57f

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

stmhal/usb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@
5454
mp_uint_t pyb_usb_flags = 0;
5555

5656
#ifdef USE_DEVICE_MODE
57-
USBD_HandleTypeDef hUSBDDevice;
57+
STATIC USBD_HandleTypeDef hUSBDDevice;
5858
pyb_usb_storage_medium_t pyb_usb_storage_medium = PYB_USB_STORAGE_MEDIUM_NONE;
5959
#endif
6060

@@ -568,7 +568,7 @@ STATIC mp_obj_t pyb_usb_hid_recv(mp_uint_t n_args, const mp_obj_t *args, mp_map_
568568
mp_obj_t o_ret = pyb_buf_get_for_recv(vals[0].u_obj, &vstr);
569569

570570
// receive the data
571-
int ret = USBD_HID_Rx((uint8_t*)vstr.buf, vstr.len, vals[1].u_int);
571+
int ret = USBD_HID_Rx(&hUSBDDevice, (uint8_t*)vstr.buf, vstr.len, vals[1].u_int);
572572

573573
// return the received data
574574
if (o_ret != MP_OBJ_NULL) {

stmhal/usb.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ typedef enum {
4747
} USB_PHY_ID;
4848

4949
extern mp_uint_t pyb_usb_flags;
50-
extern struct _USBD_HandleTypeDef hUSBDDevice;
5150
extern pyb_usb_storage_medium_t pyb_usb_storage_medium;
5251
extern const struct _mp_obj_tuple_t pyb_usb_hid_mouse_obj;
5352
extern const struct _mp_obj_tuple_t pyb_usb_hid_keyboard_obj;

stmhal/usbd_hid_interface.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ int USBD_HID_RxNum(void) {
101101

102102
// timout in milliseconds.
103103
// Returns number of bytes read from the device.
104-
int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout) {
104+
int USBD_HID_Rx(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len, uint32_t timeout) {
105105
// Wait until we have buffer to read
106106
uint32_t start = HAL_GetTick();
107107
while (current_read_buffer == current_write_buffer) {
@@ -127,7 +127,7 @@ int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout) {
127127
current_read_buffer = !current_read_buffer;
128128

129129
// Clear NAK to indicate we are ready to read more data
130-
USBD_HID_ClearNAK(&hUSBDDevice);
130+
USBD_HID_ClearNAK(pdev);
131131

132132
// Success, return number of bytes read
133133
return last_read_len;

stmhal/usbd_hid_interface.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@
77
extern const USBD_HID_ItfTypeDef USBD_HID_fops;
88

99
int USBD_HID_RxNum(void);
10-
int USBD_HID_Rx(uint8_t *buf, uint32_t len, uint32_t timeout);
10+
int USBD_HID_Rx(USBD_HandleTypeDef *pdev, uint8_t *buf, uint32_t len, uint32_t timeout);

0 commit comments

Comments
 (0)
0