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

cross mob
lock attach
Attachments are accessible only for community members.
Anonymous
Not applicable

Hello everybody

I have wiced sense kit and for example I want to use  second button on the kit which is user button and want to get sound from buzzer

I look the kit shematics and learnt that user button is on Pin 4

In the firmware code GPIO_PIN_P4 is used for GPIO interrupt.

So how can I write the code that when user button is pressed make a sound

I tried simply this one ::::

  

if (GPIO_PIN_P4 == 1){

  wiced_sense_short_beep_buzzer(100);

  } 

But didnt work. Can someone help me abouth that thanks a lot....

0 Likes
1 Solution
JacobT_81
Employee
Employee
250 replies posted 100 replies posted 50 replies posted

It appears to me that pin 4 is the Wake button on the wiced sense. P0 is the pin which you should register the interrupt for.

To utilize the buzzer functions, you must register the buzzer pin in the GPIO configure table. The buzzer is on pin 13 on wiced sense.

Additionally, the easiest way to register an interrupt of a push button is by using the same GPIO configuration table as the buzzer. Your table should look like this:

const BLE_PROFILE_GPIO_CFG wiced_sense_gpio_cfg =

{

    /*.gpio_pin =*/

    {

        GPIO_PIN_WP,      // This need to be used to enable/disable NVRAM write protect

        GPIO_PIN_BUTTON,

13, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1 // other GPIOs are not used

    },

    /*.gpio_flag =*/

    {

        GPIO_SETTINGS_WP,

GPIO_SETTINGS_BUTTON,

        GPIO_SETTINGS_BUZZER, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0

    }

};

In addition to registering the button as your interrupt, you also need to define the callback that will fire when the button is pressed.

Put this into your create function:

    // register interrupt handler for button inputs.

    bleprofile_regIntCb((BLEPROFILE_SINGLE_PARAM_CB) button_interrupt_handler);

And define and declare your function:

     static void button_interrupt_handler(UINT8 value);

     void button_interrupt_handler(UINT8 value)

     {

          // On press.

          if (value & 1)

          {

               //call buzzer functionality here

          }

     }

Jacob

View solution in original post

5 Replies