modify class request print log

This commit is contained in:
sakumisu
2021-11-09 10:28:10 +08:00
parent 936dda1df5
commit bb5f7e434b
8 changed files with 58 additions and 53 deletions

View File

@@ -5,9 +5,9 @@ struct usbd_audio_control_info audio_control_info = { 0xdb00, 0x0000, 0x0100, 0x
int audio_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) int audio_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{ {
USBD_LOG_DBG("Class request:" USBD_LOG_DBG("AUDIO Class request: "
"bRequest 0x%02x, bmRequestType 0x%02x len %d", "bRequest 0x%02x\r\n",
setup->bRequest, setup->bmRequestType, *len); setup->bRequest);
switch (setup->bRequest) { switch (setup->bRequest) {
case AUDIO_REQUEST_SET_CUR: case AUDIO_REQUEST_SET_CUR:
@@ -24,7 +24,7 @@ int audio_class_request_handler(struct usb_setup_packet *setup, uint8_t **data,
vol = (audio_control_info.vol_current - 0xDB00 + 1) * 100 / (0xFFFF - 0xDB00); vol = (audio_control_info.vol_current - 0xDB00 + 1) * 100 / (0xFFFF - 0xDB00);
} }
usbd_audio_set_volume(vol); usbd_audio_set_volume(vol);
USBD_LOG_WRN("vol:%d\r\n", vol); USBD_LOG("current volume:%d\r\n", vol);
} }
} }
@@ -44,6 +44,9 @@ int audio_class_request_handler(struct usb_setup_packet *setup, uint8_t **data,
case AUDIO_REQUEST_SET_RES: case AUDIO_REQUEST_SET_RES:
break; break;
case AUDIO_REQUEST_SET_MEM:
break;
case AUDIO_REQUEST_GET_MIN: case AUDIO_REQUEST_GET_MIN:
*data = (uint8_t *)&audio_control_info.vol_min; *data = (uint8_t *)&audio_control_info.vol_min;
*len = 2; *len = 2;
@@ -58,6 +61,10 @@ int audio_class_request_handler(struct usb_setup_packet *setup, uint8_t **data,
*data = (uint8_t *)&audio_control_info.vol_res; *data = (uint8_t *)&audio_control_info.vol_res;
*len = 2; *len = 2;
break; break;
case AUDIO_REQUEST_GET_MEM:
*data[0] = 0;
*len = 1;
break;
default: default:
USBD_LOG_ERR("Unhandled request 0x%02x", setup->bRequest); USBD_LOG_ERR("Unhandled request 0x%02x", setup->bRequest);
@@ -85,9 +92,11 @@ void audio_notify_handler(uint8_t event, void *arg)
break; break;
} }
} }
__weak void usbd_audio_set_volume(uint8_t vol) __weak void usbd_audio_set_volume(uint8_t vol)
{ {
} }
void usbd_audio_add_interface(usbd_class_t *class, usbd_interface_t *intf) void usbd_audio_add_interface(usbd_class_t *class, usbd_interface_t *intf)
{ {
static usbd_class_t *last_class = NULL; static usbd_class_t *last_class = NULL;

View File

@@ -65,6 +65,10 @@ static void usbd_cdc_acm_reset(void)
*/ */
static int cdc_acm_class_request_handler(struct usb_setup_packet *pSetup, uint8_t **data, uint32_t *len) static int cdc_acm_class_request_handler(struct usb_setup_packet *pSetup, uint8_t **data, uint32_t *len)
{ {
USBD_LOG_DBG("CDC Class request: "
"bRequest 0x%02x\r\n",
setup->bRequest);
switch (pSetup->bRequest) { switch (pSetup->bRequest) {
case CDC_REQUEST_SET_LINE_CODING: case CDC_REQUEST_SET_LINE_CODING:

View File

@@ -306,7 +306,7 @@ struct cdc_ecm_descriptor {
USB_DEVICE_CLASS_CDC, /* bFunctionClass */ \ USB_DEVICE_CLASS_CDC, /* bFunctionClass */ \
CDC_ABSTRACT_CONTROL_MODEL, /* bFunctionSubClass */ \ CDC_ABSTRACT_CONTROL_MODEL, /* bFunctionSubClass */ \
CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bFunctionProtocol */ \ CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bFunctionProtocol */ \
0x00, /* iFunction */ /* CDC Control Interface */ \ 0x00, /* iFunction */ \
0x09, /* bLength */ \ 0x09, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
bFirstInterface, /* bInterfaceNumber */ \ bFirstInterface, /* bInterfaceNumber */ \
@@ -315,31 +315,31 @@ struct cdc_ecm_descriptor {
USB_DEVICE_CLASS_CDC, /* bInterfaceClass */ \ USB_DEVICE_CLASS_CDC, /* bInterfaceClass */ \
CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass */ \ CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass */ \
CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bInterfaceProtocol */ \ CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bInterfaceProtocol */ \
str_idx, /* iInterface */ /* CDC Header */ \ str_idx, /* iInterface */ \
0x05, /* bLength */ \ 0x05, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_HEADER, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_HEADER, /* bDescriptorSubtype */ \
WBVAL(CDC_V1_10), /* bcdCDC */ /* CDC Call */ \ WBVAL(CDC_V1_10), /* bcdCDC */ \
0x05, /* bLength */ \ 0x05, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_CALL_MANAGEMENT, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_CALL_MANAGEMENT, /* bDescriptorSubtype */ \
bFirstInterface, /* bmCapabilities */ \ bFirstInterface, /* bmCapabilities */ \
(uint8_t)(bFirstInterface + 1), /* bDataInterface */ /* CDC ACM: support line request */ \ (uint8_t)(bFirstInterface + 1), /* bDataInterface */ \
0x04, /* bLength */ \ 0x04, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype */ \
0x02, /* bmCapabilities */ /* CDC Union */ \ 0x02, /* bmCapabilities */ \
0x05, /* bLength */ \ 0x05, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_UNION, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_UNION, /* bDescriptorSubtype */ \
bFirstInterface, /* bMasterInterface */ \ bFirstInterface, /* bMasterInterface */ \
(uint8_t)(bFirstInterface + 1), /* bSlaveInterface0 */ /* Endpoint Notification */ \ (uint8_t)(bFirstInterface + 1), /* bSlaveInterface0 */ \
0x07, /* bLength */ \ 0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
int_ep, /* bEndpointAddress */ \ int_ep, /* bEndpointAddress */ \
0x03, /* bmAttributes */ \ 0x03, /* bmAttributes */ \
0x40, 0x00, /* wMaxPacketSize */ \ 0x40, 0x00, /* wMaxPacketSize */ \
0x01, /* bInterval */ /* CDC Data Interface */ \ 0x00, /* bInterval */ \
0x09, /* bLength */ \ 0x09, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
(uint8_t)(bFirstInterface + 1), /* bInterfaceNumber */ \ (uint8_t)(bFirstInterface + 1), /* bInterfaceNumber */ \
@@ -348,19 +348,19 @@ struct cdc_ecm_descriptor {
CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass */ \ CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass */ \
0x00, /* bInterfaceSubClass */ \ 0x00, /* bInterfaceSubClass */ \
0x00, /* bInterfaceProtocol */ \ 0x00, /* bInterfaceProtocol */ \
0x00, /* iInterface */ /* Endpoint Out */ \ 0x00, /* iInterface */ \
0x07, /* bLength */ \ 0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
out_ep, /* bEndpointAddress */ \ out_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \ 0x02, /* bmAttributes */ \
0x40, 0x00, /* wMaxPacketSize */ \ 0x40, 0x00, /* wMaxPacketSize */ \
0x01, /* bInterval */ /* Endpoint In */ \ 0x00, /* bInterval */ \
0x07, /* bLength */ \ 0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
in_ep, /* bEndpointAddress */ \ in_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \ 0x02, /* bmAttributes */ \
0x40, 0x00, /* wMaxPacketSize */ \ 0x40, 0x00, /* wMaxPacketSize */ \
0x01 /* bInterval */ 0x00 /* bInterval */
#else #else
#define CDC_ACM_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, str_idx) \ #define CDC_ACM_DESCRIPTOR_INIT(bFirstInterface, int_ep, out_ep, in_ep, str_idx) \
/* Interface Associate */ \ /* Interface Associate */ \
@@ -371,7 +371,7 @@ struct cdc_ecm_descriptor {
USB_DEVICE_CLASS_CDC, /* bFunctionClass */ \ USB_DEVICE_CLASS_CDC, /* bFunctionClass */ \
CDC_ABSTRACT_CONTROL_MODEL, /* bFunctionSubClass */ \ CDC_ABSTRACT_CONTROL_MODEL, /* bFunctionSubClass */ \
CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bFunctionProtocol */ \ CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bFunctionProtocol */ \
0x00, /* iFunction */ /* CDC Control Interface */ \ 0x00, /* iFunction */ \
0x09, /* bLength */ \ 0x09, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
bFirstInterface, /* bInterfaceNumber */ \ bFirstInterface, /* bInterfaceNumber */ \
@@ -380,31 +380,31 @@ struct cdc_ecm_descriptor {
USB_DEVICE_CLASS_CDC, /* bInterfaceClass */ \ USB_DEVICE_CLASS_CDC, /* bInterfaceClass */ \
CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass */ \ CDC_ABSTRACT_CONTROL_MODEL, /* bInterfaceSubClass */ \
CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bInterfaceProtocol */ \ CDC_COMMON_PROTOCOL_AT_COMMANDS, /* bInterfaceProtocol */ \
str_idx, /* iInterface */ /* CDC Header */ \ str_idx, /* iInterface */ \
0x05, /* bLength */ \ 0x05, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_HEADER, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_HEADER, /* bDescriptorSubtype */ \
WBVAL(CDC_V1_10), /* bcdCDC */ /* CDC Call */ \ WBVAL(CDC_V1_10), /* bcdCDC */ \
0x05, /* bLength */ \ 0x05, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_CALL_MANAGEMENT, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_CALL_MANAGEMENT, /* bDescriptorSubtype */ \
bFirstInterface, /* bmCapabilities */ \ bFirstInterface, /* bmCapabilities */ \
(uint8_t)(bFirstInterface + 1), /* bDataInterface */ /* CDC ACM: support line request */ \ (uint8_t)(bFirstInterface + 1), /* bDataInterface */ \
0x04, /* bLength */ \ 0x04, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_ABSTRACT_CONTROL_MANAGEMENT, /* bDescriptorSubtype */ \
0x02, /* bmCapabilities */ /* CDC Union */ \ 0x02, /* bmCapabilities */ \
0x05, /* bLength */ \ 0x05, /* bLength */ \
CDC_CS_INTERFACE, /* bDescriptorType */ \ CDC_CS_INTERFACE, /* bDescriptorType */ \
CDC_FUNC_DESC_UNION, /* bDescriptorSubtype */ \ CDC_FUNC_DESC_UNION, /* bDescriptorSubtype */ \
bFirstInterface, /* bMasterInterface */ \ bFirstInterface, /* bMasterInterface */ \
(uint8_t)(bFirstInterface + 1), /* bSlaveInterface0 */ /* Endpoint Notification */ \ (uint8_t)(bFirstInterface + 1), /* bSlaveInterface0 */ \
0x07, /* bLength */ \ 0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
int_ep, /* bEndpointAddress */ \ int_ep, /* bEndpointAddress */ \
0x03, /* bmAttributes */ \ 0x03, /* bmAttributes */ \
0x02, 0x00, /* wMaxPacketSize */ \ 0x00, 0x02, /* wMaxPacketSize */ \
0x01, /* bInterval */ /* CDC Data Interface */ \ 0x00, /* bInterval */ \
0x09, /* bLength */ \ 0x09, /* bLength */ \
USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_INTERFACE, /* bDescriptorType */ \
(uint8_t)(bFirstInterface + 1), /* bInterfaceNumber */ \ (uint8_t)(bFirstInterface + 1), /* bInterfaceNumber */ \
@@ -413,19 +413,19 @@ struct cdc_ecm_descriptor {
CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass */ \ CDC_DATA_INTERFACE_CLASS, /* bInterfaceClass */ \
0x00, /* bInterfaceSubClass */ \ 0x00, /* bInterfaceSubClass */ \
0x00, /* bInterfaceProtocol */ \ 0x00, /* bInterfaceProtocol */ \
0x00, /* iInterface */ /* Endpoint Out */ \ 0x00, /* iInterface */ \
0x07, /* bLength */ \ 0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
out_ep, /* bEndpointAddress */ \ out_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \ 0x02, /* bmAttributes */ \
0x02, 0x00, /* wMaxPacketSize */ \ 0x00, 0x02, /* wMaxPacketSize */ \
0x01, /* bInterval */ /* Endpoint In */ \ 0x00, /* bInterval */ \
0x07, /* bLength */ \ 0x07, /* bLength */ \
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \ USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
in_ep, /* bEndpointAddress */ \ in_ep, /* bEndpointAddress */ \
0x02, /* bmAttributes */ \ 0x02, /* bmAttributes */ \
0x02, 0x00, /* wMaxPacketSize */ \ 0x00, 0x02, /* wMaxPacketSize */ \
0x01 /* bInterval */ 0x00 /* bInterval */
#endif #endif
// clang-format on // clang-format on

View File

@@ -14,26 +14,18 @@ int dfu_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, ui
switch (setup->bRequest) { switch (setup->bRequest) {
case DFU_REQUEST_DETACH: case DFU_REQUEST_DETACH:
break; break;
case DFU_REQUEST_DNLOAD: case DFU_REQUEST_DNLOAD:
break; break;
case DFU_REQUEST_UPLOAD: case DFU_REQUEST_UPLOAD:
break; break;
case DFU_REQUEST_GETSTATUS: case DFU_REQUEST_GETSTATUS:
break; break;
case DFU_REQUEST_CLRSTATUS: case DFU_REQUEST_CLRSTATUS:
break; break;
case DFU_REQUEST_GETSTATE: case DFU_REQUEST_GETSTATE:
break; break;
case DFU_REQUEST_ABORT: case DFU_REQUEST_ABORT:
break; break;
default: default:
USBD_LOG_ERR("Unhandled request 0x%02x", setup->bRequest); USBD_LOG_ERR("Unhandled request 0x%02x", setup->bRequest);

View File

@@ -63,9 +63,9 @@ static void usbd_hid_reset(void)
int hid_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) int hid_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{ {
USBD_LOG_DBG("Standard request:" USBD_LOG_DBG("HID Custom request: "
"bmRequestType 0x%02x, bRequest 0x%02x, len %d\r\n", "bRequest 0x%02x\r\n",
setup->bmRequestType, setup->bRequest, *len); setup->bRequest);
if (REQTYPE_GET_DIR(setup->bmRequestType) == USB_REQUEST_DEVICE_TO_HOST && if (REQTYPE_GET_DIR(setup->bmRequestType) == USB_REQUEST_DEVICE_TO_HOST &&
setup->bRequest == USB_REQUEST_GET_DESCRIPTOR) { setup->bRequest == USB_REQUEST_GET_DESCRIPTOR) {
@@ -118,9 +118,9 @@ int hid_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, u
int hid_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) int hid_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{ {
USBD_LOG("Class request:" USBD_LOG_DBG("HID Class request: "
"bmRequestType 0x%02x bRequest 0x%02x, len %d\r\n", "bRequest 0x%02x\r\n",
setup->bmRequestType, setup->bRequest, *len); setup->bRequest);
struct usbd_hid_cfg_private *current_hid_intf = NULL; struct usbd_hid_cfg_private *current_hid_intf = NULL;
usb_slist_t *i; usb_slist_t *i;

View File

@@ -27,9 +27,9 @@ extern struct video_probe_and_commit_controls commit;
int video_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len) int video_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
{ {
USBD_LOG_DBG("Class request:" USBD_LOG_DBG("VIDEO Class request: "
"bRequest 0x%02x, bmRequestType 0x%02x len %d", "bRequest 0x%02x\r\n",
setup->bRequest, setup->bmRequestType, *len); setup->bRequest);
switch (setup->bRequest) { switch (setup->bRequest) {
case VIDEO_REQUEST_SET_CUR: case VIDEO_REQUEST_SET_CUR:

View File

@@ -2,7 +2,6 @@
#define _USB_DC_H #define _USB_DC_H
#include "stdint.h" #include "stdint.h"
#include "bflb_platform.h"
#ifdef __cplusplus #ifdef __cplusplus
extern "C" { extern "C" {

View File

@@ -5,6 +5,7 @@
#include "string.h" #include "string.h"
#include "stdint.h" #include "stdint.h"
#include "stdio.h" #include "stdio.h"
#include "stdlib.h"
#include "usb_slist.h" #include "usb_slist.h"
#ifndef __packed #ifndef __packed
@@ -127,14 +128,14 @@
#define DBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF), ((x >> 16) & 0xFF), ((x >> 24) & 0xFF) #define DBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF), ((x >> 16) & 0xFF), ((x >> 24) & 0xFF)
#if 0 #if 0
#define USBD_LOG_WRN(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define USBD_LOG_WRN(a, ...) printf(a, ##__VA_ARGS__)
#define USBD_LOG_DBG(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define USBD_LOG_DBG(a, ...) printf(a, ##__VA_ARGS__)
#define USBD_LOG_ERR(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define USBD_LOG_ERR(a, ...) printf(a, ##__VA_ARGS__)
#else #else
#define USBD_LOG_WRN(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define USBD_LOG_WRN(a, ...) printf(a, ##__VA_ARGS__)
#define USBD_LOG_DBG(a, ...) #define USBD_LOG_DBG(a, ...)
#define USBD_LOG_ERR(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define USBD_LOG_ERR(a, ...) printf(a, ##__VA_ARGS__)
#define USBD_LOG(a, ...) bflb_platform_printf(a, ##__VA_ARGS__) #define USBD_LOG(a, ...) printf(a, ##__VA_ARGS__)
#endif #endif
#endif #endif