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

📄 userinit.lst

📁 凌阳SPDA1000 MP3开发资料
💻 LST
📖 第 1 页 / 共 2 页
字号:
 253   2              }       
 254   1              //用户可以根据需要编写自己的字库写入程序和检测,去掉下列两个函数
 255   1              if (gc_CurrentCard == CURRENT_MEDIA_NAND && gc_DOS_ErrorStatus == 0)
 256   1              {
 257   2                      X_MoveFiletoReserveBLK(RESERVEBLOCK_FILETYPE_USERDATA);//将HZK文件写入保留块    //lss 060613    
 258   2                      X_MoveFiletoReserveBLK(RESERVEBLOCK_ISP_FILE);//将ISP文件写入保留块     //lijh 050314   
 259   2                      X_DetectHZK();//字库检测
 260   2              }
 261   1              
 262   1              USER_LogFile_ReadWrite(0);//read log file for user setting
 263   1              if (gdw_USER_DirClus[0] != 0)
 264   1              {//if DVR is exist
 265   2                      gs_File_FCB[1].dw_FDB_StartCluster = gdw_USER_DirClus[0];
 266   2                      gbt_FindFlag = 0;//当要第一次查找或改变查找文件类型时,都需要将该值清0   
 267   2                      DOS_Search_File(0x10,1,0x10);
 268   2                      DOS_Search_File(0x12,1,0x10);
 269   2              }
 270   1      
 271   1              gs_File_FCB[0].dw_FDB_StartCluster = gdw_DOS_RootDirClus;
 272   1              gbt_FindFlag = 0;//当要第一次查找或改变查找文件类型时,都需要将该值清0
 273   1              DOS_Search_File(0,0,0x10);//全盘检索音乐文件
 274   1              DOS_Search_File(0x01,0,0x10);//向下检索一个音乐文件
 275   1              
 276   1              if(gw_FileTotalNumber[gc_UIMode])
 277   1              {
 278   2                      gw_FileIndex[gc_UIMode] = 1;
 279   2              
 280   2              }
 281   1              else
 282   1              {
 283   2                      gw_FileIndex[gc_UIMode] = 0;
 284   2              }
 285   1      
 286   1              gc_KeyValue = 0;
 287   1              gc_ADCOldKey = 0;
 288   1              
 289   1      } 
 290          //===========================================================================================
 291          void User_initialize(void)
 292          {
 293   1              L2_ConfigureIO();//set GPIO     input or output
 294   1              User_Set_P3Mode(0x3D);
 295   1      
 296   1              POWER_CTRL_HIGH;//open  power control
 297   1              
 298   1              //用户保留块大小定义,最大不能超过8MB,以扇区为单位
 299   1              gdw_UserRsvSectorNum = 32L * 55;//user reserve sector number
 300   1              USER_Set_SYSInformation(SYSI_CREATE_DATE,0x0021);//create file date
 301   1              USER_Set_SYSInformation(SYSI_CREATE_TIME,0x0021);//create file time
 302   1      }
