I am working with AT90USB1287 controller with USB communication to PC. I am sending some commands from PC to controller using USB communication to activate some controlled switch. I am able to change the states of switch by sending commands(ON and OFF, voltage controlled switch).
My problem is when switch is ON and unfortunately user forgot to send OFF command from PC and he shutdown the PC but still controller is running or suppose if i lost PC connection via usb, At that times it is causing problems.
I want to check the in ATUSB1287 controller code itself if usb connection loosed then swicth t command should be zero.
Can any one help me how to know usb connection is lost or not? this is my approach like is it possible to check in the main loop that usb connection is lost? if lost then switch off.
Any other way to switch off? after losing connection to PC or PC shutdown.
I am new to this type of thing, if anything wrong in this question please excuse me.