移除sys/flash.h、sys/flash.cpp、sys/initial.h和sys/OTA相关文件的 引用,清理cproject.yml和cbuild.yml中的未使用组件和文件配置。 BREAKING CHANGE: 移除了FlashEEPROM相关功能和接口。
55 lines
1.2 KiB
C++
55 lines
1.2 KiB
C++
#include "flash.h"
|
|
#include "gd32c10x.h"
|
|
#include "gd32c10x_crc.h"
|
|
#include "gd32c10x_fmc.h"
|
|
#include "math.h"
|
|
#include <Can.h>
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
#include <cstring>
|
|
#include <stdint.h>
|
|
|
|
FlashEEPROM flashEEP = FlashEEPROM();
|
|
|
|
// FlashEEPROM类实现
|
|
FlashEEPROM::FlashEEPROM() {
|
|
// 构造函数可以为空,或者做一些初始化工作
|
|
}
|
|
|
|
/**
|
|
* @brief 初始化Flash EEPROM模拟
|
|
* @param None
|
|
* @retval None
|
|
*/
|
|
u8 FlashEEPROM::init() {
|
|
rcu_periph_clock_enable(RCU_CRC);
|
|
crc_deinit(); // 初始化CRC模块
|
|
|
|
return 0; // 正常不会返回这个,未预料的异常情况返回
|
|
}
|
|
|
|
/**
|
|
* @brief 格式化Flash EEPROM页面
|
|
* @param None
|
|
* @retval FlashEepromStatus: 操作状态
|
|
*/
|
|
FlashEepromStatus FlashEEPROM::format() {
|
|
fmc_state_enum fmc_status;
|
|
#if EEPDEBUG
|
|
printf("擦除页面\r\n");
|
|
#endif
|
|
|
|
fmc_unlock();
|
|
fmc_status = fmc_page_erase(EEPROM_START_ADDRESS); // 擦除第一页
|
|
if (fmc_status != FMC_READY) {
|
|
fmc_lock();
|
|
return FLASH_EEPROM_ERASE_ERROR;
|
|
}
|
|
fmc_status = fmc_page_erase(EEPROM_DATA_PAGE2_ADDRESS); // 擦除第二页
|
|
if (fmc_status != FMC_READY) {
|
|
fmc_lock();
|
|
return FLASH_EEPROM_ERASE_ERROR;
|
|
}
|
|
fmc_lock();
|
|
return FLASH_EEPROM_OK;
|
|
} |