How to differentiate USB Mass Storage and Battery charging mode: STM32L476
Hello all,
I'm using STM32L476 in a custom PCB board. Using USB OTG libary (from L4 cube examples), our code initialize USB Mass storage by following four lines of code upon USB connectivity (detected by a connected GPIO pin):
USBD_Init(&USBD_Device, &MSC_Desc, 0); // USB MSC initialization
USBD_RegisterClass(&USBD_Device, USBD_MSC_CLASS); // USB class registrationUSBD_MSC_RegisterStorage(&USBD_Device, &USBD_DISK_fops); // Storage call backsUSBD_Start(&USBD_Device); // Start USB MSCWe want to put the device in low power sleep mode when the USB is connected to the battery charger (not with PC for USB MSC). I request to know, how to differentiate the USB status: USB connected to PC (USB MSC initialized) vs the USB connected to wall Battery charger.
Is there any variable to look? The above functions return USBD_OK in both cases (USB connected to PC or Wall charger).
Thank you in advance for your kind reply.