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

📄 user.c

📁 凌阳SPDA1000 MP3开发资料
💻 C
📖 第 1 页 / 共 5 页
字号:
//===========================================================
//   Project Name(项目名称):  SPCA755 rebuild
//   File Name(模块名称): user.c
//   Built Date(创建日期):2004-09-14
//   Abstract(模块描述): 用户函数模块
//   Revision History(版本信息):
//   Rev      Date           Author       Comment(修改说明)
//   1.0      2004-09-14      XYQ         created
//============================================================
//============================================================
#include "..\userdefine.h"
#include "user.h"
#include "userinit.h"
#include "interrupt.h"
#include "..\LCM\lcd501.h"
#include "main.h"
//================================================================================================

//****************************Note:以下函数必须保留,用户不能删除以下函数变量定义**********************
//**********************************************************************************************
#if ((K_CARD_TYPE &0x02)== 0x02)
bit data gb_USBCardST0;
bit data gb_USBCardST1;

U8 xdata gc_MlunCardType;
#endif

#if ((K_CARD_TYPE &0x01)== 0x01)
void	Mlun_NAND_Initialize();
#endif

#if ((K_CARD_TYPE &0x02)== 0x02)
void	Mlun_SD_Initialize();
#endif

#if ((K_CARD_TYPE &0x04)== 0x04)
void Mlun_SMC_Initialize();
#endif

#if ((K_CARD_TYPE &0x08)== 0x08)
void	Mlun_CF_Initialize();
#endif
#if (K_CARD_TYPE &0x10 == 0x10)
void	Mlun_MS_Initialize();//memory stick
#endif

#if ((K_CARD_TYPE &0x20) == 0x20)
void	Mlun_XD_Initialize();//XD stick
#endif

code void (code *MlunMediaInitialize[K_CARD_TOTAL])()=
{
	#if((K_CARD_TYPE &0x01)== 0x01)
	Mlun_NAND_Initialize,
	#endif
	#if((K_CARD_TYPE &0x02)== 0x02)
	Mlun_SD_Initialize,
	#endif
	#if((K_CARD_TYPE &0x04)== 0x04)
	Mlun_SMC_Initialize,
	#endif
	#if((K_CARD_TYPE &0x08)== 0x08)
	Mlun_CF_Initialize,
	#endif
	#if((K_CARD_TYPE &0x10)== 0x10)
	Mlun_MS_Initialize,//SPCA755 NOT SUPPORT
	#endif
	#if((K_CARD_TYPE &0x20)== 0x20)
	Mlun_XD_Initialize,//SPCA755 NOT SUPPORT
	#endif
};
xdata U8 MlunSequence[K_CARD_TOTAL];
//=============================*Note End*==================================
//-------------------------------------------------
void USER_FillSettingInfo(void);
U16 USER_GetMusicTotalTime(void);
void USER_GetSettingInfo(void);
void USER_Remove_USB(void);
void SD_InsertState_Detect(void);
void X_Get_DefaultUserValue(void);
void UI_PreProcessor_scan_key(void);
void UI_Battery_Detect();
extern U8 UserSendDataToDSP(U8 tc_FileType,U8 tc_DspCommand);
//============================================================================================
//---------
//Variable
//---------
bit           gb_ShowNowSongNumberFG;//show the filename flag
bit           gb_DisplayEvent_Happened;//ui_event flag
bit           gb_ADCKey_Pressed;
data  BIT     gb_FastFFFR=0;
data  BIT     gb_Openfile=FALSE;         // For Open file Flag behind the UI-State transition
data  BIT     gb_UIPostError = FALSE;    // The Error flag of UI post-processor for Audio Engine, such as Open file fail, initial fail etc.
                                         // here can't initialize,move to main.c to initialize.xyq021228
data  BIT     gb_RecordPauseAndStop;	 // chamber@030121 Close file when Stop after Pause!!


xdata U8   gc_SKeyState;//[2];
xdata U8   gc_SPressingKey;//multi with gcl_ADCOldKey
xdata U8   gc_SKeyHoldCnt;//[2];
xdata U8   REC_name[12];
xdata U8   gc_fileend;

