mirror of
https://github.com/sakumisu/CherryUSB.git
synced 2025-05-09 00:21:44 +08:00
modify print log,add USBD_LOG_INFO forever print
This commit is contained in:
parent
27bbaa0e0e
commit
5a22e7a57b
@ -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);
|
||||
}
|
||||
usbd_audio_set_volume(vol);
|
||||
USBD_LOG("current volume:%d\r\n", vol);
|
||||
USBD_LOG_INFO("current audio volume:%d\r\n", vol);
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,8 +67,8 @@ int audio_class_request_handler(struct usb_setup_packet *setup, uint8_t **data,
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_LOG_ERR("Unhandled request 0x%02x", setup->bRequest);
|
||||
break;
|
||||
USBD_LOG_WRN("Unhandled Audio Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -57,19 +57,19 @@ static void usbd_cdc_acm_reset(void)
|
||||
/**
|
||||
* @brief Handler called for Class requests not handled by the USB stack.
|
||||
*
|
||||
* @param pSetup Information about the request to execute.
|
||||
* @param setup Information about the request to execute.
|
||||
* @param len Size of the buffer.
|
||||
* @param data Buffer containing the request result.
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
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 *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USBD_LOG_DBG("CDC Class request: "
|
||||
"bRequest 0x%02x\r\n",
|
||||
setup->bRequest);
|
||||
|
||||
switch (pSetup->bRequest) {
|
||||
switch (setup->bRequest) {
|
||||
case CDC_REQUEST_SET_LINE_CODING:
|
||||
|
||||
/*******************************************************************************/
|
||||
@ -105,9 +105,9 @@ static int cdc_acm_class_request_handler(struct usb_setup_packet *pSetup, uint8_
|
||||
break;
|
||||
|
||||
case CDC_REQUEST_SET_CONTROL_LINE_STATE:
|
||||
usbd_cdc_acm_cfg.line_state = (uint8_t)pSetup->wValue;
|
||||
bool dtr = (pSetup->wValue & 0x01);
|
||||
bool rts = (pSetup->wValue & 0x02);
|
||||
usbd_cdc_acm_cfg.line_state = (uint8_t)setup->wValue;
|
||||
bool dtr = (setup->wValue & 0x01);
|
||||
bool rts = (setup->wValue & 0x02);
|
||||
USBD_LOG_DBG("DTR 0x%x,RTS 0x%x\r\n",
|
||||
dtr, rts);
|
||||
usbd_cdc_acm_set_dtr(dtr);
|
||||
@ -125,8 +125,7 @@ static int cdc_acm_class_request_handler(struct usb_setup_packet *pSetup, uint8_
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_LOG_DBG("CDC ACM request 0x%x, value 0x%x\r\n",
|
||||
pSetup->bRequest, pSetup->wValue);
|
||||
USBD_LOG_WRN("Unhandled CDC Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -28,8 +28,8 @@ int dfu_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, ui
|
||||
case DFU_REQUEST_ABORT:
|
||||
break;
|
||||
default:
|
||||
USBD_LOG_ERR("Unhandled request 0x%02x", setup->bRequest);
|
||||
break;
|
||||
USBD_LOG_WRN("Unhandled DFU Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -90,19 +90,19 @@ int hid_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, u
|
||||
|
||||
switch (value) {
|
||||
case HID_DESCRIPTOR_TYPE_HID:
|
||||
USBD_LOG("get HID Descriptor\r\n");
|
||||
USBD_LOG_INFO("get HID Descriptor\r\n");
|
||||
*data = (uint8_t *)current_hid_intf->hid_descriptor;
|
||||
*len = current_hid_intf->hid_descriptor[0];
|
||||
break;
|
||||
|
||||
case HID_DESCRIPTOR_TYPE_HID_REPORT:
|
||||
USBD_LOG("get Report Descriptor\r\n");
|
||||
USBD_LOG_INFO("get Report Descriptor\r\n");
|
||||
*data = (uint8_t *)current_hid_intf->hid_report_descriptor;
|
||||
*len = current_hid_intf->hid_report_descriptor_len;
|
||||
break;
|
||||
|
||||
case HID_DESCRIPTOR_TYPE_HID_PHYSICAL:
|
||||
USBD_LOG_DBG("get PHYSICAL Descriptor\r\n");
|
||||
USBD_LOG_INFO("get PHYSICAL Descriptor\r\n");
|
||||
|
||||
break;
|
||||
|
||||
@ -180,8 +180,8 @@ int hid_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, ui
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_LOG_ERR("Unhandled request 0x%02x\r\n", setup->bRequest);
|
||||
break;
|
||||
USBD_LOG_WRN("Unhandled HID Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -113,24 +113,24 @@ static void usbd_msc_reset(void)
|
||||
/**
|
||||
* @brief Handler called for Class requests not handled by the USB stack.
|
||||
*
|
||||
* @param pSetup Information about the request to execute.
|
||||
* @param setup Information about the request to execute.
|
||||
* @param len Size of the buffer.
|
||||
* @param data Buffer containing the request result.
|
||||
*
|
||||
* @return 0 on success, negative errno code on fail.
|
||||
*/
|
||||
static int msc_storage_class_request_handler(struct usb_setup_packet *pSetup, uint8_t **data, uint32_t *len)
|
||||
static int msc_storage_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USBD_LOG_DBG("MSC Class request: "
|
||||
"bRequest 0x%02x\r\n",
|
||||
setup->bRequest);
|
||||
|
||||
switch (pSetup->bRequest) {
|
||||
switch (setup->bRequest) {
|
||||
case MSC_REQUEST_RESET:
|
||||
USBD_LOG_DBG("MSC_REQUEST_RESET");
|
||||
USBD_LOG_DBG("MSC_REQUEST_RESET\r\n");
|
||||
|
||||
if (pSetup->wLength) {
|
||||
USBD_LOG_WRN("Invalid length");
|
||||
if (setup->wLength) {
|
||||
USBD_LOG_WRN("Invalid length\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -138,10 +138,10 @@ static int msc_storage_class_request_handler(struct usb_setup_packet *pSetup, ui
|
||||
break;
|
||||
|
||||
case MSC_REQUEST_GET_MAX_LUN:
|
||||
USBD_LOG_DBG("MSC_REQUEST_GET_MAX_LUN");
|
||||
USBD_LOG_DBG("MSC_REQUEST_GET_MAX_LUN\r\n");
|
||||
|
||||
if (pSetup->wLength != 1) {
|
||||
USBD_LOG_WRN("Invalid length");
|
||||
if (setup->wLength != 1) {
|
||||
USBD_LOG_WRN("Invalid length\r\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -150,8 +150,7 @@ static int msc_storage_class_request_handler(struct usb_setup_packet *pSetup, ui
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_LOG_WRN("Unknown request 0x%02x, value 0x%02x",
|
||||
pSetup->bRequest, pSetup->wValue);
|
||||
USBD_LOG_WRN("Unhandled MSC Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -27,7 +27,7 @@ extern struct video_probe_and_commit_controls commit;
|
||||
|
||||
int video_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USBD_LOG_DBG("VIDEO Class request: "
|
||||
USBD_LOG_DBG("Video Class request: "
|
||||
"bRequest 0x%02x\r\n",
|
||||
setup->bRequest);
|
||||
|
||||
@ -90,8 +90,8 @@ int video_class_request_handler(struct usb_setup_packet *setup, uint8_t **data,
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_LOG_ERR("Unhandled request 0x%02x", setup->bRequest);
|
||||
break;
|
||||
USBD_LOG_WRN("Unhandled Video Class bRequest 0x%02x\r\n", setup->bRequest);
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -8,12 +8,23 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief USB Device Controller API
|
||||
* @defgroup _usb_device_controller_api USB Device Controller API
|
||||
* @{
|
||||
* USB endpoint direction and number.
|
||||
*/
|
||||
/**< maximum packet size (MPS) for EP 0 */
|
||||
#define USB_CTRL_EP_MPS 64
|
||||
#define USB_EP_DIR_MASK 0x80U
|
||||
#define USB_EP_DIR_IN 0x80U
|
||||
#define USB_EP_DIR_OUT 0x00U
|
||||
|
||||
/** Get endpoint index (number) from endpoint address */
|
||||
#define USB_EP_GET_IDX(ep) ((ep) & ~USB_EP_DIR_MASK)
|
||||
/** Get direction from endpoint address */
|
||||
#define USB_EP_GET_DIR(ep) ((ep)&USB_EP_DIR_MASK)
|
||||
/** Get endpoint address from endpoint index and direction */
|
||||
#define USB_EP_GET_ADDR(idx, dir) ((idx) | ((dir)&USB_EP_DIR_MASK))
|
||||
/** True if the endpoint is an IN endpoint */
|
||||
#define USB_EP_DIR_IS_IN(ep) (USB_EP_GET_DIR(ep) == USB_EP_DIR_IN)
|
||||
/** True if the endpoint is an OUT endpoint */
|
||||
#define USB_EP_DIR_IS_OUT(ep) (USB_EP_GET_DIR(ep) == USB_EP_DIR_OUT)
|
||||
|
||||
/**
|
||||
* USB endpoint Transfer Type mask.
|
||||
*/
|
||||
@ -27,6 +38,14 @@ extern "C" {
|
||||
#define USB_CONTROL_OUT_EP0 0
|
||||
#define USB_CONTROL_IN_EP0 0x80
|
||||
|
||||
/**
|
||||
* @brief USB Device Controller API
|
||||
* @defgroup _usb_device_controller_api USB Device Controller API
|
||||
* @{
|
||||
*/
|
||||
/**< maximum packet size (MPS) for EP 0 */
|
||||
#define USB_CTRL_EP_MPS 64
|
||||
|
||||
/**
|
||||
* @brief USB Endpoint Transfer Type
|
||||
*/
|
||||
|
@ -38,8 +38,12 @@
|
||||
#endif
|
||||
#define __unused __attribute__((__unused__))
|
||||
|
||||
#define __ALIGN_END __attribute__((aligned(4)))
|
||||
#ifndef __ALIGN_BEGIN
|
||||
#define __ALIGN_BEGIN
|
||||
#endif
|
||||
#ifndef __ALIGN_END
|
||||
#define __ALIGN_END __attribute__((aligned(4)))
|
||||
#endif
|
||||
|
||||
#ifndef LO_BYTE
|
||||
#define LO_BYTE(x) ((uint8_t)(x & 0x00FF))
|
||||
@ -85,10 +89,12 @@
|
||||
((int)((sizeof(array) / sizeof((array)[0]))))
|
||||
#endif
|
||||
|
||||
#define USB_DESC_SECTION __attribute__((section("usb_desc"))) __used __aligned(1)
|
||||
|
||||
#ifndef BSWAP16
|
||||
#define BSWAP16(u16) (__builtin_bswap16(u16))
|
||||
#endif
|
||||
#ifndef BSWAP32
|
||||
#define BSWAP32(u32) (__builtin_bswap32(u32))
|
||||
#endif
|
||||
|
||||
#define GET_BE16(field) \
|
||||
(((uint16_t)(field)[0] << 8) | ((uint16_t)(field)[1]))
|
||||
@ -127,15 +133,17 @@
|
||||
#define WBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF)
|
||||
#define DBVAL(x) (x & 0xFF), ((x >> 8) & 0xFF), ((x >> 16) & 0xFF), ((x >> 24) & 0xFF)
|
||||
|
||||
#define USB_DESC_SECTION __attribute__((section("usb_desc"))) __used __aligned(1)
|
||||
|
||||
#if 0
|
||||
#define USBD_LOG_WRN(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#define USBD_LOG_DBG(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#define USBD_LOG_ERR(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#else
|
||||
#define USBD_LOG_WRN(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#define USBD_LOG_INFO(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#define USBD_LOG_DBG(a, ...)
|
||||
#define USBD_LOG_ERR(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#define USBD_LOG(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#define USBD_LOG_WRN(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#define USBD_LOG_ERR(a, ...) printf(a, ##__VA_ARGS__)
|
||||
#endif
|
||||
|
||||
#endif
|
@ -88,7 +88,7 @@ static struct usb_bos_descriptor *bos_desc;
|
||||
*/
|
||||
static void usbd_print_setup(struct usb_setup_packet *setup)
|
||||
{
|
||||
USBD_LOG_ERR("Setup: "
|
||||
USBD_LOG_INFO("Setup: "
|
||||
"bmRequestType 0x%02x, bRequest 0x%02x, wValue 0x%04x, wIndex 0x%04x, wLength 0x%04x\r\n",
|
||||
setup->bmRequestType,
|
||||
setup->bRequest,
|
||||
@ -202,7 +202,7 @@ static bool usbd_set_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize;
|
||||
ep_cfg.ep_type = ep_desc->bmAttributes & USBD_EP_TYPE_MASK;
|
||||
|
||||
USBD_LOG("Open endpoint:0x%x type:%u mps:%u\r\n",
|
||||
USBD_LOG_INFO("Open endpoint:0x%x type:%u mps:%u\r\n",
|
||||
ep_cfg.ep_addr, ep_cfg.ep_type, ep_cfg.ep_mps);
|
||||
|
||||
usbd_ep_open(&ep_cfg);
|
||||
@ -228,7 +228,7 @@ static bool usbd_reset_endpoint(const struct usb_endpoint_descriptor *ep_desc)
|
||||
ep_cfg.ep_mps = ep_desc->wMaxPacketSize;
|
||||
ep_cfg.ep_type = ep_desc->bmAttributes & USBD_EP_TYPE_MASK;
|
||||
|
||||
USBD_LOG("Close endpoint:0x%x type:%u\r\n",
|
||||
USBD_LOG_INFO("Close endpoint:0x%x type:%u\r\n",
|
||||
ep_cfg.ep_addr, ep_cfg.ep_type);
|
||||
|
||||
usbd_ep_close(ep_cfg.ep_addr);
|
||||
@ -261,7 +261,7 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l
|
||||
index = GET_DESC_INDEX(type_index);
|
||||
|
||||
if ((type == USB_DESCRIPTOR_TYPE_STRING) && (index == USB_OSDESC_STRING_DESC_INDEX)) {
|
||||
USBD_LOG("read MS OS 2.0 descriptor string\r\n");
|
||||
USBD_LOG_INFO("read MS OS 2.0 descriptor string\r\n");
|
||||
|
||||
if (!msosv1_desc) {
|
||||
return false;
|
||||
@ -272,7 +272,7 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l
|
||||
|
||||
return true;
|
||||
} else if (type == USB_DESCRIPTOR_TYPE_BINARY_OBJECT_STORE) {
|
||||
USBD_LOG("read BOS descriptor string\r\n");
|
||||
USBD_LOG_INFO("read BOS descriptor string\r\n");
|
||||
|
||||
if (!bos_desc) {
|
||||
return false;
|
||||
@ -781,7 +781,7 @@ static int usbd_standard_request_handler(struct usb_setup_packet *setup, uint8_t
|
||||
*/
|
||||
static int usbd_class_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wIndex 0x%04x", setup->bRequest, setup->wIndex);
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wIndex 0x%04x\r\n", setup->bRequest, setup->wIndex);
|
||||
|
||||
if (setup->bmRequestType_b.Recipient != USB_REQUEST_TO_INTERFACE) {
|
||||
return -1;
|
||||
@ -806,7 +806,7 @@ static int usbd_class_request_handler(struct usb_setup_packet *setup, uint8_t **
|
||||
|
||||
static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wValue0x%04x, wIndex 0x%04x", setup->bRequest, setup->wValue, setup->wIndex);
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wValue0x%04x, wIndex 0x%04x\r\n", setup->bRequest, setup->wValue, setup->wIndex);
|
||||
|
||||
// if(setup->bmRequestType_b.Recipient != USB_REQUEST_TO_DEVICE)
|
||||
// {
|
||||
@ -817,19 +817,19 @@ static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t *
|
||||
if (setup->bRequest == msosv1_desc->vendor_code) {
|
||||
switch (setup->wIndex) {
|
||||
case 0x04:
|
||||
USBD_LOG("get Compat ID\r\n");
|
||||
USBD_LOG_INFO("get Compat ID\r\n");
|
||||
*data = (uint8_t *)msosv1_desc->compat_id;
|
||||
*len = msosv1_desc->compat_id_len;
|
||||
|
||||
return 0;
|
||||
case 0x05:
|
||||
USBD_LOG("get Compat id properties\r\n");
|
||||
USBD_LOG_INFO("get Compat id properties\r\n");
|
||||
*data = (uint8_t *)msosv1_desc->comp_id_property;
|
||||
*len = msosv1_desc->comp_id_property_len;
|
||||
|
||||
return 0;
|
||||
default:
|
||||
USBD_LOG("unknown vendor code\r\n");
|
||||
USBD_LOG_ERR("unknown vendor code\r\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -837,12 +837,12 @@ static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t *
|
||||
if (setup->bRequest == msosv2_desc->vendor_code) {
|
||||
switch (setup->wIndex) {
|
||||
case WINUSB_REQUEST_GET_DESCRIPTOR_SET:
|
||||
USBD_LOG("GET MS OS 2.0 Descriptor\r\n");
|
||||
USBD_LOG_INFO("GET MS OS 2.0 Descriptor\r\n");
|
||||
*data = (uint8_t *)msosv2_desc->compat_id;
|
||||
*len = msosv2_desc->compat_id_len;
|
||||
return 0;
|
||||
default:
|
||||
USBD_LOG("unknown vendor code\r\n");
|
||||
USBD_LOG_ERR("unknown vendor code\r\n");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
@ -869,7 +869,7 @@ static int usbd_vendor_request_handler(struct usb_setup_packet *setup, uint8_t *
|
||||
|
||||
static int usbd_custom_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||
{
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wIndex 0x%04x", setup->bRequest, setup->wIndex);
|
||||
USBD_LOG_DBG("bRequest 0x%02x, wIndex 0x%04x\r\n", setup->bRequest, setup->wIndex);
|
||||
|
||||
if (setup->bmRequestType_b.Recipient != USB_REQUEST_TO_INTERFACE) {
|
||||
return -1;
|
||||
@ -965,11 +965,12 @@ static void usbd_send_to_host(uint16_t len)
|
||||
* packet.
|
||||
*/
|
||||
/* Send less data as requested during the Setup stage */
|
||||
if ((!usbd_core_cfg.ep0_data_buf_residue) && !(usbd_core_cfg.ep0_data_buf_len % USB_CTRL_EP_MPS)) {
|
||||
if ((!usbd_core_cfg.ep0_data_buf_residue) && (len > usbd_core_cfg.ep0_data_buf_len)) {
|
||||
/* Transfers a zero-length packet */
|
||||
// USBD_LOG("ZLP, requested %u , length %u ",
|
||||
// len, usb_dev.ep0_data_buf_len);
|
||||
usbd_core_cfg.zlp_flag = true;
|
||||
if (!(usbd_core_cfg.ep0_data_buf_len % USB_CTRL_EP_MPS)) {
|
||||
USBD_LOG_DBG("send zlp\r\n");
|
||||
usbd_core_cfg.zlp_flag = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
usbd_core_cfg.zlp_flag = false;
|
||||
@ -1218,7 +1219,7 @@ void usbd_event_notify_handler(uint8_t event, void *arg)
|
||||
break;
|
||||
|
||||
default:
|
||||
USBD_LOG_ERR("USB unknown event: %d", event);
|
||||
USBD_LOG_ERR("USB unknown event: %d\r\n", event);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user