?? user.c
字號:
//===========================================================
// Project Name(項目名稱): SPCA755 rebuild
// File Name(模塊名稱): user.c
// Built Date(創(chuàng)建日期):2004-09-14
// Abstract(模塊描述): 用戶函數(shù)模塊
// 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:以下函數(shù)必須保留,用戶不能刪除以下函數(shù)變量定義**********************
//**********************************************************************************************
#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;//當(dāng)要第一次查找或改變查找文件類型時,都需要將該值清0
DOS_Search_File(0x10,1,0x10); //在單目錄下統(tǒng)計錄音文件總數(shù) 040907 LIZHN
}
gs_File_FCB[0].dw_FDB_StartCluster = gdw_DOS_RootDirClus;
gbt_FindFlag = 0;//當(dāng)要第一次查找或改變查找文件類型時,都需要將該值清0
DOS_Search_File(0,0,0x10);//全盤檢索音樂文件
gbt_FindFlag = 0;//當(dāng)要第一次查找或改變查找文件類型時,都需要將該值清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;//當(dāng)要第一次查找或改變查找文件類型時,都需要將該值清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;//當(dāng)要第一次查找或改變查找文件類型時,都需要將該值清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);
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -