Changing a button's callback?

3 posts / 0 new
Last post
Dave.Renzo
Offline
Last seen:2 years 5 months ago
加入:2015-10-08 13:21
Changing a button's callback?

Hello support,

I am working on a project that requires the da14580 to go into extended sleep after power up. To accomplish this I am using a user defined db_init function that puts the Da to sleep if a global variable flag has not bee set:


void user_app_on_db_init_complete(void)
{
if(on_flag == 0)
{
GPIO_SetActive( GPIO_LED_PORT, GPIO_LED_PIN);
arch_ble_ext_wakeup_on();
//app_set_extended_sleep();
}
else
default_app_on_db_init_complete();

我使用醒来中断生成的with a push-button that wakes the code up, sets the flag high, creates the database and starts advertising. The da is now going to extended sleep between advertising events.

What I'd like to do is change the function of the button (the previously described functionality is a one time occurrence). I am trying to use the button to turn on an led for approximately 10 seconds. I'm unsure about the best way to do this, I tried just using a gpio interrupt but it doesn't work when I have app_default_sleep_mode = ARCH_EXT_SLEEP_ON. I also tried using a second flag that is checked in periph_init() that set's up the button again with a different callback function. This only partially works, the led comes on briefly and then goes off and any subsequent button presses don't do anything. Is there a better way to approach this? Without the use of the debugger I haven;t been able to figure out what's causing the led to turn off.

Device:
MT_dialog
Offline
Last seen:1 week 4 days ago
Staff
加入:2015-06-08 11:34
Hi Dave,

Hi Dave,

I ve tested the following, you can set your wakeup interrupt and force your ble to wake up and set your led. In your interrupt you can set via using the app_easy_wakeup_set() an additional handler that will set a timer of 10 seconds and when the time elapses you can switch the led of. In order for this in sleep mode you have to go to the set_pad_functions() and conditionally place the led in the condition it was during waking up.

Thanks MT_dialog

Dave.Renzo
Offline
Last seen:2 years 5 months ago
加入:2015-10-08 13:21
Thanks for the suggestion, it

Thanks for the suggestion, it's working great.

Topic locked