void Init_Fun(void) { UART_SEND; Flash_IO_Init(); Delay_Init(); Uart_Init(); ADC_Init_Fun(); EEPROM_IO_Init(); Key_IO_Init(); Cartridge_Type_Check(); UART_RECEIVE; Flash_Times = Read_Num_From_EEPROM(); if(Flash_Times >= Flash_Times_Level8) { Flash_Times_Level = Flash_Times_Level_9; Low_Lamp = 1; }else{ Low_Lamp = 0; if(Flash_Times >= Flash_Times_Level7) { Flash_Times_Level = Flash_Times_Level_8; }else{ if(Flash_Times >= Flash_Times_Level6) { Flash_Times_Level = Flash_Times_Level_7; }else{ if(Flash_Times >= Flash_Times_Level5) { Flash_Times_Level = Flash_Times_Level_6; }else{ if(Flash_Times >= Flash_Times_Level4) { Flash_Times_Level = Flash_Times_Level_5; }else{ if(Flash_Times >= Flash_Times_Level3) { Flash_Times_Level = Flash_Times_Level_4; }else{ if(Flash_Times >= Flash_Times_Level2) { Flash_Times_Level = Flash_Times_Level_3; }else{ if(Flash_Times >= Flash_Times_Level1) { Flash_Times_Level = Flash_Times_Level_2; }else{ Flash_Times_Level = Flash_Times_Level_1; } } } } } } } } }
/** * @brief Initializes peripherals used by the I2C EEPROM driver. * @param None * @retval EEPROM_OK (0) if operation is correctly performed, else return value * different from EEPROM_OK (0) */ uint32_t BSP_EEPROM_Init(void) { /* I2C Initialization */ EEPROM_IO_Init(); /* Select the EEPROM address and check if OK */ if(EEPROM_IO_IsDeviceReady(EEPROM_I2C_ADDRESS, EEPROM_MAX_TRIALS) != HAL_OK) { return EEPROM_FAIL; } return EEPROM_OK; }
/** * @brief Initializes peripherals used by the I2C EEPROM driver. * * @note There are 2 different versions of M24LR64 (A01 & A02). * Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01) * and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02) * @retval EEPROM_OK (0) if operation is correctly performed, else return value * different from EEPROM_OK (0) */ uint32_t BSP_EEPROM_Init(void) { /* I2C Initialization */ EEPROM_IO_Init(); /*Select the EEPROM address for A01 and check if OK*/ EEPROMAddress = DISCOVERY_EEPROM_I2C_ADDRESS_A01; if (EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS_NUMBER) != HAL_OK) { return EEPROM_FAIL; } return EEPROM_OK; }
/** * @brief Initializes peripherals used by the I2C EEPROM driver. * * @note There are 2 different versions of M24LR64 (A01 & A02). * Then try to connect on 1st one (EEPROM_I2C_ADDRESS_A01) * and if problem, check the 2nd one (EEPROM_I2C_ADDRESS_A02) * @retval EEPROM_OK (0) if operation is correctly performed, else return value * different from EEPROM_OK (0) */ static uint32_t EEPROM_I2C_Init(void) { EEPROM_IO_Init(); /*Select the EEPROM address for M24LR64 A02 and check if OK*/ EEPROMAddress = EEPROM_ADDRESS_M24LR64_A01; EEPROMPageSize = EEPROM_PAGESIZE_M24LR64; if (EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) { /*Select the EEPROM address for M24LR64 A01 and check if OK*/ EEPROMAddress = EEPROM_ADDRESS_M24LR64_A02; EEPROMPageSize = EEPROM_PAGESIZE_M24LR64; if (EEPROM_IO_IsDeviceReady(EEPROMAddress, EEPROM_MAX_TRIALS) != HAL_OK) { return EEPROM_FAIL; } } return EEPROM_OK; }