[CYW20706 - WICED SDK] I have a question - *user_data param in interrupt handler

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
LiLe_3234306
Level 3
Level 3
25 replies posted First comment on KBA 50 sign-ins

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
1 Solution
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

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

View solution in original post

0 Likes
2 Replies
Owen_Zhang123
Moderator
Moderator
Moderator
5 questions asked 500 solutions authored 250 sign-ins

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

0 Likes

Hi Owen,

Understood.

Thanks,

Liam

0 Likes