1
0
mirror of https://bitbucket.org/librepilot/librepilot.git synced 2024-12-02 10:24:11 +01:00

f4 usb hid: use static data for dummy report Tx

This code was previously passing a pointer to stack
data into PIOS_USBHOOK_CtrlTx() which may be sending
this data asynchronously.  Now pass a pointer to
static data so that the asynchronous send doesn't
tx random stack contents.
This commit is contained in:
Stacey Sheldon 2013-03-15 23:59:58 -04:00 committed by Alessio Morale
parent 859734af98
commit 232f9b2f8f

View File

@ -350,6 +350,7 @@ static void PIOS_USB_HID_IF_DeInit(uint32_t usb_hid_id)
static uint8_t hid_protocol; static uint8_t hid_protocol;
static uint8_t hid_altset; static uint8_t hid_altset;
static uint8_t dummy_report[2];
static bool PIOS_USB_HID_IF_Setup(uint32_t usb_hid_id, struct usb_setup_request *req) static bool PIOS_USB_HID_IF_Setup(uint32_t usb_hid_id, struct usb_setup_request *req)
{ {
@ -405,15 +406,12 @@ static bool PIOS_USB_HID_IF_Setup(uint32_t usb_hid_id, struct usb_setup_request
PIOS_USBHOOK_CtrlTx(&hid_protocol, 1); PIOS_USBHOOK_CtrlTx(&hid_protocol, 1);
break; break;
case USB_HID_REQ_GET_REPORT: case USB_HID_REQ_GET_REPORT:
{
/* Give back a dummy input report */ /* Give back a dummy input report */
uint8_t dummy_report[2] = { dummy_report[0] = req->wValue >> 8; /* Report ID */
[0] = req->wValue >> 8, /* Report ID */ dummy_report[1] = 0x00; /* dummy value */
[1] = 0x00, PIOS_USBHOOK_CtrlTx(dummy_report,
}; MIN(sizeof(dummy_report), req->wLength));
PIOS_USBHOOK_CtrlTx(dummy_report, sizeof(dummy_report)); break;
}
break;
default: default:
/* Unhandled class request */ /* Unhandled class request */
return false; return false;