/** * @brief MSC class application * @param None * @retval None */ static void MSC_Application(void) { switch(USBH_USR_ApplicationState) { case USH_USR_FS_INIT: /* Register work area for logical drives */ if (f_mount(&USBDISK_FatFs, "", 0) != FR_OK) { LCD_ErrLog("> File System NOT initialized.\n"); Error_Handler(); } else { LCD_UsrLog("> File System initialized.\n"); USBH_USR_ApplicationState = USH_USR_FS_READLIST; } break; case USH_USR_FS_READLIST: LCD_UsrLog("> Exploring disk flash ...\n"); if (Explore_Disk("0:/", 1) != FR_OK) { LCD_ErrLog("> File cannot be explored.\n"); Error_Handler(); } else { line_idx = 0; USBH_USR_ApplicationState = USH_USR_FS_DRAW; LCD_UsrLog("To start Image Slideshow\n"); LCD_UsrLog("Press Key\n"); while(BSP_PB_GetState (BUTTON_KEY) != SET) { Toggle_Leds(); } } break; case USH_USR_FS_DRAW: /* USER Button in polling */ while(BSP_PB_GetState (BUTTON_KEY) != RESET) { Toggle_Leds(); } while(Appli_state == APPLICATION_START) { Image_Browser("0:/"); return; } break; default: break; } return; }
/** * @brief Manages MSC Menu Process. * @param None * @retval None */ void MSC_MenuProcess(void) { switch(msc_demo.state) { case MSC_DEMO_IDLE: BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(16, (uint8_t *)" "); BSP_LCD_DisplayStringAtLine(17, (uint8_t *)"Use [Buttons Left/Right] to scroll up/down "); BSP_LCD_DisplayStringAtLine(18, (uint8_t *)"Use [Joystick Up/Down] to scroll MSC menu "); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); MSC_SelectItem(MSC_main_menu, 0); msc_demo.state = MSC_DEMO_WAIT; msc_demo.select = 0; break; case MSC_DEMO_WAIT: if(msc_demo.select != prev_select) { prev_select = msc_demo.select; MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F); /* Handle select item */ if(msc_demo.select & 0x80) { switch(msc_demo.select & 0x7F) { case 0: msc_demo.state = MSC_DEMO_FILE_OPERATIONS; break; case 1: msc_demo.state = MSC_DEMO_EXPLORER; break; case 2: msc_demo.state = MSC_REENUMERATE; break; default: break; } } } break; case MSC_DEMO_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_state == APPLICATION_MSC) { MSC_File_Operations(); } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_DEMO_EXPLORER: /* Display disk content */ if(Appli_state == APPLICATION_MSC) { /* Register the file system object to the FatFs module */ if(f_mount(&USBH_fatfs, "", 0 ) != FR_OK ) { LCD_ErrLog("Cannot Initialize FatFs! \n"); } else { Explore_Disk("0:/", 1); } } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_REENUMERATE: /* Force MSC Device to re-enumerate */ USBH_ReEnumerate(&hUSBHost); msc_demo.state = MSC_DEMO_WAIT; break; default: break; } msc_demo.select &= 0x7F; }
/** * @brief User task * @param pvParameters not used * @retval None */ static void MSC_MenuThread(void const *argument) { uint32_t ITstatus = 0; for(;;) { if(osSemaphoreWait(MenuEvent, 100) == osOK) { switch(msc_demo.state) { case MSC_DEMO_IDLE: MSC_SelectItem(MSC_main_menu, 0); msc_demo.state = MSC_DEMO_WAIT; msc_demo.select = 0; osSemaphoreRelease(MenuEvent); break; case MSC_DEMO_WAIT: MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F); /* Handle select item */ if(msc_demo.select & 0x80) { switch(msc_demo.select & 0x7F) { case 0: msc_demo.state = MSC_DEMO_FILE_OPERATIONS; osSemaphoreRelease(MenuEvent); break; case 1: msc_demo.state = MSC_DEMO_EXPLORER; osSemaphoreRelease(MenuEvent); break; case 2: msc_demo.state = MSC_REENUMERATE; osSemaphoreRelease(MenuEvent); break; default: break; } } break; case MSC_DEMO_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_state == APPLICATION_READY) { MSC_File_Operations(); } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_DEMO_EXPLORER: /* Display disk content */ if(Appli_state == APPLICATION_READY) { Explore_Disk("0:/", 1); } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_REENUMERATE: /* Force MSC Device to re-enumerate */ USBH_ReEnumerate(&hUSBHost); msc_demo.state = MSC_DEMO_WAIT; break; default: break; } msc_demo.select &= 0x7F; } if (osJoySemaphore != NULL) { if(osSemaphoreWait(osJoySemaphore , 0) == osOK) { ITstatus = BSP_IO_ITGetStatus(JOY_ALL_PINS); if (ITstatus) { Joystick_MscMenu(); /* Clear joystick interrupt pending bits */ BSP_IO_ITClear(); } } } } }
/** * @brief Displays disk content. * @param path: Pointer to root path * @param recu_level: Disk content level * @retval Operation result */ FRESULT Explore_Disk(char *path, uint8_t recu_level) { FRESULT res = FR_OK; FILINFO fno; DIR dir; char *fn; char tmp[14]; uint8_t line_idx = 0; #if _USE_LFN static char lfn[_MAX_LFN + 1]; /* Buffer to store the LFN */ fno.lfname = lfn; fno.lfsize = sizeof lfn; #endif res = f_opendir(&dir, path); if(res == FR_OK) { while(USBH_MSC_IsReady(&hUSBHost)) { res = f_readdir(&dir, &fno); if(res != FR_OK || fno.fname[0] == 0) { break; } if(fno.fname[0] == '.') { continue; } #if _USE_LFN fn = *fno.lfname ? fno.lfname : fno.fname; #else fn = fno.fname; #endif strcpy(tmp, fn); line_idx++; if(line_idx > 9) { line_idx = 0; LCD_UsrLog("> Press [Key] To Continue.\n"); /* KEY Button in polling */ while(BSP_PB_GetState(BUTTON_KEY) != RESET) { /* Wait for User Input */ } } if(recu_level == 1) { LCD_DbgLog(" |__"); } else if(recu_level == 2) { LCD_DbgLog(" | |__"); } if((fno.fattrib & AM_MASK) == AM_DIR) { strcat(tmp, "\n"); LCD_UsrLog((void *)tmp); Explore_Disk(fn, 2); } else { strcat(tmp, "\n"); LCD_DbgLog((void *)tmp); } if(((fno.fattrib & AM_MASK) == AM_DIR)&&(recu_level == 2)) { Explore_Disk(fn, 2); } } f_closedir(&dir); LCD_UsrLog("> Select an operation to Continue.\n" ); } return res; }
/** * @brief Displays disk content * @param path: pointer to root path * @param recu_level: explorer level * @retval None */ static uint8_t Explore_Disk(char* path , uint8_t recu_level) { FRESULT res; FILINFO fno; DIR dir; char *fn; char tmp[14]; res = f_opendir(&dir, path); if (res == FR_OK) { /* USER Button in polling */ LCD_UsrLog("To see the disk root content:\n" ); LCD_UsrLog("Press Key...\n"); while((BSP_PB_GetState (BUTTON_KEY) != SET)) { Toggle_Leds(); } while((BSP_PB_GetState (BUTTON_KEY) != RESET)) { Toggle_Leds(); } while(Appli_state == APPLICATION_START) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } if (fno.fname[0] == '.') { continue; } fn = fno.fname; strcpy(tmp, fn); line_idx++; if(line_idx > 12) { line_idx = 0; LCD_UsrLog("Press Key to continue...\n"); /* USER Button in polling */ while((Appli_state == APPLICATION_START) && \ (BSP_PB_GetState (BUTTON_KEY) != SET)) { Toggle_Leds(); } } if(recu_level == 1) { LCD_DbgLog(" |__"); } else if(recu_level == 2) { LCD_DbgLog(" | |__"); } if((fno.fattrib & AM_MASK) == AM_DIR) { strcat(tmp, "\n"); LCD_UsrLog((void *)tmp); } else { strcat(tmp, "\n"); LCD_DbgLog((void *)tmp); } if(((fno.fattrib & AM_MASK) == AM_DIR)&&(recu_level == 1)) { Explore_Disk(fn, 2); } } } f_closedir(&dir); return res; }
/** * @brief Explore_Disk * Displays disk content * @param path: pointer to root path * @retval None */ static uint8_t Explore_Disk (char* path , uint8_t recu_level) { FRESULT res; FILINFO fno; DIR dir; char *fn; char tmp[14]; res = f_opendir(&dir, path); if (res == FR_OK) { while(HCD_IsDeviceConnected(&USB_OTG_Core)) { res = f_readdir(&dir, &fno); if (res != FR_OK || fno.fname[0] == 0) { break; } if (fno.fname[0] == '.') { continue; } fn = fno.fname; strcpy(tmp, fn); line_idx++; if (line_idx > 9) { line_idx = 0; LCD_SetTextColor(Green); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 42, " "); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 30, "Press Key to continue..."); LCD_SetTextColor(LCD_LOG_DEFAULT_COLOR); /*Key B3 in polling*/ while((HCD_IsDeviceConnected(&USB_OTG_Core)) && \ (STM_EVAL_PBGetState (BUTTON_USER) == RESET)) { Toggle_Leds(); } } if (recu_level == 1) { LCD_DbgLog(" |__"); } else if(recu_level == 2) { LCD_DbgLog(" | |__"); } if ((fno.fattrib & AM_MASK) == AM_DIR) { strcat(tmp, "\n"); LCD_UsrLog((void *)tmp); } else { strcat(tmp, "\n"); LCD_DbgLog((void *)tmp); } if (((fno.fattrib & AM_MASK) == AM_DIR)&&(recu_level == 1)) { Explore_Disk(fn, 2); } } } return res; }
/** * @brief Manages MSC Menu Process. * @param None * @retval None */ void MSC_MenuProcess(void) { switch(msc_demo.state) { case MSC_DEMO_IDLE: MSC_SelectItem(MSC_main_menu, 0); msc_demo.state = MSC_DEMO_WAIT; msc_demo.select = 0; break; case MSC_DEMO_WAIT: if(msc_demo.select != prev_select) { prev_select = msc_demo.select; MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F); /* Handle select item */ if(msc_demo.select & 0x80) { switch(msc_demo.select & 0x7F) { case 0: msc_demo.state = MSC_DEMO_FILE_OPERATIONS; break; case 1: msc_demo.state = MSC_DEMO_EXPLORER; break; case 2: msc_demo.state = MSC_REENUMERATE; break; default: break; } } } break; case MSC_DEMO_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_state == APPLICATION_READY) { MSC_File_Operations(); } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_DEMO_EXPLORER: /* Display disk content */ if(Appli_state == APPLICATION_READY) { Explore_Disk("0:/", 1); } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_REENUMERATE: /* Force MSC Device to re-enumerate */ USBH_ReEnumerate(&hUSBHost); msc_demo.state = MSC_DEMO_WAIT; break; default: break; } msc_demo.select &= 0x7F; }
/** * @brief USBH_USR_MSC_Application * Demo application for mass storage * @param None * @retval Staus */ int USBH_USR_MSC_Application(void) { FRESULT res; uint8_t writeTextBuff[] = "STM32 Connectivity line Host Demo application using FAT_FS "; uint16_t bytesWritten, bytesToWrite; switch(USBH_USR_ApplicationState) { case USH_USR_FS_INIT: /* Initialises the File System*/ if ( f_mount( 0, &fatfs ) != FR_OK ) { /* efs initialisation fails*/ LCD_ErrLog("> Cannot initialize File System.\n"); return(-1); } LCD_UsrLog("> File System initialized.\n"); LCD_UsrLog("> Disk capacity : %d Bytes\n", USBH_MSC_Param.MSCapacity * \ USBH_MSC_Param.MSPageLength); if(USBH_MSC_Param.MSWriteProtect == DISK_WRITE_PROTECTED) { LCD_ErrLog((void *)MSG_WR_PROTECT); } USBH_USR_ApplicationState = USH_USR_FS_READLIST; break; case USH_USR_FS_READLIST: LCD_UsrLog((void *)MSG_ROOT_CONT); Explore_Disk("0:/", 1); line_idx = 0; USBH_USR_ApplicationState = USH_USR_FS_WRITEFILE; break; case USH_USR_FS_WRITEFILE: LCD_SetTextColor(Green); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 42, " "); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 30, "Press Key to write file"); LCD_SetTextColor(LCD_LOG_DEFAULT_COLOR); USB_OTG_BSP_mDelay(100); /*Key B3 in polling*/ while((HCD_IsDeviceConnected(&USB_OTG_Core)) && \ (STM_EVAL_PBGetState (BUTTON_USER) == RESET)) { Toggle_Leds(); } /* Writes a text file, STM32.TXT in the disk*/ LCD_UsrLog("> Writing File to disk flash ...\n"); if (USBH_MSC_Param.MSWriteProtect == DISK_WRITE_PROTECTED) { LCD_ErrLog ( "> Disk flash is write protected \n"); USBH_USR_ApplicationState = USH_USR_FS_DRAW; break; } /* Register work area for logical drives */ f_mount(0, &fatfs); if (f_open(&file, "0:STM32.TXT",FA_CREATE_ALWAYS | FA_WRITE) == FR_OK) { /* Write buffer to file */ bytesToWrite = sizeof(writeTextBuff); res= f_write (&file, writeTextBuff, bytesToWrite, (void *)&bytesWritten); if((bytesWritten == 0) || (res != FR_OK)) /*EOF or Error*/ { LCD_ErrLog("> STM32.TXT CANNOT be writen.\n"); } else { LCD_UsrLog("> 'STM32.TXT' file created\n"); } /*close file and filesystem*/ f_close(&file); f_mount(0, NULL); } else { LCD_UsrLog ("> STM32.TXT created in the disk\n"); } USBH_USR_ApplicationState = USH_USR_FS_DRAW; LCD_SetTextColor(Green); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 42, " "); LCD_DisplayStringLine( LCD_PIXEL_HEIGHT - 30, "To start Image slide show Press Key."); LCD_SetTextColor(LCD_LOG_DEFAULT_COLOR); break; case USH_USR_FS_DRAW: /*Key B3 in polling*/ while((HCD_IsDeviceConnected(&USB_OTG_Core)) && \ (STM_EVAL_PBGetState (BUTTON_USER) == RESET)) { Toggle_Leds(); } while(HCD_IsDeviceConnected(&USB_OTG_Core)) { if ( f_mount( 0, &fatfs ) != FR_OK ) { /* fat_fs initialisation fails*/ return(-1); } return Image_Browser("0:/"); } break; default: break; } return(0); }
/** * @brief Manages MSC Menu Process. * @param None * @retval None */ void MSC_MenuProcess(void) { switch(demo.msc_state) { case APPLI_MSC_IDLE: Demo_SelectItem(MSC_main_menu, 0); demo.msc_state = APPLI_MSC_WAIT; demo.select = 0; break; case APPLI_MSC_WAIT: if(demo.select != prev_select) { prev_select = demo.select; Demo_SelectItem(MSC_main_menu, demo.select & 0x7F); /* Handle select item */ if(demo.select & 0x80) { demo.select &= 0x7F; switch(demo.select) { case 0: demo.msc_state = APPLI_MSC_FILE_OPERATIONS; break; case 1: demo.msc_state = APPLI_MSC_EXPLORER; break; case 2: /* Return */ demo.state = DEMO_IDLE; demo.select = 0; LCD_UsrLogY("> MSC application closed.\n"); f_mount(0,0,0); break; default: break; } } } break; case APPLI_MSC_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_HS_state == APPLICATION_HS_READY) { MSC_File_Operations(); } demo.msc_state = APPLI_MSC_WAIT; break; case APPLI_MSC_EXPLORER: /* Display disk content */ if(Appli_HS_state == APPLICATION_HS_READY) { Explore_Disk("0:/", 1); } demo.msc_state = APPLI_MSC_WAIT; break; default: break; } }
/** * @brief Manages MSC Menu Process. * @param None * @retval None */ void MSC_MenuProcess(void) { switch(msc_demo.state) { case MSC_DEMO_START: if(Appli_state == APPLICATION_MSC) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to start read and write operations"); /* Wait for User Input */ while((BSP_PB_GetState(BUTTON_TAMPER) != SET) && (Appli_state != APPLICATION_DISCONNECT)) { } msc_demo.state = MSC_DEMO_FILE_OPERATIONS; /* Prevent debounce effect for user key */ HAL_Delay(400); BSP_LCD_ClearStringLine(19); } break; case MSC_DEMO_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_state == APPLICATION_MSC) { MSC_File_Operations(); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to display disk content"); /* Wait for User Input */ while((BSP_PB_GetState(BUTTON_TAMPER) != SET) && (Appli_state != APPLICATION_DISCONNECT)) { } msc_demo.state = MSC_DEMO_EXPLORER; /* Prevent debounce effect for user key */ HAL_Delay(400); BSP_LCD_ClearStringLine(19); } break; case MSC_DEMO_EXPLORER: /* Display disk content */ if(Appli_state == APPLICATION_MSC) { /* Register the file system object to the FatFs module */ if(f_mount(&USBH_fatfs, "", 0 ) != FR_OK ) { LCD_ErrLog("Cannot Initialize FatFs! \n"); } else { Explore_Disk("0:/", 1); msc_demo.state = MSC_DEMO_START; /* Prevent debounce effect for user key */ HAL_Delay(400); } } break; default: break; } }
/** * @brief User task * @param pvParameters not used * @retval None */ static void MSC_MenuThread(void const *argument) { for(;;) { if(osSemaphoreWait(MenuEvent, osWaitForever) == osOK) { switch(msc_demo.state) { case MSC_DEMO_IDLE: MSC_SelectItem(MSC_main_menu, 0); msc_demo.state = MSC_DEMO_WAIT; msc_demo.select = 0; osSemaphoreRelease(MenuEvent); break; case MSC_DEMO_WAIT: MSC_SelectItem(MSC_main_menu, msc_demo.select & 0x7F); /* Handle select item */ if(msc_demo.select & 0x80) { switch(msc_demo.select & 0x7F) { case 0: msc_demo.state = MSC_DEMO_FILE_OPERATIONS; osSemaphoreRelease(MenuEvent); break; case 1: msc_demo.state = MSC_DEMO_EXPLORER; osSemaphoreRelease(MenuEvent); break; case 2: msc_demo.state = MSC_REENUMERATE; osSemaphoreRelease(MenuEvent); break; default: break; } } break; case MSC_DEMO_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_state == APPLICATION_READY) { MSC_File_Operations(); } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_DEMO_EXPLORER: /* Display disk content */ if(Appli_state == APPLICATION_READY) { Explore_Disk("0:/", 1); } msc_demo.state = MSC_DEMO_WAIT; break; case MSC_REENUMERATE: /* Force MSC Device to re-enumerate */ USBH_ReEnumerate(&hUSBHost); msc_demo.state = MSC_DEMO_WAIT; break; default: break; } msc_demo.select &= 0x7F; } } }
/** * @brief Manages MSC Menu Process. * @param None * @retval None */ void MSC_MenuProcess(void) { switch(msc_demo.state) { case MSC_DEMO_START: if(Appli_state == APPLICATION_READY) { BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to start read and write operations"); /* Wait for User Input */ while((BSP_PB_GetState(BUTTON_WAKEUP) != SET) && (Appli_state != APPLICATION_DISCONNECT)) { } msc_demo.state = MSC_DEMO_FILE_OPERATIONS; /* Prevent debounce effect for user key */ HAL_Delay(400); BSP_LCD_ClearStringLine(19); } break; case MSC_DEMO_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_state == APPLICATION_READY) { MSC_File_Operations(); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to display disk content"); /* Wait for User Input */ while((BSP_PB_GetState(BUTTON_WAKEUP) != SET) && (Appli_state != APPLICATION_DISCONNECT)) { } msc_demo.state = MSC_DEMO_EXPLORER; /* Prevent debounce effect for user key */ HAL_Delay(400); BSP_LCD_ClearStringLine(19); } break; case MSC_DEMO_EXPLORER: /* Display disk content */ if(Appli_state == APPLICATION_READY) { Explore_Disk("0:/", 1); msc_demo.state = MSC_DEMO_START; /* Prevent debounce effect for user key */ HAL_Delay(400); } break; default: break; } if(Appli_state == APPLICATION_DISCONNECT) { Appli_state = APPLICATION_IDLE; LCD_LOG_ClearTextZone(); LCD_ErrLog("MSC device disconnected!\n"); msc_demo.state = MSC_DEMO_START; msc_demo.select = 0; } }
/** * @brief Manages MSC Menu Process. * @param None * @retval None */ void MSC_MenuProcess(void) { switch(demo.msc_state) { case APPLI_MSC_START: if(Appli_HS_state == APPLICATION_HS_READY) { BSP_LCD_ClearStringLine(19); BSP_LCD_ClearStringLine(20); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to start read and write operations"); /* Wait for User Input */ while((BSP_PB_GetState(BUTTON_TAMPER) != SET) && (Appli_HS_state != APPLICATION_HS_DISCONNECT)) { } demo.msc_state = APPLI_MSC_FILE_OPERATIONS; /* Prevent debounce effect for user key */ HAL_Delay(400); BSP_LCD_ClearStringLine(19); } break; case APPLI_MSC_FILE_OPERATIONS: /* Read and Write File Here */ if(Appli_HS_state == APPLICATION_HS_READY) { MSC_File_Operations(); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(19, (uint8_t *)"Press User button to display disk content"); /* Wait for User Input */ while((BSP_PB_GetState(BUTTON_TAMPER) != SET) && (Appli_HS_state != APPLICATION_HS_DISCONNECT)) { } demo.msc_state = APPLI_MSC_EXPLORER; /* Prevent debounce effect for user key */ HAL_Delay(400); BSP_LCD_ClearStringLine(19); } break; case APPLI_MSC_EXPLORER: /* Display disk content */ if(Appli_HS_state == APPLICATION_HS_READY) { Explore_Disk("0:/", 1); demo.msc_state = APPLI_MSC_START; demo.state = DEMO_IDLE; BSP_LCD_ClearStringLine(19); BSP_LCD_ClearStringLine(20); BSP_LCD_SetTextColor(LCD_COLOR_GREEN); BSP_LCD_DisplayStringAtLine(20, (uint8_t *)"Press User button to exit"); /* Prevent debounce effect for user key */ HAL_Delay(400); /* Wait for User Input */ while((BSP_PB_GetState(BUTTON_TAMPER) != SET) && (Appli_HS_state != APPLICATION_HS_DISCONNECT)) { } /* Prevent debounce effect for user key */ HAL_Delay(400); } break; default: break; } }