Hello, I am using a custom board with DA14531mod and working with the central SDK.
In the user_wakeup.c, I have implemented the single press and the long press. I am trying to implement the double press button, attached the code.
/** **************************************************************************************** * @brief Button release ISR (Interrupt Service Routine) handler. * @return void **************************************************************************************** */ void buttonRelease_isr(void) { stateButton buttonPress; systick_stop(); spi_flash_release_from_power_down(); spi_flash_read_data(&data_read_button[0], 0xCD90, sizeof(data_read_button), &bytes_read_button); spi_flash_read_data(&data_read_button2[0], 0xCD85, sizeof(data_read_button2), &bytes_read_button2); if (data_read_button2[0] == 1){ newState = longPress; } else if(data_read_button[0] == 1){ newState = doublePress; } else{ newState = simple; spi_flash_block_erase(0xCD90, SPI_FLASH_OP_SE); spi_flash_write_data(&data_button[0], 0xCD90, sizeof(data), &bytes_written_button); systick_register_callback(systick_isr2); systick_start(INTERVAL_DOUBLE_PRESS_TIME, true); while(systick_value() != 0){ } } buttonPress = newState; switch(buttonPress){ case simple: user_app_wakeup_press_cb(); break; case doublePress: spi_flash_block_erase(0xCD90, SPI_FLASH_OP_SE); systick_start(5000000, false); while(systick_value() != 0){ GPIO_SetActive(GPIO_LED_PORT_1, GPIO_LED_PIN_R1); GPIO_SetActive(GPIO_LED_PORT_1, GPIO_LED_PIN_G1); GPIO_SetActive(GPIO_LED_PORT_2, GPIO_LED_PIN_R2); GPIO_SetActive(GPIO_LED_PORT_2, GPIO_LED_PIN_G2); } user_app_wakeup_press_cb(); break; case longPress: spi_flash_block_erase(0xBD90, SPI_FLASH_OP_SE); user_app_wakeup_press_cb(); break; default: user_app_wakeup_press_cb(); break; } } /** **************************************************************************************** * @brief Button press ISR (Interrupt Service Routine) handler. * @brief Generates a timer. If LONG_PRESS_TIME time is passed an exception is generated. * @return void **************************************************************************************** */ void buttonPress_isr(void) { // three_second_push = 0; //spi_flash_release_from_power_down(); spi_flash_block_erase(0xCD85, SPI_FLASH_OP_SE); systick_stop(); systick_register_callback(systick_isr); systick_start(LONG_PRESS_TIME, true); }
Before I have tried to implement this with a timer but It's not working because micro controller goes into deep sleep mode.
Do you have any recommendations ?