⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 userinit.c

📁 凌阳SPDA1000 MP3开发资料
💻 C
📖 第 1 页 / 共 2 页
字号:
			while(1);
		}
	}	
	//用户可以根据需要编写自己的字库写入程序和检测,去掉下列两个函数
	if (gc_CurrentCard == CURRENT_MEDIA_NAND && gc_DOS_ErrorStatus == 0)
	{
		X_MoveFiletoReserveBLK(RESERVEBLOCK_FILETYPE_USERDATA);//将HZK文件写入保留块	//lss 060613	
		X_MoveFiletoReserveBLK(RESERVEBLOCK_ISP_FILE);//将ISP文件写入保留块	//lijh 050314	
		X_DetectHZK();//字库检测
	}
	
	USER_LogFile_ReadWrite(0);//read log file for user setting
	if (gdw_USER_DirClus[0] != 0)
	{//if DVR is exist
		gs_File_FCB[1].dw_FDB_StartCluster = gdw_USER_DirClus[0];
		gbt_FindFlag = 0;//当要第一次查找或改变查找文件类型时,都需要将该值清0	
		DOS_Search_File(0x10,1,0x10);
		DOS_Search_File(0x12,1,0x10);
	}

	gs_File_FCB[0].dw_FDB_StartCluster = gdw_DOS_RootDirClus;
	gbt_FindFlag = 0;//当要第一次查找或改变查找文件类型时,都需要将该值清0
	DOS_Search_File(0,0,0x10);//全盘检索音乐文件
	DOS_Search_File(0x01,0,0x10);//向下检索一个音乐文件
	
	if(gw_FileTotalNumber[gc_UIMode])
	{
		gw_FileIndex[gc_UIMode] = 1;
	
	}
	else
	{
		gw_FileIndex[gc_UIMode] = 0;
	}

	gc_KeyValue = 0;
	gc_ADCOldKey = 0;
   	
} 
//===========================================================================================
void User_initialize(void)
{
	L2_ConfigureIO();//set GPIO	input or output
	User_Set_P3Mode(0x3D);

	POWER_CTRL_HIGH;//DbgP30=1;//open	power control
	
	//用户保留块大小定义,最大不能超过8MB,以扇区为单位
	gdw_UserRsvSectorNum = 32L * 55;//user reserve sector number
	USER_Set_SYSInformation(SYSI_CREATE_DATE,0x0021);//create file date
	USER_Set_SYSInformation(SYSI_CREATE_TIME,0x0021);//create file time
}
//===========================================================================================
//================================================================================================
void User_initialize4_UI(void)
{

    gb_LowBatt_State=0; //how to change it? change it in void LCD501_Disp_Battery()
    gc_EVENT=0;
    gc_SPressingKey = 0;
 	gc_SKeyState = 0;
	ADCOldKey1 = 0;
	gc_SKeyHoldCnt = 0;

    gc_Busy_Timer=0;
    gc_AB_Cnt=0;
    gb_PlayPause=FALSE;//signal of pause
    gb_Storage_Full=0;//
	gb_UIPostError=0;

    gc_fileend=TRUE;	   //...

	G_Current_Contrast = 2;//...
    G_W_OldTime=0;
    G_DISPLAY_TotalSec=0;
    gc_Menu_State = 0;
    gc_MenuHZK=0;
   
    gb_UIEvent=FALSE;
	gc_sts=9;
    gc_USR_PowerOffCount = 1;//lyh add
    gw_PowerOffTimer=1440;
    gc_Battery_Detect_Timer=0;
    gc_Battery_Level=5;//how to ....

    gc_DVRE_Mode_Selected=0;
	gc_PlaySequenceMode = REP_ALL_MODE;	
    gc_USB_Connect=0;
    gb_USB_PowerPlug_Interrupt=0;
    gb_LrcGetTimeOrNot=0;	
    gc_PlayMode=0;//lyh add 
    

    gw_DispFileName_ByteOffset=0;
    gb_DisplayEvent_Happened=1;
	
    gw_PowerOffTimer=1440;
	
}
//===========================================================================================
//================================================================================================
void L2_ConfigureIO(void)
{	
	U8 tc_P3Value;

	User_Set_P1Mode(0xFF);
    P1 &=0x1F;

	User_Set_P3Mode(0x30);  
    P3 &=0xC7; 
	//SPCA759
	User_Set_MuxPinFunc(IOREG_MUX_PIN_VALUE);
	User_Set_GPIOMode(IOREG_GPIOOE_6_0_VALUE);
	User_Set_P1Mode(IOREG_P1OESEL_VALUE);	
	User_Set_P3Mode(IOREG_P3OESEL_VALUE);
	tc_P3Value = User_Read_P3Mode();
	tc_P3Value|= 0x02;
	User_Set_P3Mode(tc_P3Value);	
}
//-------------------------------------------------------------------------------
//建议该函数只在开机和关机时使用,开机读取日志文件,关机保存日志文件,不要在其余位置调用
//-------------------------------------------------------------------------------
U8 USER_LogFile_ReadWrite(bit tbt_ReadOrWrite)
{//建议该函数只在开机和关机时使用,开机读取日志文件,关机保存日志文件,不要在其余位置调用
 //开机读取日志文件应该在文件检索之前	
	U8 tc_Status;
	U8 tc_CheckSum = 0;
	U8 tc_Loop;
	bit tbt_SaveFlag;//lijh 050627 add

	tbt_SaveFlag = gbt_FindFlag;//lijh 050627 add
	gbt_FindFlag = 0;

	if ((gdw_USER_DirClus[0] != 0) && (gc_DOS_ErrorStatus == 0))
	{//DVR dir is exist
	//	Libprintf("find DVR\n");
		gs_File_FCB[2].dw_FDB_StartCluster = gdw_USER_DirClus[0];
	}
	else
	{//DVR dir is no exist and not to create log file
	//	Libprintf("no find DVR\n");
		X_Get_DefaultUserValue();
		return 1;
	}

	EXT_NameC[0]=1;
	EXT_NameC[1]='L';
	EXT_NameC[2]='O';
    EXT_NameC[3]='G';
	//search user log file in specify dir
	tc_Status = DOS_Search_File(0x13,2,0x10);
	gbt_FindFlag = tbt_SaveFlag;
	//Libprintf("tc_sts=%bx\n",tc_Status);
	if (tc_Status == 0x00)
	{//find log file		
		DOS_Open_File(2, 2, 0);//open log file,and get the startcluster
		DOS_Read_File(2);
		DOS_Close_File(2,0,0);
		
		//detect log file flag
		if (gc_PlayRecordDataBuf[510] == 0x55 && gc_PlayRecordDataBuf[511] == 0xaa) 
		{//"55aa"flag is exist
 			
			if (tbt_ReadOrWrite)
			{//save(modify) log file
				
				USER_FillSettingInfo();//fill gc_PlayRecordDataBuf[]
				
				//get the checksum of the first 10 byte
				for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
					tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];
				
				gc_PlayRecordDataBuf[500] = tc_CheckSum;
				DOS_Open_File(2, 2, 0);//open log file,and get the startcluster
				DOS_Write_File(2);
				DOS_Close_File(2,0,0);
			}
			else
			{//read log file
				
				//get the checksum of the first 10 byte
				for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
					tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];

				//detect the check sum
				if (tc_CheckSum == gc_PlayRecordDataBuf[500])
				{//checksum is ok, get the setting info
					
					USER_GetSettingInfo();
				}
				else
				{
					X_Get_DefaultUserValue();//get default value
				}
			}
		}
		else
		{//have no "55aa"flag,is not real log file 

			if (tbt_ReadOrWrite)
			{//
				USER_FillSettingInfo();			
				
				//get the checksum of the first 10 byte
				for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
					tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];

				gc_PlayRecordDataBuf[500] = tc_CheckSum;//write checksum byte
				gc_PlayRecordDataBuf[510] = 0x55;//mark "0x55"
				gc_PlayRecordDataBuf[511] = 0xaa;//mark "0xaa"
				
				DOS_Open_File(2, 2, 0);//open log file,and get the startcluster
				DOS_Write_File(2);
				DOS_Close_File(2,0,0);
			}
			else
			{
				X_Get_DefaultUserValue();//get default value
			}	
		}
	}
	else if (tbt_ReadOrWrite)
	{//when write mode ,no find log file,create log file
		
	//ceate log file in Root Dir
		if (DOS_Open_File(2,1,0))
		{//disk is full
			gc_DOS_ErrorStatus = DOS_ERROR_DISK_FULL;
			return 1;		
		}
		USER_FillSettingInfo();//fill gc_PlayRecordDataBuf[]
		
		//get the checksum of the first 10 byte
		for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
			tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];
		
		gc_PlayRecordDataBuf[500] = tc_CheckSum;//write checksum byte
		gc_PlayRecordDataBuf[510] = 0x55;//mark "0x55"
		gc_PlayRecordDataBuf[511] = 0xaa;//mark "0xaa"

		DOS_Write_File(2);//create log file
		DOS_Close_File(2,1,LogFileName);
	}
	else
		X_Get_DefaultUserValue();//get default value
				
	return 0;	
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -