/** * @brief Show EEPROM Features * @param feature : feature index * @retval None */ static void EEPROM_Show_Feature(uint8_t feature) { uint8_t Tx1Buffer[] = "STM32756G EEPROM"; uint8_t EEPROM_I2C[] = "I2C"; uint8_t *Bus = NULL; uint8_t Rx1Buffer[BUFFER_SIZE1] = {0}; uint8_t Tx2Buffer[BUFFER_SIZE1] = {0}; __IO TestStatus TransferStatus1 = FAILED; __IO uint32_t NumDataRead = 0; BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillRect(12, 92, BSP_LCD_GetXSize()- 24, BSP_LCD_GetYSize() - 104); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); /* Initialize the EEPROM driver --------------------------------------------*/ if (BSP_EEPROM_Init() != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Initialization problem", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"Check if HW connected or", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)"HW version not supported", CENTER_MODE); return; } EepromDetected = 1; switch (feature) { case 0: /* Read old parameter in EEPROM */ if (EepromDetected == 1) { /* Set the Number of data to be read */ NumDataRead = (uint32_t)BUFFER_SIZE1; /* Read from EEPROM from EEPROM_READ_ADDRESS1 */ if (BSP_EEPROM_ReadBuffer(Rx1Buffer, EEPROM_READ_ADDRESS1, (uint16_t *)(&NumDataRead)) != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Init issue at read old data", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)"Press again TAMPER button", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 160, (uint8_t*)"To write new data", CENTER_MODE); return; } BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"String read", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"in the current EEPROM selected:", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayStringAt(0, 160, Rx1Buffer, CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DisplayStringAt(0, 190, (uint8_t*)"Press TAMPER button", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 205, (uint8_t*)"To write new data", CENTER_MODE); } else { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Problem to communicate", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"with EEPROM", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)"Press again TAMPER button", CENTER_MODE); } break; case 1: /* Write new parameter in EEPROM */ if (EepromDetected == 1) { if(EepromTestNb == 1) { Bus = EEPROM_I2C; } snprintf((char*)Tx2Buffer, BUFFER_SIZE1, "%s_%s Ex. test %d", Tx1Buffer, Bus, NbLoop); /* First write in the memory followed by a read of the written data ----*/ /* Write on EEPROM to EEPROM_WRITE_ADDRESS1 */ if (BSP_EEPROM_WriteBuffer(Tx2Buffer, EEPROM_WRITE_ADDRESS1, BUFFER_SIZE1) != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Init issue at write", CENTER_MODE); return; } /* Set the Number of data to be read */ NumDataRead = (uint32_t)BUFFER_SIZE1; /* Read from I2C EEPROM from EEPROM_READ_ADDRESS1 */ if (BSP_EEPROM_ReadBuffer(Rx1Buffer, EEPROM_READ_ADDRESS1, (uint16_t *)(&NumDataRead)) != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Init issue at read", CENTER_MODE); return; } /* Check if the data written to the memory is read correctly */ TransferStatus1 = Buffercmp(Tx2Buffer, Rx1Buffer, BUFFER_SIZE1); if(TransferStatus1 != FAILED) { BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"String writes", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"in the current EEPROM selected:", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayStringAt(0, 160, Tx2Buffer, CENTER_MODE); } else { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"FAILED to write!", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"Press TAMPER button to end test", CENTER_MODE); } } else { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t*)"Problem to communicate", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t*)"again with EEPROM", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 145, (uint8_t*)"Press TAMPER button to end test", CENTER_MODE); } break; } }
/** * @brief Show EEPROM Features * @param feature : feature index * @retval None */ static void EEPROM_Show_Feature(uint8_t feature) { uint8_t Tx1Buffer[] = "STM324xG-EVAL EEPROM Ex."; uint8_t Rx1Buffer[BUFFER_SIZE1] = {0}; uint8_t Tx2Buffer[BUFFER_SIZE1] = {0}; __IO TestStatus TransferStatus1 = FAILED; BSP_LCD_SetBackColor(LCD_COLOR_WHITE); BSP_LCD_SetTextColor(LCD_COLOR_WHITE); BSP_LCD_FillRect(12, 92, BSP_LCD_GetXSize() - 24, BSP_LCD_GetYSize()- 104); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); /* Initialize the I2C EEPROM driver ----------------------------------------*/ if(BSP_EEPROM_Init() != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"Initialization Issue", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t *)"Check if HW connected or", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 145, (uint8_t *)"HW version not supported", CENTER_MODE); return; } /* Wait for EEPROM standby state */ BSP_EEPROM_WaitEepromStandbyState(); switch (feature) { case 0: /* Read old parameter in EEPROM */ /* Set the Number of data to be read */ NumDataRead = BUFFER_SIZE1; /* Read from I2C EEPROM from EEPROM_READ_ADDRESS1 */ if(BSP_EEPROM_ReadBuffer(Rx1Buffer, EEPROM_READ_ADDRESS1, (uint16_t *)(&NumDataRead)) != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"Init issue at read old data", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DisplayStringAt(0, 145, (uint8_t *)"Press again USER key", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 160, (uint8_t *)"To write new data", CENTER_MODE); return; } BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"PASSED String read", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t *)"in EEPROM:", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayStringAt(0, 160, Rx1Buffer, CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLACK); BSP_LCD_DisplayStringAt(0, 190, (uint8_t *)"Press USER key", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 205, (uint8_t *)"To write new data", CENTER_MODE); break; case 1: /* Write new parameter in EEPROM */ snprintf((char*)Tx2Buffer, BUFFER_SIZE1, "%s Test %d", Tx1Buffer, NbLoop); /* First write in the memory followed by a read of the written data --------*/ /* Write on I2C EEPROM to EEPROM_WRITE_ADDRESS1 */ if(BSP_EEPROM_WriteBuffer(Tx2Buffer, EEPROM_WRITE_ADDRESS1, BUFFER_SIZE1) != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"Init issue at write", CENTER_MODE); return; } /* Wait for EEPROM standby state */ BSP_EEPROM_WaitEepromStandbyState(); /* Set the Number of data to be read */ NumDataRead = BUFFER_SIZE1; /* Read from I2C EEPROM from EEPROM_READ_ADDRESS1 */ if(BSP_EEPROM_ReadBuffer(Rx1Buffer, EEPROM_READ_ADDRESS1, (uint16_t *)(&NumDataRead)) != EEPROM_OK) { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"Init issue at read", CENTER_MODE); return; } /* Check if the data written to the memory is read correctly */ TransferStatus1 = Buffercmp(Tx2Buffer, Rx1Buffer, BUFFER_SIZE1); if(TransferStatus1 != FAILED) { BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"PASSED String writes", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t *)"in EEPROM:", CENTER_MODE); BSP_LCD_SetTextColor(LCD_COLOR_BLUE); BSP_LCD_DisplayStringAt(0, 160, Tx2Buffer, CENTER_MODE); } else { BSP_LCD_SetTextColor(LCD_COLOR_RED); BSP_LCD_DisplayStringAt(0, 115, (uint8_t *)"FAILED to write!", CENTER_MODE); BSP_LCD_DisplayStringAt(0, 130, (uint8_t *)"Press USER key to end test", CENTER_MODE); } break; } }