diff options
author | Damien George <damien.p.george@gmail.com> | 2015-02-03 22:37:50 +0000 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2015-02-13 14:02:51 +0000 |
commit | 55d6218b9a17f23754bd00d2759800a1447599ca (patch) | |
tree | 5a6c25a68897d1a2a985a4945704290a80ea4f65 /stmhal/usbdev/class | |
parent | 65af7ebdc5c53eebcec7950948abcc16d6a0ac6c (diff) |
stmhal: Properly define pyb.usb_mode() semantics.
Diffstat (limited to 'stmhal/usbdev/class')
-rw-r--r-- | stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h | 3 | ||||
-rw-r--r-- | stmhal/usbdev/class/src/usbd_cdc_msc_hid.c | 9 |
2 files changed, 9 insertions, 3 deletions
diff --git a/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h b/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h index bc1e33eca..52d845b24 100644 --- a/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h +++ b/stmhal/usbdev/class/inc/usbd_cdc_msc_hid.h @@ -92,7 +92,8 @@ extern const uint8_t USBD_HID_KEYBOARD_ReportDesc[USBD_HID_KEYBOARD_REPORT_DESC_ extern USBD_ClassTypeDef USBD_CDC_MSC_HID; -void USBD_SelectMode(uint32_t mode, USBD_HID_ModeInfoTypeDef *hid_info); +// returns 0 on success, -1 on failure +int USBD_SelectMode(uint32_t mode, USBD_HID_ModeInfoTypeDef *hid_info); uint8_t USBD_CDC_RegisterInterface (USBD_HandleTypeDef *pdev, USBD_CDC_ItfTypeDef *fops); uint8_t USBD_CDC_SetTxBuffer (USBD_HandleTypeDef *pdev, uint8_t *pbuff, uint16_t length); diff --git a/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c b/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c index 77852a03d..3db7bd220 100644 --- a/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c +++ b/stmhal/usbdev/class/src/usbd_cdc_msc_hid.c @@ -559,7 +559,7 @@ __ALIGN_BEGIN const uint8_t USBD_HID_KEYBOARD_ReportDesc[USBD_HID_KEYBOARD_REPOR 0xC0 // End Collection }; -void USBD_SelectMode(uint32_t mode, USBD_HID_ModeInfoTypeDef *hid_info) { +int USBD_SelectMode(uint32_t mode, USBD_HID_ModeInfoTypeDef *hid_info) { // save mode usbd_mode = mode; @@ -593,10 +593,14 @@ void USBD_SelectMode(uint32_t mode, USBD_HID_ModeInfoTypeDef *hid_info) { hid_iface_num = HID_IFACE_NUM_WITH_MSC; break; */ + + default: + // mode not supported + return -1; } + // configure the HID descriptor, if needed if (usbd_mode & USBD_MODE_HID) { - // configure the HID descriptor hid_desc[HID_DESC_OFFSET_SUBCLASS] = hid_info->subclass; hid_desc[HID_DESC_OFFSET_PROTOCOL] = hid_info->protocol; hid_desc[HID_DESC_OFFSET_REPORT_DESC_LEN] = hid_info->report_desc_len; @@ -605,6 +609,7 @@ void USBD_SelectMode(uint32_t mode, USBD_HID_ModeInfoTypeDef *hid_info) { hid_report_desc = hid_info->report_desc; } + return 0; } static uint8_t USBD_CDC_MSC_HID_Init(USBD_HandleTypeDef *pdev, uint8_t cfgidx) { |