ALI M5661 Firmware Programming Guide
ALI M5661 Firmware Programming Guide
www.ali.com.tw
This document contains confidential proprietary information that is solely for authorized personnel. It is not to be disclosed to any unauthorized person without prior written consent of ALi Corporation.
ALi Corporation
ALi Corporation makes no representations or warranties with respect to the accuracy or completeness of the contents of this document. No license, whether express, implied, arising by estoppel or otherwise, to any intellectual property right is granted by this document.
ALi Corporation also reserves the right to make changes to these specifications and product description at any time without notice. Contact your local sales office to obtain the latest specifications before placing your order.
Third-party brands and name mentioned in this publication are for identification purpose only and may be the property of their respective owners.
www.ali.com.tw
Version History
Date 12/15/2004 8/15/2005 10/22/2005 10/22/2005 Version 1.0 1.1 1.2 1.3 Description First release Update functions Update functions and append OLED and Classification functions Append the OledString function.
www.ali.com.tw
CONTENTS Copyright ALi Corporation, 2004. All rights reserved ............................ 2 Version History................................................................................................. 3 1 2 Firmware Architecture ............................................................................. 6 Programming Guide ................................................................................. 7
2.1 2.2 2.3 2.4 2.5 2.6 2.7 2.8 2.9 2.10 2.11 2.12 2.13 2.14 2.15 2.16 2.17 2.18 2.19 2.20 2.21 2.22 2.23 2.24 2.25 2.26 2.27 2.28 2.29 2.30 FILE SYSTEM (FILESYSTEM.C) ........................................................................... 7 NAND FLASH (NANDFLASH.C)......................................................................... 18 SD (SD.C)........................................................................................................ 27 PLAYBACK (PLAYBACK.C) ............................................................................... 32 RECORD (RECORD.C) ....................................................................................... 36 IMAADPCM (IMAADPCM.C) ............................................................................. 39 KEY (KEY.C) .................................................................................................... 42 FM (FMCHIP.C)................................................................................................ 44 BASE64 (BASE64.C)......................................................................................... 47 LCD (LCD.C) ................................................................................................... 48 OLED (OLED.C)................................................................................................ 69 OLEDSTRING (OLEDSTRING.C) ........................................................................ 86 IDMA (IDMA.C)............................................................................................... 92 USB (USB.C) ................................................................................................. 102 USBHOST (USBHOST.C) ............................................................................... 105 USB HOST COMMON (USBHOSTCOMMON.C)............................................... 109 USB HOST FAT (USBHOSTFAT.C)...................................................................111 ATA (ATA.C) .................................................................................................. 125 COMMON (COMMON.C).................................................................................. 126 DDM (DDM.C) ............................................................................................. 139 DRM (DRM.C) ................................................................................................ 140 INTCODEC (INTCODEC.C) .............................................................................. 144 EXTCODEC (EXTCODEC.C) ............................................................................ 148 MTP (MTP.C) .................................................................................................. 149 SAVESETTING (SAVESETTING.C) .................................................................... 153 UI COMMON (UICOMMON.C)......................................................................... 154 UI PLAY (UIPLAY.C)....................................................................................... 170 UI PLAY DVR (UIPLAY.C) ............................................................................. 181 UI RECORD (UIREC.C)................................................................................... 184 UI FM (UIFM.C) ........................................................................................... 189 4
www.ali.com.tw
M5661 Firmware Programming Guide 2.31 2.32 2.33 2.34 2.35 2.36 2.37 2.38 UI SYSTEM (UISYS.C).................................................................................... 196 UI FILE LIST (UIFILELIST.C).......................................................................... 202 UI PLAY COMMON (UIPLAYCOMMON.C)....................................................... 203 UI PLAY MENU (UIPLAYMENU.C) ................................................................. 209 UI PLAY MENU2 (UIPLAYMENU2.C) ............................................................. 211 UI USB DEVICE (UIUSBDEVICE.C) ................................................................ 213 UI USB HOST (UIUSBHOST.C) ....................................................................... 214 UI CLASS LIST (UICLASSLIST.C) ................................................................... 216
www.ali.com.tw
User Interface
DDM
Initial
LCD
Key
USB
Playback
DVR
Record
FM
System
ATA
File System
Nand Flash
SD
www.ali.com.tw
M5661 Firmware Programming Guide 2 Programming Guide 2.1 File System (FileSystem.c) 2.1.1 API Functions
FsInit( )
Check MBR, FAT version, PBR. Make sure that bytes per sector is 512. bit FsInit(void) Parameters None Return values bit type TRUE: file system initialed OK. FALSE: file system initialed FAILED. Global variable XBYTE gxbErrCode If FsInit( ) fail, gxbErrCode will be set as ERR_FS_INIT_ERROR; BOOL gfKeptDataModified XDWORD gxdwKeptDataSec Example
FsRead()
This function would read the data from NAND FLASH and you can get it from global array gxbFsData. bit FsRead(DWORD dwStorLba, BYTE bStorLen, BYTE bStorPath) Parameters DWORD dwStorLba NAND FLASH start sector you want to read. BYTE bStorLen Data length in sector you want to read. BYTE bStorPath There are several Storage Path FS_DATA_0_0, FS_FAT and FS_LRC that you can use. The data you read from the NAND FLASH would be stored in the selected
www.ali.com.tw
There is one other important note that getting data from the global array must have offset index by using the global variable gxwOffsetDataSec. This global variable would be stored with proper value after executing this function. XBYTE gxbStorType STOR_NAND: To read data from Nand Flash. STOR_SD: To read data from SD card. Return values Bit type TRUE: Success. FALSE: Fail or read I/O error. Example For below example is to read the data at the 5s sector with 1 sector length in Nand Flash. The data would be stored in the Storage Path FS_DATA_0_0. FsRead(5,1,FS_DATA_0_0); To get the fourth data byte. BYTE a=gxbFsData[3+gxwOffsetDataSec];
See also
FsWrite()
This function can write data to NAND FLASH. bit FsWrite(DWORD dwStorLba, BYTE bStorLen, BYTE bStorPath) Parameters DWORD dwStorLba
www.ali.com.tw
See also
FsFindDir()
To finds a directory. bit FsFindDir(PBYTE pbDirName, BOOL fCreate) Parameters PBYTE pbDirName Directory name you want to find. BOOL fCreate TRUE: The function would create this directory if cant find the directory. FALSE: The function wouldnt create this directory if cant find the directory. Return values Bit type TRUE: Success. FALSE: Cant find (create) directory, or i/o read error. Global variable XBYTE gxbStorType STOR_NAND: To read data from Nand Flash STOR_SD: To read data from SD card IBYTE gbStorPath: The data path you want to read, this value of argument you can take on is following, FS_DATA_0_0, FS_FAT, FS_FAT1_EXT2, FS_LRC and FS_FAT1_EXT1. For more description, you can refer the function of FsRead().
www.ali.com.tw
See also
FsFullFormat()
This function would be a full format to reconstruct PBR and erase all the space of flash. bit FsFullFormat(void) Parameters None Global arguments: XBYTE gxbStorType STOR_NAND: To read data from Nand Flash STOR_SD: To read data from SD card IBYTE gbStorPath: The data path you want to read, this value of argument you can take on is following, FS_DATA_0_0, FS_FAT, FS_FAT1_EXT2, FS_LRC and FS_FAT1_EXT1. For more description, you can refer the function of FsRead(). Return values Bit type TRUE: format successfully. FALSE: format fail or I/O error. Example
See also
FsQuickFormat()
This function is not a low level format that is different from fsFullFormat(). What it does is keeping MBR and PMR, and clearing occupied cluster# at FAT and root. bit FsQuickFormat(void) Parameters None
www.ali.com.tw
10
See also
FsOpenNewFile()
Open a new file. bit FsOpenNewFile(BYTE bDirIndex, bit fFindEmptyClu) Parameters BYTE bDirIndex, The Index of Directory where the Rec file would be stored. The range of this parameter is from 0 to REC_DIR_NUM defined in const.h. bit fFindEmptyClu TRUE: Find Empty cluster for record. FALSE: It would not to find empty cluster. Global Variable XBYTE gxbFileName: gxbFileName[0]~gxbFileName[REC_PREFIX_LEN] need to assign proper value before using this function. Return values Bit type Return TRUE if write data success, or else. Example
See also
www.ali.com.tw
11
Return values Bit type TRUE: file open successfully. FALSE: cant find file or I/O read error. Example
www.ali.com.tw
12
FsCloseFile()
Close the current file. bit FsCloseFile(BYTE bDirIndex) Parameters BYTE bDirIndex, The parameter of index is determined by what directory you want to close at. The range of this parameter is from 0 to REC_DIR_NUM defined in const.h. Return values Bit type TRUE: file open successfully. FALSE: cant find file or I/O read error. Global Variable
Example
See also
FsDeleteFile()
Delete a current exist file. It would also clear the occupied cluster# at FAT. After deletion of the file, the file pointer would point to the previous file. bit FsDeleteFile(void) Parameters None Return values Bit type TRUE: delete file successfully FALSE: cant delete file or i/o read error Global variable XBYTE gxbStorTyp The storage which you want to read from. IBYTE gbStorPath The data path you want to read, this value of argument you can take on is as follows.
www.ali.com.tw
13
See also
FsReadFileSector()
Read the data from a file with the size of a sector. bit FsReadFileSector(DWORD dwSector, BOOL fLrcfile , BYTE bSrampath) Parameters DWORD dwSector Sector Number based on a file. BOOL fLrcfile This parameter is determined by which file would be read. The file type has defined constant value of READ_LYRICS_SECTOR and READ_PLAYBACK_SECTOR that you can assign. READ_LYRICS_SECTOR: Current playback file. READ_PLAYBACK_SECTOR: Lyrics file. BYTE bSrampath The parameter indicates where the data would be store in. It is the same as the parameter IBYTE gbStorPath in the function of fsRead(). For the detail, you can refer to this function. Return values Bit type TRUE: FALSE: Global variable FILE_INF_DATA gpstFileIndex Which file structure be used XBYTE gxbStorType STOR_NAND: To read data from Nand Flash STOR_SD: To read data from SD card IBYTE gbStorPath
www.ali.com.tw
14
See also
FsChangeDir()
Change system directory. BOOL FsChangeDir(BYTE bChangeType) Parameters BYTE bChagneType The type of Directory you want to change. Directory Type are defined as following constant value, ENTER_DIR, BACK_DIR, RESTORE_DIR. Return values Bit type TURE: Success. FALSE: Fail. Global variable
Example
See also
FsWriteFileSector()
Get an empty sector for the sake of writing file data to this sector. bit FsWriteFileSector(DWORD dwSector) Parameters DWORD dwSector Return values Bit type TURE: Success. FALSE: Fail. Global variable
www.ali.com.tw
15
See also
FsWriteFileHeader()
Write WAVE File Header. bit FsWriteFileHeader(void) Parameters None Return values Bit type TURE: Success. FALSE: Fail. Global variable
Example
See also
2.1.2 FsWrite( )
SYS Functions
Write data from SRAM to NAND flash with low-level function. bit FsWrite(DWORD dwStorLba, BYTE bStorLen, BYTE bStorPath) Parameters DWORD dwStorLba Specifies the logical block address (LBA) to put data. BYTE bStorLen Specifies the number of sector to write. BYTE bStorPath Specifies the index of SRAM buffer with data. Return values Bit type Example The following example use FsWrite( ) to close a FAT32 file. FatWrite(gxdwFileCurrentClu, FAT32_EOC_TAG); dwCurrentWriteSec=gxdwFat1+((gxdwFileCurrentClu * gxbFatType)>>12); if(gxdwFileCurrentClu%1024==682) dwCurrentWriteSec+=1;
www.ali.com.tw
16
www.ali.com.tw
17
M5661 Firmware Programming Guide 2.2 Nand Flash (NandFlash.c) 2.2.1 API Functions
NandInit()
Initialization Nand Flash. Divide into 3 Parts: NandInitPre: Variable and Register Init, Identify Nand Type. NandDefaultSetting1: Get and set Configure. NandDefaultSetting2: Build LUT. API bit NandInit(void) Parameters None Return values Bit type TRUE: FALSE: Global variables
Example
See also
NandWrite()
Write function to Nand flash. bit NandWrite(void) Parameters None Return values Bit type TRUE: FALSE: Global variables
Example
www.ali.com.tw
18
NandRead()
Read function from Nand flash. bit NandRead(void) Parameters None Return values Bit type TRUE: FALSE: Global variables gbSpecialRW: gdwStorLba: gbStorTransLen: gbStorPath: Example The sector number that will be read. Number of sectors will be read. The assigned area that data will be read to.
See also
NandFinishJob()
bit NandFinishJob(void) Parameters None Return values Bit type TRUE: FALSE: Global variables
Example
See also
www.ali.com.tw
19
Example
See also
NandEraseBlock()
Erase one block. void NandEraseBlock(WORD wLogBlk) Parameters WORD wLogBlk Return values None Global variables
Example
See also
NandInitPre()
. void NandInitPre(void) Parameters None Return values None
www.ali.com.tw
20
Example
See also
NandReadCapa()
Handle UFI command. void NandReadCapa(void) Parameters None Return values None Global variables
Example
See also
PhyAccessNand_pm()
bit PhyAccessNand_pm(BYTE bType) Parameters BYTE bType Return values Bit type TRUE: FALSE: Global variables
Example
See also
www.ali.com.tw
21
bit PhyBlockEraseAll(BYTE blevel) Parameters BYTE blevel Return values Bit type TRUE: FALSE: Global variables
Example
See also
ReadBadBlock ()
Physical Write Configure Data from HOST -> SRAM -> gwConfigBlock LBA 0~3: 0xD000 LBA 4~7: 0xD800 .... LBA 28~31: 0xD800 => BadBlockInfo => => Config BadBlockInfo
Example
See also
ReadBadBlock()
Special ATAPI command: send bad block info to host. void ReadBadBlock(BYTE bType)
www.ali.com.tw
22
Example
See also
ReadDevice()
Example
See also
ReadSecurity()
Password locates in Configure Block 0, Lab 8. Every set contains 32-byte. bit ReadSecurity(BYTE n) Parameters BYTE n Return values Bit type TRUE: FALSE: Global variables
www.ali.com.tw
23
See also
UsbAccessDataSram()
Write data from USB to SRAM, or Read from SRAM to USB bit UsbAccessDataSram(WORD wRaAddr, WORD wLen, bit fWrite) Parameters wRaAddr: wLen: fWrite: DATA SRAM address. transfer len (unit is BYTE). TRUE FALSE Return values Bit type TRUE: FALSE: Global variables => => WRITE READ
Example
See also
WriteSecurity()
Password locates in Configure Block 0, Lab 8. Every set contains 32-byte. bit WriteSecurity(BYTE n) Parameters BYTE n Return values Bit type TRUE: FALSE: Global variables
www.ali.com.tw
24
See also
EraseNandBlock()
Erase block sequential. bit EraseNandBlock(WORD wStartBlk, BYTE bBlkLen) Parameters wStartBlk: Physical Block Address. bBlkLen: Len.
Return values Bit type TRUE: always TRUE. FALSE: Global variables
Example
See also
GetIniDefectBlock()
Example
See also
www.ali.com.tw
25
Example
See also
2.2.2
SYS Functions
www.ali.com.tw
26
SD_Init_400K()
SD Initialization. bit SD_Init_400K(void) Parameters None Return values Bit type TRUE: FALSE: SD/MMC card was initialized successfully. SD/MMC card was not initialized successfully. (Include SD/MMC was not inserted) Global variables gfSDinit: gxbSd_cmd: gfMediumChange: Indicate that SD/MMC card had been initialized. The divisor to control the SD/MMC Clock (<400KHZ). Indicate that FW need to let Host know medium change. (Since SD insert and init OK). Example
See also
SD_Read()
Read data from SD. (data target: SRAM). bit SD_Read(void) Parameters None Return values Bit type TRUE: FALSE: All data transfer was completed. Error occurs.
Global variables gbStorTransLen: gbStorPath: gdwStorLba: The number of blocks to be transfer. The address of Target (in SRAM). The LBA of Source (in SD/MMC Card).
www.ali.com.tw
27
See also
SD_Write()
Write data to SD. (data source: SRAM). bit SD_Write(void) Parameters None Return values Bit type TRUE: FALSE: All data transfer was completed. Error occurs.
Global variables gbStorTransLen: gbStorPath: gdwStorLba: gxbSD_Error: gxbSDCardType: gfR1Err: Example The number of blocks to be transfer. The address of Target (in SRAM). The LBA of Source (in SD/MMC Card). Error code. SD_MODE(SD),MMC_MODE(MMC). TRUE,R1 report error.
See also
SD_Det()
Check whether SD/MMC card is inserted or not. bit SD_Det(void) Parameters None Return values Bit type TRUE SD/MMC card was installed.
www.ali.com.tw
28
Example
See also
CardDetach()
Detach SD/MMC card. void CardDetach(void) Parameters None Return values None Global variables
Example
See also
SDModeSense6Data()
ATAPI Function. (Send 8 bytes data to PC, including card's write-protected information.) When accepted Modesense6 CMD (opcode=0x1A). void SDModeSense6Data(void) Parameters None Return values None Global variables gxbSDCardType: gfSDWP: Example SD_MODE(SD),MMC_MODE(MMC). TRUE, the SD/MMC card is write-protected.
See also
www.ali.com.tw
29
See also
SD_USBRead()
Read data from SD. (data Target: USB ) bit SD_USBRead(void) Parameters None Return values Bit type TRUE: FALSE: All data was transfer to USB. Error occurs.
Global variables gdwCBWDataTransferLength: gxdwLBA_address: gxdwSD_Blocknum: gxwSD_SecCnt: The number of bytes to be transfer. The LBA of Source (in SD/MMC Card).
The number of blocks in SD/MMC Card. Anytime the number of Blocks to be transferred ,when SD_USBRead() is called.
gxbSDCardType: gfSplitCommand:
gfR1Err: gxbSD_Error:
TRUE,R1 report error. Error code(the most significant nibble: SD CMD, the
www.ali.com.tw
30
See also
SD_USBWrite()
Write data from SD. (data Target: USB) bit SD_USBWrite(void) Parameters None Return values Bit type TRUE: FALSE: All data was transfer to USB. Error occurs.
Global variables gdwCBWDataTransferLength: gxdwLBA_address: gxdwSD_Blocknum: gxwSD_SecCnt: The number of bytes to be transfer. The LBA of Source (in SD/MMC Card).
The number of blocks in SD/MMC Card. Anytime the number of Blocks to be transferred ,when SD_USBRead() is called.
gxbSDCardType: gfSplitCommand:
gfR1Err: gxbSD_Error:
TRUE,R1 report error. Error code(the most significant nibble: SD CMD, the least significant nibble: error condition).
Example
See also
2.3.2
SYS Functions
www.ali.com.tw
31
M5661 Firmware Programming Guide 2.4 Playback (Playback.c) 2.4.1 API Functions
DetermineDspClock()
Because DSP clock is determined by user setting, for example music type and so on, a function is created to handle it (according to global variable setting). void DetermineDspClock() Parameters None Return values None Global variables
Example
See also
PeFillDspBuf()
Try to fill DSP buffer. void PeFillDspBuf(void) Parameters None Return values None Global variables
Example
See also
PeInit( )
Playback initialization. This function initializes play engine. Call this function when player program starts. bit PeInit(void)
www.ali.com.tw
32
PlayEngine( ) PeReptAdjust()
. WORD PeReptAdjust(void) Parameters None Return values WORD type Global variables
Example
See also
PeSetPlaybackRate()
. void PeSetPlaybackRate(BYTE bRate) Parameters BYTE bRate Return values None Global variables
Example
www.ali.com.tw
33
PeStart ( )
Start playback. bit PeStart(void) Parameters None Return values Bit type Global variables
Example
See also
PlayEngine( )
This function executes play command. bit PlayEngine(BYTE bCommand) Parameters BYTE bCommand Specify which command to execute. Commands could be following values: P_PLAYBACK Use this command to start playing back, or return from pause to playback mode. P_PAUSE Use this command to pause current playing job. P_PREV Use this command to switch to previous MP3 file for playing. P_NEXT Use this command to switch to next MP3 file for playing. P_FIRST Use this command to switch to first MP3 file for playing. P_LAST Use this command to switch to last MP3 file for playing. P_STOP
www.ali.com.tw
34
See also
2.4.2
SYS Functions
www.ali.com.tw
35
M5661 Firmware Programming Guide 2.5 Record (Record.c) 2.5.1 API Functions
ReInit( )
Initialize variables and settings for recording. Once the recording program is started, you should call this function to initialize the recording file pointer, recording settings and CODEC setting. bit ReInit(void) Parameters None Return values Bit type TRUE: Initialize successfully FALSE: Initialization failed Global variables Omitted. Example The following example shows how to start a recording task. if(ReInit()) { ReStart(); } See also ReStart( ) | ReEngine( )
ReStart( )
Start recording. This function will change system state to recording state. bit ReStart(void) Parameters None Return values Bit type TRUE: Start successfully. FALSE: Something error. Global variables Omitted. Example The following example shows how to start a recording task.
www.ali.com.tw
36
RecEngine( )
Perform recording functions. bit RecEngine(BYTE bCommand) Parameters BYTE bCommand Specify which action to be performed. The command could be: R_NOP (value = 0x00)
This command will drive recording engine to detect input buffer status, perform encoding, and write encoded stream into storing media. R_REC (value = 0x01)
This command brings system state from pause to recording. R_PAUSE (value = 0x02)
This command brings system state from recording to pause. R_STOP (value = 0x03)
This command will terminate current recording job and finish the file. then brings system state to stop. Commands that not listed above will be discarded by recording engine. Return values Bit type TRUE: No error occurs. FALSE: Something error occurs. Global variables Omitted. Example
FsRead()
Call storage read function. bit FsRead(DWORD dwStorLba, BYTE bStorLen, BYTE bStorPath)
www.ali.com.tw
37
See also
UpdateRecSaveInf()
Write recording recover information (Update file sector). void UpdateRecSaveInf(void) Parameters None Return values None Global variables
Example
See also
2.5.2
SYS Functions
www.ali.com.tw
38
M5661 Firmware Programming Guide 2.6 ImaAdpcm (ImaAdpcm.c) 2.6.1 API Functions
ImaAdpcmEncInit( )
Initial buffer read/write pointer, and ADPCM encode engines state for ADPCM encode. void ImaAdpcmEncInit( ) Parameters None Return values None Global variables XBYTE gxbFsData XBYTE gxwOffsetDataSec Example
See also
ImaAdpcmEncode( )
Use ADPCM to encode a sample. void ImaAdpcmEncode(INT wInputSample) Parameters INT wInputSample Return values None Global variable
Example The following code uses ImaAdpcmEncode( ) to encode a block of PCM data. for ( i =0; i <BUFFER_SIZE; i ++) { ImaAdpcmEncode( PcmBuffer[i] ); } See also ImaAdpcmDecode()
ImaAdpcmDecode( )
Use ADPCM to decode a sample.
www.ali.com.tw
39
Example
CdcPlayIsr( )
Get two samples (left-channel and a dummy) from ADPCM buffer and push to CODEC. void CdcPlayIsr(void) Parameters None Return values None Global variable
Example The following example shows how to consecutively play ADPCM data. void ExtInt0(void) interrupt 0 using 1 { if(bIntFlag & DAC_FIFO_EMPTY) { if(PCM_EMPTY) { ImaAdpcmDecode( ); } CdcPlayIsr( ); // put two samples to DAC FIFO } } See also CdcRecIsr()
CdcRecIsr( )
Get two samples (left-channel and a dummy) from CODEC FIFO, and store it into buffer. void CdcRecIsr(void) Parameters None
www.ali.com.tw
40
Example The following example use CdcRecIsr() to record data from ADC to buffer. void ExtInt0(void) interrupt 0 using 1 { if(bIntFlag & ADC_FIFO_FULL) { CdcRecIsr( ); // get two samples from ADC FIFO } } See also CdcPlayIsr()
2.6.2
SYS Functions
www.ali.com.tw
41
M5661 Firmware Programming Guide 2.7 Key (Key.c) 2.7.1 API Functions
KeyInit( )
Initials variables and GPIO settings of Keys. void KeyInit(void) Parameters None Return values None Global variables gbKeyRept: gxbKeyId: Key pressed repeat counter. Keep the key status until be read.
gxbKeyLastId: The key ID for next time use. gfKeyPressed: Key pressed status flag. Example
See also
KeyDetect( )
Detect key(s) status. Use 3*3 matrix to detect keys. Output: GPIO_B_2, GPIO_B_3, GPIO_B_4. Input: GPIO_B_5, GPIO_B_6, GPIO_B_7. void KeyDetect(void) Parameters None Return values None Global variables gbKeyRept: gxbKeyId: Key pressed repeat counter. Keep the key status until be read.
gxbKeyLastId: The key ID for next time use. gfKeyPressed: Key pressed status flag. Example
www.ali.com.tw
42
2.7.2
SYS Functions
www.ali.com.tw
43
FmCheckStereo()
Check Fm is stereo or mono. bit FmCheckStereo(void) Parameters None Return values Bit type TRUE: Stereo FALSE: Mono Global variables
Example
See also
FmDataInit()
Initials FM Module. void FmDataInit(void) Parameters None Return values None Global variables
Example
See also
FmInit() FmInit()
Initials FM Module. bit FmInit(void)
www.ali.com.tw
44
Example
FmEnd()
Stop FM Module, sets IC mute and standby. void FmEnd(void) Parameters None Return values None Global variables
Example
See also
FmSearch()
Search Up/Down from currently frequency. BOOL FmSearch(BOOL fSearchUp) Parameters BOOL fSearchUp Return values Bit type Global variables 1: Up 0: Down
Example
www.ali.com.tw
45
FmSetFreq()
Set FM IC's PLL by "gxwFmFreq". bit FmSetFreq(void) Parameters None Return values Bit type TRUE: Set Freq successful.
FALSE: Busy time out or error. Global variables gxwFmFreq : FM frequency based on 100KHz. Example
See also
FmSetMute()
Sets FM in mute mode, this function will set Frequency too. If want to cancel mute, just call FmSetFreq(). void FmSetMute(void) Parameters None Return values None Global variables gxwFmFreq : FM frequency based on 100KHz. Example
See also
2.8.2
SYS Functions
www.ali.com.tw
46
M5661 Firmware Programming Guide 2.9 Base64 (Base64.c) 2.9.1 API Functions
MS_Base64D()
WORD MS_Base64D(BYTE *psrc, BYTE *pdes, WORD wLen, BYTE bWchar) Parameters BYTE *psrc WORD wLen BYTE bWchar Return values WORD type Global variables
Example
See also
2.9.2
SYS Functions
www.ali.com.tw
47
LCD (Lcd.c)
Mnemonic Name LDC_CLK_CTRL LCD Clock Control Register MODE SELECT2 Mode Select Register2 GPIOC_DAT GPIOC_DIR LCDCTRL LCD Control Register LCD_PAR_RDDAT LCD Parallel Read Data Register LCD_WRDAT LCD Write Data Register Type R/W R/W R/W R/W R/W R/W R/W Default 00h 00h 00h 00h 00h 00h 00h
Reserved
CLKEN LCD Clock Enable 1: LCD Clock Enable. 0: LCD Clock Disable. CLKSEL 00: 01: 10: 11: LCD Clock Source Select Source Clock = 6Mhz Source Clock = 3 MHz Source Clock = 1.5 MHz Source Clock = 0.75Mhz
D5
N
D4
I2CS_EN
D3
I2CM_EN
D2
I2S1_PIN_S EL
D1
I2S2_EN
D0
I2S1_EN
Type R/W
Default 00h
Bit 7: FORCE_ROMCSJ Bit 6: LCD_SEREN This bit is used to enable serial LCD controller and switch function onto GPIOC[7:4]. 1: Serial LCD interface Enable. 0: Serial LCD interface Disable. Bit 5: LCD_PAREN This bit is used to enable parallel LCD controller and switch control/data signals to GPIOC[7:4]/GPIOF[7:0]. 1: Parallel LCD interface Enable. 0: Parallel LCD interface Disable. Bit 4: I2CS_EN 1: I2C Slave Enable. 0: I2C Slave Disable. Bit 3: I2CM_EN
www.ali.com.tw
48
Type R/W
Default 00h
GPIOC_DIR[7:0] GPIOC_DAT[7:0] GPIOC Out/In Data Register GPIOC out/in data port, If GPIOC_DIR[n]=1, the corresponding GPIOC_DAT[n] will show on XGPIOC[n] pin. If GPIOC_DIR[n]=0, reading GPIOC_DAT[n] will get the status on XGPIOC[n] pin. GPIOC_DIR[7:0] GPIOC Direction Register This register specifies the direction of XGPIOC pins. 1: Output 0: Input
D3 RD
Bit 3: RD LCD Parallel Read Signal This bit control GPIOC[7] when LCD_EN is enabling Bit 2: WR LCD Parallel Write Signal This bit control GPIOC[6] when LCD_EN is enabling Bit 1: A0 LCD Parallel A0 Signal This bit control GPIOC[5] when LCD_EN is enabling
www.ali.com.tw
49
LCD_PAR_RDDAT[7:0]
Bit 7-0: LCD_PAR_RDDAT LCD Parallel Read Data The register reflects GPIOF[7:0] status when LCD_EN is enabling.
LCD_WRDAT[7:0]
Bit 7-0: LCD_WRDAT LCD Parallel Mode Write Data In the parallel mode, MCU write this register to direct control LCD data signal GPIOF[7:0] In the serial mode, this register is used as LCD display data mapping port, whenever MCU write this register, LCD serial signals will be auto-generated on GPIOC[7:4]
LcdInit( )
LCD initialization: set register, power on LCD and clear LCD memory data. bit LcdInit(none) Parameters None Return values Bit type TRUE: LCD initialed successfully. FALSE: LCD initialed time out. Global variable
Example
See also
LcdCtrlEn( )
Switch share bus for LCD control.
www.ali.com.tw
50
Example
LcdCtrlDis( )
Switch share bus for Nand Flash control. Note: You should not call this function again when bus has shared for LCD. That would let system crashed. void LcdCtrlDis(void) Parameters None Return values None Global variable
Example
LcdSendCommand ( )
Send command to LCD. void LcdSendCommand(BYTE bCommandVal) Parameters BYTE bCommandVal Commands form DB7-DB0.
www.ali.com.tw
51
Example
See also
LcdWriteData( )
Write data to LCD. (show data) void LcdWriteData(BYTE bLcdData) Parameters BYTE bLcdData Display data. Return values None Global variable
Example
LcdReadData( )
Read data from LCD. Note: Before read data, you should read a dummy data first. BYTE LcdReadData (void) Parameters None Return values BYTE type LCD data Global variable
Example
www.ali.com.tw
52
LcdGoto( )
Set the LCD read/write position. void LcdGoto(BYTE bPage, BYTE bColumn) Parameters BYTE bPage Specifies the display page number. BYTE bColNum Specifies the display column number. Return values None Global variable
Example
LcdBackLightControl( )
Control LCD backlight on/off void LcdBackLightControl(BYTE bSwitch) Parameters BYTE bSwitch LCD_BACKLIGHT_ON: Back Light ON. LCD_BACKLIGHT_OFF: Back Light OFF. Return values None Global variable
Example
See also
www.ali.com.tw
53
Example
LcdClearBlock( )
Clean one block on LCD. void LcdClearBlock(BYTE bPage, BYTE bColNum, BYTE bHeight, BYTE bWidth) Parameters BYTE bPage Specifies the display page number. BYTE bColNum Specifies the display column number. BYTE bHeight Specifies the picture height. BYTE bWidth Specifies the picture width. Return values None Global variable
Example
LcdScrollText( )
Scroll data on LCD.
www.ali.com.tw
54
Example
See also
LcdCopyPage()
Copy a page data to another page. void LcdCopyPage(BYTE bPage1,BYTE bPage2) Parameters BYTE bPage1: BYTE bPage2: Return values None Example source page target page
See also
LcdReverse( )
Reverse a block on LCD. PS: If you want to reverse screen, just send LCD command "LCD_REVERSE_DISPLAY" void LcdReverse(BYTE bPage, BYTE bColNum, BYTE bHeight, BYTE bWidth)
www.ali.com.tw
55
Example
See also
LcdWritePic( )
Write serial data to LCD void LcdWritePic(PBYTE pbDataSource, BYTE bPage, BYTE bColNum, BYTE bHeight, BYTE bWidth) Parameters BYTE pbDataSource Point to binary data. BYTE bPage Specifies the display page number. BYTE bColNum Specifies the display column number. BYTE bHeight Specifies the picture hight. BYTE bWidth Specifies the picture width. Return values None Global variable BYTE gxbLcdLimitCol The limit column number of the right side. Any data over the limit column would be
www.ali.com.tw
56
Example
See also
LcdShowString( )
Show String on LCD. You should set the font size by LCD_SMALL_FONT_WIDTH and LCD_BIG_FONT_WIDTH BYTE LcdShowString(PBYTE pbShowStr, BYTE bPage, BYTE bColNum, BYTE bLen) Parameters BYTE pbShowStr Point to string array you want to show. BYTE bPage Specifies the display page number. BYTE bColNum Specifies the display column number. BYTE bLen Specifies the string length. Return values BYTE type: (Scroll function need that information). Next display string index (0 base and byte unit) EX. In standard SDK, if you want to show "ABCDE" in column 104, "ABC" will be shown, and "DE" will be skip (Over Lcd Screen). This function will return 3 (Point to D). If you show "ABCDE" in column 108, "AB" will be shown, Half of "C" will be shown, and "DE" will be skip. This function will return 2 (Point to C). If you show "ABCDE" in column 0, all string would be shown. This function will return 5 (Point over the string) Global variable BOOL gxfSourceUnicode: Specifies string type: STRING_TYPE_ASCII or STRING_TYPE_UNICODE Example The following example will show ABC string. gxfSourceUnicode=STRING_TYPE_ASCII BYTE bString[3]={A,B,C};
www.ali.com.tw
57
LcdShowSysString( )
Show system string on LCD. This function will read a string form Nand Flash and then show it. BYTE LcdShowSysString(WORD wStrNum, BYTE bPage, BYTE bColNum) Parameters BYTE wStrNum The system string code number. It should be defined in SysStrDef.h BYTE bPage Specifies the display page number. BYTE bColNum Specifies the display column number. Return values The length of system string (pixel) Global variable
Example
LcdShowSysFont( )
Show System font on LCD. void LcdShowSysFont(PBYTE pbFontCode, BYTE bPage, BYTE bColNum, BYTE bLen) Parameters BYTE pbFontCode Display font code. It show be defined in SysFontDef.h by the AP LCD Bitmap Convert. BYTE bPage Specifies the display page number. BYTE bColNum Specifies the display column number. BYTE bLen Specifies the string length.
www.ali.com.tw
58
Example
See also
LcdShowTitleNum( )
Show 6x16 number on LCD (Only number and decimal). This function use the same font with system font, but 6x16 pixels, and this function is faster. (It use CBYTE data, and not load Nand Flash) void LcdShowTitleNum(WORD wShowNum, BYTE bPage, BYTE bColNum, BYTE bLen) Parameters BYTE wShowNum Display number BYTE bPage Specifies the display page number. BYTE bColNum Specifies the display column number. BYTE bLen Display length. For short number, this function would add zero, for long number this function would cut number. EX: wShowNum=23, bLen=3 will show 023 wShowNum=128, bLen=2 will show 28 Return values None Global variable
Example
See also
LcdCenterColumn( )
Get the string display column if you want it show in the center. This function should
www.ali.com.tw
59
Example
LcdGetStrLen( )
Get string length (pixel). BYTE LcdGetStrLen(PBYTE pbString, BYTE bLen) Parameters BYTE pbString String buffer. BYTE bLen String Length (byte) Return values BYTE type: String Length (pixel) Global variable BOOL gxfSourceUnicode: Specifies string type: STRING_TYPE_ASCII or STRING_TYPE_UNICODE
Example
See also
www.ali.com.tw
60
Example The following example will show 5 pictures. for(bI=0;bI<5;bI++) { for(wDelayTime=0;wDelayTime<0xFFFF;wDelayTime++) { }; LcdShowAnimation(bI,2,0,4,128) } See also
LcdShowTagTitle( )
Start to show Tag Title on LCD. If Tag Title not exists, it would show file name. Note: You should call this function first, and then call LcdScrollTag() to scroll it void LcdShowTagTitle(void) Parameters None Return values None
www.ali.com.tw
61
Example
LcdScrollTag( )
Scroll Tag on LCD. You should call LcdShowTagTitle() first. void LcdScrollTag(void) Parameters None Return values None Global variable XBYTE gxbLcdTagStatus Set the tag state flag, see LcdShowTagTitle() function Example
www.ali.com.tw
62
LcdScrollLyric( )
Scroll Lyrics on LCD. Note: You should call LcdShowLyrics() first. If gxbMusicType&M_LYRICS_FLAG is False, you should not call this function void LcdScrollLyric (void) Parameters None Return values None Global variable XBYTE gxbLcdLyricStatus Set lyric state, see LcdShowLyrics() function. Example
www.ali.com.tw
63
LcdShowFileList()
Display a file name in file list. You should call this function before calling LcdScrollFileList(). void LcdShowFileList(PBYTE pbFileName, PBYTE pbLongFileName, BYTE bPage) Parameters PBYTE pbFileName: short filename buffer PBYTE pbLongFileName: Long filename buffer BYTE bPage: Specifies the display page number Return values None Global variable
Example
LcdScrollFileList()
Scroll long file name in file list.
www.ali.com.tw
64
Example
LcdShowClassList()
Display a file name in file list. You should call this function before calling LcdScrollFileList(). void LcdShowClassList(PBYTE pbClassName, BYTE bPage) Parameters PBYTE pbClassName: Display classification name array BYTE bPage Display LCD pafge Return values None Global variable
Example
LcdShowDirName()
Display dir-name. void LcdShowDirName(void)
www.ali.com.tw
65
Example
See also
LcdShowSpectrum( )
Show Spectrum (only left-right channel volume). void LcdShowSpectrum(BYTE bDispType) Parameters BYTE bDispType: The display type of spectrum Return values None Global variable
Example
See also
LcdShowInitLowPower()
Show Low Power in init module. void LcdShowInitLowPower(void) Parameters None Return values None Global variable
Example
www.ali.com.tw
66
LcdWaitBusy( )
Wait while LCD is busy bit LcdWaitBusy(void) Parameters None Return values Bit type TRUE: Not busy FALSE: Time out for waiting Example
BYTE_DELAY( )
Add command delay time void BYTE_DELAY(BYTE bDelay) Parameters BYTE bDelay Delay time.
www.ali.com.tw
67
See also
LcdTurnTag( )
Switch Tag on LCD (Title->Artist->Album) void LcdTurnTag(void) Parameters None Return values None Example
See also
LcdCopyShortFileName()
Copy short file name to gxbLcdShowFileName buffer. This function will cut down space character (ASCII32) and add a point . character before sub filename. void LcdCopyShortFileName(PBYTE pbFileName) large Parameters PBYTE pbFileName: Filename buffer Return values None Example
www.ali.com.tw
68
OledInit( )
Oled initialization: set register, power on LCD and clear LCD memory data. void OledInit(void) Parameters None Return values None Global variable
Example
See also
OledCtrlEn( )
Switch share bus for Oled control. Note: Before using OLED command,you must call OledCtrlEn(), and then call OledCtrlDis() after finish the sake of display. And another point, there are several Oled functions already accomolish this job. void LcdCtrlEn(void) Parameters None Return values None Global variable
Example
OledCtrlDis( )
Switch share bus for Nand Flash control.
www.ali.com.tw
69
Example
OLED_SET_CMD()
Set the operation mode in Command mode. Before read/write command to oled, call this macro to set the operation as command. OLED_SET_CMD() Parameters None Return values None Global variable
Example
OLED_SET_STS()
Before reading oled status, call this macro to set the operation as read status. OLED_SET_DAT() Parameters None Return values None Global variable
www.ali.com.tw
70
OLED_WRITE(bData)
Write command or data to OLED. Note: If the current operation mode is Command mode(OLED_SET_CMD()), this function writes command to OLED, else data. OLED_WRITE(bData) Parameters BYTE bData Write command or data to oled Return values None Global variable
Example OLED_SET_CMD() OLED_WRITE(cmd1) //write command cmd1 to oled OLED_WRITE(cmd2) //write command cmd2 to oled OLED_SET_DAT() OLED_WRITE(data1) //write command data1 to oled See also OLED_SET_DAT(),OLED_SET_STS(),OLED_WRITE(bData), OLED_READ(bData)
OLED_READ(bData)
Read status or data from OLED Note: Before reading data ,you must read a dummy data first. OLED_READ(bData) Parameters BYTE bData bData will be store data or status getting form OLED. Return values None Global variable
www.ali.com.tw
71
OledDisplayPowerOn( )
Power on or power off Oled. void OledDisplayPowerOn(BOOL fPowerOn) Parameters BOOL fPowerOn TRUE: Oled display power on FLASE: Oled display power off Return values None Global variable
Example
See also
OledSetContrast()
Set oled contrast. Void OledSetContrast(BYTE bContrast) Parameters BYTE bContrast It can be set in the range of 0~255 Return values None Global variable
Example
OledDisplayFade()
Display fade in or display fade out.
www.ali.com.tw
72
Example
See also
BACKLIGHT_ON()
Set current contrast according to global variable gxbLcdContrast. BACKLIGHT_ON() Parameters None Return values None Global variable GxbLcdContrast Current contrast value. Example
BACKLIGHT_OFF()
Set contrast 0 Note: This function just the macro of OledSetContrast(0) to simulate the backlight off for the sake of power save issue. BACKLIGHT_OFF()
www.ali.com.tw
73
OledClearArea()
Clear the rectangular area display. void OledClearArea(BYTE bColStart, BYTE bRowStart, BYTE bWidth, BYTE bHeight) Parameters BYTE bColStart Specifies the start column of rectangular area. BYTE bRowStart Specifies the start row of rectangular area. BYTE bWidth Specifies the width of rectangular area. BYTE bHeight Specifies the height of rectangular area. Return values None Global variable None Example None See also OLED_CLEAR_ALL();
OLED_CLEAR_ALL()
Clear all area of display window OLED_CLEAR_ALL()
www.ali.com.tw
74
Example
See also
OledCopyArea()
Copy rectangular area to another rectangular area. Note: Hardware acceleration command void OledCopyArea(BYTE bColStart, BYTE bRowStart, BYTE bWidth, BYTE bHeight, BYTE bColTarget, BYTE bRowTarget) ; Parameters BYTE bColStart Start column of the copied area. BYTE bRowStart Start row of the copied area. BYTE bWidth Width of the copied area. BYTE bHeight Height of the copied area. BYTE bColTarget Specifies start column of the target area. BYTE bRowTarget Specifies start row of the target area. Return values None Global variable None Example
See also
www.ali.com.tw
75
Example
See also
OledDrawPoint ()
Draw a pixel. Note: If OLED_USE_MASK_DISPLAY has been defined and gfIconMaskEn is true, draw point with mask will be enable. Details will be described as following parameter. Void OledDrawPoint(BYTE bCol,BYTE bRow,WORD wColor); Parameters BYTE bCol Column of point. BYTE bRow Row of point. WORD wColor Point color. Return values none Global variable BYTE gxbMaskLeft
www.ali.com.tw
76
See also
OledDrawLine ()
Draw a line. Note: Hardware acceleration command void OledDrawLine(BYTE bColStart, BYTE bRowStart, BYTE ColEnd, BYTE bRowEnd) Parameters BYTE bColStart Start point column of this line. BYTE bRowStart Start point row of this line. BYTE ColEnd End point column of this line. BYTE bRowEnd End point row of this line. Return values None Global variable WORD gxwFGColor Color of line Example
OledDrawRect ()
Draw rectangle with foreground color
www.ali.com.tw
77
Global variable WORD gxwBGColor Background color, determine the rectangle filled color. WORD gxwFGColor Foreground color, determine the line color) BOOL gfTransparent TRUE: draw a rectangle filled with background color. FALSE: draw a rectangle without filling background color. Example None See also OledDrawLine ();
OledDrawDirection()
Change the graphic sram increased direction. Note: Write data to oled, the graphyic sram will be auto increased address. And increased direction is column first in default. Call this function could change increased direction. void OledDrawDirection(BYTE bAccessDir) Parameters BYTE bAccessDir OLED_RAM_ACCESS_MODE_COLUMN_FIRST: Increased direction is column first. OLED_RAM_ACCESS_MODE_ROW_FIRST: Increased direction is row first. Return values None Global variable None Example None
www.ali.com.tw
78
OledShowIconFromSram ()
Get the Icon data from sram and send it to OLED. void OledShowIconFromSram(WORD wSramAdd,BYTE bColStart,BYTE bRowStart,BYTE bWidth,BYTE bHeight); Parameters WORD wSramAdd Start sram address of data BYTE bColStart BYTE bRowStart BYTE bWidth BYTE bHeight Above parameters determine a drawing rectangle area. Return values
Global variable BOOL gfIconMaskEn TURE: Calls the OledDrawPoint() to accomplish this function. So, it has the effect of Mask,but slowly; (refer to OledDrawPoint()). FALSE: Uses the DMA to copy data from SRAM to OLED. So it more faster and efficient. Note: On another important point, be sure that SRAM address must be in the range of 0xc000~0xe000(8K) if using the DMA access, and data size(bWidth*bHeight*2) can not large then 2k bytes in once calling. BYTE gxbMaskLeft BYTE GxbMaskRight BYTE GxbMaskTop BYTE GxbMaskBottom Above global variables are defined the mask window. BYTE gfMaskInside TRUE: mask inside FALSE: mask ouside Example
www.ali.com.tw
79
BYTE bColStart BYTE bRowStart BYTE bWidth BYTE bHeight The rectangular area you want to read. Return values None Global variable None Example None See also
OledDMASramToSM()
Send data from sram to smart media interface(Oled share this interface with nand flash) void OledDMASramToSM(WORD wDMASramAdd,WORD wDataSize); Parameters WORD wDMASramAdd Offset address of DMA start address. Note: DMA accessible sram is in the range of 0xc000~0xe000(8K), and this parameter is offset address of 0xc000. WORD wDataSize Send data size.
www.ali.com.tw
80
OledShowBitsIcon ( )
Display the 1bit bitmap icon to OLED. Note: This function often be used to display string. void OledShowBitsIcon(PBYTE pbDataSource,BYTE bColStart,BYTE bRowStart,BYTE bWidth,BYTE bPageHeight); Parameters PBYTE pbDataSource Pointer to bitmap data source BYTE bColStart BYTE bRowStart BYTE bWidth BYTE bPageHeight Above parameters specific a rectangular area be drawn. bPageHeight is in the unit of page(8 pixels) Return values None Global variable BOOL gfIconMaskEn TURE: Oled display mask will be enable if OLED_USE_MASK_DISPLAY defined and call the OledDrawPoint() to accomplish this function. So, it has the effect of Mask,but slowly; (refer to OledDrawPoint()). BYTE gxbMaskLeft BYTE GxbMaskRight BYTE GxbMaskTop BYTE GxbMaskBottom Above global variables are defined the mask window. BOOL gfTransparent TRUE: display the bitmap with background.
www.ali.com.tw
81
OledShowIcon( )
Display high color Icon to Oled. Note: Icon data file (099Icon_BGR_v11.bin) will be download to device storage, and you could get the Icon storing information from "IconDefine.h". This header file define icon start Address and Icon width and Height info. etc... "IconGenerator.exe". converts BMP
Icon and generates the icon binary file compatible with our device required format. About the details that how to use the application,please refer to IconGenerator document. void OledShowIcon(WORD wIconIndex,BYTE bColStart,BYTE bRowStart); Paramete WORD wIconIndex Icon offset bytes(address) at the binary file. (All define in BYTE bColStart BYTE bRowStart Icon will be displayed start column and start row. "IconData.h")
www.ali.com.tw
82
OledShowNumber ( )
Display digit number. void OledShowNumber(WORD wShowNum,BYTE bColStart,BYTE bRowStart,BYTE bNumLen); Paramete WORD wShowNum Value you want to display. BYTE bColStart BYTE bRowStart Display column and row
www.ali.com.tw
83
Example Display number of 321 WORD wNumber=321; OledShowNumber(wNumber,0,0,5); It will display as result of 00321 See also
ShowProgress()
Display progress bar ShowProgress(BYTE bColStart,BYTE bRowStart,BYTE bValue) Paramete BYTE bColStart, BYTE bRowStart, Progress bar start column and start row postion BYTE bValue Value of progress in the range of 0~72(PROGRESS_MAX) Return values None Global variable
Example
See also
ShowAnimation ()
Display the animation void ShowAnimation(WORD wOffsetIndex,BYTE bFrameNum,BYTE bColStart,BYTE bRowStart,WORD wDelayTime) Paramete WORD wOffsetIndex Animation offset address
www.ali.com.tw
84
Example
www.ali.com.tw
85
StrShowString()
Show String on LCD. You should set the font size by LCD_SMALL_FONT_WIDTH and LCD_BIG_FONT_WIDTH BYTE StrShowString(PBYTE pbShowStr,BYTE bColStart,BYTE bRowStart,BYTE bStrLen); Parameters BYTE pbShowStr Point to string array you want to show. BYTE bColStart Specifies the display column number. BYTE bRowStart Specifies the display row number. BYTE bStrLen Specifies the string length. Return values BYTE type: (Scroll function need that information). Next display string index (0 base and byte unit) EX. In standard SDK, if you want to show "ABCDE" in column 104, "ABC" will be shown, and "DE" will be skip (Over Lcd Screen). This function will return 3 (Point to D). If you show "ABCDE" in column 108, "AB" will be shown, Half of "C" will be shown, and "DE" will be skip. This function will return 2 (Point to C). If you show "ABCDE" in column 0, all string would be shown. This function will return 5 (Point over the string) Global variable BOOL gxfSourceUnicode: Specifies string type: STRING_TYPE_ASCII or STRING_TYPE_UNICODE Example The following example will show ABC string. gxfSourceUnicode=STRING_TYPE_ASCII BYTE bString[3]={A,B,C}; StrShowString(bString,0,0,3); See also LcdShowString(), StrShowSysString()
StrShowSysString()
Show system string on LCD. This function will read a string form Nand Flash and then show it.
www.ali.com.tw
86
Example
StrStrAnsiLen()
Get string length in pixel BYTE StrStrAnsiLen(PBYTE pbString,BYTE bLen) Parameters BYTE pbString String buffer. BYTE bLen String Length (byte) Return values BYTE type: String Length (pixel) Global variable BOOL gxfSourceUnicode: Specifies string type: STRING_TYPE_ASCII or STRING_TYPE_UNICODE
Example
www.ali.com.tw
87
LcdScrollTag()
Scroll Tag on LCD. You should call LcdShowTagTitle() first. void LcdScrollTag(void) Parameters None Return values None
www.ali.com.tw
88
LcdShowLyrics()
Show new Lyrics. Note: You should call this function first, and then call LcdScrollLyrics() to scroll it. void LcdShowLyrics(void) Parameters None Return values None Global variable XBYTE gxbLcdLyricStatus Set lyric state. bit 1: Lyric scroll done flag LCD_LYRIC_SCROLL_DONE: Lyric scroll done. LCD_LYRIC_SCROLLING: Lyric scrolling. Example
LcdScrollLyric()
Scroll Lyrics on LCD. Note: You should call LcdShowLyrics() first. If gxbMusicType&M_LYRICS_FLAG is False, you should not call this function void LcdScrollLyric (void) Parameters None
www.ali.com.tw
89
LcdSetLyricDone()
Sets Lyric state was done, when one line lyric display finish. void LcdSetLyricDone(void) Parameters None Return values None Global variable XBYTE gxbLcdLyricStatus Set lyric state done, see LcdShowLyrics() function. Example
LcdShowFileList()
Display a file name in file list. You should call this function before calling LcdScrollFileList(). void LcdShowFileList(PBYTE pbFileName, PBYTE pbLongFileName, BYTE bPage) Parameters PBYTE pbFileName: short filename buffer PBYTE pbLongFileName: Long filename buffer BYTE bPage: Specifies the display page number
www.ali.com.tw
90
Example
LcdScrollFileList()
Scroll long file name in file list. void LcdScrollFileList(PBYTE pbFileName, BYTE bPage) Parameters PBYTE pbFileName: display long file name array. BYTE bPage: display LCD page. Return values None Global variable
Example
LcdShowClassList()
Display a file name in file list. You should call this function before calling LcdScrollFileList(). void LcdShowClassList(PBYTE pbClassName, BYTE bPage) Parameters PBYTE pbClassName: Display classification name array BYTE bPage Display LCD pafge Return values None
www.ali.com.tw
91
Example
LcdShowDirName()
Display dir-name. void LcdShowDirName(void) Parameters None Return values None Global variable
Example
See also
2.13
IDMA (Idma.c)
IdmaPioPmW( )
Write date to DSP PM with IDMA PIO mode void IdmaPioPmW(void *pbSourceAddr, WORD wTargetAddr, WORD wLen) Parameters void *pbSourceAddr Source data address was in SRAM. WORD wTargetAddr Target data address in DSP-PM. WORD wLen Data Length. Its word unit, for example, if source data is 99 bytes, wLen=33. Return values None
www.ali.com.tw
92
IdmaPioPmR( )
Reads date from DSP PM with IDMA PIO mode. Note: This function will just read 24bits data. If you use a double-word variable to get the value, you should clear the 8bits over data yourself. void IdmaPioPmR(WORD wSourceAddr, void *pbTargetAddr, WORD wLen) Parameters WORD wSourceAddr Source data address was in DSP-PM. void *pbTargetAddr Target data address in SRAM. WORD wLen Data Length. Its word unit, for example, if target data is 99 bytes, wLen=33. Return values None Global variable
Example
IdmaPioDmyW( )
Write date to DSP DMY with IDMA PIO mode void IdmaPioDmyW(void *pbSourceAddr, WORD wTargetAddr, WORD wLen, BOOL fWidth24) Parameters void *pbSourceAddr Source data address was in SRAM. WORD wTargetAddr Target data address in DSP-DMY.
www.ali.com.tw
93
Example
IdmaPioDmyR( )
Read date from DSP DMY with IDMA PIO mode. Note: In DSP 24bits mode, this function will just read 24bits data. If you use a double-word variable to get the value, you should clear the 8bits over data yourself. void IdmaPioDmyR(WORD wSourceAddr, void *pbTargetAddr, WORD wLen, BOOL fWidth24) Parameters WORD wSourceAddr Source data address was in DSP-DMY. void *pbTargetAddr Target data address in SRAM. WORD wLen Data Length. Its word unit, for example, if source data is 96 bytes: 24bits source data: wLen=32. 16bits source data: wLen=48. BOOL fWidth24 TRUE: 24bits source data. FALSE: 16bits source data. Note: In DSP 16bits mode this arguments would be ignore. Return values None
www.ali.com.tw
94
Example
IdmaPioDmxW( )
Write date to DSP DMX with IDMA PIO mode. Note1: To write a word variable data, the result of this function is different with IdmaDmxW(). For example, we want to write data 00 01 02 03 (LH) to DSP DMX. H 03 02 01 L (DMX) 00
The first word data is 0x0100 for us. But 8051 word pointer will point to 01, low byte in SRAM. If you use word pointer write 0x0100, 0x0302, the data in SRAM is: H 02 03 00 L (SRAM) 01 (Word Pointer) L (DMX) 01
If you use pure IDMA sequence would write 01 00 03 02 (LH) to DSP DMX: H 02 03 00
To solve this problem, this function will reverse high-low byte data every 2 bytes. You can write word data to DMX by calling this function immediately and not need to reverse data. If you want to write serial byte data to DMX, this function would make error about sequence. Use IdmaDmxW() function instead of this function.
Note2: In DSP 24bits mode and set fWidth24=FALSE (16bits source data), the result of the function is different with IdmaDmxW(). For example, source data in SRAM is: H 03 02 H 03 02 function. The IdmaDmxPioW() function will write data to DMX (add zero value in high byte): H 00 03 02 00 01 L (DMX) 00 01 L (SRAM) 00 L (DMX) 00
The IdmaDmxW() function will write data to DMX (add zero value in low byte): 00 01 00
Its real to transfer 16bits data to 24bits. The zero value will auto drop by IdmaDmxR()
Its for writing 24bits data but small value. You can do the same job by setting fWidth24=TRUE and use a double-word variable. But its not effective because we will need two kinds of code to handle this and more variable size. The zero value will auto drop by IdmaPioDmxR() function. In most of application, we
www.ali.com.tw
95
void IdmaPioDmxW(void *pbSourceAddr, WORD wTargetAddr, WORD wLen, BOOL fWidth24) Parameters void *pbSourceAddr Source data address was in SRAM. WORD wTargetAddr Target data address in DSP-DMX. WORD wLen Data Length. Its word unit, for example, if source data is 96 bytes: 24bits source data: wLen=32. 16bits source data: wLen=48. BOOL fWidth24 TRUE: 24bits source data. FALSE: 16bits source data. Note: In DSP 16bits mode this arguments would be ignore. Return values None Global variable
Example
IdmaPioDmxR( )
Read date from DSP DMX with IDMA PIO mode Note1: In DSP 24bits mode, this function will just read 24bits data. If you use a double-word variable to get the value, you should clear the 8bits over data yourself.
Note2: To read a word variable data, the result of this function is different with IdmaDmxR(). For example, the data is 00 01 02 03 (LH) in DSP DMX. The first word data should be 0x0100 for us. H 03 02 H 03 02 01 L (DSP DMX) 00 L (SRAM) 00
If you use pure IDMA sequence to get data, it would be the same data with DMX. 01
www.ali.com.tw
96
Note3: In DSP 24bits mode and set fWidth24=FALSE (16bits source data), the result of the function is different with IdmaDmxR(). In application, we often use a small value in 24bits mode (although it still allocate 24bit space in DMX). For example, source data in DMX is: H 00 04 03 00 02 L (DMX) 01
Its correct to read it by setting fWidth24=TRUE and use a double-word variable. If we have known the highest byte is always zero, its not effective, because we will need two kinds of code to handle this and more variable size. This function will auto drop the highest byte when set fWidth24=FALSE in 24bit mode. In most of application, we just need a word variable to read/write it. The IdmaDmxR() function will auto drop the lowest byte when set fWidth24=FALSE in 24bit mode. Its real to transfer 24bits data to 16bits. For example, if source 16bits data in SRAM is: H 04 03 H 04 03 02 L (SRAM) 01 L (DMX) 00
The IdmaDmxW() function will write data to DMX (add zero value in low byte): 00 02 01
So the IsmaDmyR() function should drop the lowest byte zero value to get correct value. H 04 03 fWidth24) Parameters WORD wSourceAddr Source data address was in DSP-DMX. void *pbTargetAddr Target data address in SRAM. WORD wLen Data Length. Its word unit, for example, if source data is 96 bytes: 24bits source data: wLen=32. 16bits source data: wLen=48. 02 L (SRAM) 01
www.ali.com.tw
97
Example
IdmaPmW( )
Write date to DSP PM with IDMA mode. This function will use IDMA bank0 to transfer data. Note: If wDSPAddr is odd, the 3 bytes of begining data would be drop by IDMA hardware. At this statue, wLen should be subtractive 1 word. void void IdmaPmW(WORD wDSPAddr, WORD wLen) Parameters WORD wDSPAddr Target data address in DSP-PM. WORD wLen Data Length. Its word unit, for example, if source data is 99 bytes, wLen=33. Return values None Global variable
Example
IdmaDmyW( )
Write date to DSP DMY with IDMA mode. This function will use IDMA bank0 to transfer data. void void IdmaDmyW(WORD wDSPAddr, WORD wLen, BOOL fWidth24)
www.ali.com.tw
98
Example
IdmaDmyR( )
Read date from DSP DMY with IDMA mode. This function will use IDMA bank0 to transfer data. Note: IDMA DMY Read always get 16bits data (It always drop the lowest byte data). If you want to read 24bits data, use IdmaPioDmyR() function instead of this function. void void IdmaDmyR(WORD wDSPAddr, WORD wLen) Parameters WORD wDSPAddr Target data address in DSP-DMY. WORD wLen Data Length. Its word unit, for example, if source data is 99 bytes, wLen=33. Return values None Global variable
Example
www.ali.com.tw
99
IdmaDmxW( )
Write date to DSP DMX with IDMA mode. This function will use IDMA bank0 to transfer data. void void IdmaDmxW(WORD wDSPAddr, WORD wLen, BOOL fWidth24) Parameters WORD wDSPAddr Target data address in DSP-DMX. WORD wLen Data Length. Its word unit, for example, if source data is 96 bytes: 24bits source data: wLen=32. 16bits source data: wLen=48. BOOL fWidth24 TRUE: 24bits source data. FALSE: 16bits source data. Note: In DSP 16bits mode this arguments would be ignore. Return values None Global variable
Example
IdmaDmxR( )
Read date from DSP DMX with IDMA mode. This function will use IDMA bank0 to transfer data. Note: IDMA DMX always get 16bits data (If source data in DSP is 24 bits, it always drop the lowest byte data). If you want to read 24bits data, use IdmaPioDmxR() function instead of this function. void void IdmaDmxR(WORD wDSPAddr, WORD wLen) Parameters WORD wDSPAddr Target data address in DSP-DMX.
www.ali.com.tw
100
Example
IdmaPioDebugW( )
Write date to DSP DMX with IDMA PIO mode in DSP 24bits mode and use 16bits data source. The result of this function is the same with IdmaDmxW() function. In application, its useless for us. The function is only for debugging. void IdmaPioDebugW(void *pbSourceAddr, WORD wTargetAddr, WORD wLen) Parameters void *pbSourceAddr Source data address was in SRAM. WORD wTargetAddr Target data address in DSP-DMX. WORD wLen Data Length. Its word unit, for example, if source data is 96 bytes, wLen=48. Return values None Global variable
Example
IdmaPioDebugR( )
Read date from DSP DMX with IDMA PIO mode in DSP 24bits mode and use 16bits data source. The result of this function is the same IdmaDmxR() function. In application, its
www.ali.com.tw
101
Example
2.14
USB (Usb.c)
CheckReceiveCBW()
Check CBW in EP0. void CheckReceiveCBW(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
102
Example
See also
UsbDevice()
Main loop. void UsbDevice(void) Parameters None Return values None Global variable
Example
See also
UsbDeviceInit()
Initialization device. void UsbDeviceInit(void) Parameters None Return values None Global variable
www.ali.com.tw
103
Example
See also
UsbSuspend_DPLL()
. void UsbSuspend_DPLL(void) Parameters None Return values None Global variable
Example
See also
UsbSuspend_WaitCmd()
. void UsbSuspend_WaitCmd(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
104
2.15
USBHost (USBHost.c)
UmsRequestSense()
Send Inquiry command. void UmsRequestSense(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
105
See also
UsbHostDetect()
Detect device Connect Function. bit UsbHostDetect(void) Parameters None Return values Bit type TRUE: FALSE: Global variable
Example
See also
UsbHostInit()
Initialization host.
www.ali.com.tw
106
Example
See also
UsbHostIsWriteProtect()
Determine Write Protect function. bit UsbHostIsWriteProtect(void) Parameters None Return values Bit type TRUE: FALSE: Global variable Write-Protect. Normal.
Example
See also
UsbHostRead()
Host read function. bit UsbHostRead(void) Parameters None Return values Bit type
www.ali.com.tw
107
See also
UsbHostWrite()
Host writes function. bit UsbHostWrite(void) Parameters None Return values Bit type TRUE: FALSE: Global variable gdwStorLba: gbStorTransLen: gbStorPath: Example The sector number that will be read. Number of sectors will be read. The assigned area that data will be read to.
See also
www.ali.com.tw
108
2.16
HostDelay()
Delay loop time. void HostDelay(WORD DelayTime) Parameters WORD DelayTime Return values None Global variable
Example
See also
UsbHostNormalCheck()
bit UsbHostNormalCheck(void)
www.ali.com.tw
109
Example
See also
UsbHostPowerOff()
Host was power off. bit UsbHostPowerOff(void) Parameters None Return values Bit type TRUE: FALSE: Global variable
Example
See also
UsbHostPowerOn()
Host was power on. bit UsbHostPowerOn(void) Parameters None Return values Bit type TRUE:
www.ali.com.tw
110
Example
See also
2.17
CntFreeCluster()
Count free clusters of current partition, and set First Free cluster. DWORD CntFreeCluster(BYTE DiskIndex) Parameters BYTE DiskIndex Return values DWORD type Free cluster number, if -1 failure. Global variable
Example
See also
www.ali.com.tw
111
Example
See also
FatChangePartition()
Change to the Nth partition, get the essence information. BYTE FatChangePartition(BYTE DiskIndex, BYTE ParIndex) Parameters BYTE DiskIndex Disk type should be checked. Its value should be one of SOURCE_DEV or TARGET_DEV. BYTE ParIndex Partition index. Its' value should less than the partition number. Return values BYTE type TRUE if success, and FALSE for failure Global variable
Example
See also
FATCheckExistFile()
Check whether the file exists in the dir given by g_UIDesEntry. DWORD FATCheckExistFile(void)
www.ali.com.tw
112
Example
See also
FATCreateDir()
Create a dir in the folder represented by g_UIDesEntry. bit FATCreateDir(void) Parameters None Return values Bit type TRUE: FALSE: Global variable
Example
See also
FATDeleteAll()
Deletes the whole partition, it can be used as format. BYTE FATDeleteAll(BYTE DiskIndex) Parameters BYTE DiskIndex Return values BYTE type True if succeed, otherwise False.
www.ali.com.tw
113
Example
See also
FATDirCopy()
Copies one dir to the other one, it's a reentrant function. BYTE FATDirCopy(P_FILE_ENTRY pSrcEntry,P_FILE_ENTRY pDesEntry,BYTE Mode) Parameters IN P_FILE_ENTRY pSrcEntry: the src dir entry. IN P_FILE_ENTRY pDesEntry: the des dir entry. IN BYTE Mode: there are four modes: 1,Duplicating the whole dir (WHOLE_DIR|NEW_ENTRY)
2,Copy the whole dir to a certain dir (WHOLE_DIR|EXIST_ENTRY) 3,Duplicating files and subfolders (CONTENT_ONLY|NEW_ENTRY) 4,Copy files and subfolders to a certain dir(CONTENT_ONLY|EXISR_ENTRY) Return values BYTE type True if succeed, otherwise False. Global variable
Example
See also
FATDirDelete()
Delete dir(s), it's a reentrant function. BYTE FATDirDelete(BYTE DiskIndex,P_FILE_ENTRY pFileEntry,BYTE Mode) Parameters BYTE DiskIndex: P_FILE_ENTRY pFileEntry: the dir file entry BYTE Mode: there are two delete modes: 1, Delete the dir given by pFileEntry(DEL_THE_DIR)
www.ali.com.tw
114
Example
See also
FATFileCopy()
Copy one fat file. BYTE FATFileCopy(P_FILE_ENTRY pSrcEntry,P_FILE_ENTRY pDesEntry) Parameters P_FILE_ENTRY pSrcEntry: Source file entry. IN P_FILE_ENTRY pDesEntry: Destination file entry. Return values BYTE type True if succeed, otherwise False. Global variable
Example
See also
FATFileEntryCopy()
Copy the source entry to the destination one. BYTE FATFileEntryCopy(P_FILE_ENTRY pSrcEntry,P_FILE_ENTRY pDesEntry) Parameters P_FILE_ENTRY pSrcEntry: source entry. P_FILE_ENTRY pDesEntry: destination entry. Return values BYTE type True if succeed, otherwise False.
www.ali.com.tw
115
Example
See also
GetFirstClusterInChain()
Find the first cluster of the dir entry. DWORD GetFirstClusterInChain(BYTE DiskIndex,P_FILE_ENTRY pFileEntry) Parameters BYTE DiskIndex: disk type. P_FILE_ENTRY pFileEntry: the destination dir to which the cluster chain attached. Return values BYTE type True if succeed, otherwise False. Global variable
Example
See also
GetNextEntryOffset()
Get the next valid file entry. DWORD GetNextEntryOffset(BYTE DiskIndex, P_FILE_ENTRY pFileEntry,BYTE fBackward,BYTE fExcluded) Parameters BYTE DiskIndex: USB or ATA disk P_FILE_ENTRY pFileEntry: The current file entry, it's not necessary a valid one. BYTE fBackward: 1 if search backwards, else search forwards. BYTE fExcluded: 1 mean search the next valid entry, skip the current one; 0 was search a valid entry from the current position. Return values DWORD type The last offset if success and -1 if failure, -2 if it reaches the end.
www.ali.com.tw
116
Example
See also
ReadSectorOfFileEntry()
Read the sector of the file entry to buffer and return the sector number. bit ReadSectorOfFileEntry(BYTE DiskIndex, P_FILE_ENTRY pFileEntry, DWORD CurClu) Parameters BYTE DiskIndex: USB disk or IDE disk. P_FILE_ENTRY pFileEntry: The current file entry, it's must be a valid one. DWORD CurClu: The cluster where the entry stores, if we don't know the cluster number would be set zero. Return values BYTE type TRUE was success, and FALSE for failure. Global variable
Example
See also
UIClearSelectBuff()
Clear the UIbuffer with 0xff. void UIClearSelectBuff(void) Parameters None Return values None Global variable
Example
www.ali.com.tw
117
UIDeleteAll()
Delete all the files on the partition. BYTE UIDeleteAll(BYTE DiskIndex) Parameters BYTE DiskIndex Return values BYTE type True was success else FALSE. Global variable
Example
See also
UIDeleteSelected()
Delete selected files. BYTE UIDeleteSelected(BYTE DiskIndex) Parameters BYTE DiskIndex: Decide USB disk or IDE disk Return values BYTE type True was success else FALSE. Global variable
Example
See also
UIDiskInit()
Initialization disk. BYTE UIDiskInit(BYTE DiskIndex)
www.ali.com.tw
118
Example
See also
UIEnter()
Enter a dir represented by g_UICurEntry. BYTE UIEnter(BYTE DiskIndex) Parameters BYTE DiskIndex: SOURCE_DEV or TARGET_DEV. Return values BYTE type True if succeed, otherwise False. Global variable
Example
See also
UIEscape()
Go to the parent dir. BYTE UIEscape(BYTE DiskIndex) Parameters BYTE DiskIndex Decide USB disk or IDE disk. Return values BYTE type TRUE was success, else FALSE. If reach end, it returns 2.
www.ali.com.tw
119
Example
See also
UIGetDiskInfo()
Get partition count of the disk. BYTE UIGetDiskInfo(BYTE DiskIndex) Parameters BYTE DiskIndex: Decide USB disk or IDE disk. Return values BYTE type The count of partition a disk. Global variable
Example
See also
UIGetFileInformation()
Get the file information. DWORD UIGetFileInformation(BYTE DiskIndex,BYTE Attr) Parameters BYTE DiskIndex: SOURCE_DEV or TARGET_DEV. BYTE Attr: The kind of information we need. Return values DWORD type -1 if Failure, otherwise return specific disk information. Global variable
www.ali.com.tw
120
See also
UIGetSelectFileSize()
Get selected files' total size by sector. DWORD UIGetSelectFileSize(void) Parameters None Return values DWORD type Selected files size. (Unit is sector). Global variable
Example
See also
UIIsSelect()
Judge if the file or dir is selected. BYTE UIIsSelect(BYTE DiskIndex) Parameters BYTE DiskIndex: USB disk or IDE disk Return values BYTE type: True if selected else FALSE. Global variable
Example
See also
www.ali.com.tw
121
Example
See also
UIPrevious()
Get the previous dir or file. When reach the head, the offset won't change. BYTE UIPrevious(BYTE DiskIndex) Parameters BYTE DiskIndex: SOURCE_DEV or TARGET_DEV. Return values BYTE type: TRUE was success, else FALSE. If reach end, it returns 2. Global variable
Example
See also
UISelect()
Select a file, put it into the UIBuffer. If already in buffer, unselect it. BYTE UISelect(BYTE DiskIndex) Parameters BYTE DiskIndex:
www.ali.com.tw
122
Example
See also
UISetDefaultDir()
Set to the default dir when a disk is chosen. BYTE UISetDefaultDir(BYTE DiskIndex) Parameters BYTE DiskIndex: Decide USB disk or IDE disk. Return values BYTE type: True was success otherwise False. Global variable
Example
See also
UITop()
Go to the top of the current dir. BYTE UITop(BYTE DiskIndex) Parameters BYTE DiskIndex: SOURCE_DEV or TARGET_DEV Return values BYTE type: TRUE was success else FALSE. Global variable
www.ali.com.tw
123
See also
www.ali.com.tw
124
DoAtaCommand()
Example
See also
SpecialAtapiHandle()
Handle special ATAPI command. This command will update the content of serial-interface memory. bit SpecialAtapiHandle(void) Parameters None Return values Bit type TRUE: FALSE: Global variable
Example
See also
www.ali.com.tw
125
BattCheck()
Check Battery. BYTE BattCheck(void) Parameters None Return values BYTE type Global variable
Example
See also
ConvertStorLba()
. DWORD ConvertStorLba(void) Parameters None Return values DWORD type Global variable
Example
See also
DisableTimer1()
Disable timer 1 interrupt. void DisableTimer1(void) Parameters None
www.ali.com.tw
126
Example
See also
EnableTimer0()
Enable Timer 0 interrupt. void EnableTimer0(void) Parameters None Return values None Global variable
Example
See also
EnableTimer1()
Enable Timer 1 interrupt. void EnableTimer1(WORD wWatchTimer) Parameters WORD wWatchTimer Return values None Global variable
Example
See also
www.ali.com.tw
127
Example
See also
GetExtTime2Counter()
Get external timer2 counter. void GetExtTime2Counter(void) Parameters None Return values None Global variable
Example
See also
LoadExtendMemCode()
. void LoadExtendMemCode(void) Parameters None Return values None
www.ali.com.tw
128
Example
See also
LoadProgram()
Load assigned Program Module. void LoadProgram(WORD wIndex, BYTE bCodePart) Parameters WORD wIndex: Load Which PM. "1": Extend Code only. "2": Basic Code only. Others: Whole Code. Return values None Global variable gxwProgramIndex: Load which PM, and keep data in external memory. Example
See also
LoadRecInfo()
. void LoadRecInfo(void) Parameters None Return values None Global variable
Example
www.ali.com.tw
129
LoadStringTableIndex()
Load string table index. void LoadStringTableIndex(void) Parameters None Return values None Global variable
Example
See also
LoadTransTableIndex()
Load transfer table index. void LoadTransTableIndex(void) Parameters None Return values None Global variable
Example
See also
NandPrivateDis()
Nand private disable. void NandPrivateDis(void) Parameters None
www.ali.com.tw
130
Example
See also
NandPrivateEn()
Nand private enable. void NandPrivateEn(void) Parameters None Return values None Global variable
Example
See also
NandReadPhySec()
. bit NandReadPhySec(wPhysec, bLength, wSramAddr) Parameters wPhysec bLength wSramAddr Return values Bit type TRUE: FALSE: Global variable
www.ali.com.tw
131
See also
ReadSClockFromSram()
Get secure clock offset from DCV SRAM. void ReadSClockFromSram(void) Parameters None Return values None Global variable
Example
See also
ReadSettingData()
Read setting data from Nand Flash private area. void ReadSettingData(BYTE bStorPath) Parameters bStorPath: DMA path Return values None Global variable
Example
See also
ReCheckStorage()
Check storage again. bit ReCheckStorage(BYTE bStorage)
www.ali.com.tw
132
Example
See also
RestoreSramData()
Restore SRAM data from Nand Flash setting data. Note: You should read and check Nand Flash setting data ready first. void RestoreSramData(void) Parameters None Return values None Global variable
Example
See also
SetPowerOff()
Turn off power. void SetPowerOff(void) Parameters None Return values None Global variable
www.ali.com.tw
133
See also
SetSettingToVariable()
Set setting from FsData[] to variable. void SetSettingToVariable(void) Parameters None Return values None Global variable
Example
See also
SettingCheck()
Check setting data in Nand Flash private area has written correctly last time. bit SettingCheck(void) Parameters None Return values Bit type TRUE: FALSE: Global variable
Example
See also
SramCheck()
Check backup SRAM if data has written correctly last time.
www.ali.com.tw
134
Global variable
Example
See also
SramRead()
Read data from backup SRAM. void SramRead(BYTE bAddr, void *pbData) Parameters BYTE bAddr: The address of SRAM will be read. Void *pbData: Point to a variable that the data value of SRAM will be read. Return values None Global variable
Example
See also
SramWrite()
Write data for backup SRAM. void SramWrite(BYTE bAddr, void *pbData) Parameters BYTE bAddr: The address of SRAM that will be write.
www.ali.com.tw
135
Example
See also
StrComp()
Compare two strings. bit StrComp(PBYTE pbString1, PBYTE pbString2, BYTE xbLength ) Parameters PBYTE pbString1: string 1. PBYTE pbString2: string 2. BYTE xbLength: number of letters will be compared. Return values Bit type TRUE: The same. FALSE: Not same. Global variable
Example
See also
SystemPowerOff()
System turns off power. void SystemPowerOff(void) Parameters None Return values None
www.ali.com.tw
136
Example
See also
SystemPowerOn()
System turns on power. void SystemPowerOn(void) Parameters None Return values None Global variable
Example
See also
VbusCheck()
Check Vbus status. bit VbusCheck(void) Parameters None Return values Bit type TRUE: FALSE: Global variable
Example
See also
www.ali.com.tw
137
Example
See also
www.ali.com.tw
138
DynamicDownloadManager()
Dynamics Download program from Nand Flash to SRAM. void DynamicDownloadManager(void) Parameters None Return values None Global variable gxwAddrPMI: Number of sector the program module index. gwProgramIndex: Number of Program module. Set the variable before enter this function. Example
See also
NandReadPhySecFunc()
Read physical page(s) to SRAM (program ram). void NandReadPhySecFunc(void) Parameters None Return values None Global variable gfLargeBlock: gf16bit: gfAddress4Cycle: Example Nand flash type variable. Nand flash type variable. Nand flash type variable.
See also
www.ali.com.tw
139
2.21
Drm (Drm.c)
DrmGetDeviceCertificate()
Example
See also
DrmGetLicenseStat()
Example
See also
DrmGetSecureClock()
www.ali.com.tw
140
Example
See also
DrmGetSecureTimeChallenge()
Example
See also
DrmGetSyncList()
Example
www.ali.com.tw
141
DrmSetLicenseResponse()
Example
See also
DrmSetSecureTimeResponse()
Example
See also
TurnTextTime()
www.ali.com.tw
142
Example
See also
TurnTimeText()
void TurnTimeText(DWORD dwGetTime) Parameters DWORD dwGetTime Return values None Global variable
Example
See also
www.ali.com.tw
143
IntCdcAdcGain()
void IntCdcAdcGain(BYTE bPsetVal) Parameters BYTE bPsetVal Return values None Global variable
Example
See also
IntCdcCtrl()
void IntCdcCtrl(BYTE bCommand) Parameters BYTE bCommand Return values None Global variable
Example
See also
IntCdcGetAdcGain()
www.ali.com.tw
144
Example
See also
IntCdcPowerDownPa()
Example
See also
IntCdcRStringPowerOn()
Example
See also
www.ali.com.tw
145
void IntCdcSetPaGain(BYTE bVol) Parameters Byte bVol Return values None Global variable
Example
See also
IntCdcSetPaGainTask()
void IntCdcSetPaGainTask(bit fImmediatelySet) Parameters bit fImmediatelySet Return values None Global variable
Example
See also
IntCdcSetSampleRate()
www.ali.com.tw
146
See also
www.ali.com.tw
147
ExtCdcCtrl()
void ExtCdcCtrl(BYTE bCommand) Parameters BYTE bCommand Return values None Global variable
Example
See also
ExtCdcSetSampleRate()
Example
See also
www.ali.com.tw
148
CardDetect()
Example
See also
FillMemory()
void FillMemory(IN PBYTE pbBuf, IN WORD wBufLen, IN BYTE bFilledVal) Parameters PBYTE pbBuf WORD wBufLen BYTE bFilledVal Return values None Global variable
Example
See also
MemoryCopy()
www.ali.com.tw
149
Example
See also
MtpDeviceInit()
Example
See also
MtpFinishJob()
www.ali.com.tw
150
See also
MtpProcess()
Process function for MTP protocol. void MtpProcess(void) Parameters None Return values None Global variable
Example
See also
SaveFsInfo()
void SaveFsInfo(OUT FS_INF_DATA* pFs) Parameters OUT FS_INF_DATA* pFs Return values None Global variable
Example
See also
SendMtpDataBlock()
Send MTP Data Block to Host. void SendMtpDataBlock(PBYTE pBuf, DWORD dwLen)
www.ali.com.tw
151
Example
See also
www.ali.com.tw
152
RestoreDefaultSetting()
Restore default setting from Nand Flash private area. void RestoreDefaultSetting(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
153
2.26.1 Registers
DCV_INT_FLAG INT0 Flag Register (FF1Ah) FF1Ah D7 D6 D5 D4 INT0_FLAG INT0 Flag Register D3 D2 D1 D0 Type R/W Default 00h
PASCPPR_I PASCPPL_I PASCPNR_I PASCPNL_I DCV_RTC_I DCV_BAT_ DCV_BRN_ ALARM_INT NT NT NT BRN_DET DET NT NT
Bit 7: PASCPPR_INT Bit 6: PASCPPL_INT Bit 5: PASCPNR_INT Bit 4: PASCPNL_INT Bit 3: ALARM_INT Bit 2: DCV_RTC_INT Bit 1: DCV_BAT_BRN_DET Bit 0: DCV_BRN_DET
PASCPPR Interrupt Flag PASCPPL Interrupt Flag PASCPNR Interrupt Flag PASCPNL Interrupt Flag ALARM Interrupt Flag DCV-RTC Interrupt Flag DCV Battery Brown Out Detect Interrupt Flag DCV Brown Out Detect Interrupt Flag
DCV_ADDR DCV Address Register (FFD4h) FFD4h D7 D6 D5 D4 DCV_ADDR DCV Address Register D3 D2 D1 D0 Type R/W Default 00h
DCV_ADDR
Bits 7-0: DCV Address Register DCV_WRDATA DCV Write Data Register (FFD5h) FFD5h D7 D6 D5 DCV_WRDATA DCV Write Data Register D4 D3 D2 D1 D0 Type R/W Default 00h
DCV_WRDATA[7:0] Bits 7-0: DCV Write Data Register DCV_RDDATA DCV Read Data Register (FFD6h) FFD6h D7 D6 D5 DCV_RDDATA DCV Read Data Register D4 D3 D2 D1 D0
Type R/W
Default 00h
www.ali.com.tw
154
RTC Timer/Counter Register 0 15h Bit 7 Bit 6 Bit 5 RTC0 The First Byte of the 32-bit RTC Register Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Type R/W Default 00h
RTC[7:0]
A write access the RTC counter register, while a read access the RTC timer
RTC Timer/Counter Register 1 16h Bit 7 Bit 6 Bit 5 RTC1 The Second Byte of the 32-bit RTC Register Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Type R/W Default 00h
RTC[15:8]
A write access the RTC counter register, while a read access the RTC timer
RTC Timer/Counter Register 2 17h Bit 7 Bit 6 Bit 5 RTC2 The Third Byte of the 32-bit RTC Register Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Type R/W Default 00h
RTC[23:16]
A write access the RTC counter register, while a read access the RTC timer
RTC Timer/Counter Register 3 18h Bit 7 Bit 6 Bit 5 RTC3 The Fourth Byte of the 32-bit RTC Register Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Type R/W Default 00h
RTC[31:24]
A write access the RTC counter register, while a read access the RTC timer
www.ali.com.tw
155
ALARM0[7:0]
Bit 7~0: ALARM0[7:0] Set alarm register Alarm Register 1 1Ah Bit 7 Bit 6 Bit 5 ALARM1 The Second Byte of the 32-bit Alarm Register Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Type R/W Default 00h
ALARM0[15:8]
ALARM2 The Third Byte of the 32-bit Alarm Register Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Type R/W Default 00h
ALARM0[23:16]
ALARM3 The Fourth Byte of the 32-bit Alarm Register Bit 5 Bit 4 Bit 3 Bit 2 Bit 1 Bit 0 Type R/W Default 00h
ALARM0[31:24]
SettingForIceStart( )
Init and set default value in ICE mode. It is because real system running in normal mode will change program module, and running in ICE mode is one program module you download only. void SettingForIceStart(void ) Parameters None Return values None
www.ali.com.tw
156
SystemOff( )
Let system power off (Display power off and save setting etc). void SystemOff(void ) Parameters None Return values None Global variable
UiShowLowPower( )
When low battery, show message and power down. void UiShowLowPower(void ) Parameters None Return values None Global variable
Example
UiShowAutoPowerOff( )
When auto power off time up, let LCD display flash. void UiShowAutoPowerOff(void ) Parameters None Return values None Global variable XBYTE gxbDisplayCounter Display flash delay time.
www.ali.com.tw
157
UiShowStorageSts( )
If use the external card (such as SD card), show a card icon. void UiShowStorageSts(void ) Parameters None Return values None Global variable
UiCheckIniErr( )
Check Init Error and display it. void UiCheckIniErr( ) Parameters None Return values None Global variable XBYTE gxbLastErrCode Initial module should set the error code in this variable.
SaveSetting( )
Save settings and states in RTC SRAM. void SaveSetting( ) Parameters None Return values None Global variable
www.ali.com.tw
158
UiCheckCardRemoved( )
Check SD card, if card removed, change to Nand Flash. This function will swap to system module to show message and change media if SD card removed, then change back to original module. void UiCheckCardRemoved(void ) Parameters None Return values None Global variable
UiNormalCheck( )
Check system state. (VBus, KeyHold, Battery, Alarm, SD card...) void UiNormalCheck(void ) Parameters None Return values None Global variable
www.ali.com.tw
159
UiGoMainMenu( )
Go into main menu state, and display main menu. void UiGoMainMenu(void ) Parameters None Return values None Global variable
UiFixAlarmTime( )
When user edit time or alarm up, alarm may illegal, so need to call this function to fix alarm to today. You should set gxdwAlarmTime before you call this function. void UiFixAlarmTime( ) Parameters None Return values None Global variable XDWORD gxdwAlarmTime Fixed alarm time. Example
www.ali.com.tw
160
UiSysGetAlarmTime( )
Get DCV alarm time. void UiSysGetAlarmTime( ) Parameters None Return values None Global variable XDWORD gxdwAlarmTime Alarm time Example
UiSysSetAlarmTime( )
Set DCV alarm time. (This function will call UiFixAlarmTime() to fix alarm time first) void UiSysSetAlarmTime( ) Parameters None Return values None Global variable XDWORD gxdwAlarmTime Alarm time. Example
UiSysGetNowTimeText( )
Transfer time counter number to global string array gxbStringEditTime. void UiSysGetNowTimeText(DWORD dwGetTime)
www.ali.com.tw
161
See also
UiShowKeyHold( )
If key hold, show a key hold icon on screen. void UiShowKeyHold() Parameters None Return values None Global variable
Example
UiGoVolMenu( )
Go to volume control state. void UiGoVolMenu() Parameters None Return values None Global variable
www.ali.com.tw
162
See also
UiDrawSubMenu( )
Show sub menu. void UiDrawSubMenu(BYTE bMarkNum, WORD wTitleStr, BYTE bTitleLen) Parameters BYTE bMarkNum Display icon number. WORD wTitleStr. Display title string BYTE bTitleLen Display title string length. Return values None Global variable
Example
UiShowSubMenuNum( )
Show sub menu number. void UiShowSubMenuNum(BYTE bCurrentNum, BYTE bTotalNum) Parameters BYTE bCurrentNum Number of Current menu item. BYTE bTotalNum Number of Total menu item. Return values None Global variable None
www.ali.com.tw
163
UiShowRecFile( )
Show playback DVR mode file name (8.1 short name). void UiShowRecFile() Parameters None Return values None Global variable
Example
See also
UiShowUdefEqVal( )
Show the user defines EQ value. void UiShowUdefEqVal(BYTE bSelNum, BYTE bEqVal) Parameters BYTE bSelNum Musical scale (0-5) BYTE bEqVal Equalizer level (0-15) Return values None Global variable
Example The following example will show total user define EQ value. for(bI=0;bI<=5;bI++) UiShowUdefEqVal(bI,gxbUserDefEq[bI]); See also UiEditUDefEq() | UiShowUDefEqSel() | UiClearUDefEqSel() | UiDrawUserDefEq
www.ali.com.tw
164
UiShowUDefEqSel( )
Show a selected frame when selects another user define EQ musical scale. void UiShowUDefEqSel() Parameters None Return values None Global variable XBYTE gxbSelUserDefEq User selects which scale number. Example
UiClearUDefEqSel( )
Clear a selected frame that user select user define EQ musical scale. UiShowUDefEqSel() function didnt clear the selected frame because it didnt remember
www.ali.com.tw
165
UiDrawUserDefEq( )
Display user defines EQ edit. void UiDrawUserDefEq() Parameters None Return values None Global variable
Example
UiGoRecQtyMenu( )
Go to record quality menu state. void UiGoRecQtyMenu() Parameters None Return values None Global variable
www.ali.com.tw
166
See also
UiGoRecMenuFrom( )
In record menu, go to record source menu state. void UiGoRecMenuFrom() Parameters None Return values None Global variable
Example
See also
UiGoRecFromMenu( )
Go to record source menu state. void UiGoRecFromMenu() Parameters None Return values None Global variable
Example
See also
UiGoRecMenuQty( )
In record menu, go to record source menu state. void UiGoRecMenuQty()
www.ali.com.tw
167
Example
See also
UiSaveScreen( )
Save LCD data to memory. Note: buffer size should be more than 1024 bytes. void UiSaveScreen(PBYTE pbBuffer) Parameters PBYTE pbBuffer Point to memory buffer. Return values None Global variable
Example
UiLoadScreen( )
Restore LCD data from memory. void UiLoadScreen(PBYTE pbBuffer) Parameters PBYTE pbBuffer Point to memory buffer Return values None Global variable
www.ali.com.tw
168
www.ali.com.tw
169
Super Loop
Error Handle
2.27.2 System State UI should response base on system state. For example, when system state is in playing state and user input Key 2, UI should send P_PAUSE command to play engine, not P_PLAYBACK command. You can get the system state by reading gxbSysState variable. 2.27.3 Menu State UI should response base on menu state. For example, when EQ menu is appeared and user input Key 2, UI should set the EQ value, not send any command to play engine. You can get the menu state by reading gxbUiMenuMainStates and gxbUiMenuSubStates variable. gxbUiMenuMainStates means which kind menu it entered. gxbUiMenuSubStates means which item user selected. For example, when user enter EQ menu and select POP, gxbUiMenuMainStates is
www.ali.com.tw
170
M5661 Firmware Programming Guide UI_EQ_MENU and gxbUiMenuSubStates is UI_EQ_POP_MENU. 2.27.4 A-B Repeat State
AB_REPT_RESET
AB_REPT_END
AB_REPT_START
UI should set gxbAbRepeatSts variable to handle the A-B repeat state. The state is: AB_REPT_RESET: Default state. User didnt set A-B repeat or has canceled A-B repeat. AB_REPT_START: User has set A-B repeat start point. AB_REPT_END: Use has set A-B repeat end point. After setting A-B repeat state, UI should send A-B repeat command to play engine. For more detail, see section Play Engine Command below. 2.27.5 Random Play List UI should handle random play list. That is, UI should decide which music would be played in random mode. Use below function to get a random number: UiRndPlayInit( ): This function will get a random seed from RTC timer and the current file number. UI should call this function when random play mode starts. UiGetRndPlayNum( ): This function will return a random number. Parameters fGetNext means to get the next random number or previous random number. For example, if the random play list is 325 and we are playing the second music. Call this function and set fGetNext = UI_RND_PLAY_NEXT will get the random number 5, set fGetNext = UI_RND_PLAY_PREV will get the random number 3. Parameters: bit fGetNext UI_RND_PLAY_NEXT: Get next random number UI_RND_PLAY_PREV Get previous random number
After getting a random number, UI should send random play command to play engine. For more detail, see section Play Engine Command below.
www.ali.com.tw
171
M5661 Firmware Programming Guide 2.27.6 UiDispCtrl function UI would call some service function. When these service function cause some events, for example, play engine ready to start playing, UI might need to display or control something at this time. The service function would call back UiDispCtrl() function and let UI to do his job at this time. Parameters: BYTE bStatus The service function set the event in the variable. These are useful event for UI: UI_PE_INIT_END Play engine initial has finished. UI_PE_START_START Play engine is preparing to start to play a song. UI_PE_START_END Play engine is ready to start to play a song. UI_PE_PLAY_UPDATE Play engine has updated the music information. (Ex. Playing time) UI_PE_STOP Play engine has stopped. UI_PE_PAUSE Play engine has paused. UI_PE_RETURN_PLAY Play engine has continued to play music. UI_SCROLL_DISPLAY UI call itself event. UI could scroll tag or lyric at this time. 2.27.7 Music Tag Display UI should call LcdShowTagTitle() function first, and then call LcdScrollTag() function if tag exist. For more detail, see LcdShowTagTitle() and LcdScrollTag() function. 2.27.8 Lyric Display UI should handshake with play engine and Lcd function to display lyric. You can get the play engines lyric state by reading gxbLrcState variable. The useful meaning of value for UI is:
LRC_STS_DISP_STR: Play engine has completed get a lyric and its time to show the lyric. UI should display a new lyric now. www.ali.com.tw
172
You can get the Lcd lyric state by reading gxbLcdLyricStatus variable. The useful meaning of value for UI is: gxbLcdLyricStatus
bit 1: Lyric scroll done flag. UI can read this bit to know the scroll state. If UI need to force finish a lyric, call LcdSetLyricDone() function to set this bit. LCD_LYRIC_SCROLL_DONE: Lyric scroll done. LCD_LYRIC_SCROLLING: Lyric scrolling. bit 4-7: Subtitle state. UI can read these bits to know lyric state. NO_SUBTITLE: Default status, not load lyric yet or no lyric SHORT_SUBTITLE: Short lyric less than 16 words LONG_SUBTITLE: Long lyric more than 16 words
For more detail, see LcdShowLyrics(), LcdScrollLyric, PeLyrics() function in section Lcd (Lcd.c) above. 2.27.9 User Define EQ You can enable user define EQ option by setting definition UI_USE_USER_EQ = 1. If set UI_PLAY_USER_EQ_EDIT = 1, user can change user define EQ value in Playback module. You can call UiSetUdefEqVal() function to send user define EQ value to DSP. These value is stored in array gxbUserDefEq[]. To edit or display user define EQ, you can call UiShowUdefEqVal( ), UiEditUDefEq(), UiShowUDefEqSel(), UiClearUDefEqSel(), UiDrawUserDefEq function. For more detail, see section Ui Common (UiCommon.c) above. 2.27.10 Display function and micro You could call these function to display some information. UiReDrawMusicPlayer() Clear and redraw music player screen. UiShowMusicType() Display music type in title (MP3 or WMA) UiShowPlayStatus() Display play state icon (Play , Pause , Stop , etc) UiShowEqMode() Display EQ state icon UiShowPlayTime()
www.ali.com.tw
173
M5661 Firmware Programming Guide Display music play time UiShowAbRepeat() Display A-B repeat icon PS. This function will call UiShowRepeatMode() function if no A-B repeat UiShow3dMode() Display 3D mode icon UI_SHOW_CURRENT_FILE() Display current play file number UI_SHOW_TOTAL_FILE() Display total play file number UI_SHOW_BITRATE() Display music bit rate. (gxwUiLastBitRate variable value) UI_SHOW_BATTERY() Display battery icon. (gxbLastBattSts variable value) PS. UiNormalCheck() function will show battery icon. You just use the micro if you want to force display battery icon. 2.27.11 DSP Information UI could get or send information to DSP by using Idma Pio R/W. These are useful DSP address for UI: DSP_EQ_ADDR Get or set EQ value. DSP_3D_ADDR Get or set 3D value DSP_LEFT_VOLUME_ADDR Get or set music left volume DSP_RIGHT_VOLUME_ADDR Get or set music right volume DSP_BIT_RATE_ADDR Get music bit rate value For more detail, see section IDMA (Idma.c). 2.27.12 Play Engine Command UI should send command to play engine base on user input. The useful meaning of value for UI is: P_NOP: No command. Play engine will continue playing or waiting. P_PLAYBACK: Play command. Play engine will start to play music.
www.ali.com.tw
174
M5661 Firmware Programming Guide P_PAUSE: Pause command. Play engine will pause. P_PREV: Previous music command. Play engine will play previous music. P_NEXT: Next music command. Play engine will play next music. P_STOP: Stop command. Play engine will stop playing. P_FIRST: First music command. Play engine will play first music. P_LAST: Last music command. Play engine will play last music. P_RESTART: Restart command. Play engine will play the same music again. P_RND_NEXT: For random play next music command. Play engine will go to next music but would not play it. P_RND_FIRST: For random play first music command. Play engine will go to first music but would not play it. P_RND_START: For random start to play command. Play engine will start playing music. P_AB_REPT_START: A-B repeat start command. Play engine will get the A-B repeat start point. P_AB_REPT_END: A-B repeat end command. Play engine will get the A-B repeat end point. P_AB_REPT_RESET: A-B repeat cancel command. Play engine will stop A-B repeat. P_AB_REPT_RETURN_A: A-B repeat return command. Play engine will return to start point.
UI should handle to play next music by comparing gdwFileSector and gxdwFileTotalSector. If gdwFileSector is larger than gxdwFileTotalSector, UI should send P_NEXT command. UI should handle the first or last music control by comparing gxwCurrentFileNum and gxwNumTotalFiles. For example, when player is playing last music, and user press Key 6, UI should send P_FIRST command, not P_NEXT command. UI should handle the A-B repeat by comparing gdwFileSector and gxdwFileSectorReptB. If gdwFileSector is larger than gxdwFileSectorReptB, UI should send P_AB_REPT_RETURN_A command. UI should send P_RND_FIRST, P_RND_NEXT, P_RND_NEXT, P_RND_START command to control random play. For example, for playing third music, UI should send command: P_RND_FIRST (Let play engine go back first music) P_RND_NEXT (Second music) 175
www.ali.com.tw
M5661 Firmware Programming Guide P_RND_NEXT (Third music) P_RND_START (Start playing) 2.27.13 Flow Description 2.27.13.1 Play Module Initial
Set variable default value (common setting) Set variable default value (play module setting) Initial error handle Restore last setting Play engine initial and start Play module display
Set variable default value (common setting) Set variable default value. If some variable use the same kind default value in any module, for example, gxbUiMenuMainStates should be UI_NO_MENU in any module starting, set the default value at this time. You could do this job easily by calling UI_SET_DEFAULT define. Set variable default value (play module setting) Set variable default value. That default value might not be the same or variable might not be used in other modules, set the default value as this time. Initial error handle Some error might be detected in init module. Ui should handle these errors. If any error detected in init module, gxbLastErrCode would be set the error code. You could check the error code ERR_INIT_xxx (xxx is the error kind) in const.h You could do this job by calling UiCheckIniErr() function. Restore last setting Most of setting value would be restored in init module. UI only need to restore last play file number (gxwCurrentFileNum). Play engine initial and start Just call PeInit() function to do this job. Note: If file system init failed, dont call this function to avoid system crash. Play module display Just call UiReDrawMusicPlayer() function to do this job.
www.ali.com.tw
176
Volume Control
Normal Check Base on State and User Input Control Job (Call Service Function and Change State) Error Handle Get Key
Just call KeyGet() function to do this job. Check Backlight Just call UiCheckBackLight() function to do this job. (This function will check power long key for power off, too) Volume Control Display and control volume when user input volume key. Lyric and Tag Display Display and scroll lyric or tag. For more detail, see section Music Tag Display and Lyric Display above. Normal Check Check system state. Just call UiNormalCheck() function to do this job.
2.27.13.3
www.ali.com.tw
177
Main Menu
Error Handle
Base on User Input Sending Command to Play Engine When system state is wait or pause, UIs job is simple. Just send command to play engine base on user input. An exception is pressing Key 5 would enter main menu.
2.27.13.4
UI_NO_MENU UiGoNoMenu() Key 5 Key 5 Key 2 UI_MUSIC_MENU UI_MUSIC_REPEAT_MENU UiGoMusicMenuRepeat() Key 5 Key 4 Key 6 Key 2 UI_MUSIC_MENU UI_MUSIC_EQ_MENU UiGoMusicMenuEQ() Key 5 Key 4 Key 6 Key 2 UI_MUSIC_MENU UI_MUSIC_3D_MENU UiGoMusicMenu3D() Key 5 UI_3D_MENU ??? UiGoMusic3DMenu() Key 2 Set 3D Mode Key 4 Key 6 UI_EQ_MENU ??? UiGoMusicEqMenu() Key 2 Set EQ Mode Key 4 Key 6 UI_REPEAT_MENU ??? UiGoMusicRepeatMenu() Key 2 Set Repeat Mode Key 4 Key 6
Error Handle
Description When system state is play, UIs job is more complex. See Play State Job picture above. In dotted line box, any block is a state. In the state block, First line is gxbUiMenuMainStates value, second line is gxbUiMenuSubStates value, and last line is the entry function (UI will call this function to enter this state). The symbol
www.ali.com.tw
178
www.ali.com.tw
179
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus) Parameters PBYTE bStatus Return values None Global variable
Example
See also
UiGoNoMenu()
Default state. No menu appear, and sub menu state is dont care. UI should send command to play engine base on user input. void UiGoNoMenu(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
180
2.28.1 UI Play and UI Play DVR The Architecture of UI play and UI play DVR module is similar. You can get the information about System State, Menu State, A-B Repeat State, Random Play List, UiDispCtrl function, and Play Engine Command from section UI Play (UiPlay.c) above. Their contents are the same. The differentia in play DVR module is: Not display tag information Not display music type & bit rate information Not support EQ and 3D function Let user select record source or quality You could separate out not used function by definition _PM_DVR_ 2.28.2 Display function and micro
Display function is almost the same with play module. The different function is: UiShowRecFile() Show record file name (8+3 short file name). Because UI play DVR module not display tag informat, use this function instead of LcdShowTagTitle() function.
2.28.3
Volume Information
If recorded file is mp3 file, UI could get volume information from DSP. Please see section DSP information above. If recorded file is adpcm file, UI should get volume information form gwLastVolIndicator viraible.
www.ali.com.tw
181
UI_NO_MENU UiGoNoMenu() Key 5 Key 7 Long Key 2 UI_REC_MENU UI_REC_FROM_MENU UiGoRecMenuFrom () Key 5 Key 4 Key 6 Key 2 UI_REC_MENU UI_REC_QTY_MENU UiGoRecQtyMenu() Key 5 Key 4 Key 2 UI_MUSIC_MENU UI_MUSIC_REPEAT_MENU UiGoMusicMenuRepeat() Key 5 UI_REPEAT_MENU ??? UiGoMusicRepeatMenu() Key 2 Set Repeat Mode Key 6 UI_QTY_MENU ??? UiGoRecQtyMenu() Key 2 Set Record Quality Key 4 Key 6 UI_FROM_MENU ??? UiGoRecFromMenu() Key 2 Set Record Source Key 4 Key 6
www.ali.com.tw
Key 5
Error Handle
182
www.ali.com.tw
183
Super Loop
Error Handle
2.29.2 System State UI should response base on system state. For example, when system state is in recording state and user input Key 7, UI should send R_PAUSE command to record engine. You can get the system state by reading gxbSysState variable. 2.29.3 UiDispCtrl function UI would call some service function. When these service function cause some events, for example, record engine ready to start recording, UI might need to display or control something at this time. The service function would call back UiDispCtrl() function and let UI to do his job at this time. Parameters: BYTE bStatus The service function set the event in the variable.
www.ali.com.tw
184
M5661 Firmware Programming Guide These are useful event for UI: UI_RE_INIT_START Record engine is preparing to initial. UI_RE_INIT_END Record engine initial has finished. UI_RE_START_START Record engine is preparing to start to record. UI_RE_START_END Record engine is ready to start to record. UI_RE_REC_UPDATE Record engine has updated the recording information. (Ex. Recording time) UI_RE_STOP Record engine has stopped. UI_RE_PAUSE Record engine has paused. UI_RE_RETURN_REC Record engine has continued to record. 2.29.4 Display function and micro You could call these functions to display some information. UiReDrawRec() Clear and redraw record module screen. UiShowRecStatus() Display recording state icon (Record , Pause , Stop , etc) UiShowRecTime() Display recording time UI_SHOW_BATTERY() Display battery icon. (gxbLastBattSts variable value) PS. UiNormalCheck() function will show battery icon. You just use the micro if you want to force display battery icon. 2.29.5 Record Engine Command UI should send command to record engine base on user input. The useful meaning of value for UI is: R_NOP: No command. Record engine will continue recording or waiting. R_REC:
www.ali.com.tw
185
M5661 Firmware Programming Guide Record command. Record engine will continue to record. R_PAUSE: Pause command. Record engine will pause. R_STOP: Stop command. Record engine will stop recording.
Note: UI should send R_STOP command before swaping to another module or power off, or it will lose the recording file.
Set variable default value (common setting) Set variable default value (record module setting) Initial error handle Record engine initial and start Play module display
Set variable default value (common setting) Set variable default value. If some variable use the same kind default value in any module, for example, gxbUiMenuMainStates should be UI_NO_MENU in any module starting, set the default value at this time. You could do this job easily by calling UI_SET_DEFAULT define. Set variable default value (record module setting) Set variable default value. That default value might not be the same or variable might not be used in other modules, set the default value as this time. Initial error handle Some error might be detected in init module. UI should handle these errors. If any error detected in init module, gxbLastErrCode would be set the error code. You could check the error code ERR_INIT_xxx (xxx is the error kind) in const.h You could do this job by calling UiCheckIniErr() function. Record engine initial and start Just call ReInit() and ReStart() function to do this job. Play module display Just call UiReDrawMusicPlayer() function to do this job.
www.ali.com.tw
186
Normal Check
Base on State and User Input Control Job (Call Service Function and Change State)
Error Handle
www.ali.com.tw
187
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus) Parameters BYTE bStatus Return values None Global variable
Example
See also
UiShowWakeUp()
Show alarm display. void UiShowWakeUp(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
188
UI FM FM Module Initial
Super Loop
Error Handle
2.30.2 Menu State UI should response base on menu state. For example, when record quality menu is appeared and user input Key 2, UI should set the record quality value, not control FM chip. You can get the menu state by reading gxbUiMenuMainStates and gxbUiMenuSubStates variable. gxbUiMenuMainStates means which kind menu it entered. gxbUiMenuSubStates means which item user selected. For example, when user enter record quality menu and select Long Time, gxbUiMenuMainStates is UI_QTY_MENU and gxbUiMenuSubStates is UI_QTY_LONG. 2.30.3 UiDispCtrl function UI would call some service function. When these service function cause some events UI might need to display or control something at this time. In FM module, there is only one
www.ali.com.tw
189
M5661 Firmware Programming Guide event that FmChip.c will call back UiDispCtrl. Its UI_FM_SEARCHING. Other events are UI call itself event. Parameters: BYTE bStatus The service function set the event in the variable. These are useful event for UI: UI_FM_SEARCHING FM is searching station. UI_SEL_PRESET_START UI call itself event. User is starting to select a preset station. UI_SEL_PRESET_SELECT UI call itself event. User is selecting preset stations. UI_SAVE_PRESET_START UI call itself event. User is starting to save a preset station. UI_SAVE_PRESET_SELECT UI call itself event. User is selecting preset channel to save preset station. UI_SAVE_PRESET_SAVE UI call itself event. User is saving a preset station. UI_FM_SEARCH_DOWN UI call itself event. User is searching station down. UI_FM_SEARCH_UP UI call itself event. User is searching station up. 2.30.4 Display function and micro You could call these function to display some information. UiReDrawFM() Clear and redraw FM module screen. UiShowFreq() Display current frequency UiShowStereo() Check and display stereo state. UiRedrawStero() Display stereo state. (Call this function to force display stereo state) UiShowPreset() Display preset channel. UiScrollPrset() Scroll preset channel.
www.ali.com.tw
190
M5661 Firmware Programming Guide 2.30.5 Flow Description 2.30.5.1 FM Module Initial
Set variable default value (common setting) Set variable default value (FM module setting) Initial error handle FM chip initial and start FM module display
Set variable default value (common setting) Set variable default value. If some variable use the same kind default value in any module, for example, gxbUiMenuMainStates should be UI_NO_MENU in any module starting, set the default value at this time. You could do this job easily by calling UI_SET_DEFAULT define. Set variable default value (FM module setting) Set variable default value. That default value might not be the same or variable might not be used in other modules, set the default value as this time. Initial error handle Some error might be detected in init module. Ui should handle these errors. If any error detected in init module, gxbLastErrCode would be set the error code. You could check the error code ERR_INIT_xxx (xxx is the error kind) in const.h You could do this job by calling UiCheckIniErr() function. FM chip initial and start Just call FmInit() function to do this job. FM module display Just call UiReDrawFM() function to do this job.
www.ali.com.tw
191
M5661 Firmware Programming Guide 2.30.5.2 Super Loop Common State Job
Get Key
Volume Control
Normal Check Base on State and User Input Control Job (Call Service Function and Change State) Error Handle Get Key
Just call KeyGet() function to do this job. Check Backlight Just call UiCheckBackLight() function to do this job. (This function will check power long key for power off, too) Display Stereo State Just call UiShowStereo() function to do this job. Normal Check Check system state. Just call UiNormalCheck() function to do this job.
www.ali.com.tw
192
Key 7
Key 2
Key 5 Key 4 Key 7 Long Key 6 Key 2 Set Record Quality UI_QTY_MENU ??? UiGoRecQtyMenu()
Error Handle
Description In black dotted line box, any block is a state. In the state block, First line is gxbUiMenuMainStates value, second line is gxbUiMenuSubStates value, and last line is the entry function (UI will call this function to enter this state). The symbol means the value in this state isnt important (dont care). The symbol ??? means the value isnt fixed (dependent on user input or other states). FM Chip Control In red dotted line box, UI should set frequency or search station base on user input in those states. For more detail, see section Fm (FmChip.c) above. UI No Menu State Default state. No menu appear, and sub menu state is dont care. In any program module, when system enter main menu state, UiGoMainMenu() function in UiCommon.c might call back UiGoNoMenu() to enter UI No Menu state if user press Key 5.
www.ali.com.tw
193
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus) Parameters BYTE bStatus Return values None Global variable
Example
See also
UiGoNoMenu()
Default state. No menu appear, and sub menu state is dont care. UI should send command to play engine base on user input. void UiGoNoMenu(void) Parameters None
www.ali.com.tw
194
Example
See also
UiShowWakeUp()
Show alarm display. void UiShowWakeUp(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
195
Time
Adjust Alarm
Adjust On/Off
On Off
Power Setup Language English Chinese(Trad) Chinese(Simp) Contrast Backlight Source Quality Line In MIC Long Time Normal Quality High Quality
Display
Record
User Define EQ
Storage
2.31.2 Menu State In system module, UI should control menu state. You can get the menu state by reading gxbUiMenuMainStates and gxbUiMenuSubStates variable. gxbUiMenuMainStates means which kind menu it entered. gxbUiMenuSubStates means which item user selected. For example, when user enter Time menu and select Adjust, gxbUiMenuMainStates is UI_SYS_TIME_MENU and gxbUiMenuSubStates is UI_TIME_NOW_MENU. 2.31.3 Small Loop Job
www.ali.com.tw
196
Normal Check
UI system module is a tree architecture module. Any tree node is a small loop.
Get Key
Just call KeyGet() function to do this job. Check Backlight Just call UiCheckBackLight() function to do this job. (This function will check power long key for power off, too) Normal Check Check system state. Just call UiNormalCheck() function to do this job.
UI System module architecture would be affected by these definitions in UiCommon.h. UI_USE_REC_SOURCE Define this if hardware support different record source. This define will affect record source menu. UI_USE_STORAGE_SOURCE Define this if hardware support different storage (card reader). This define will affect storage menu. UI_STORAGE_SOURCE_MAX When UI_USE_STORAGE_SOURCE define, how many storages support. UI_SYS_MAX_MENU How many top menu item in system module.
2.31.5 Time Setting
Any module get current time variable gxdwNowTime by hardware RTC counter. For display,
www.ali.com.tw
197
you can call UiSysGetNowTimeText() function to transfer time number to ASCII time string in gxbStringEditTime[] arrary. For more detail, see section UI Common (UiCommon.c) above. For saving time setting, you can call UiTurnTimeText() function to transfer ASCII time string to time number, and then call UiSetNowTime() to save time.
2.31.6 Alarm Setting
You can call UiSysGetAlarmTime() function to get alarm time in variable gxdwAlarmTime. Its the same with time setting, for display, you can call UiSysGetNowTimeText() function to transfer time number to ASCII time string in gxbStringEditTime[] arrary. For saving alarm time setting, you can call UiTurnTimeText() function to transfer ASCII time string to time number, and then call UiSetNewAlarmTime() to save time. Sometime, we need to adjust the alarm time number. For example, current time is 01:00 AM (time number 60), if user set alarm time 00:00 AM, it mean alarm time is 00:00 AM tomorrow. We should adjust alarm time number to 86400 (24hr=86400sec). You can call UiFixAlarmTime() function to do this job.
2.31.7 Power Setting
Initial module will get the power setting in variable gxwAutoOff. You can call UiGetPSaveTime() function to transfer time number to ASCII time string in gxbStringEditPSaveTime[] variable. The meaning of gxwAutoOff is: Bit 15:Auto off option. Set to 1 if auto off enable. Bit 14:Dont auto off when playback option. Set to 1 to enable this option. Bit 13-0:Auto off time value (minutes) UiNormalCheck() function will check this variable and handle auto off job.
2.31.8 Language Setting
You can change system language by setting variable gxbLangueType. The setting value is: LANGUAGE_TYPE_EN: English LANGUAGE_TYPE_TW: Tradition Chinese LANGUAGE_TYPE_CN: Simplified Chinese
2.31.9 Contrast Setting
You can get Lcd contrast value by reading variable gxbLcdContrast. You can call UiShowContrast() function to change Lcd contrast value.
www.ali.com.tw
198
You can change backlight time setting by setting variable gxbBackLightCounter. UiCheckBackLight() function will check this variable and handle backlight job.
2.31.11 Record Setting
You can change system storage by setting variable gxbStorType and gxbStorage. File system use variable gxbStorType and UI use gxbStorage variable. These two variable is usally the same but not always. UI should initial job (SD init, Nand Flash init, file system init, record system init) after user select another storage. For more detail, see section SD (SD.c), NandFlash (NandFlash.c), File System (FileSystem.c), Record (Record.c) above.
2.31.14 API Functions
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus,BYTE bSubStatus) Parameters BYTE bStatus BYTE bSubStatus Return values None Global variable
Example
See also
www.ali.com.tw
199
Example
See also
UiShowWakeUp()
Show alarm display. void UiShowWakeUp(void) Parameters None Return values None Global variable
Example
See also
UiShwCardRemoved()
Card was removed. void UiShwCardRemoved(void) Parameters None Return values None
www.ali.com.tw
200
Example
See also
www.ali.com.tw
201
2.32
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus) Parameters BYTE bStatus Return values None Global variable
Example
See also
UiGoNoMenu()
Default state. No menu appear, and sub menu state is dont care. UI should send command to play engine base on user input. void UiGoNoMenu(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
202
2.33
UiCancelIntroMode()
Cancel intro mode. void UiCancelIntroMode(void) Parameters None Return values None Global variable
Example
See also
UiCountCurtFileNum()
Count curt file numbers. void UiCountCurtFileNum(struct FILE_INF_DATA xdata *stOldFileInf,struct FILE_INF_DATA xdata *stNewFileInf) Parameters struct FILE_INF_DATA xdata *stOldFileInf struct FILE_INF_DATA xdata *stNewFileInf Return values None Global variable
Example
See also
www.ali.com.tw
203
Example
See also
UiGetCurtDirName()
Get curt directory name. void UiGetCurtDirName(void) Parameters None Return values None Global variable
Example
See also
UiGetRndPlayNum()
Gets a random play list num. WORD UiGetRndPlayNum(bit fGetNext) Parameters bit fGetNext If fGetNext==TRUE, get the next song number. If fGetNext==FALSE, get the prev song number. Return values WORD type
www.ali.com.tw
204
Example
See also
UiGoIntroMode()
Set intro mode. void UiGoIntroMode(void) Parameters None Return values None Global variable
Example
See also
UiKeepLastLyric()
Keep last lyric. void UiKeepLastLyric(void) Parameters None Return values None Global variable
Example
See also
UiNextMenuItem()
.
www.ali.com.tw
205
Example
See also
UiPlayLyricControl()
Lyric function. void UiPlayLyricControl(void) Parameters None Return values None Global variable
Example
See also
void UiPrevMenuItem(void)
Example
www.ali.com.tw
206
UiRndPlayInit()
Get a random seed from RTC timer and the current file number. UI should call this function when random play mode starts. void UiRndPlayInit(void) Parameters None Return values None Global variable
Example
See also
UiSetUdefEqVal()
Send user define EQ value to DSP. These value is stored in array gxbUserDefEq[]. void UiSetUdefEqVal(void) Parameters None Return values None Global variable
Example
See also
UiShowWakeUp()
Show alarm display. void UiShowWakeUp(void) Parameters None
www.ali.com.tw
207
Example
See also
www.ali.com.tw
208
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus) Parameters BYTE bStatus Return values None Global variable
Example
See also
UiGoNoMenu()
Default state. No menu appear, and sub menu state is dont care. UI should send command to play engine base on user input. void UiGoNoMenu(void) Parameters None Return values None Global variable
Example
See also
UiSelectItemControl()
Select item for control. void UiSelectItemControl(void)
www.ali.com.tw
209
Example
See also
UiShowMusicMenuText()
Show music menu text. void UiShowMusicMenuText(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
210
2.35
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus) Parameters BYTE bStatus Return values None Global variable
Example
See also
UiGoNoMenu()
Default state. No menu appear, and sub menu state is dont care. UI should send command to play engine base on user input. void UiGoNoMenu(void) Parameters None Return values None Global variable
Example
See also
UiShowMusicMenuText()
Show Music Menu Text.
www.ali.com.tw
211
Example
See also
www.ali.com.tw
212
2.36
USB_Suspend()
Handle USB suspend and resume. void USB_Suspend(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
213
2.37
UiDispCtrl()
Display and control for TARGET Playback. void UiDispCtrl(BYTE bStatus) Parameters BYTE bStatus Return values None Global variable
Example
See also
UiShowSizeNumber()
Display size number (ex: 1024 will show 1K). void UiShowSizeNumber(DWORD dwSecNum, BYTE bPage, BYTE bColNum) Parameters DWORD dwSecNum BYTE bPage BYTE bColNum Return values None Global variable
Example
See also
www.ali.com.tw
214
Example
See also
www.ali.com.tw
215
CdbGetDbSector( )
Get class database start sector in private area. You should call the function before accessing class database. void CdbGetDbSector(void) Parameters None Return values None Global variable gxdwCdbStartSec: Class database start sector gxwCdbMaxSec: The max length of class database (sector) Example
See also
CdbInit()
Class database initial (building database) BOOL CdbInit(void) Parameters None Return values Bit type TRUE: Initialed successfully. FALSE: Initialed failed Global variable
Example
www.ali.com.tw
216
CdbReadSector()
Read a sector from class database PS. While creating database, this function will use a read-write cache system. You should read data from cache and handle it carefully. BOOL CdbReadSector(DWORD dwCdbSec) Parameters DWORD dwCdbSec The sector in class database you want to read Return values Bit type TRUE: successfully. FALSE: failed Global variable
Example
See also
CdbWriteSector()
Write a sector into class database BOOL CdbWriteSector(DWORD dwCdbSec) Parameters DWORD dwCdbSec The sector in class database you want to write Return values Bit type TRUE: successfully. FALSE: failed Global variable
Example
www.ali.com.tw
217
CdbSearchData()
Search a data in class database and load class header info BOOL CdbSearchData(BYTE bSearchType) Parameters BYTE bSearchType The type of searching class database, all supported type is: CDB_SEARCH_FIRST_GENRE CDB_SEARCH_FIRST_ARTIST CDB_SEARCH_FIRST_ALBUM CDB_SEARCH_FIRST_TITLE CDB_SEARCH_LAST_GENRE CDB_SEARCH_LAST_ARTIST CDB_SEARCH_LAST_ALBUM CDB_SEARCH_LAST_TITLE CDB_SEARCH_NEXT CDB_SEARCH_PREV CDB_SEARCH_ENTER CDB_SEARCH_BACK CDB_SEARCH_ENTER_LAST
Return values Bit type TRUE: successfully. FALSE: failed Global variable gdwCdbAddPoint: Current loading address in class database Example
See also
www.ali.com.tw
218
See also
CdbGetClassString()
Load and copy class string BOOL CdbGetClassString(DWORD dwCdbPoint, PBYTE pbStrBuf) Parameters DWORD dwCdbPoint Reading address in class database PBYTE pbStrBuf String buffer for saving class string Return values Bit type TRUE: successfully. FALSE: failed Global variable
Example
See also
www.ali.com.tw
219
CdbGetDataBaseHeader()
Get class database header info DWORD CdbGetDataBaseHeader(BYTE bInfAdd) Parameters BYTE bInfAdd The address of header info Return values DWORD type The class database header info Global variable
Example
See also
CdbLoadDirInfo()
Load dir info PBYTE CdbLoadDirInfo(WORD wDirNum) Parameters WORD wDirNum The dir number Return values PBYTE type Success: Dir info point Failed: CDB_NULL_POINT Global variable
Example
See also
www.ali.com.tw
220
CdbDelLeafNode()
Delete a leaf node (title node) in class database. If no other brother nodes, the function will delete parent node, too. The variable gdwCdbAddPoint would not be changed after calling this function void CdbDelLeafNode(void) Parameters None Return values None Global variable DWORD gdwCdbAddPoint: Current loading address in class database Example
See also
CdbClearHeaderInfo()
Clear class database header info (empty database) void CdbClearHeaderInfo(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
221
Example
See also
CdbBulitDirInfo( )
Built dir infor in class database WORD CdbBulitDirInfo(void) Parameters None Return values WORD type Total dir info number Global variable
Example
See also
CdbSearchDirInf( )
Search Dir Info for making class database WORD CdbSearchDirInf(DWORD dwDirSec,WORD wDirOff) Parameters DWORD dwDirSec The sector of the dir entry WORD wDirOff
www.ali.com.tw
222
Example
See also
CdbCompClassStr( )
Compare Class string BOOL CdbCompClassStr(DWORD dwCdbPoint, PBYTE pbStr) Parameters DWORD dwCdbPoint: The address in class database PBYTE pbStr: The compared string buffer Return values BOOL type TRUE: The string is the same FALSE: The string is different Global variable
Example
See also
CdbClearNode( )
Clean and set current class info struct (stCdbClassInfo) void CdbClearNode(BYTE bClassMode) Parameters BYTE bClassMode: The class mode of the node Return values None
www.ali.com.tw
223
Example
See also
CdbNewNode( )
Built a new class node in class database DWORD CdbNewNode(BYTE bClassMode, DWORD dwParentPoint, BOOL fNextNode) Parameters BYTE bClassMode: The class mode of the node DWORD dwParentPoint The address of the parent node in class database BOOL fNextNode TRUE: Building next node FALSE: Building enter node Return values DWORD type The address of new node in class database (original gxdwCdbEmptyPoint) Global variable gxdwCdbEmptyPoint: The empty address in class database. The variable will point to next empty address after calling the function. Example
See also
CdbLoadAllUnKnownTag( )
Load all of unkown tag string to sram void CdbLoadAllUnKnownTag(void) Parameters None Return values None Global variable
www.ali.com.tw
224
See also
CdbNewFirstNode( )
Built first node of one class DWORD CdbNewFirstNode(BYTE bClassMode) Parameters BYTE bClassMode: The class mode of the node Return values DWORD type The address of new node in class database (original gxdwCdbEmptyPoint) Global variable gxdwCdbEmptyPoint: The empty address in class database. The variable will point to next empty address after calling the function. Example
CdbIncMusicNumInNode( )
Increase Total Music Number in class node void CdbIncMusicNumInNode(void) Parameters None Return values None Global variable
Example
See also
CdbFindAndBulitClass( )
Find the parent node and built new node in class database BOOL CdbFindAndBulitClass(BYTE bSearchType, BYTE bClassMode)
www.ali.com.tw
225
CdbUpdateHeaderEndInf( )
Update header info about the end point and number void CdbUpdateHeaderEndInf(void) Parameters None Return values None Global variable
Example
See also
CdbScanChildNode( )
Get child node number and end point void CdbScanChildNode(void) Parameters None Return values None
www.ali.com.tw
226
See also
CdbBulitClassEndInf( )
Built class info about end point void CdbBulitClassEndInf(void) Parameters None Return values None Global variable
Example
See also
CdbBulitClassInfo( )
Built class info in class database BOOL CdbBulitClassInfo(void) Parameters None Return values Bit type TRUE: successfully. FALSE: failed Global variable gxdwCdbEmptyPoint: The empty address in class database. gxwNumTotalFiles: Total music file number Example
www.ali.com.tw
227
Example
See also
CdbReadFlashSector( )
Read a sector (I/O read, No cache) BOOL CdbReadFlashSector(DWORD dwCdbSec) Parameters DWORD dwCdbSec The sector number in class database Return values Bit type TRUE: successfully. FALSE: failed Global variable
Example
CdbUpdateOneBlock( )
Update 1 block(16bytes) memory data in class database BOOL CdbUpdateOneBlock(DWORD dwCdbPoint, PBYTE pbSoureceData) Parameters DWORD dwCdbPoint The address in class database PBYTE pbSourceData
www.ali.com.tw
228
Example
See also
CdbLoadGenreString( )
Load Genre String (GenreTable) from NnadFlash void CdbLoadGenreString(BYTE bGenreNum, PBYTE pbBuffer) Parameters BYTE bGenreNum The genre number of ID3v1 PBYTE pbBuffer String buffer Return values None Global variable
Example
See also
CdbGenreNumToString( )
Transfer ID3v2 genre number to string. Ex. (0) will be transfer to Blues void CdbGenreNumToString(void) Parameters None Return values None Global variable
Example
www.ali.com.tw
229
CdbGetTagInfo( )
Get Music Tag Info BOOL CdbGetTagInfo(void) Parameters None Return values Bit type TRUE: successfully. FALSE: failed Global variable
Example
See also
CdbAnsiToUnicode( )
Transfer Ansi string to Unicode String void CdbAnsiToUnicode(PBYTE pbString,BYTE bStrMaxLen) Parameters PBYTE pbString Source string buffer BYTE bStrMaxLen Max length of target buffer Return values None Global variable
Example
See also
CdbModifyNodeLink( )
Read and modify a node link (DWORD) void CdbModifyNodeLink(DWORD dwAddrPoint,DWORD dwNewLink) Parameters DWORD dwAddrPoint
www.ali.com.tw
230
Example
See also
CdbDecreaseNodeItemNum( )
Decrease item number after current node void CdbDecreaseNodeItemNum(void) Parameters None Return values None Global variable
Example
See also
CdbInitDataCache( )
Init CDB data cache void CdbInitDataCache(void) Parameters None Return values None Global variable
Example
See also
www.ali.com.tw
231
See also
CdbUpdateDataCache( )
Update CDB cache for building database void CdbUpdateDataCache(PBYTE pbClassStrBuf) Parameters PBYTE pbClassStrBuf The class string buffer Return values None Global variable gxbCdbCacheModuleNum: Select data cache module Example
See also
CdbInitSysCache( )
Init CDB system cache void CdbInitSysCache(void) Parameters None
www.ali.com.tw
232
Example
See also
CdbSearchSysCache( )
Search CDB system cache for building database PS. Do NOT call this function if you read the same sector BOOL CdbSearchSysCache(DWORD dwCdbSec) Parameters DWORD dwCdbSec The sector in class database Return values BOOL Type: CDB_SEARCH_CACHE_HIT: Sector found in data cache CDB_SEARCH_CACHE_MISS: Sector not found in data cache Global variable gxbCurtSysCacheNum: Current system cache number to read/write gxwSysCacheTimeStamp: Current system cache time stemp Example
See also
CdbSysCacheReadNewSector( )
Read a new sector to sys cache, you should call this function after searching system cache miss BOOL CdbSysCacheReadNewSector(DWORD dwCdbSec) Parameters DWORD dwCdbSec The sector in class database Return values Bit type TRUE: successfully.
www.ali.com.tw
233
Example
See also
CdbMoveBufAndSysCache( )
Move one sector system cache data void CdbMoveBufAndSysCache(BYTE bSysCacheNum,BOOL fBuf2Cache) Parameters BYTE bSysCacheNum The system cache number you want to access BOOL fBuf2Cache TRUE: Move data from I/O buffer to system cache FALSE: Move data from system cache to I/O buffer Return values None Global variable
Example
See also
CdbGet2kStartAddr( )
Get Nand-Flash 2K page start address DWORD CdbGet2kStartAddr(DWORD dwCdbSec) Parameters DWORD dwCdbSec The sector in class database Return values DWORD Type: 2K page start address Global variable
Example
www.ali.com.tw
234
CdbWriteDownDirtySysCache( )
Write down dirty (modified) system cache data. (It will write down the same 2K page data if necessary) BOOL CdbWriteDownDirtySysCache(BYTE bSysCacheNum) Parameters BYTE bSysCacheNum The system cache number Return values Bit type TRUE: successfully. FALSE: failed Global variable
Example
See also
www.ali.com.tw
235