none
How to get power button interrupts in WinCE 6.0

    Question

  • Hello! I am facing a problem in getting interrupts working on my device (Windows CE 6.0).
    Could you please suggest what is wrong?
    I want to create a Interrupt thread to catch power button interrupts.
    I tried all IRQ in range 0-32 but no one works.
    I have called the CreateThread and Resume thread in the xxx_Init() for my driver.
    Next follows fragment of my code:
    //Create an Event
    hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
    // Register with the Kernel
    KernelIoControl(IOCTL_HAL_REQUEST_SYSINTR, &IRQ, sizeof(DWORD), &SysintrValue, sizeof(DWORD), NULL);
    InterruptInitialize( SysintrValue, hEvent, NULL, 0 );
    // Set the Thread Priority            
    CeSetThreadPriority(GetCurrentThread(), 150);
    while (1)
    {
    	// Wait for the Event to be Signaled
    	RetVal = WaitForSingleObject(hEvent, 5000 );
    	...
    }
    

    WaitForSingleObject returns WAIT_TIMEOUT always.
    So the Kernel is not generating the event for my thread.. 
    What can be wrong here ? 
    Tuesday, September 20, 2011 2:18 PM

All replies

  • You should first verify that your code doesn't return a failure in case you are trying to use an IRQ that is not valid.

    What platform you are using?

    Is the button connected to a pin on your hardware that can be used as an interrupt?

    Best regards,

    Mike

    Tuesday, September 20, 2011 3:13 PM
  • You should first verify that your code doesn't return a failure in case you are trying to use an IRQ that is not valid.

    What platform you are using?

    Is the button connected to a pin on your hardware that can be used as an interrupt?

    Best regards,

    Mike  

    Hi Mike!

    This code doesn't return any errors. KernelIOControl returns TRUE for each IRQ in range 0-31. And WaitForSingleObject exit on timeout.

    I need to handle powerbutton on stoke device. So i'm trying to replace driver or do this programmatically somehow.

    I can't determine button pin on the device, but device platform is SiRF Atlas IV .

    Tuesday, September 20, 2011 5:07 PM
  • The IRQ value that you need is a software value that is defined by the implementation of your BSP.  You need to look at your OAL code to determine the correct value to use, which very well could be greater than 31.

    You may also need to make sure that your OAL actually initializes the hardware IRQ correctly.


    Bruce Eitman (eMVP)
    Senior Engineer
    Bruce.Eitman AT Eurotech DOT com
    My BLOG http://geekswithblogs.net/bruceeitman

    Eurotech Inc.
    www.Eurotech.com
    Wednesday, September 21, 2011 11:52 AM
  • Hello, Alexader.

      Have you got a solution ? As Bruce said you should check the BSP implementation. I wasn't able to catch a button (situated on my evaluation board which is actually a SBC6410) interrupt till I had initialized the GPIO & interrupt controller registers on my own. This is the platform dependent actions.

    Best regards.

    Alexey.

    Saturday, December 10, 2011 6:49 AM