U8 gc_LongKey_Speed;
U8 ForBackWord_SecondCount;

bit                 gb_FFFRHoldToPlay;
bit                 gb_LowBattery_StopRecord;
U8 xdata gc_Play_Pause_Stop_State;
U8 xdata gc_Menu_State;
unsigned int  code  USER_SetIdleTime[]={0,180,300,600,1800};
U8 code  UserBackLightArray[]={5,10,15,30,0xff,0};
U8 code  USER_Set_Play_DPC_Value[]={12,8,3,17,22};
//U8 xdata gc_the_CurrentDSP_Volume;
//============================================================================================

 xdata	U32	gdw_TxtFileStartCluster;//lyh add
 xdata	U32	gdw_TxtFileCurrentCluster;
 xdata	U32	gdw_TxtFileSize;
 xdata	U8	gc_TxtDisplayBuf[41];
 xdata	U8	gc_TxtCurrentLen;
 xdata 	U8  gc_TheSameTXT;
 xdata 	U8  gc_DownorUp;
 xdata 	U8  gc_OffsetByte;
//============================================================================================
xdata U8 gc_USR_PowerOffCount;
U8 xdata X_G_LRC_HaveGetFirstLyrics;//lyh add
bit             _G_RecordNextFile;//lyh add
xdata U8 gc_USR_HaveID3OrNot;
data  U8     gc_sts ;//lyh add
U8 data  gc_Battery_Detect_Timer;//lyh add
xdata U8 ADCOldKey1;
//============================================================================================
xdata U16 gw_TotalSecond;
//============================================================================================
 #define MAXLEN 6
 xdata U8  gc_UI_CurrSecond;//gc_UI_BSecond;
 xdata U32   gdw_UI_ADataPoint;
 xdata U32   gdw_UI_BDataPoint;
 xdata U32   gdw_UI_AFrameCnt;
 xdata U8 gc_UI_ABStateMode;
 idata U8  gc_DOS_ErrorStatus;//lzp add for test
//============================================================================================
//-------------------------------------------------------------------------------
U16 USER_GetMusicTotalTime(void)
{
	U16 tw_FileTotalSecond;
	
	if ((gs_File_FCB[gc_UIMode].c_FileType == AUDIO_FILE_TYPE_WAV)&&(gc_UIMode == 1))
	{
		tw_FileTotalSecond = ((gs_File_FCB[gc_UIMode].dw_File_TotalSize-60)*252/256)/4000;	
	}
	else
	{
		tw_FileTotalSecond =((gs_File_FCB[gc_UIMode].dw_File_TotalSize/gs_System_State.w_BitRate)/125);
	
	}


	return tw_FileTotalSecond;
}
//==========================================================================================
void USER_Remove_USB(void)
{
	//must initialize after remove USB
	#if (K_CARD_TYPE == 0x03)
	SMC_STORAGE_Initialize();
	if (gc_DOS_ErrorStatus = SD_STORAGE_Initialize())//try to initialize SD card
	#endif
	{//if SD card is not exist
		gc_DOS_ErrorStatus = SMC_STORAGE_Initialize();//try to initialize SMC
	}
	//*
	gw_FileIndex[0]=0;
	gw_FileIndex[1]=0;
	gw_FileIndex[2]=0;
	
	gw_FileTotalNumber[0]=0;
	gw_FileTotalNumber[1]=0;
	//*/
	if (gc_DOS_ErrorStatus == 0)
	{		
		USER_FindDir(0,gdw_DOS_RootDirClus);//detect DVR dir
	}
	
	if (gdw_USER_DirClus[0])	
	{//if DVR is exist
		gs_File_FCB[1].dw_FDB_StartCluster = gdw_USER_DirClus[0];	 //040830 lzp add 
		gbt_FindFlag = 0;//当要第一次查找或改变查找文件类型时,都需要将该值清0	
		DOS_Search_File(0x10,1,0x10);      //在单目录下统计录音文件总数 040907 LIZHN
	}

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

		gw_FileIndex[gc_UIMode] = 1;
	}
	else
	{
		gw_FileIndex[gc_UIMode] = 0;//clear index
	
//		gs_File_FCB[gc_UIMode].c_FileType = gc_UIMode + 4;
	}
	gb_Storage_Full=0;
	gc_Menu_State=0;
	gc_Busy_Timer = 0;
