Saturday, December 16th 2017, 4:01pm UTC+1

You are not logged in.

  • Login
  • Register

witte

Beginner

Date of registration: Jul 11th 2017

Posts: 5

1

Wednesday, July 12th 2017, 1:23am

Is there an event for USB disconnection?

Hello,


I'm using emUSB Driver with embOS.
My application mount an MSD device to storage some files.
I'd like to know if is possible or there is any callback event the emUSB-Device provide when a disconnection occurs from USB.

Thank you!

SEGGER - Yan

Super Moderator

Date of registration: Feb 28th 2014

Posts: 23

2

Wednesday, July 12th 2017, 10:17am

No. But the blocking USBD_MSD_Task will return once USB is disconnected. You can check the connection state using USBD_GetState.

witte

Beginner

Date of registration: Jul 11th 2017

Posts: 5

3

Wednesday, July 12th 2017, 4:41pm

Dear Yan,

I've tried to use the return after call the USBD_MSD_Task(), but I don't know why, sometimes the function don't return after disconnect the USB cable.


I think that some reason the function blocks.
I have some debug logs that prove it.

Have you ever seen this before?

Thanks.

SEGGER - Yan

Super Moderator

Date of registration: Feb 28th 2014

Posts: 23

4

Wednesday, July 12th 2017, 4:43pm

That is strange, could you please post the logs?

witte

Beginner

Date of registration: Jul 11th 2017

Posts: 5

5

Wednesday, July 12th 2017, 5:20pm

Yan,

The log I mentioned is from my application.
It just print on a log.txt file saved on SD Card:
  • "USB Connected" when run the task USBD_MSD_Task()
  • "USB Disconnected" when the function USBD_MSD_Task() returns.

Sometimes the message "USB Disconnected" does not happens.

Is there some DEBUG flag that I'm able to show more useful messages for you?

Thanks.

SEGGER - Yan

Super Moderator

Date of registration: Feb 28th 2014

Posts: 23

6

Wednesday, July 12th 2017, 5:24pm

Yes, with the define DEBUG=1
you can use

C/C++ Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
  USBD_SetLogFunc(USB_X_Log);
  USBD_SetWarnFunc(USB_X_Warn);
  USBD_SetLogFilter(0
              	| USB_MTYPE_INIT
              	| USB_MTYPE_CORE
              	| USB_MTYPE_CONFIG
//              	| USB_MTYPE_DRIVER
//              	| USB_MTYPE_ENUMERATION
//              	| USB_MTYPE_TRANSFER
//              	| USB_MTYPE_IAD
//              	| USB_MTYPE_CDC
//              	| USB_MTYPE_HID
              	| USB_MTYPE_MSD
//              	| USB_MTYPE_MSD_CDROM
//              	| USB_MTYPE_MSD_PHY
//              	| USB_MTYPE_MTP
//              	| USB_MTYPE_PRINTER
//              	| USB_MTYPE_RNDIS
//              	| USB_MTYPE_RNDIS_INTERN
//              	| USB_MTYPE_SMART_MSD
//              	| USB_MTYPE_UVC
//              	| USB_MTYPE_ECM_INTERN
              	);


The USB_X_Log/USB_X_Warn are located in the USB_ConfigIO.c file, if possible you should use RTT as it influences the timing the least of all possible I/O methods.

witte

Beginner

Date of registration: Jul 11th 2017

Posts: 5

7

Wednesday, July 12th 2017, 5:47pm

Unfortunately I don't have those functions in my library.
The version that I'm working is:

Source code

1
2
/* USB system version */
#define USB_VERSION                23608UL


This version is defined on USB.h file.

SEGGER - Yan

Super Moderator

Date of registration: Feb 28th 2014

Posts: 23

8

Wednesday, July 12th 2017, 5:59pm

Uhhh, this is ancient. Please update to the newest.

witte

Beginner

Date of registration: Jul 11th 2017

Posts: 5

9

Wednesday, July 12th 2017, 6:55pm

I'll do this next week I'll let you know if works and if the problem was solved.
By now, thanks for your support!