C51 COMPILER V8.05a   USERINIT                                                             07/11/2007 20:43:06 PAGE 6   

 303          //===========================================================================================
 304          //================================================================================================
 305          void User_initialize4_UI(void)
 306          {
 307   1      
 308   1          gb_LowBatt_State=0; //how to change it? change it in void LCD501_Disp_Battery()
 309   1          gc_EVENT=0;
 310   1          gc_SPressingKey = 0;
 311   1              gc_SKeyState = 0;
 312   1              ADCOldKey1 = 0;
 313   1              gc_SKeyHoldCnt = 0;
 314   1      
 315   1          gc_Busy_Timer=0;
 316   1          gc_AB_Cnt=0;
 317   1          gb_PlayPause=FALSE;//signal of pause
 318   1          gb_Storage_Full=0;//
 319   1              gb_UIPostError=0;
 320   1      
 321   1          gc_fileend=TRUE;       //...
 322   1      
 323   1              G_Current_Contrast = 2;//...
 324   1          G_W_OldTime=0;
 325   1          G_DISPLAY_TotalSec=0;
 326   1          gc_Menu_State = 0;
 327   1          gc_MenuHZK=0;
 328   1         
 329   1          gb_UIEvent=FALSE;
 330   1              gc_sts=9;
 331   1          gc_USR_PowerOffCount = 1;//lyh add
 332   1          gw_PowerOffTimer=1440;
 333   1          gc_Battery_Detect_Timer=0;
 334   1          gc_Battery_Level=5;//how to ....
 335   1      
 336   1          gc_DVRE_Mode_Selected=0;
 337   1              gc_PlaySequenceMode = REP_ALL_MODE;     
 338   1          gc_USB_Connect=0;
 339   1          gb_USB_PowerPlug_Interrupt=0;
 340   1          gb_LrcGetTimeOrNot=0;       
 341   1          gc_PlayMode=0;//lyh add 
 342   1          
 343   1      
 344   1          gw_DispFileName_ByteOffset=0;
 345   1          gb_DisplayEvent_Happened=1;
 346   1              
 347   1          gw_PowerOffTimer=1440;
 348   1              
 349   1      }
 350          //===========================================================================================
 351          //================================================================================================
 352          void L2_ConfigureIO(void)
 353          {       
 354   1              U8 tc_P3Value;
 355   1      
 356   1              User_Set_P1Mode(0xFF);
 357   1          P1 &=0x1F;
 358   1      
 359   1              User_Set_P3Mode(0x30);  
 360   1      //    P3 &=0xC7; 
 361   1              //SPCA759
 362   1              User_Set_MuxPinFunc(IOREG_MUX_PIN_VALUE);
 363   1              User_Set_GPIOMode(IOREG_GPIOOE_6_0_VALUE);
 364   1              User_Set_P1Mode(IOREG_P1OESEL_VALUE);   
C51 COMPILER V8.05a   USERINIT                                                             07/11/2007 20:43:06 PAGE 7   

 365   1              User_Set_P3Mode(IOREG_P3OESEL_VALUE);
 366   1              tc_P3Value = User_Read_P3Mode();
 367   1              tc_P3Value|= 0x02;
 368   1              User_Set_P3Mode(tc_P3Value);    
 369   1      }
 370          //-------------------------------------------------------------------------------
 371          //建议该函数只在开机和关机时使用,开机读取日志文件,关机保存日志文件,不要在其余位置调用
 372          //-------------------------------------------------------------------------------
 373          U8 USER_LogFile_ReadWrite(bit tbt_ReadOrWrite)
 374          {//建议该函数只在开机和关机时使用,开机读取日志文件,关机保存日志文件,不要在其余位置调用
 375   1       //开机读取日志文件应该在文件检索之前   
 376   1              U8 tc_Status;
 377   1              U8 tc_CheckSum = 0;
 378   1              U8 tc_Loop;
 379   1              bit tbt_SaveFlag;//lijh 050627 add
 380   1      
 381   1              tbt_SaveFlag = gbt_FindFlag;//lijh 050627 add
 382   1              gbt_FindFlag = 0;
 383   1      
 384   1              if ((gdw_USER_DirClus[0] != 0) && (gc_DOS_ErrorStatus == 0))
 385   1              {//DVR dir is exist
 386   2              //      Libprintf("find DVR\n");
 387   2                      gs_File_FCB[2].dw_FDB_StartCluster = gdw_USER_DirClus[0];
 388   2              }
 389   1              else
 390   1              {//DVR dir is no exist and not to create log file
 391   2              //      Libprintf("no find DVR\n");
 392   2                      X_Get_DefaultUserValue();
 393   2                      return 1;
 394   2              }
 395   1      
 396   1              EXT_NameC[0]=1;
 397   1              EXT_NameC[1]='L';
 398   1              EXT_NameC[2]='O';
 399   1          EXT_NameC[3]='G';
 400   1              //search user log file in specify dir
 401   1              tc_Status = DOS_Search_File(0x13,2,0x10);
 402   1              gbt_FindFlag = tbt_SaveFlag;
 403   1              //Libprintf("tc_sts=%bx\n",tc_Status);
 404   1              if (tc_Status == 0x00)
 405   1              {//find log file                
 406   2                      DOS_Open_File(2, 2, 0);//open log file,and get the startcluster
 407   2                      DOS_Read_File(2);
 408   2                      DOS_Close_File(2,0,0);
 409   2                      
 410   2                      //detect log file flag
 411   2                      if (gc_PlayRecordDataBuf[510] == 0x55 && gc_PlayRecordDataBuf[511] == 0xaa) 
 412   2                      {//"55aa"flag is exist
 413   3                              
 414   3                              if (tbt_ReadOrWrite)
 415   3                              {//save(modify) log file
 416   4                                      
 417   4                                      USER_FillSettingInfo();//fill gc_PlayRecordDataBuf[]
 418   4                                      
 419   4                                      //get the checksum of the first 10 byte
 420   4                                      for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
 421   4                                              tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];
 422   4                                      
 423   4                                      gc_PlayRecordDataBuf[500] = tc_CheckSum;
 424   4                                      DOS_Open_File(2, 2, 0);//open log file,and get the startcluster
 425   4                                      DOS_Write_File(2);
 426   4                                      DOS_Close_File(2,0,0);
C51 COMPILER V8.05a   USERINIT                                                             07/11/2007 20:43:06 PAGE 8   

 427   4                              }
 428   3                              else
 429   3                              {//read log file
 430   4                                      
 431   4                                      //get the checksum of the first 10 byte
 432   4                                      for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
 433   4                                              tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];
 434   4      
 435   4                                      //detect the check sum
 436   4                                      if (tc_CheckSum == gc_PlayRecordDataBuf[500])
 437   4                                      {//checksum is ok, get the setting info
 438   5                                              
 439   5                                              USER_GetSettingInfo();
 440   5                                      }
 441   4                                      else
 442   4                                      {
 443   5                                              X_Get_DefaultUserValue();//get default value
 444   5                                      }
 445   4                              }
 446   3                      }
 447   2                      else
 448   2                      {//have no "55aa"flag,is not real log file 
 449   3      
 450   3                              if (tbt_ReadOrWrite)
 451   3                              {//
 452   4                                      USER_FillSettingInfo();                 
 453   4                                      
 454   4                                      //get the checksum of the first 10 byte
 455   4                                      for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
 456   4                                              tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];
 457   4      
 458   4                                      gc_PlayRecordDataBuf[500] = tc_CheckSum;//write checksum byte
 459   4                                      gc_PlayRecordDataBuf[510] = 0x55;//mark "0x55"
 460   4                                      gc_PlayRecordDataBuf[511] = 0xaa;//mark "0xaa"
 461   4                                      
 462   4                                      DOS_Open_File(2, 2, 0);//open log file,and get the startcluster
 463   4                                      DOS_Write_File(2);
 464   4                                      DOS_Close_File(2,0,0);
 465   4                              }
 466   3                              else
 467   3                              {
 468   4                                      X_Get_DefaultUserValue();//get default value
 469   4                              }       
 470   3                      }
 471   2              }
 472   1              else if (tbt_ReadOrWrite)
 473   1              {//when write mode ,no find log file,create log file
 474   2                      
 475   2              //ceate log file in Root Dir
 476   2                      if (DOS_Open_File(2,1,0))
 477   2                      {//disk is full
 478   3                              gc_DOS_ErrorStatus = DOS_ERROR_DISK_FULL;
 479   3                              return 1;               
 480   3                      }
 481   2                      USER_FillSettingInfo();//fill gc_PlayRecordDataBuf[]
 482   2                      
 483   2                      //get the checksum of the first 10 byte
 484   2                      for (tc_Loop = 0; tc_Loop < USER_SETTING_CHECKSUM_LENTH; tc_Loop ++)
 485   2                              tc_CheckSum += gc_PlayRecordDataBuf[tc_Loop];
 486   2                      
 487   2                      gc_PlayRecordDataBuf[500] = tc_CheckSum;//write checksum byte
 488   2                      gc_PlayRecordDataBuf[510] = 0x55;//mark "0x55"
C51 COMPILER V8.05a   USERINIT                                                             07/11/2007 20:43:06 PAGE 9   

 489   2                      gc_PlayRecordDataBuf[511] = 0xaa;//mark "0xaa"
 490   2      
 491   2                      DOS_Write_File(2);//create log file
 492   2                      DOS_Close_File(2,1,LogFileName);
 493   2              }
 494   1              else
 495   1                      X_Get_DefaultUserValue();//get default value
 496   1                                      
 497   1              return 0;       
 498   1      }
 499          


MODULE INFORMATION:   STATIC OVERLAYABLE
   CODE SIZE        =    924    ----
   CONSTANT SIZE    =    170    ----
   XDATA SIZE       =     13       4
   PDATA SIZE       =   ----    ----
   DATA SIZE        =      2    ----
   IDATA SIZE       =   ----    ----
   BIT SIZE         =   ----       2
END OF MODULE INFORMATION.


C51 COMPILATION COMPLETE.  0 WARNING(S),  0 ERROR(S)

⌨️ 快捷键说明

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