/*
	 if(!USER_Get_SYSInformation(0))  
	 {
	 	 gb_Storage_Full=1;
	 }
	 else
	 {
	 	gb_Storage_Full = 0;
	 }
*/   
    UI_idle_Display();//lyh add
    gc_SystemStateMode=SYSTEM_STATE0_IDLE;
    USER_MCUClock_Select(K_MCU_LOWSPEED);//return back MCU Clock
}

//======================================================================================
#if (K_CARD_TYPE == 0x03)
void SD_InsertState_Detect(void)
{
	U8 tc_CardInsert;
	U8 tc_DoInitialize = 0;
	//printf("Time=%bx\n",gc_ReadWriteTimeOut);
	if (gc_ReadWriteTimeOut)
	{//if data read write timeout occur
	    //printf("Read Write TimeOut\n");
		System_Stop();
		gc_ReadWriteTimeOut = 0;
		gc_SystemStateMode = SYSTEM_STATE0_IDLE;
	}
	
	if (gc_SystemStateMode == SYSTEM_STATE0_IDLE)
	{//if in IDLE STATE
		
		STORAGE_Detect(&tc_CardInsert);
//printf("tc_CardInsert=%bu\n",tc_CardInsert);
		if (tc_CardInsert)//首先要判断是否有卡插入
		{//if SD or MMC is not insert last time
			if (!(gc_CurrentExistMedia & 0x40))//如果有,而且是bit6为0,说明上一次检测时,是没有卡插入的。因为如果上一次有卡插入的话,其值一定为1。
			{
				if (!SD_SetInterface(CURRENT_MEDIA_SD))
				{
					gc_CurrentCard = CURRENT_MEDIA_SD;
					gc_CurrentExistMedia |= 0x40;
					gc_DOS_ErrorStatus = SD_STORAGE_Initialize();
//printf("gc_DOS_ErrorStatus=%bu\n",gc_DOS_ErrorStatus);
		 			tc_DoInitialize = 1;	
				}
				else if (!SD_SetInterface(CURRENT_MEDIA_MMC))
				{
					gc_CurrentCard = CURRENT_MEDIA_MMC;
					gc_CurrentExistMedia |= 0x40;
					gc_DOS_ErrorStatus = SD_STORAGE_Initialize();
					tc_DoInitialize = 1;	
				}
				else if (gc_CurrentExistMedia & 0x80)
				{
					FlashExchang(CURRENT_MEDIA_NAND,CURRENT_MEDIA_MMC,1);
				}
		
			}
		}
		else
		{
			if ((gc_CurrentExistMedia & 0x40) == 0x40)
			{//if SD or MMC is insert last time
				gc_CurrentExistMedia &= 0xbf;
				if (gc_CurrentExistMedia & 0x80)
				{			
					gc_DOS_ErrorStatus = SMC_STORAGE_Initialize();
					tc_DoInitialize = 1;
				} 
			}
		}
		
		if (tc_DoInitialize)
		{
			
			if (gc_DOS_ErrorStatus == 0)
			{		
				USER_FindDir(0,gdw_DOS_RootDirClus);//detect DVR dir
			}

			if (gdw_USER_DirClus[0] != 0)
			{
				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
			{
		
			}
	
			UI_SetDispTimeToDispBuf(0);//clear time
			
			
		}
	}    
}
#endif
//==========================================================================================

//==========================================================================================
void UI_Connect_USB()
{
   if(gb_USB_Setup_Ack==1)
   LCD501_Disp_PCConnect();
}

//==========================================================================================
void UI_Battery_Detect_ND_Display()
{

	if(!gc_Battery_Detect_Timer)
	{
         //printf("gc_Battery_Detect_Timer=%bu\n",gc_Battery_Detect_Timer);

⌨️ 快捷键说明

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