Hi,
I'm trying to change a characteristic value by pushing a button.
I can change this value with an android app as much as i want but when I do it with the SW3 button on the DA14580 it only works the first time.
Can you help me about this problem ?
This is my code :void app_proxr_edit()
{
if (alert_state.lvl / 4)
alert_state.lvl -= 4;
else
alert_state.lvl += 4;
attmdb_att_set_value(proxr_env.pass_shdl + PASS_IDX_ALERT_LVL_VAL, sizeof(uint8_t), &alert_state.lvl);
}
void app_button_press_cb(void)
{
app_proxr_edit();
if(GetBits16(SYS_STAT_REG, PER_IS_DOWN))
periph_init();
if (arch_ble_ext_wakeup_get())
{
arch_set_sleep_mode(app_default_sleep_mode);
//SetBits32(GP_CONTROL_REG, BLE_WAKEUP_REQ, 1);
arch_ble_force_wakeup( );
arch_ble_ext_wakeup_off();
// ke_msg_send_basic(APP_WAKEUP_MSG, TASK_APP, 0);
app_easy_wakeup();
}
app_button_enable();
}
void app_button_enable(void)
{
app_easy_wakeup_set(app_wakeup_cb);
wkupct_register_callback(app_button_press_cb);
#if USE_PUSH_BUTTON
如果(GPIO_GetPinStatus (GPIO_BUTTON_PORT GPIO_BUTTON_PIN ))
wkupct_enable_irq(WKUPCT_PIN_SELECT(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN), // select pin (GPIO_BUTTON_PORT, GPIO_BUTTON_PIN)
WKUPCT_PIN_POLARITY(GPIO_BUTTON_PORT, GPIO_BUTTON_PIN, WKUPCT_PIN_POLARITY_LOW), // polarity low
1, // 1 event
0); // debouncing time = 0
#endif
}
Hi SithonTechnologies,
I suppose that you have the pro kit and by sw_3 you mean the p1_1 pin. It sounds like a wrong pin or polarity selection. Can you check if the first time you press the button the app_button_enable() function gets executed in order to reset the interrupt and when pressed the second time is the interrupt executed or not ? to check your code i applied some very simple modifications in the proximity example code. Just add your app_proxr_edit() function with a very simple implementation (toggle between 1 and 2) and change the value of the LLS service after that place the edit function in the app_button_press_cb() function (proximity reporter uses the p1_1 ass a button pin) and change the value by pressing the button (at least ), maybe this will help you find your problem.
Thanks MT_dialog
Hi MT_dialog,
Your supposition was right, i use the pro kit.
I found my problem, GPIO_GetPinStatus( GPIO_BUTTON_PORT, GPIO_BUTTON_PIN ) always returned false in the app_button_enable() function.
Thanks for the help.
SithonTechnologies