User Activity

Hi,I want to implement button interrupt with time period to send the mcu to Dee-sleep ,and wake up. For example; When I press button for 5 sec, MCU will go to sleep, when I press the button second time for 5 sec MCU will wakes up. but I don't know ...
uint8_t tx_data[2] = "AT"; uint8_t rx_data[10]; HAL_Delay(1000); while (1) {  HAL_UART_Transmit (&huart1, tx_data, sizeof(rx_data) , 250);  HAL_Delay(500);  HAL_UART_Receive(&huart1,rx_data, 20,1000);  HAL_GPIO_TogglePin (GPIOA, LED_Pin);  HAL_Delay(...