|
发表于 2023-9-5 09:08:41
|
显示全部楼层
- //+++++++++++++++++++++++++++++my_code++++++++++++++++++++++++++++++//
- #if MY_VM_ENABLE
- int my_write_parm(void)
- {
- int ret=1;
- ret = syscfg_write(_CFG_USER_VM_SET_PARM, &sVM, sizeof(Typedef_VM_CFG));
- if(ret!=sizeof(Typedef_VM_CFG))
- {
- ret=0;
- printf("write parm err\n");
- }
- return ret;
- }
- int my_read_parm(void)
- {
- int ret=1;
- ret = syscfg_read(_CFG_USER_VM_SET_PARM, &sVM, sizeof(Typedef_VM_CFG));
- if(ret!=sizeof(Typedef_VM_CFG))
- {
- ret=0;
- printf("read parm err\n");
- }
- return ret;
- }
- void my_vm_init(void)
- {
- u8 str[16] = {0};
- u32 tmp;
- int ret = 0;
- printf("---my_vm_init---\n");
- ret = my_read_parm();
- if ( (!ret)||(sVM.vm_flag != _VM_FLAG) ) {
- printf("--my_vm_init_err:%d,%d\n",ret,sVM.vm_flag);
- restore_factory();
- }
- printf("read_parm OK:%d,%d,%d\n",sVM.Baud_index,sVM.bMusicSingleTrig,sVM.PorMode);
- }
- void restore_factory(void)
- {
- int ret;
- printf("---restore_factory---\n");
- memset(&sVM, 0, sizeof(sVM));
- strcpy(&sVM.EdrPinCode, "1234"); //默认密码"1234"
- sVM.Baud_index = _DEFAULT_BAUD; //默认115200
- sVM.PorMode = POR_MODE_DEV; //默认上电进蓝牙
- sVM.bMusicSingleTrig = 0; //0-循环播放 1-单曲循环
- sVM.bEdrPinCodePair = 0; //0-关闭配对密码 1-要密码
- sVM.bPorBtNotPair = 0; //0-蓝牙上电配对 1-上电不配对
- sVM.bCloseADkey = 0; //0-打开ADKey 1-关闭ADKey
- sVM.bCloseTone = 0; //0-打开ADKey 1-关闭ADKey
- sVM.bHfpEnable = 1; //1-默认打开HFP
- sVM.vm_flag = _VM_FLAG;
- ret = my_write_parm();
- //ret = syscfg_write(_CFG_USER_UART_BUND_INDEX, &sVM.Baud_index, sizeof(sVM.Baud_index));
- }
- //+++++++++++++++++++++++++++++++++++my_code.h+++++++++++++++++++++++++++++//
- typedef struct _VM_CFG
- {
- u32 vm_flag;
- u32 Baud_index;
- //u8 mode;
- u8 PorMode;
- u8 EdrPinCode[5];
-
- u16 bMusicSingleTrig:1, //单曲触发
- bEdrPinCodePair:1, //
- bPorBtNotPair:1,
- bCloseADkey:1,
- bCloseTone:1,
- bBleEnable:1,
- bHfpEnable:1,
- bno:9;
-
- }Typedef_VM_CFG;
- extern Typedef_VM_CFG sVM;
复制代码 |
|