rusefi-1/firmware/controllers/flash_main.h

43 lines
1003 B
C
Raw Normal View History

2015-07-10 06:01:56 -07:00
/**
* @file flash_main.h
* @brief
*
* @date Sep 19, 2013
2017-01-03 03:05:22 -08:00
* @author Andrey Belomutskiy, (c) 2012-2017
2015-07-10 06:01:56 -07:00
*/
#ifndef FLASH_MAIN_H_
#define FLASH_MAIN_H_
#include "engine.h"
2016-07-01 20:01:22 -07:00
#define FLASH_DATA_VERSION 10000
2015-07-10 06:01:56 -07:00
2016-04-03 11:02:00 -07:00
typedef enum {
2017-02-13 22:03:01 -08:00
PC_OK = 0,
2016-04-03 11:02:00 -07:00
CRC_FAILED = 1,
INCOMPATIBLE_VERSION = 2,
RESET_REQUESTED = 3,
PC_ERROR = 4
} persisted_configuration_state_e;
2016-04-03 15:02:39 -07:00
persisted_configuration_state_e readConfiguration(Logging * logger);
2015-07-10 06:01:56 -07:00
void readFromFlash(void);
void initFlash(Logging *sharedLogger);
/**
* Because of hardware-related issues, stm32f4 chip is totally
* frozen while we are writing to internal flash. Writing the configuration takes
* about 1-2 seconds, we cannot afford to do that while the engine is
* running so we postpone the write until the engine is stopped.
*/
void writeToFlashNow(void);
void setNeedToWriteConfiguration(void);
/**
* @return true if an flash write is pending
*/
bool getNeedToWriteConfiguration(void);
void writeToFlashIfPending(void);
#endif /* FLASH_MAIN_H_ */