cancel
Showing results for 
Search instead for 
Did you mean: 

How to detect sleep/resume events from the host of USB HID.

FKopp.1
Associate II

Hi,

I'm using my stm32 as a USB HID device and I would like to be able to detect when the host computer goes into sleep mode and when it resumes. How would I detect this change?

I tried checking the following continuously in the main loop but detected no change:

if(((USBD_HandleTypeDef*)hpcd_USB_FS.pData)->dev_state==USBD_STATE_SUSPENDED){

Am I missing something or is there a better way?

This discussion is locked. Please start a new topic to ask your question.
5 REPLIES 5
waclawek.jan
Super User

0693W000006I44MQAS.pngJW

FKopp.1
Associate II

.

This seems to be talking about OTG devices, but I'm just a regular FS usb device

waclawek.jan
Super User

You did not care to tell us which STM32 are you using, and my crystal cube told me the wrong one. So one more guess:

0693W000006I50VQAS.png 

JW

Thanks for the reply, The device is an stm32L151C8T6A

I'm doing the following check continuously in the main loop

if(USB_ISTR & USB_ISTR_SUSP){

The bit seems always to be 1. Is there something else I need to enable to make this work?