K1Guitar/driver/drv_nvm.h

71 lines
1.8 KiB
C
Raw Normal View History

#ifndef _DRV_NVM_H_
#define _DRV_NVM_H_
#define NVM_VERSION 0x02
#define fwname "BRS08L\x00"
#define fwdata __DATE__
#define fwtime __TIME__
#define INNER_FLASH_SAVE_ADDRESS (FLASH_BASE + 0x00040000 - SECTOR_SIZE)
typedef struct {
uint16_t BPM;
uint8_t Timbre;
uint8_t BandVol;
uint8_t StringVol;
uint8_t MIcVol;
uint8_t MicRev;
uint8_t AutoCloseTime;
uint8_t Transpose;
uint8_t Language;
uint8_t Param1;
uint8_t Param2;
uint8_t Param3;
} DeviceParam_Type;
typedef struct {
uint8_t Signature[4];
uint8_t Name[12];
uint8_t Data[16];
uint8_t Time[16];
uint8_t nvm_version;
uint8_t lock_mcu_flash;
uint8_t lock_mcu_swd;
uint32_t sn_key;
// 随机数
//uint32_t seed;
// 芯片密钥用于防止镜像文件复制到另一颗MCU上
//uint32_t chip_key[12];
// 如果值等于MAGIC_POWER_ON_RESTORE恢复默认值(不包含动态参数)
uint16_t RestoreParameter; // MAGIC_POWER_ON_RESTORE
uint8_t cal_time;
// 机器参数
DeviceParam_Type param;
} NvmParam_Type;
typedef struct {
NvmParam_Type data;
uint16_t sum[2];
} NvmData_Type;
#define MAGIC_POWER_ON_RESTORE 0xA637
extern void drv_nvm_init(void);
NvmParam_Type * drv_nvm_param_ptr(void);
uint8_t drv_nvm_save_to_flash(void);
void drv_nvm_load_default_calibration_value(NvmParam_Type * pData, uint8_t withDynamic);
//void drv_nvm_load_default_calibration_dynamic_value(NvmParam_Type * pData);
void drv_nvm_load_default_calibration_static_value(NvmParam_Type * pData, uint8_t reset_open_status);//gh,2024.1.3 reset_open_status是1就是恢复出厂设置是0就是开机
uint8_t drv_nvm_get_param_value_by_id (uint8_t nvmId);
#endif // _DRV_NVM_H_