replace printf with USB_LOG_DBG for templates

This commit is contained in:
sakumisu
2022-06-04 21:08:19 +08:00
parent ad17e1f40f
commit 38db93fc7e
10 changed files with 62 additions and 62 deletions

View File

@@ -120,11 +120,11 @@ volatile bool tx_flag = 0;
void usbd_audio_open(uint8_t intf) void usbd_audio_open(uint8_t intf)
{ {
tx_flag = 1; tx_flag = 1;
printf("OPEN\r\n"); USB_LOG_RAW("OPEN\r\n");
} }
void usbd_audio_close(uint8_t intf) void usbd_audio_close(uint8_t intf)
{ {
printf("CLOSE\r\n"); USB_LOG_RAW("CLOSE\r\n");
tx_flag = 0; tx_flag = 0;
} }
@@ -148,7 +148,7 @@ void audio_init()
usbd_audio_add_interface(&audio_class, &audio_stream_intf); usbd_audio_add_interface(&audio_class, &audio_stream_intf);
usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep); usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep);
usbd_audio_add_entity(0x02, AUDIO_CONTROL_FEATURE_UNIT); usbd_audio_add_entity(0x02, AUDIO_CONTROL_FEATURE_UNIT);
usbd_initialize(); usbd_initialize();
} }

View File

@@ -171,7 +171,7 @@ uint32_t actual_read_length = 0;
void usbd_audio_out_callback(uint8_t ep) void usbd_audio_out_callback(uint8_t ep)
{ {
if (usbd_ep_read(ep, out_buffer, AUDIO_OUT_EP_MPS, &actual_read_length) < 0) { if (usbd_ep_read(ep, out_buffer, AUDIO_OUT_EP_MPS, &actual_read_length) < 0) {
printf("Read DATA Packet failed\r\n"); USB_LOG_RAW("Read DATA Packet failed\r\n");
usbd_ep_set_stall(ep); usbd_ep_set_stall(ep);
return; return;
} }
@@ -201,7 +201,7 @@ void audio_init()
usbd_interface_add_endpoint(&audio_stream_intf2, &audio_out_ep); usbd_interface_add_endpoint(&audio_stream_intf2, &audio_out_ep);
usbd_audio_add_entity(0x02, AUDIO_CONTROL_FEATURE_UNIT); usbd_audio_add_entity(0x02, AUDIO_CONTROL_FEATURE_UNIT);
usbd_audio_add_entity(0x05, AUDIO_CONTROL_FEATURE_UNIT); usbd_audio_add_entity(0x05, AUDIO_CONTROL_FEATURE_UNIT);
usbd_initialize(); usbd_initialize();
} }

View File

@@ -151,11 +151,11 @@ volatile bool tx_flag = 0;
void usbd_audio_open(uint8_t intf) void usbd_audio_open(uint8_t intf)
{ {
tx_flag = 1; tx_flag = 1;
printf("OPEN\r\n"); USB_LOG_RAW("OPEN\r\n");
} }
void usbd_audio_close(uint8_t intf) void usbd_audio_close(uint8_t intf)
{ {
printf("CLOSE\r\n"); USB_LOG_RAW("CLOSE\r\n");
tx_flag = 0; tx_flag = 0;
} }
@@ -180,7 +180,7 @@ void audio_init()
usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep); usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep);
usbd_audio_add_entity(0x01, AUDIO_CONTROL_CLOCK_SOURCE); usbd_audio_add_entity(0x01, AUDIO_CONTROL_CLOCK_SOURCE);
usbd_audio_add_entity(0x03, AUDIO_CONTROL_FEATURE_UNIT); usbd_audio_add_entity(0x03, AUDIO_CONTROL_FEATURE_UNIT);
usbd_initialize(); usbd_initialize();
} }

View File

