1. 增加Flash修改使用大小延迟计算Crc32
This commit is contained in:
parent
a2c2ec8c83
commit
1a2afd46f6
@ -369,9 +369,10 @@ uint32_t HFlashGetUseSize(HFlashAddr_t addr);
|
||||
* @brief HFlashSetUseSize 设置Flash数据的使用大小
|
||||
* @param addr 需要注册的地址
|
||||
* @param size 使用大小
|
||||
* @param delayCrc32 是否延迟计算CRC 1: 是 0: 否
|
||||
* @return 1: 设置成功 0: 设置失败
|
||||
*/
|
||||
uint8_t HFlashSetUseSize(HFlashAddr_t addr, uint32_t size);
|
||||
uint8_t HFlashSetUseSize(HFlashAddr_t addr, uint32_t size, uint8_t delayCrc32);
|
||||
|
||||
/**
|
||||
* @brief HFlashGetSize 获取Flash数据的大小
|
||||
|
||||
@ -59,6 +59,13 @@ static HTimer_t sCheckTimer = HTIMER_INVALID;
|
||||
static void WatiErase();
|
||||
static void CheckSyncCache();
|
||||
|
||||
static void ResetCacheState()
|
||||
{
|
||||
if (sOpts && sOpts->cache && sOpts->cacheSize) {
|
||||
memset(sOpts->cache, 0, sizeof(HFlashMemCache) * sOpts->cacheSize);
|
||||
}
|
||||
}
|
||||
|
||||
// 对齐页地址, 向下取整
|
||||
static inline uint32_t Align4K(uint32_t addr) {
|
||||
return addr & ~(HFLASH_BLOCK_SIZE - 1);
|
||||
@ -627,6 +634,8 @@ void HFlashMemInit(HFlashMemOpts *opts)
|
||||
HTimerRemove(sCheckTimer);
|
||||
sCheckTimer = HTIMER_INVALID;
|
||||
}
|
||||
|
||||
ResetCacheState();
|
||||
}
|
||||
|
||||
const HFlashMemOpts *HFlashMemGetOpt()
|
||||
@ -787,5 +796,6 @@ void HFlashMemFreeCache()
|
||||
HTimerRemove(sCheckTimer);
|
||||
sCheckTimer = HTIMER_INVALID;
|
||||
}
|
||||
ResetCacheState();
|
||||
memset(&sInfo, 0, sizeof(sInfo));
|
||||
}
|
||||
|
||||
@ -1898,7 +1898,7 @@ void HFlashDefaultUpdateVersion(HFlashAddr_t addr, uint16_t oldVersion, uint16_t
|
||||
|
||||
void HFlashDeleteData(HFlashAddr_t addr)
|
||||
{
|
||||
HFlashSetUseSize(addr, 0);
|
||||
HFlashSetUseSize(addr, 0, 0);
|
||||
}
|
||||
|
||||
uint32_t HFlashGetUseSize(HFlashAddr_t addr)
|
||||
@ -1912,7 +1912,7 @@ uint32_t HFlashGetUseSize(HFlashAddr_t addr)
|
||||
return cache->info.useSize;
|
||||
}
|
||||
|
||||
uint8_t HFlashSetUseSize(HFlashAddr_t addr, uint32_t size)
|
||||
uint8_t HFlashSetUseSize(HFlashAddr_t addr, uint32_t size, uint8_t delayCrc32)
|
||||
{
|
||||
HFlashCacheInfo *cache = FindCache(addr);
|
||||
if (cache == NULL) {
|
||||
@ -1926,7 +1926,7 @@ uint8_t HFlashSetUseSize(HFlashAddr_t addr, uint32_t size)
|
||||
}
|
||||
|
||||
cache->info.useSize = size;
|
||||
cache->info.crc32 = GetFlashCrc32(addr, size);
|
||||
cache->waitCrc = !!delayCrc32;
|
||||
WriteCachePage(cache);
|
||||
if (size) {
|
||||
AddBackupAddr(addr, size);
|
||||
|
||||
@ -120,6 +120,7 @@ uint8_t HTimerRegisterTimerInfo(uint8_t id, HTimerInfo *info, uint16_t infoLen)
|
||||
return 0;
|
||||
}
|
||||
|
||||
memset(info, 0, infoLen);
|
||||
sTimeRegisters[id].timers = info;
|
||||
sTimeRegisters[id].len = infoLen;
|
||||
sTimeRegisters[id].enable = 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user