4 Replies Latest reply on Aug 8, 2020 7:15 AM by DiDi_4439146

    Events which need to be handled for sleep / restart of host?

    DiDi_4439146

      I am testing with a couple examples from the FX3 SDK (namely the usb HID Mouse example). I modified the code slightly so that it will continuously send mouse circles, but if I put the computer to sleep, or if I restart the computer the circles stop, and I have to press the gpio button again to re initiate the circles.

       

      My question is what events need to be handled in order to properly handle a sleep or a restart on the host?

        • 1. Re: Events which need to be handled for sleep / restart of host?
          JayakrishnaT_76

          Hello,

           

          According to my understanding, at the start you need to press the GPIO once. After this, the device will continuously send mouse circles. But, after a sleep or reset, the device will no longer send the mouse circles unless the GPIO is pressed again. Please correct me if Iam wrong.

          Can you please share the modified firmware so that we can evaluate it at our end?

           

          Best Regards,

          Jayakrishna

          1 of 1 people found this helpful
          • 2. Re: Events which need to be handled for sleep / restart of host?
            DiDi_4439146

            Yes that's correct:
            the code is exactly the example hid_examples/cyfx3_hid

             

            with the following modification to "cyfx3_hid.c":

             

            while (glButtonPress)

                            {

                                /* Send Input Report */

                                status = CyFxHidSendReport ();

                                if (status == CY_U3P_SUCCESS)

                                {

                                    //glButtonPress--;

                                }

                                else

                                {

                                    CyU3PUsbStall (CY_FX_HID_EP_INTR_IN, CyTrue, CyFalse);

                                }

                            }

             

             

            (basically just comment out the glButtonPress decrement)

             

            I'm using this example code to figure out what needs to be handled when the computer is put in sleep mode, or restarted. I have another codebase where the device stops functioning so I was hoping to shed some clarity by understanding with a simple example first. I cannot share the more complicated example on a public forum though because it's proprietary.

            1 of 1 people found this helpful
            • 3. Re: Events which need to be handled for sleep / restart of host?
              JayakrishnaT_76

              Hello,

               

              When you restart the PC, the USB RESET event will be triggered. After this, the host requests for the descriptors  again. In the example project that you are testing currently, initially the value of glButtonPressed will be 1 after the button is pressed. But once the re-enumeration happens, the value of glButtonPressed goes to 0. This is because during enumeration the host sends a SET_IDLE request. Once this request is received the firmware resets the glButtonPressed to 0. This is the reason why you are not able to see the circles after restarting the PC.

               

              After sending the SET_IDLE request, the host requests for the report descriptors from the device using GET_DESCRIPTOR request. Inside the handling of this request, you can set the value of glButtonPressed to 1 to re initiate the circles after restarting the PC. Please refer to the attached project to understand how this is implemented.

               

              I have tested this project on my end and I was able to re initiate the circles after restarting the PC. Please let me know if you have any queries on this.

               

              Best Regards,

              Jayakrishna

              1 of 1 people found this helpful
              • 4. Re: Events which need to be handled for sleep / restart of host?
                DiDi_4439146

                Jayakrishna thank you very much. This solved my problem!

                1 of 1 people found this helpful