@@ -199,20 +199,20 @@ void usbd_audio_open(uint8_t intf)
{ {
if (intf == 1) { if (intf == 1) {
rx_flag = 1; rx_flag = 1;
MSG("OPEN1\r\n"); USB_LOG_RAW("OPEN1\r\n");
} else { } else {
tx_flag = 1; tx_flag = 1;
MSG("OPEN2\r\n"); USB_LOG_RAW("OPEN2\r\n");
} }
} }
void usbd_audio_close(uint8_t intf) void usbd_audio_close(uint8_t intf)
{ {
if (intf == 1) { if (intf == 1) {
rx_flag = 1; rx_flag = 1;
MSG("CLOSE1\r\n"); USB_LOG_RAW("CLOSE1\r\n");
} else { } else {
tx_flag = 0; tx_flag = 0;
MSG("CLOSE2\r\n"); USB_LOG_RAW("CLOSE2\r\n");
} }
} }
@@ -256,7 +256,7 @@ void audio_init()
usbd_audio_add_entity(0x05, AUDIO_CONTROL_CLOCK_SOURCE); usbd_audio_add_entity(0x05, AUDIO_CONTROL_CLOCK_SOURCE);
usbd_audio_add_entity(0x07, AUDIO_CONTROL_FEATURE_UNIT); usbd_audio_add_entity(0x07, AUDIO_CONTROL_FEATURE_UNIT);
usbd_initialize(); usbd_initialize();
} }

View File

@@ -151,11 +151,11 @@ volatile bool rx_flag = 0;
void usbd_audio_open(uint8_t intf) void usbd_audio_open(uint8_t intf)
{ {
rx_flag = 1; rx_flag = 1;
printf("OPEN\r\n"); USB_LOG_RAW("OPEN\r\n");
} }
void usbd_audio_close(uint8_t intf) void usbd_audio_close(uint8_t intf)
{ {
printf("CLOSE\r\n"); USB_LOG_RAW("CLOSE\r\n");
rx_flag = 0; rx_flag = 0;
} }
@@ -180,7 +180,7 @@ void audio_init()
usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep); usbd_interface_add_endpoint(&audio_stream_intf, &audio_in_ep);
usbd_audio_add_entity(0x01, AUDIO_CONTROL_CLOCK_SOURCE); usbd_audio_add_entity(0x01, AUDIO_CONTROL_CLOCK_SOURCE);
usbd_audio_add_entity(0x03, AUDIO_CONTROL_FEATURE_UNIT); usbd_audio_add_entity(0x03, AUDIO_CONTROL_FEATURE_UNIT);
usbd_initialize(); usbd_initialize();
} }

View File

@@ -113,16 +113,16 @@ void usbd_cdc_acm_out(uint8_t ep)
usbd_ep_read(ep, data, 64, &read_byte); usbd_ep_read(ep, data, 64, &read_byte);
for (uint8_t i = 0; i < read_byte; i++) { for (uint8_t i = 0; i < read_byte; i++) {
printf("%02x ", data[i]); USB_LOG_RAW("%02x ", data[i]);
} }
printf("\r\n"); USB_LOG_RAW("\r\n");
printf("read len:%d\r\n", read_byte); USB_LOG_RAW("read len:%d\r\n", read_byte);
usbd_ep_read(ep, NULL, 0, NULL); usbd_ep_read(ep, NULL, 0, NULL);
} }
void usbd_cdc_acm_in(uint8_t ep) void usbd_cdc_acm_in(uint8_t ep)
{ {
printf("in\r\n"); USB_LOG_RAW("in\r\n");
} }
/*!< endpoint call back */ /*!< endpoint call back */
@@ -148,7 +148,7 @@ void cdc_acm_msc_init(void)
usbd_interface_add_endpoint(&cdc_data_intf, &cdc_in_ep); usbd_interface_add_endpoint(&cdc_data_intf, &cdc_in_ep);
usbd_msc_class_init(MSC_OUT_EP, MSC_IN_EP); usbd_msc_class_init(MSC_OUT_EP, MSC_IN_EP);
usbd_initialize(); usbd_initialize();
} }

View File

