cancel
Showing results for 
Search instead for 
Did you mean: 

Studio Bluetooth

LiLe_3234306
New Contributor II

Hi,

I have a question about "user_data" parameter in interrupt handler.
In the prototype of wiced_hal_gpio_register_pin_for_interrupt() API, 3'rd param(void *userdata) is "Will be passed back to userfn as-is". However, when I test it with following test code, it looks not working. I guessed "udata" must be printed out "123" but printed out "168". I am not sure if my test code is incorrect or it's SDK bug.

Q) May I ask what's wrong with following test code?

H/W : CYW920706WCDEVAL

S/W : WICED SDK 6.4.0 

 

void headset_set_input_interrupt(void)
{
          uint8_t my_data = 123;

          wiced_hal_gpio_register_pin_for_interrupt( WICED_GPIO_BUTTON, headset_interrupt_handler, (void *)&my_data );
          wiced_hal_gpio_configure_pin( WICED_GPIO_BUTTON, WICED_GPIO_BUTTON_SETTINGS( GPIO_EN_INT_BOTH_EDGE ), WICED_GPIO_BUTTON_DEFAULT_STATE );
}

void headset_interrupt_handler( void *user_data, uint8_t value )
{
        WICED_BT_TRACE("[%s] enter...\n", __FUNCTION__);

        if ( wiced_hal_gpio_get_pin_input_status(WICED_GPIO_BUTTON) == BUTTON_PRESSED )
        {
                 WICED_BT_TRACE( "Button pressed\n");
         }
        else
        {
                uint8_t udata = (uint8_t *)user_data;

                WICED_BT_TRACE( "Button released\n" );
                WICED_BT_TRACE( "udata = %d\n", udata);
      }
}

Thanks,

Liam

0 Likes
2 Replies
Owen_Zhang123
Moderator
Moderator

We need to check the problem internally. You may use a global variable for it as a workaround.

0 Likes
LiLe_3234306
New Contributor II

Hi Owen,

Understood.

Thanks,

Liam

0 Likes