@@ -123,16 +123,16 @@ void usbd_cdc_acm_bulk_out(uint8_t ep)
usbd_ep_read(ep, data, 64, &read_byte); usbd_ep_read(ep, data, 64, &read_byte);
for (uint8_t i = 0; i < read_byte; i++) { for (uint8_t i = 0; i < read_byte; i++) {
printf("%02x ", data[i]); USB_LOG_RAW("%02x ", data[i]);
} }
printf("\r\n"); USB_LOG_RAW("\r\n");
printf("read len:%d\r\n", read_byte); USB_LOG_RAW("read len:%d\r\n", read_byte);
usbd_ep_read(ep, NULL, 0, NULL); usbd_ep_read(ep, NULL, 0, NULL);
} }
void usbd_cdc_acm_bulk_in(uint8_t ep) void usbd_cdc_acm_bulk_in(uint8_t ep)
{ {
printf("in\r\n"); USB_LOG_RAW("in\r\n");
} }
/*!< endpoint call back */ /*!< endpoint call back */
@@ -196,7 +196,7 @@ usbd_endpoint_t cdc_in_ep4 = {
void cdc_acm_multi_init(void) void cdc_acm_multi_init(void)
{ {
usbd_desc_register(cdc_descriptor); usbd_desc_register(cdc_descriptor);
usbd_cdc_add_acm_interface(&cdc_class1, &cdc_cmd_intf1); usbd_cdc_add_acm_interface(&cdc_class1, &cdc_cmd_intf1);
usbd_cdc_add_acm_interface(&cdc_class1, &cdc_data_intf1); usbd_cdc_add_acm_interface(&cdc_class1, &cdc_data_intf1);
usbd_interface_add_endpoint(&cdc_data_intf1, &cdc_out_ep1); usbd_interface_add_endpoint(&cdc_data_intf1, &cdc_out_ep1);

View File

@@ -108,16 +108,16 @@ void usbd_cdc_acm_out(uint8_t ep)
usbd_ep_read(ep, data, 64, &read_byte); usbd_ep_read(ep, data, 64, &read_byte);
for (uint8_t i = 0; i < read_byte; i++) { for (uint8_t i = 0; i < read_byte; i++) {
printf("%02x ", data[i]); USB_LOG_RAW("%02x ", data[i]);
} }
printf("\r\n"); USB_LOG_RAW("\r\n");
printf("read len:%d\r\n", read_byte); USB_LOG_RAW("read len:%d\r\n", read_byte);
usbd_ep_read(ep, NULL, 0, NULL); usbd_ep_read(ep, NULL, 0, NULL);
} }
void usbd_cdc_acm_in(uint8_t ep) void usbd_cdc_acm_in(uint8_t ep)
{ {
printf("in\r\n"); USB_LOG_RAW("in\r\n");
} }
/*!< endpoint call back */ /*!< endpoint call back */

View File

@@ -11,11 +11,11 @@ void usbh_cdc_acm_callback(void *arg, int nbytes)
if (nbytes > 0) { if (nbytes > 0) {
for (size_t i = 0; i < nbytes; i++) { for (size_t i = 0; i < nbytes; i++) {
printf("0x%02x ", cdc_buffer[i]); USB_LOG_RAW("0x%02x ", cdc_buffer[i]);
} }
} }
printf("nbytes:%d\r\n", nbytes); USB_LOG_RAW("nbytes:%d\r\n", nbytes);
} }
int cdc_acm_test(void) int cdc_acm_test(void)
@@ -25,30 +25,30 @@ int cdc_acm_test(void)
struct usbh_cdc_acm *cdc_acm_class = (struct usbh_cdc_acm *)usbh_find_class_instance("/dev/ttyACM0"); struct usbh_cdc_acm *cdc_acm_class = (struct usbh_cdc_acm *)usbh_find_class_instance("/dev/ttyACM0");
if (cdc_acm_class == NULL) { if (cdc_acm_class == NULL) {
printf("do not find /dev/ttyACM0\r\n"); USB_LOG_RAW("do not find /dev/ttyACM0\r\n");
return -1; return -1;
} }
memset(cdc_buffer, 0, 512); memset(cdc_buffer, 0, 512);
ret = usbh_ep_bulk_transfer(cdc_acm_class->bulkin, cdc_buffer, 512, 3000); ret = usbh_ep_bulk_transfer(cdc_acm_class->bulkin, cdc_buffer, 512, 3000);
if (ret < 0) { if (ret < 0) {
printf("bulk in error,ret:%d\r\n", ret); USB_LOG_RAW("bulk in error,ret:%d\r\n", ret);
} else { } else {
printf("recv over:%d\r\n", ret); USB_LOG_RAW("recv over:%d\r\n", ret);
for (size_t i = 0; i < ret; i++) { for (size_t i = 0; i < ret; i++) {
printf("0x%02x ", cdc_buffer[i]); USB_LOG_RAW("0x%02x ", cdc_buffer[i]);
} }
} }
printf("\r\n"); USB_LOG_RAW("\r\n");
const uint8_t data1[10] = { 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x08, 0x14 }; const uint8_t data1[10] = { 0x02, 0x00, 0x00, 0x00, 0x02, 0x02, 0x08, 0x14 };
memcpy(cdc_buffer, data1, 8); memcpy(cdc_buffer, data1, 8);
ret = usbh_ep_bulk_transfer(cdc_acm_class->bulkout, cdc_buffer, 8, 3000); ret = usbh_ep_bulk_transfer(cdc_acm_class->bulkout, cdc_buffer, 8, 3000);
if (ret < 0) { if (ret < 0) {
printf("bulk out error,ret:%d\r\n", ret); USB_LOG_RAW("bulk out error,ret:%d\r\n", ret);
} else { } else {
printf("send over:%d\r\n", ret); USB_LOG_RAW("send over:%d\r\n", ret);
} }
#if 0 #if 0
@@ -56,15 +56,15 @@ int cdc_acm_test(void)
#else #else
ret = usbh_ep_bulk_transfer(cdc_acm_class->bulkin, cdc_buffer, 512, 3000); ret = usbh_ep_bulk_transfer(cdc_acm_class->bulkin, cdc_buffer, 512, 3000);
if (ret < 0) { if (ret < 0) {
printf("bulk in error,ret:%d\r\n", ret); USB_LOG_RAW("bulk in error,ret:%d\r\n", ret);
} else { } else {
printf("recv over:%d\r\n", ret); USB_LOG_RAW("recv over:%d\r\n", ret);
for (size_t i = 0; i < ret; i++) { for (size_t i = 0; i < ret; i++) {
printf("0x%02x ", cdc_buffer[i]); USB_LOG_RAW("0x%02x ", cdc_buffer[i]);
} }
} }
printf("\r\n"); USB_LOG_RAW("\r\n");
return ret; return ret;
#endif #endif
@@ -80,23 +80,23 @@ int msc_test(void)
int ret; int ret;
struct usbh_msc *msc_class = (struct usbh_msc *)usbh_find_class_instance("/dev/sda"); struct usbh_msc *msc_class = (struct usbh_msc *)usbh_find_class_instance("/dev/sda");
if (msc_class == NULL) { if (msc_class == NULL) {
printf("do not find /dev/sda\r\n"); USB_LOG_RAW("do not find /dev/sda\r\n");
return -1; return -1;
} }
#if 1 #if 1
/* get the partition table */ /* get the partition table */
ret = usbh_msc_scsi_read10(msc_class, 0, partition_table, 1); ret = usbh_msc_scsi_read10(msc_class, 0, partition_table, 1);
if (ret < 0) { if (ret < 0) {
printf("scsi_read10 error,ret:%d\r\n", ret); USB_LOG_RAW("scsi_read10 error,ret:%d\r\n", ret);
return ret; return ret;
} }
for (uint32_t i = 0; i < 512; i++) { for (uint32_t i = 0; i < 512; i++) {
if (i % 16 == 0) { if (i % 16 == 0) {
printf("\r\n"); USB_LOG_RAW("\r\n");
} }
printf("%02x ", partition_table[i]); USB_LOG_RAW("%02x ", partition_table[i]);
} }
printf("\r\n"); USB_LOG_RAW("\r\n");
#endif #endif
#if 0 #if 0
@@ -105,11 +105,11 @@ int msc_test(void)
usb_iofree(msc_buffer); usb_iofree(msc_buffer);
// for (uint32_t i = 0; i < 1024; i++) { // for (uint32_t i = 0; i < 1024; i++) {
// if (i % 16 == 0) { // if (i % 16 == 0) {
// printf("\r\n"); // USB_LOG_RAW("\r\n");
// } // }
// printf("%02x ", msc_buffer[i]); // USB_LOG_RAW("%02x ", msc_buffer[i]);
// } // }
// printf("\r\n"); // USB_LOG_RAW("\r\n");
#endif #endif
#if 0 #if 0
@@ -127,16 +127,16 @@ int msc_test(void)
res_sd = f_read(&fnew, ReadBuffer, 512, &fnum); res_sd = f_read(&fnew, ReadBuffer, 512, &fnum);
for (uint32_t i = 0; i < fnum; i++) { for (uint32_t i = 0; i < fnum; i++) {
if (i % 16 == 0) { if (i % 16 == 0) {
printf("\r\n"); USB_LOG_RAW("\r\n");
} }
printf("%02x ", ReadBuffer[i]); USB_LOG_RAW("%02x ", ReadBuffer[i]);
} }
printf("\r\n"); USB_LOG_RAW("\r\n");
f_close(&fnew); f_close(&fnew);
/*unmount*/ /*unmount*/
f_mount(NULL, "2:", 1); f_mount(NULL, "2:", 1);
} else { } else {
printf("open error:%d\r\n", res_sd); USB_LOG_RAW("open error:%d\r\n", res_sd);
} }
usb_iofree(ReadBuffer); usb_iofree(ReadBuffer);
#endif #endif
@@ -151,11 +151,11 @@ void usbh_hid_callback(void *arg, int nbytes)
if (nbytes > 0) { if (nbytes > 0) {
for (size_t i = 0; i < nbytes; i++) { for (size_t i = 0; i < nbytes; i++) {
printf("0x%02x ", hid_buffer[i]); USB_LOG_RAW("0x%02x ", hid_buffer[i]);
} }
} }
printf("nbytes:%d\r\n", nbytes); USB_LOG_RAW("nbytes:%d\r\n", nbytes);
} }
int hid_test(void) int hid_test(void)
@@ -163,20 +163,20 @@ int hid_test(void)
int ret; int ret;
struct usbh_hid *hid_class = (struct usbh_hid *)usbh_find_class_instance("/dev/input0"); struct usbh_hid *hid_class = (struct usbh_hid *)usbh_find_class_instance("/dev/input0");
if (hid_class == NULL) { if (hid_class == NULL) {
printf("do not find /dev/input0\r\n"); USB_LOG_RAW("do not find /dev/input0\r\n");
return -1; return -1;
} }
#if 1 #if 1
ret = usbh_ep_intr_async_transfer(hid_class->intin, hid_buffer, 128, usbh_hid_callback, hid_class); ret = usbh_ep_intr_async_transfer(hid_class->intin, hid_buffer, 128, usbh_hid_callback, hid_class);
if (ret < 0) { if (ret < 0) {
printf("intr asnyc in error,ret:%d\r\n", ret); USB_LOG_RAW("intr asnyc in error,ret:%d\r\n", ret);
} }
#else #else
ret = usbh_ep_intr_transfer(hid_class->intin, hid_buffer, 128, 1000); ret = usbh_ep_intr_transfer(hid_class->intin, hid_buffer, 128, 1000);
if (ret < 0) { if (ret < 0) {
return ret; return ret;
} }
printf("recv len:%d\r\n", ret); USB_LOG_RAW("recv len:%d\r\n", ret);
#endif #endif
return ret; return ret;
} }

View File

@@ -134,11 +134,11 @@ volatile bool tx_flag = 0;
void usbd_video_open(uint8_t intf) void usbd_video_open(uint8_t intf)
{ {
tx_flag = 1; tx_flag = 1;
MSG("OPEN\r\n"); USB_LOG_RAW("OPEN\r\n");
} }
void usbd_video_close(uint8_t intf) void usbd_video_close(uint8_t intf)
{ {
MSG("CLOSE\r\n"); USB_LOG_RAW("CLOSE\r\n");
tx_flag = 0; tx_flag = 0;
} }