ADVERTISEMENT

ALI-M5661.rar

prosba do serwisujących sprzęt audio DK-Digital -

Co dokladnie tlumaczyc bo nie kumam? Dodano po 8 : Załaczam wskazane wczesniej dokumenty o ALIM5661. Wiadomo jak to z rapidami...


Download file - link to post
  • ALI-M5661.rar
    • UserManual.pdf
    • ProgGuide.pdf
    • HiColor UserManual.pdf
    • FirmwareBlock.pdf
    • User Manual.pdf
    • BootSequence.pdf
    • New IC SAR ADC(brief).pdf
    • Flash Card Support.pdf


ALI-M5661.rar > HiColor UserManual.pdf

M5661 HiColor OELD EV-Board User Manual

M5661 HiColor OLED EV-Board User Manual

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
1

M5661 HiColor OELD EV-Board User Manual

Revision History
Version

Date

1.00

Jul. 17, 2005

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.
Copyright © ALi Corporation, 2004. All rights reserved

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
History

Date
7/17

Version
1.00

Customer_X

Description
Who
High color (64K) OLED EV board user Jeff H.S. Lin
guide

____________________________________________________________________
www.ali.com.tw
ALi Confidential
2

Contents
Contents ............................................................................................................................................. 3
1
Features ...................................................................................................................................... 3
2
Overview.................................................................................................................................... 6
3
USB Device ............................................................................................................................... 6
3.1
MSC mode ................................................................................................................. 7
3.2
MTP mode.................................................................................................................. 8
4
Stand-Alone Digital Audio Device............................................................................................ 9
4.1
Power On/Off............................................................................................................. 9
4.2 Change mode ..................................................................................................................... 10
5
Music Playback........................................................................................................................ 11
5.1 Playback............................................................................................................................. 12
5.2 Pause .................................................................................................................................. 12
5.3 Stop .................................................................................................................................... 12
5.4 File navigation (Select folder/file) ..................................................................................... 12
5.5 Select file ........................................................................................................................... 12
5.6 Fast backward/forward....................................................................................................... 12
5.7 Playback Sub-Menu ........................................................................................................... 13
5.8 A-B Repeat......................................................................................................................... 15
5.9 Adjust Volume.................................................................................................................... 15
6
DVR (Digital Voice Recording) .............................................................................................. 16
6.1
Record to a File........................................................................................................ 17
6.2
DVR Recording Sub-Menu...................................................................................... 18
6.3
Play a recorded file. ................................................................................................. 19
7
FM Radio ................................................................................................................................. 19
7.1
Adjust Frequency ..................................................................................................... 19
7.2
Automatic Search..................................................................................................... 20
7.3
Edit Preset Frequency .............................................................................................. 20
7.4
Select Preset Frequency ........................................................................................... 20
7.5
Adjust Volume.......................................................................................................... 20
8
Photo View............................................................................................................................... 20
9
File Manager ............................................................................................................................ 20
10
Setup ................................................................................................................................ 21
10.1
Usb Mode................................................................................................................. 24
10.2
Time ......................................................................................................................... 24
10.3
Power ....................................................................................................................... 25
10.4
Language.................................................................................................................. 26
10.5
Display ..................................................................................................................... 26
10.6
Recording................................................................................................................. 26
10.7
Sys Tools .................................................................................................................. 26
10.8
Custom EQ............................................................................................................... 26
10.9
Storage ..................................................................................................................... 27
11
Firmware Upgrade (End-User) ........................................................................................ 27
11.1
“End-User Firmware Upgrade” utility..................................................................... 27
12
Firmware Upgrade (Engineering) .................................................................................... 28

1

System Features
Support internal memory (NAND flash) and external memory card

M5661 HiColor OELD EV-Board User Manual

NAND flash type:
" M5661 Pen Drive
Flash-Card Support.xls

External memory card type: SD, MMC,
Player:
Playback source: internal memory or external memory card
Support MP3 decoding:
Bit rate: 8K bps ~ 320K bps
Sampling rate: 8K ~48K
Channel: Stereo
Support WMA decoding:
Bit rate: 5K bps ~ 320K bps
Sampling rate: 8K ~48K
Channel: Stereo
Support IMA-ADPCM decoding:
Bit rate: 32K bps ~ 352 K bps
Sampling rate: 8K ~ 44.1K
Channel: Mono/Stereo
Support Lyrics display from
LRC text file format
Support artist / title / album display from
MP3 tag: V1.0, V2.2, V2.3, V2.4
WMA content metadata
Support A-B repeat.
Support adjustable playback rate.
Support fast forward / backward playback.
Support long file-name, file navigation
Selectable repeat mode: no repeat, single repeat, repeat all, and random all.
Selectable equalizer mode: Normal / Pop / Rock / Classic / Jazz / Bass / User EQ.
Selectable virtual surround mode: enable or disable.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Voice Recorder
Released Version for
Record source: Line-In, or MIC, or FM
Record target: internal memory or external memory card
Selectable record mode: high quality, normal quality, or long-time mode
Support the following MP3 encoding modes:
256K bps, 44.1K sampling, stereo
128K bps, 44.1K sampling, stereo
64K bps, 22.05K sampling, stereo
32K bps, 16K sampling, mono
16K bps, 12K sampling, mono
Support the following IMA-ADPCM encoding modes:

Customer_X

Sampling: 8K ,
Sampling: 11.025K,
Sampling: 16K,
Sampling: 22.05K,

Mono,
Mono,
Mono,
Mono,

Bit rate: 32K
Bit rate: 44K
Bit rate: 64K
Bit rate 88K

____________________________________________________________________
www.ali.com.tw
ALi Confidential
4

M5661 HiColor OELD EV-Board User Manual
Sampling: 32K
Sampling: 44.1K

Mono,
Mono,

Bit rate 128K
Bit rate 176k

Sampling: 8K ,
Sampling: 11.025K ,
Sampling: 16K,
Sampling: 22.05K,
Sampling: 32K
Sampling: 44.1K

Stereo,
Stereo,
Stereo,
Stereo,
Stereo,
Stereo,

Bit rate: 64K
Bit rate: 88K
Bit rate: 128K
Bit rate:: 172K
Bit rate 256K
Bit rate 352K

The summary of file format with different source and quality mode
Line In/ FM
MIC
High
MP3, 128K bps, 44.1K, stereo MP3, 32K bps, 16K, mono
Normal
MP3, 64K bps, 22.05K, stereo MP3, 16K bps, 12K, mono
Long time MP3, 32K bps, 16K, mono
ADPCM, 32K bps, 8K, mono
Support VAD in MP3 / IMA-ADPCM encoding mode.
The VAD sensitivity level is adjustable.( 69 / 76 / 83 dBV)

FM Tuner
Frequency: 87.5 ~108 MHz
Tuner can adjust step by step or automatically search.
User can set 10 preset bands
JPG, and BMP file photo view
Support baseline JPG file

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

USB host copy function
Support file navigation to manage (copy/delete) the file object between external
USB flash disk and internal NAND flash disk. (copy, delete)
Support USB Mass Storage Class device.
Clock
Time
Alarm
LCD

Customer_X

Selectable contrast
Selectable backlight time

Automatic power off
Selectable power off time
Enable or disable power off function in playback is selectable
Multi-language
Support Unicode for metadata information display and filename.
User interface menu can select Traditional Chinese, Simplified Chinese, or English.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
5

M5661 HiColor OELD EV-Board User Manual

Return to the environment last time automatically when power on

2

User Guide Overview
M5661 can operate in two types: USB flash disk / digital audio device (stand-alone).
If plugged to PC, it will become an USB flash disk. When it is stand-alone, it will become a
portable digital audio device.

Buttons:
Button ID
VolPlay

Key number
PB2
PB1

Vol+
Prev
Function
Next
Rec
Mode

PB3
PB4
PB5
PB6
PB7
PB8

Function
Volume decrease
PowerOn,
Play,
Pause,
PowerOff
Volume increase
Previous
Command/Function
Next
Recording/A-B repeat
Mode change

The EV board block diagram:

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
LCD

Line-In

Mic

Headset

FM

PB2, Vol-

PB6, Next

PB1, Play

PB5, Function

PB3, Vol+

PB4, Prev

Customer_X
PB7, Rec

]

3

USB host port
(Behind
the
USB
device
port)

PB8, Mode

USB

USB
port

device

USB Device
Plug the device to PC’s USB port the LCD panel will display the following icon according to
current USB Device mode:

____________________________________________________________________
www.ali.com.tw
ALi Confidential
6

M5661 HiColor OELD EV-Board User Manual

DRM-10-compliant firmware (version 1.60.xx series) supports both MTP mode and MSC
mode (USB mass storage class). If the firmware just supports MSC mode (Version 1.50.xx
series ), it will just show up MSC icon on LCD.

3.1 MSC mode
When M5661 device (MSC mode) gets connected to PC, and is in idle state.

PC is writing data to M5661 device.

PC is reading data from M5661 device

And the removable disk(s) icons will show up on “My Computer”:
(If external Flash Disk enabled (MMC/SD), there will be two disk icons)

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
7

M5661 HiColor OELD EV-Board User Manual

3.2 MTP mode.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
And the portable media player icon(s) will show up on “My Computer”:
Released Version for
(If external Flash Disk enabled (MMC/SD), there will be two icons)

When M5661 device (MTP mode) gets connected to PC (support XP only), and is in idle state.

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
8

M5661 HiColor OELD EV-Board User Manual

Windows Media Player 10 will detect M5661 device and display icon(s) on the screen.
User can sync transfer the content to M5661 device.
(If external Flash Disk enabled (MMC/SD), there will be two icons)

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X
4 Stand-Alone Digital Audio Device
4.1 Power On/Off
Press the button Play (key1) can turn on the device, and press and hold this button will turn off
the device.
When power on, the LCD panel will display the power-on animation:

____________________________________________________________________
www.ali.com.tw
ALi Confidential
9

M5661 HiColor OELD EV-Board User Manual

Then it will go to the mode directly (Music, Voice, FM, Photo, File Manger, or Setup) when
user powered off the device last time.
Note:
1. The device can memorize the last mode. If it was turned off from FM mode, it will return to
FM mode when turning on.
2. The default mode is Music mode.

4.2 Change mode
Press the mode button (key 8) can change the mode, and the change sequence is as followed:
Music --- FM --- DVR --- Photo View --- File Manager --- System Setup
Layer 1

Layer 2

Music

FM

DVR

Photo

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

File Manager

Setup

____________________________________________________________________
www.ali.com.tw
ALi Confidential
10

M5661 HiColor OELD EV-Board User Manual

5

Music Playback

EQ (*1)

3D Sound on/off status

Repeat mode (*2)

A-B repeat

WMA/MP3 bit rate

Battery status

Current file no / total file no
ID3 Tag, metadata

Lyric

External Memory Card
Alarm (on/off)
Lock (on/off)
Right channel volume bar
Total music time
Playback Status (*1)
Playback progress bar

*1 – EQ
Normal
Pop
Rock
Classic
Jazz
Bass
User EQ

*2 – Repeat modes:
No repeat:
Single repeat:

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

Repeat all:
Random repeat all:
* 3 - Playback status:
Stop
Playback
Pause
____________________________________________________________________
www.ali.com.tw
ALi Confidential
11

M5661 HiColor OELD EV-Board User Manual

Fast Forward
Fast Backward

Layer 1

Layer 2

Layer 3

Music

Playback

File navigation

Layer 4

Layer 5

5.1 Playback
When the device status is stop or pause, press the button Play (key 1) to playback.

5.2 Pause
When the device status is playback, press the button Play (key 1) will pause it.

5.3 Stop
When the device status is playback or pause, long press the Button Menu (key 5) to stop
music playback.

5.4 File navigation (Select folder/file)
Long press the Button Menu (key 5) will enter folder/file browsing. User can browse all files in
the current folder. Using the button Prev (key 4) / Next (key 6) to move the cursor up/down to
the target object, then press the button Play (key 1) to play the selected file.(i.e. play from the
current folder which contains the selected file.). Press the button Menu (key 5) can abort
browsing folder/file, and go back to the playback mode.

揚智機密不得洩漏
ALI CONFIDENTIAL
Press button Play at a folder will go into that folder.
NO DISCLOSURE
Released Version for
Current opened folder

Music file

Customer_X

Only supported music file will be displayed on the LCD, such as MP3 and WMA files.

5.5 Select file
Press the button Prev (key 4) / Next (key 6) to select previous / next file. User can select
previous / next file in any status.

5.6 Fast backward/forward
When the device status is in playback, long press the button Prev (key 4) / Next (key 6) will
fast backward/forward the current file. Fast forward / backward will gradually speed up to 16
x when user doesn’t release the Prev / Next.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
12

M5661 HiColor OELD EV-Board User Manual

FF can move to next file when reaching the end of file. FB doesn’t support this feature.

5.7 Playback Sub-Menu
The topology of playback sub-menu function
Layer 1
Playback

Layer 2
Repeat

Layer 3

Layer 4

Layer 5

No Repeat

Single Repeat

Repeat All

Random Repeat
All

EQ

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
Normal

Pop

Rock

Customer_X
Classic

Jazz

____________________________________________________________________
www.ali.com.tw
ALi Confidential
13

M5661 HiColor OELD EV-Board User Manual

Bass

User EQ

3D sound

Adjustment

On

On

Play Rate

1.00x

1.14x

1.33x

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
0.67x

0.80x

Intro

Customer_X
Adjustment

When the device is in Playback mode, press the button Menu(key 5) will enter playback
sub-menu.
Press button Prev (key 4) / Next (key 6) to select an item, and press button Play (key 1) to
____________________________________________________________________
www.ali.com.tw
ALi Confidential
14

M5661 HiColor OELD EV-Board User Manual

select it.
The items of sub-menu include: Repeat, Equalizer, 3D surround and Play rate, Inro.
(1) Change Repeat Mode
Go to the playback sub-menu and select Repeat mode, there are four repeat modes on the
list:
No Repeat: Just play the current file. Stop playback when done.
All: Repeatedly play all files, (starting from current file)
Single: Repeatedly play current file.
Random repeat all: Repeatedly play a random file (randomly selected from all).
(2) Change Equalizer Mode
Go to the playback sub-menu and select Equalizer mode, there are seven Equalizer
modes on the list: Normal, Pop, Rock, Classic, Jazz, Bass, and User define.
(3) Virtual 3D Surround
Go to the playback sub-menu and select Virtual Surround mode, user can enable or
Disable the Virtual Surround function.
(4) Change Play Rate
Go to the playback sub-menu and select Play Rate item, user can adjust the play rate.
The options of play rate are 0.67x, 0.80x, 1.00x, 1.14x, 1.33x.
(5) Intro playback
Intro playback is to play just a short period of content, instead of the entire file, let user
can quickly scan all audio content in the disk. User can set the Intro period 0 ~ 15
seconds. 0 second means disable this function.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Intro-Period adjustment
Released Version for

5.8 A-B Repeat

Customer_X

During playback, press the button Rec (key 7) to set the start point of the A-B repeat section,
and press this button again can set the end point of the A-B repeat section. The device will play
the section repeatedly. After that, press the same button again will cancel the A-B repeat mode.

5.9 Adjust Volume
In any playbackstate, press the button Vol- (key 2) to decrease the volume, or press the button
Vol+ (key 3) to increase volume.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
15

M5661 HiColor OELD EV-Board User Manual

(step: 0 ~ 31)

6

DVR (Digital Voice Recording)
In DVR mode, user can record sound from Line In, MIC to digital files, and play the voice
recording files.

Playback mode:
Repeat mode

External memory card

File format and bit rate

Key hold

DVR icon

Alarm
Battery

Current file no / Total
file no.
Right channel indicator
Total playback time
Left channel indicator
Playback status (*1)

揚智機密不得洩漏
ALI CONFIDENTIAL
Recording mode (when pressing button Rec)
NO DISCLOSURE
Released Version for
Playback progress
Filename

Voice source (*3)

Recording status (blinking)

Customer_X
*1 – Playback status icons:
Stop
Playback
Pause
Fast Forward
Fast Backward
____________________________________________________________________
www.ali.com.tw
ALi Confidential
16

M5661 HiColor OELD EV-Board User Manual

*2 – Repeat mode icons:
No repeat:
Single repeat:
Repeat all:
Random repeat all:

*3 –

In recording mode, this is the voice source icon.
Line In :
Mic
:

6.1 Record to a File
(1) General Recording Function
When the device status is stop or pause, press button Rec (key 7) will start recording.
During recording, press button Rec (key 7) can pause it, and press the same button (key 7)
again will continue recording. In the end, press button Menu (key 5) to stop recording and
save the recording file.
(2) The Recording Folder and Filename format
The recording file will be saved in different folders, according to the recording quality and
voice source.
For example, the FM recording files will be saved in folder “\FMIN” .

揚智機密不得洩漏
ALI CONFIDENTIAL
The unified filename format is,
" MIC " / " LINE " / “FM” + seriesNO +DISCLOSURE
number " .MP3 " / " .WAV”.
Such as,
Released Version for
“MIC0001.WAV”, “MIC0002.MP3”, “LINE0003.WAV”, “FM00001.MP3” …

And, the recording filename will contain prefix to indicate the voice source, serial number,
and file type.

Customer_X

(3) Auto Insert Recording Serial Number Name.
The serial number of recording filename increases every time. When filename already exits,
it will search for next available serial number to make up its filename.
(4) VAD Recording Function
When the recording voice is quieter than background sound, the device automatically
pauses recording and the icon
will disappear. Then, if the recording voice is louder than
background sound, it will automatically record and Blink the item
again. The
background sound means that the first sound after pressing the button Rec (key 7).

____________________________________________________________________
www.ali.com.tw
ALi Confidential
17

M5661 HiColor OELD EV-Board User Manual

6.2 DVR Recording Sub-Menu
When the device status is stop, long press the button Rec (key 7) will enter the DVR sub-menu.
Then press button Prev (key 4) or button Next (key 6) to move item, and press button Play
(key 1) to select it or press button Menu (key 5) to exit it. The items of sub-menu are:
Source, Quality and VAD.

Layer 1

Layer 2

DVR

DVR playback

Layer 3

Layer 4

Source

MIC

DVR Record

Layer 5

Line-In

Quality

Adjustment

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
VAD

Off

On

(1) Change the Source
Go to the recording sub-menu and select source item. Under this item, user can select “Line
In” or “Mic” as the source.

Customer_X

Voice source

MIC

Line-In

____________________________________________________________________
www.ali.com.tw
ALi Confidential
18

M5661 HiColor OELD EV-Board User Manual

(2) Change the Quality
Go to the recording sub-menu and select quality item. Under this item, user can select the
quality degree. (4 degrees)
Quality

Adjustment

(3) VAD Function Selection
Go to the recording sub-menu and select VAD item. Under this item, user can select
whether using VAD (voice active detection) function
VAD

Off

On

揚智機密不得洩漏
6.3 Play a recorded file.ALI CONFIDENTIAL
The operation of playback is similar to music playback mode.
NO DISCLOSURE
Press button Menu will go into DVR Playback Sub-Menu, to change Repeat mode, Intro
Playback Period, and Play Rate ( see the Music Playback).
Released Version for
.

7

FM Radio
Layer 1
FM

Customer_X

Layer 2
FM playback

Layer 3
Preset Edit

Layer 4

Layer 5

7.1 A
djust Frequency
Press button Prev (key 4) to decrease the frequency, and press button Next (key 5) to increase
____________________________________________________________________
www.ali.com.tw
ALi Confidential
19

M5661 HiColor OELD EV-Board User Manual

the frequency. Each step is 0.1 MHz.

7.2 Automatic Search
Long press button Prev (key 4) will decrease the frequency and search a radio station
automatically. Long press button Next (key 6) will search band will increase the frequency to
search a radio station.

7.3 Edit Preset Frequency
Long press function key (key 5) and the LCD panel will display preset number and frequency.

As the operation of “Adjust Frequency” or “Automatic Search”, to select a frequency, and
press the button Rec (key 7) to save the frequency to current preset number. After that, the
preset number will go to the next automatically, and let user to save next preset frequency. If
user want to edit specific preset number, press button Play (key 1) to change the preset number.
Finally, press the Button Menu (key5) to close the edit mode.

7.4 Select Preset Frequency
After edit preset frequency, user can change the frequency directly by select the preset number.
Just press the button Play (key 1) to select the preset number.

7.5 Adjust Volume

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

In any state, press the button Vol- (key 2) to decrease the volume, or press the button Vol+
(key 3) to increase volume.

8

Photo View
Layer 1
Photo

Layer 2
Source disk

Layer 3
File navigation

Layer 4

Layer 5

Customer_X
Only supported picture file will be displayed on the screen. (BMP and JPG files)
Press button Next / Prev to select the photo file, then press button Play to view the photo.
Press Play at a folder will go into it.

9

File Manager

____________________________________________________________________
www.ali.com.tw
ALi Confidential
20

M5661 HiColor OELD EV-Board User Manual

The topology:
Layer 1

Layer 2

Layer 3

Layer 4

File manager

Source disk

Partition

Function

Layer 5

File navigation

Select a source disk from menu

Select a partition from the source disk
Press button Play will enter file navigation, press button Menu will enter function menu

File navigation:

揚智機密不得洩漏
ALI CONFIDENTIAL
Button Next / Prev: move to the object
Button Vol+: to check (select) the file object.
Button Play: go into the folder in the current object is a folder
NO DISCLOSURE
Button Menu: go into function menu, to Copy / Delete / View file information.
Released Version for

Customer_X
Press button Menu again will cancel the operation
Press button Play will perform the selected function.

10 Setup
In setup mode, user can change the system settings. The common operation of this mode is to
press the button Play (key 1) to select, press the button Menu (key 5) to cancel, and press the
____________________________________________________________________
www.ali.com.tw
ALi Confidential
21

M5661 HiColor OELD EV-Board User Manual

button Prev (key 4) or the button Next (key 6) to move item.
The topology of System Setup menu

Layer 1
Setup

Layer 2
USB mode

Layer 3

Layer 4

Layer 5

Layer 6

Pen drive
(MSC mode)

DRM download
(MTP mode)

Time

Set clock

Adjustment

Set alarm

Edit alarm

Adjustment

On/Off

Off

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
On

Power saving

Language

Setting

Customer_X
Chinese Tran

Chinese Simp

English

____________________________________________________________________
www.ali.com.tw
ALi Confidential
22

M5661 HiColor OELD EV-Board User Manual

Display

Adjustment

Backlight

Record

Contrast

Adjustment

Source

Mic

Line-In

Quality

Adjustment

VAD

Off

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
On

System Tool

Format

Quick format

No

Customer_X
Yes

Full format

No

Yes

____________________________________________________________________
www.ali.com.tw
ALi Confidential
23

M5661 HiColor OELD EV-Board User Manual

Default

No

Yes

System Info

User EQ

Adjustment

Storage

Information

Internal

SD / MMC

10.1 Usb Mode

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
Pen Drive”, the device will act as a USB pen drive when plugging

(1) Pen Drive
Select “USB Mode
into USB port.
(2) DRM Download
Select “USB Mode DRM Download”, the device will act as a MTP device when
plugging into USB port. It is used to download the Janus-DRM-protected (Digital Right
Management) media files and license through WMP 10(Windows Media Player 10), and it
only supports Windows XP SP1 above.

Customer_X

10.2 Time
(1) Adjust
Select “Time Adjust”, and the LCD panel will display current time.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
24

M5661 HiColor OELD EV-Board User Manual

Press the button Prev (key 4) or button Next (key 6) to move cursor, and then press the
button Vol- (key 2) / Vol+ (key 3) to change the value. The time is set while adjusting. In
the end, press the button Play (key 1) or the Button Menu (key 5) to return to Setup menu.
(2) Alarm
Select “Time Alarm Adjust”, and the LCD panel will display current alarm time.

Press the button Prev (key 4) / Next (key 6) to move cursor, and then press the button Vol(key2) / Vol+ (key 3) to change the value. The alarm time is set while adjusting. In the end,
press the button Play (key 1) / the Button Menu (key 5) to return to Setup menu.
Select “Time Alarm On/Off On” to enable the alarm function; or
select ”Time Alarm On/Off Off” to disable the alarm function.
When the alarm function is turned on, the LCD panel will display alarm icon

10.3 Power

揚智機密不得洩漏
ALI CONFIDENTIAL
Auto-off timer
NO DISCLOSURE
Released Version for

Select the power item, and the LCD panel will display as follows:

Auto power off
Always on
playback

in

Customer_X

Auto-Off: Auto Power Off setting
Press button Prev (key 4) / Next (key 6) to move cursor, and then press the button Vol- (key 2)
/ Vol+ (key 3) to change the value. If user adjust the number to “020”, it means the device will
power off automatically if the user doesn’t press any key in twenty minutes. When the
Auto-Off timer expires, system will check the item ”Always on in playback”. If this item is
checked and the device is playing songs, system won’t power off the device. This setting is
useful for sleeping mode.
When user wants to enjoy music while sleeping, and automatically power off the device when
all songs are played out. He can set " Auto Off " timer, and checked the flag " Always on in
playback "
.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
25

M5661 HiColor OELD EV-Board User Manual

10.4 Language
User can select language to change the system menu and information display. The current EV
board supports three kinds of languages including English, Chinese (Trad.), Chinese (Simp).

10.5 Display
(1) Contrast
Select “Display Contrast”; press button Prev (key 4) / Next (key 6) to change contrast,
and then press the button Play (key 1) or the Button Menu (key 5) to return to Setup menu.

(2) Backlight
Select “Display Backlight”; press the button Prev (key 4) or button Next (key 6) to
change the backlight time, and then press the button Play (key 1) or the Button Menu (key
5) to return to menu.

10.6 Recording
(1) Recording Source
Select “Record Source Line In” to set recording from “Line In” input;
Or select “Record Source MIC” to set recording from device’s built-in microphone.
(2) Record Quality
Select “Record Quality Long Time” for voice quality and smaller file size.
Select “Record Quality Normal Quality” for radio quality and normal file size.
Select “Record Quality High Quality” for CD quality and bigger file size.

揚智機密不得洩漏
(3) VAD functional selection ALI CONFIDENTIAL
Select “Record VAD” to turn on/off VAD function.
NO DISCLOSURE
10.7 Sys Tools
Released Version for
(2) Format
Select “Sys Tools Format Quick” to quickly format;
Select “Sys Tools Format Complete” to completely format as the FAT16 file system.
(3) Reset
Select “Sys Tools

Customer_X

Reset” to reset the portable audio player to the default setting.

(4) System Info
Select “Sys Tools System Info” to check the system information: Firmware version, Chip
version, and free space of the internal memory.

10.8 Custom EQ
Select the “Custom EQ” item to adjust the custom EQ. Press the button Prev (key 4) / Next
____________________________________________________________________
www.ali.com.tw
ALi Confidential
26

M5661 HiColor OELD EV-Board User Manual

(key 6) to move cursor, and then press the button Vol- (key 2) / Vol+ (key 3) to change the
value.

10.9 Storage
Select “Storage Internal” to playback from or record to device’s internal memory. Select
“Storage SD/MMC Card” to playback from or record to device’s external SD/MMC card.
When the device is selected to use the external memory card to playback or recording, the
LCD panel will show a disk icon (

) to indicate that system is using external memory card.

11 Firmware Upgrade (End-User)
11.1

“End-User Firmware Upgrade” utility

User can upgrade the firmware binary by the “End-User Firmware Upgrade” utility

1.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
If there is no such device connected on the USB host port, a warning message will show .
Released Version for

Customer_X
2.

If more than one device connected on the USB host, a warning message will show .

____________________________________________________________________
www.ali.com.tw
ALi Confidential
27

M5661 HiColor OELD EV-Board User Manual

3.

This tool only burning one device every time. Confirmation dialog box will ask user to begin
firmware upgrade process.

4.

揚智機密不得洩漏
process finishes, a message box will display.
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

After clicking the [Yes], the firmware upgrade will proceed. When the firmware upgrade

Customer_X
The new firmware won't take effect until user re-plugs the device to PC.

12 Firmware Upgrade (Engineering)
This is a firmware Upgrade utility for engineering purpose (User can change some
____________________________________________________________________
www.ali.com.tw
ALi Confidential
28

M5661 HiColor OELD EV-Board User Manual

configurable information before burning the firmware binary to the M5661 device)
Step1.
1. Select Config + FW or Upgrade ProgramModule only

2. Select
Nandflash Type

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
3. Press it

Step2.

Customer_X

Select
Source Code

Press it

____________________________________________________________________
www.ali.com.tw
ALi Confidential
29

M5661 HiColor OELD EV-Board User Manual

Step3.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
30


ALI-M5661.rar > FirmwareBlock.pdf

M5661 Firmware Block
David Chiu

ALi Confidential

1

Project Structure
User
Interface

DDM

LCD

USB

ATA

Initial

Key

Playback

DVR

Record

FM

System

File System

Nand Flash

SD

ALi Confidential

2

USB
User Interface
UiCommon.c
UiUsbDevice.c
UiSysStr.c

Common.c

Lcd.c

Usb.c

Ata.c

NandFlash.c
SD.c

ALi Confidential

3

Playback
Common.c

Playback.c

FileSystem.c

SD.c

User Interface
UiCommon.c
UiPlay.c
UiSysStr.c

Lcd.c

Idma.c

Key.c

Codec.c

NandFlash.c

ALi Confidential

4

DVR
Common.c

Playback.c

FileSystem.c

SD.c

User Interface
UiCommon.c
UiPlay.c
UiSysStr.c

Lcd.c

Idma.c

Key.c

Codec.c

NandFlash.c

ALi Confidential

5

Record
User Interface
UiCommon.c
UiRec.c
UiSysStr.c

Common.c

Key.c

Lcd.c

Record.c

FileSystem.c

Idma.c

Codec.c

SD.c

NandFlash.c

ALi Confidential

ImaAdpcm.c

6

FM
Common.c

FmChip.c

User Interface
UiCommon.c
UiFM.c
UiSysStr.c

Lcd.c

Key.c

Codec.c

ALi Confidential

7

System
User Interface
UiCommon.c
UiSys.c
UiSysStr.c

Common.c

FileSystem.c

SD.c

Lcd.c

Key.c

NandFlash.c

ALi Confidential

8

Initial DDM Playback DVR Record
DDM.lin
Const.h
Reg5661.h
TypeDef.h
Key.h
Lcd.h
Codec.h
Common.h
Initial.h
UiCommon.h
Uiplay.h
UiRec.h
UiFm.h
UiSys.h
UiUsbDevice.h
UiSysStr.h
FileSystem.h
Playback.h
Record.h
FmChip.h
Usb.h
Ata.h
NandFlash.h
Sd.h
Idma.h
ImaAdpcm.h
DDM.h

STARTUP.A51
Key.c
Lcd.c
Codec.c
Common.c
Initial.c
UiCommon.c
UiPlay.c
UiRec.c
UiFm.c
UiSys.c
UiUsbDevice.c
UiSysStr.c
FileSystem.c
Playback.c
Record.c
FmChip.c
Usb.c
Ata.c
NandFlash.c
Sd.c
Idma.c
ImaAdpcm.c
DDM.c

Fm






















































































ALi Confidential
















System UsbFlashDisk
























9


ALI-M5661.rar > User Manual.pdf

M5661 User Manual

M5661User Manual

www.ali.com.tw

1

M5661 User Manual

Revision History
Version

Date

1.0

Dec.15, 2004

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.
Copyright © ALi Corporation, 2004. All rights reserved

History

Date
9/15/2004
12/15
10/22/2005

Version
0.9
1.0
1.2

www.ali.com.tw

Description
First release
Update features
Update features

Who
David Chiu
David Chiu
Yen lung Chiu

2

Contents
Contents ............................................................................................................................................. 3
1
Features ...................................................................................................................................... 4
2
Overview.................................................................................................................................... 6
3
USB Flash Disk.......................................................................................................................... 6
3.1
MSC mode ................................................................................................................. 7
3.2
MTP mode. ................................................................................................................ 7
4
Digital Audio device .................................................................................................................. 9
4.1
Power On/Off............................................................................................................. 9
4.2 Change mode ....................................................................................................................... 9
5
Music Mode ............................................................................................................................. 10
5.1 Playback............................................................................................................................. 11
5.2 Pause .................................................................................................................................. 11
5.3 Stop .................................................................................................................................... 11
5.4 File navigation (Select folder/file) ..................................................................................... 11
5.5 Select file ........................................................................................................................... 12
5.6 Fast backward/forward....................................................................................................... 12
5.7 Playback Sub-Menu ........................................................................................................... 12
5.8 A-B Repeat......................................................................................................................... 15
5.9 Adjust Volume ................................................................................................................... 15
6
DVR (Digital Voice Recording) .............................................................................................. 16
6.1
Record to a File........................................................................................................ 17
6.2
DVR Recording Sub-Menu...................................................................................... 17
6.3
Play a recorded file. ................................................................................................. 19
7
FM Radio ................................................................................................................................. 19
7.1
Adjust Frequency ..................................................................................................... 19
7.2
Automatic Search..................................................................................................... 19
7.3
Edit Preset Frequency .............................................................................................. 19
7.4
Select Preset Frequency ........................................................................................... 20
7.5
Adjust Volume ......................................................................................................... 20
8
File Manager ............................................................................................................................ 20
9
Setup ........................................................................................................................................ 21
9.1
Usb Mode................................................................................................................. 24
9.2
Time ......................................................................................................................... 24
9.3
Power ....................................................................................................................... 25
9.4
Language.................................................................................................................. 25
9.5
Display ..................................................................................................................... 25
9.6
Recording................................................................................................................. 26
9.7
Sys Tools.................................................................................................................. 26
9.8
Custom EQ............................................................................................................... 26
9.9
Storage ..................................................................................................................... 26
10
Firmware Upgrade (End-User) ........................................................................................ 27
10.1
“End-User Firmware Upgrade” utility..................................................................... 27
11
Firmware Upgrade (Engineering) .................................................................................... 28

M5661 User Manual

1

Features
Support internal memory (Nand flash) and external memory card
NAND flash type:
" M5661 Pen Drive
Flash-Card Support.xls

External memory card type: SD, MMC,
Player:
Playback source: internal memory or external memory card
Support MP3 decoding:
Bit rate: 8K bps ~ 320K bps
Sampling rate: 8K ~48K
Channel: Stereo
Support WMA decoding:
Bit rate: 5K bps ~ 320K bps
Sampling rate: 8K ~48K
Channel: Stereo
Support IMA-ADPCM decoding:
Bit rate: 32K bps ~ 352 K bps
Sampling rate: 8K ~ 44.1K
Channel: Mono/Stereo
Support Lyrics display from
LRC text file format
Support artist / title / album display from
MP3 tag: V1.0, V2.2, V2.3, V2.4
WMA content metadata
Support A-B repeat.
Support adjustable playback rate.
Support fast forward / backward playback.
Support long file-name, file navigation
Selectable repeat mode: no repeat, single repeat, repeat all, and random all.
Selectable equalizer mode: Normal / Pop / Rock / Classic / Jazz / Bass / User EQ.
Selectable virtual surround mode: enable or disable.
Voice Recorder
Record source: Line-In, or MIC, or FM
Record target: internal memory or external memory card
Selectable record mode: high quality, normal quality, or long-time mode
Support the following MP3 encoding modes:
256K bps, 44.1K sampling, stereo
128K bps, 44.1K sampling, stereo
64K bps, 22.05K sampling, stereo
32K bps, 16K sampling, mono
16K bps, 12K sampling, mono
Support the following IMA-ADPCM encoding modes:
www.ali.com.tw

4

M5661 User Manual

Sampling: 8K ,
Sampling: 11.025K,
Sampling: 16K,
Sampling: 22.05K,
Sampling: 32K
Sampling: 44.1K

Mono,
Mono,
Mono,
Mono,
Mono,
Mono,

Bit rate: 32K
Bit rate: 44K
Bit rate: 64K
Bit rate 88K
Bit rate 128K
Bit rate 176k

Sampling: 8K ,
Sampling: 11.025K ,
Sampling: 16K,
Sampling: 22.05K,
Sampling: 32K
Sampling: 44.1K

Stereo,
Stereo,
Stereo,
Stereo,
Stereo,
Stereo,

Bit rate: 64K
Bit rate: 88K
Bit rate: 128K
Bit rate:: 172K
Bit rate 256K
Bit rate 352K

The summary of file format with different source and quality mode
Line In/ FM
MIC
High
MP3, 128K bps, 44.1K, stereo MP3, 32K bps, 16K, mono
Normal
MP3, 64K bps, 22.05K, stereo MP3, 16K bps, 12K, mono
Long time MP3, 32K bps, 16K, mono
ADPCM, 32K bps, 8K, mono
Support VAD in MP3 / IMA-ADPCM encoding mode.
The VAD sensitivity level is adjustable.( 69 / 76 / 83 dBV)

FM Tuner
Frequency: 87.5 ~108 MHz
Tuner can adjust step by step or automatic search
User can set 10 preset bands
Clock
Time
Alarm
LCD
Selectable contrast
Selectable backlight time

Automatic power off
Selectable power off time
Enable or disable power off function in playback is selectable
Multi-language
Support unicode
User interface can select Traditional Chinese, Simplified Chinese, or English.
Return to the environment last time automatically when power on

www.ali.com.tw

5

M5661 User Manual

2

Overview
M5661 can operate in two types: USB flash disk / digital audio device (stand-alone).
If plugged to PC, it will become an USB flash disk. When it is stand-alone, it will become a
portable digital audio device.

Buttons:
Button ID
VolPlay

Key number
PB2
PB1

Vol+
Prev
Function
Next
Rec
Mode

PB3
PB4
PB5
PB6
PB7
PB8

Function
Volume decrease
PowerOn,
Play,
Pause,
PowerOff
Volume increase
Previous
Command/Function
Next
Recording/A-B repeat
Mode change

The EV board block diagram:
LCD
Line-In
Mic

Headset
FM

PB2, VolPB6, Next
PB1, Play
PB5, Function
PB3, Vol+
PB4, Prev
PB7, Rec

]

3

USB host port
(Behind
the
USB
device
port)

PB8, Mode
USB

USB
port

device

USB Flash Disk
Plug the device to PC’s USB port the LCD panel will display the following icon according to
current USB Device mode:
DRM-10-compliant firmware (version 1.60.xx series) supports both MTP mode and MSC
mode (USB mass storage class). If the firmware just supports MSC mode (Version 1.50.xx
series ), it will just show up MSC icon on LCD.

www.ali.com.tw

6

M5661 User Manual

3.1 MSC mode
When M5661 device (MSC mode) gets connected to PC, and is in idle state.

PC is writing data to M5661 device.

PC is reading data from M5661 device

And the removable disk(s) icons will show up on “My Computer”:
(If external Flash Disk enabled (MMC/SD), there will be two disk icons)

3.2 MTP mode.
When M5661 device (MTP mode) gets connected to PC (support XP only), and is in idle state.

www.ali.com.tw

7

M5661 User Manual

And the portable media player icon(s) will show up on “My Computer”:
(If external Flash Disk enabled (MMC/SD), there will be two icons)

Windows Media Player 10 will detect M5661 device and display icon(s) on the screen.
User can sync transfer the content to M5661 device.
(If external Flash Disk enabled (MMC/SD), there will be two icons)

www.ali.com.tw

8

M5661 User Manual

4 Digital Audio device
4.1 Power On/Off
Press the button Play (key1) can turn on the device, and press and hold this button will turn off
the device.
When power on, the LCD panel will display the power-on animation:









Then it will go to the mode directly (Music, Voice, FM, Photo, File Manger, or Setup) when
user powered off the device last time.
Note:
1. The device can memorize the mode last time. If it was turned off from FM mode, it will
return to FM mode when turn on.
2. The default mode is music mode.

4.2 Change mode
Press the mode button (key 8) can change the mode, and the change sequence is as followed:
Music --- DVR --- FM --- System Setup --- File Manager
Layer 1

Layer 2

Music

DVR

FM

www.ali.com.tw

9

M5661 User Manual

Setup

File Manager

5

Music Mode

(16)
(5)(6)(7)

(8)(9) (11)(12)
(10)

(1)
(2)
(3)
(4)

(13)

(14)
(15)
(1) Music mode icon
(2) Current file number/Number of total files
(3) Title/Artist/Album or filename
(4) Lyrics
Status:
Stop
Playback
Pause
Fast Forward
Fast Backward
(5)
(6)
(7)
(8)

Playback status
Time
File format
Bit rate

(9) Repeat: No repeat
Single repeat
All Repeat
Random repeat
Play in Folder
Repeat All in Folder
Random Repeat in Folder
www.ali.com.tw

10

M5661 User Manual

A-B repeat
(10)
(11)
(12)
(13)
(14)

Alarm
External memory card
Battery
Key hold
Equalizer: Normal
Pop
Rock
Classic
Jazz
Bass
User EQ
(15) Virtual surround
(16) Volume indicator

Layer 1

Layer 2

Layer 3

Music

Playback

File navigation

Layer 4

Layer 5

5.1 Playback
When the device status is stop or pause, press the play button (key 1) to playback.

5.2 Pause
When the device status is playback, press the play button (key 1) will pause it.

5.3 Stop
When the device status is playback or pause, long press the function button (key 5) to stop it.

5.4 File navigation (Select folder/file)
Long press the Button Menu (key 5) will enter folder/file browsing. User can browse all files in
the current folder. Using the button Prev (key 4) / Next (key 6) to move the cursor up/down to
the target object, then press the button Play (key 1) to play the selected file.(i.e. play from the
current folder which contains the selected file.). Press the button Menu (key 5) can abort
browsing folder/file, and go back to the playback mode.
Press button Play at a folder will go into that folder.

www.ali.com.tw

11

M5661 User Manual

Current opened folder

Music file

Only supported music file will be displayed on the LCD, such as MP3 and WMA files.

5.5 Select file
Press the button Prev (key 4) / Next (key 6) to select previous / next file. User can select
previous / next file in any status.

5.6 Fast backward/forward
When the device status is in playback, long press the button Prev (key 4) / Next (key 6) will
fast backward/forward the current file. Fast forward / backward will gradually speed up to 16
x when user doesn’t release the Prev / Next.
FF can move to next file when reaching the end of file. FB doesn’t support this feature.

5.7 Playback Sub-Menu
The topology of playback sub-menu function
Layer 1
Playback

Layer 2
Repeat

Layer 3

Layer 4

Layer 5

No Repeat

Single Repeat

Repeat All

Random Repeat All

In Folder Play

In Folder All

www.ali.com.tw

12

M5661 User Manual

In Folder Random

EQ

Normal

Pop

Rock

Classic

Jazz

Bass

User EQ

3D sound

Adjustment

On

On

www.ali.com.tw

13

M5661 User Manual

Play Rate

1.00x

1.14x

1.33x

0.67x

0.80x

Intro

Adjustment

Volume Show

Off

Wave

Stereo

When the device is in Playback mode, press the button Menu(key 5) will enter playback
sub-menu.
Press button Prev (key 4) / Next (key 6) to select an item, and press button Play (key 1) to
select it.
The items of sub-menu include: Repeat, Equalizer, 3D surround and Play rate, Inro.
(1) Change Repeat Mode
Go to the playback sub-menu and select Repeat mode, there are four repeat modes on the
www.ali.com.tw

14

M5661 User Manual

list:
No Repeat: Just play the current file. Stop playback when done.
Repeat All: Repeatedly play all files, (starting from current file)
Single Repeat: Repeatedly play current file.
Random repeat all: Repeatedly play a random file (randomly selected from all).
In Folder Play: Just play the current file in certain folder. Stop playback when done.
In Folder All: Repeatedly play all files in certain folder.
In Folder Random: Repeatedly play a random file in certain folder.
(2) Change Equalizer Mode
Go to the playback sub-menu and select Equalizer mode, there are seven Equalizer
modes on the list: Normal, Pop, Rock, Classic, Jazz, Bass, and User define.
(3) Virtual 3D Surround
Go to the playback sub-menu and select Virtual Surround mode, user can enable or
Disable the Virtual Surround function.
(4) Change Play Rate
Go to the playback sub-menu and select Play Rate item, user can adjust the play rate.
The options of play rate are 0.67x, 0.80x, 1.00x, 1.14x, 1.33x.
(5) Intro playback
Intro playback is to play just a short period of content, instead of the entire file, let user
can quickly scan all audio content in the disk. User can set the Intro period 0 ~ 15
seconds. 0 second means disable this function.
Intro-Period adjustment

(6) Volume Show
Go to the playback sub-menu and select Volume Show mode, user can select the volume
display style when playback . There are three choices for this option, turn off, wave
motion, stereo mode.

5.8 A-B Repeat
During playback, press the button Rec (key 7) to set the start point of the A-B repeat section,
and press this button again can set the end point of the A-B repeat section. The device will
play the section repeatedly. After that, press the same button again will cancel the A-B repeat
mode.

5.9 Adjust Volume
In any playbackstate, press the button Vol- (key 2) to decrease the volume, or press the button
Vol+ (key 3) to increase volume.
(step: 0 ~ 31)

www.ali.com.tw

15

M5661 User Manual

6

DVR (Digital Voice Recording)
In DVR mode, user can record sound from Line In, MIC to digital files, and play the voice
recording files.
Playback mode:
(4)(5)

(1)
(2)
(3)

(6) (8)(9)
(7)

(10)

Recording mode(when pressing button Rec)

(11)

(1) Voice mode icon
(2) Current file number/Number of total files
(3) Filename
(4) Status: Stop
Playback
Pause
Record
(blinking)
(5) Time
(6) Repeat: No repeat
Single repeat
All Repeat
Random repeat
Play in Folder
Repeat All in Folder
Random Repeat in Folder
A-B repeat
(7) Alarm
(8) External memory card
www.ali.com.tw

16

M5661 User Manual

(9) Battery
(10) Key hold
(11) Recording Source
Line In
Mic

6.1 Record to a File
(1) General Recording Function
When the device status is stop or pause, press button Rec (key 7) will start recording.
During recording, press button Rec (key 7) can pause it, and press the same button (key 7)
again will continue recording. In the end, press button Menu (key 5) to stop recording and
save the recording file.
(2) The Recording Folder and Filename format
The recording file will be saved in different folders, according to the recording quality and
voice source.
For example, the FM recording files will be saved in folder “\FMIN” .
And, the recording filename will contain prefix to indicate the voice source, serial number,
and file type.
The unified filename format is,
" MIC " / " LINE " / “FM” + series number + " .MP3 " / " .WAV”.
Such as,
“MIC0001.WAV”, “MIC0002.MP3”, “LINE0003.WAV”, “FM00001.MP3” …
(3) Auto Insert Recording Serial Number Name.
The serial number of recording filename increases every time. When filename already exits,
it will search for next available serial number to make up its filename.

(4) VAD Recording Function
When the recording voice is quieter than background sound, the device automatically
pauses recording and the icon
will disappear. Then, if the recording voice is louder than
background sound, it will automatically record and Blink the item
again. The
background sound means that the first sound after pressing the button Rec (key 7).

6.2 DVR Recording Sub-Menu
When the device status is stop, long press the button Rec (key 7) will enter the DVR sub-menu.
Then press button Prev (key 4) or button Next (key 6) to move item, and press button Play
(key 1) to select it or press button Menu (key 5) to exit it. The items of sub-menu are:
Source, Quality and VAD.

www.ali.com.tw

17

M5661 User Manual

Layer 1

Layer 2

Layer 3

Source

Layer 4

Layer 5

MIC

DVR Playback

DVR Record

Line-In

Quality

Adjustment

VAD

Off

On

(1) Change the Source
Go to the recording sub-menu and select source item. Under this item, user can select “Line
In” or “Mic” as the source.
Voice source

MIC

Line-In

(2) Change the Quality
Go to the recording sub-menu and select quality item. Under this item, user can select the
quality degree. (4 degrees)
Quality

www.ali.com.tw

Adjustment

18

M5661 User Manual

(3) VAD Function Selection
Go to the recording sub-menu and select VAD item. Under this item, user can select
whether using VAD (voice active detection) function
VAD

Off

On

.

6.3 Play a recorded file.
The operation of playback is similar to music playback mode.
Press button Menu will go into DVR Playback Sub-Menu, to change Repeat mode, Intro
Playback Period, and Play Rate ( see the Music Playback).

7

FM Radio
Layer 1
FM playback

Layer 2
Preset Edit

Layer 3

Layer 4

Layer 5

7.1 Adjust Frequency
Press button Prev (key 4) to decrease the frequency, and press button Next (key 5) to increase
the frequency. Each step is 0.1 MHz.

7.2 Automatic Search
Long press button Prev (key 4) will decrease the frequency and search a radio station
automatically. Long press button Next (key 6) will search band will increase the frequency to
search a radio station.

7.3 Edit Preset Frequency
www.ali.com.tw

19

M5661 User Manual

Long press function key (key 5) and the LCD panel will display preset number and frequency.
0
As the operation of
“Adjust Frequency” or “Automatic Search”, to select a frequency, and press the button Rec
(key 7) to save the frequency to current preset number. After that, the preset number will go to
the next automatically, and let user to save next preset frequency. If user want to edit specific
preset number, press button Play (key 1) to change the preset number. Finally, press the
Button Menu (key5) to close the edit mode.

7.4 Select Preset Frequency
After edit preset frequency, user can change the frequency directly by select the preset number.
Just press the button Play (key 1) to select the preset number.

7.5 Adjust Volume
In any state, press the button Vol- (key 2) to decrease the volume, or press the button Vol+
(key 3) to increase volume.

8

File Manager
Layer 1

Layer 2

Layer 3

Source disk

Partition

Function

File navigation

Layer 4

Layer 5

Operation

Select a source disk from menu

Select a partition from the source disk
Press button Play will enter file navigation, press button Menu will enter function menu

www.ali.com.tw

20

M5661 User Manual

File navigation:

Button Next / Prev: move to the object
Button Vol+: to check (select) the file object.
Button Play: go into the folder in the current object is a folder
Button Menu: go into function menu, to Copy / Delete / View file information.

Press button Menu again will cancel the operation
Press button Play will perform the selected function.

9

Setup
In setup mode, user can change the system settings. The common operation of this mode is to
press the button Play (key 1) to select, press the button Menu (key 5) to cancel, and press the
button Prev (key 4) or the button Next (key 6) to move item.
The topology of System Setup menu

Layer 1
USB mode

Layer 2

Layer 3

Layer 4

Layer 5 Layer
6

Pen drive
(MSC mode)

DRM download
(MTP mode)

Time

Adjustment

Set alarm

Edit alarm

Adjustment

On/Off

www.ali.com.tw

Set clock

Off

21

M5661 User Manual

On

Power saving

Setting

Language

Chinese Tran

Chinese Simp

English

Display

Adjustment

Backlight

Record

Contrast

Adjustment

Source

Mic

Line-In

Quality

www.ali.com.tw

Adjustment

22

M5661 User Manual

VAD

Off

On

System Tool

Delete File

FileList

No

Yes

Format

Quick format

No

Yes

Full format

No

Yes

Default

No

Yes

System Info

www.ali.com.tw

Information

23

M5661 User Manual

User EQ

Adjustment

Storage

Internal

SD / MMC

9.1 Usb Mode
(1) Pen Drive
Select “USB Mode Pen Drive”, the device will act as a USB pen drive when plugging
into USB port.
(2) DRM Download
Select “USB Mode DRM Download”, the device will act as a MTP device when
plugging into USB port. It is used to download the Janus-DRM-protected (Digital Right
Management) media files and license through WMP 10(Windows Media Player 10), and it
only supports Windows XP SP1 above.

9.2 Time
(1) Adjust
Select “Time Adjust”, and the LCD panel will display current time.

Press the button Prev (key 4) or button Next (key 6) to move cursor, and then press the
button Vol- (key 2) / Vol+ (key 3) to change the value. The time is set while adjusting. In
the end, press the button Play (key 1) or the Button Menu (key 5) to return to Setup menu.
(2) Alarm
Select “Time Alarm Adjust”, and the LCD panel will display current alarm time.

www.ali.com.tw

24

M5661 User Manual

Press the button Prev (key 4) / Next (key 6) to move cursor, and then press the button Vol(key2) / Vol+ (key 3) to change the value. The alarm time is set while adjusting. In the end,
press the button Play (key 1) / the Button Menu (key 5) to return to Setup menu.
Select “Time Alarm On/Off On” to enable the alarm function; or
select ”Time Alarm On/Off Off” to disable the alarm function.
When the alarm function is turned on, the LCD panel will display alarm icon

9.3 Power
Select the power item, and the LCD panel will display as follows:

Auto power off

Auto-off timer

Always on in
playback
Auto-Off: Auto Power Off setting
Press button Prev (key 4) / Next (key 6) to move cursor, and then press the button Vol- (key 2)
/ Vol+ (key 3) to change the value. If user adjust the number to “020”, it means the device will
power off automatically if the user doesn’t press any key in twenty minutes. When the
Auto-Off timer expires, system will check the item ”Always on in playback”. If this item is
checked and the device is playing songs, system won’t power off the device. This setting is
useful for sleeping mode.
When user wants to enjoy music while sleeping, and automatically power off the device when
all songs are played out. He can set " Auto Off " timer, and checked the flag " Always on in
playback "
.

9.4 Language
User can select language to change the system menu and information display. The current EV
board supports 55 kinds of languages including English, Chinese (Trad.), Chinese
(Simp) …exc.

9.5 Display
(1) Contrast
Select “Display Contrast”; press button Prev (key 4) / Next (key 6) to change contrast,
and then press the button Play (key 1) or the Button Menu (key 5) to return to Setup menu.

www.ali.com.tw

25

M5661 User Manual

(2) Backlight
Select “Display Backlight”; press the button Prev (key 4) or button Next (key 6) to
change the backlight time, and then press the button Play (key 1) or the Button Menu (key
5) to return to menu.

9.6 Recording
(1) Recording Source
Select “Record Source Line In” to set recording from “Line In” input;
Or select “Record Source MIC” to set recording from device’s built-in microphone.
(2) Record Quality
Select “Record Quality Long Time” for voice quality and smaller file size.
Select “Record Quality Normal Quality” for radio quality and normal file size.
Select “Record Quality High Quality” for CD quality and bigger file size.
(3) VAD functional selection
Select “Record VAD” to turn on/off VAD function.

9.7 Sys Tools
(2) Format
Select “Sys Tools Format Quick” to quickly format;
Select “Sys Tools Format Complete” to completely format as the FAT16 file system.
(3) Reset
Select “Sys Tools

Reset” to reset the portable audio player to the default setting.

(4) System Info
Select “Sys Tools System Info” to check the system information: Firmware version, Chip
version, and free space of the internal memory.

9.8 Custom EQ
Select the “Custom EQ” item to adjust the custom EQ. Press the button Prev (key 4) / Next
(key 6) to move cursor, and then press the button Vol- (key 2) / Vol+ (key 3) to change the
value.

9.9 Storage
Select “Storage Internal” to playback from or record to device’s internal memory. Select
“Storage SD/MMC Card” to playback from or record to device’s external SD/MMC card.
When the device is selected to use the external memory card to playback or recording, the
LCD panel will show a disk icon (
www.ali.com.tw

) to indicate that system is using external memory card.
26

M5661 User Manual

10 Firmware Upgrade (End-User)
10.1

“End-User Firmware Upgrade” utility

User can upgrade the firmware binary by the “End-User Firmware Upgrade” utility

1.

If there is no such device connected on the USB host port, a warning message will show .

2.

If more than one device connected on the USB host, a warning message will show .

3.

This tool only burning one device every time. Confirmation dialog box will ask user to begin
firmware upgrade process.

www.ali.com.tw

27

M5661 User Manual

4.

After clicking the [Yes], the firmware upgrade will proceed. When the firmware upgrade
process finishes, a message box will display.

The new firmware won't take effect until user re-plugs the device to PC.

11 Firmware Upgrade (Engineering)
www.ali.com.tw

28

M5661 User Manual

This is a firmware Upgrade utility for engineering purpose (User can change some
configurable information before burning the firmware binary to the M5661 device)
Step1.
1. Select Config + FW or Upgrade ProgramModule only

2. Select
Nandflash Type
3. Press it

Step2.

Select
Source Code

Press it

www.ali.com.tw

29

M5661 User Manual

Step3.

www.ali.com.tw

30

M5661 User Manual

www.ali.com.tw

31


ALI-M5661.rar > UserManual.pdf

M5661 EV-Board User Manual

M5661 EV-Board User Manual

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
1

M5661 EV-Board User Manual

Revision History
Version

Date

1.12

Mar. 4, 2005

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.
Copyright © ALi Corporation, 2004. All rights reserved

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
History

Date
9/15/2004
12/15/2004
2/24/2005
2/24/2005
3/04/2005

Version
0.9
1.0
1.1
1.11
1.12

Customer_X

Description
First release
Update features
Update features
Modify
Add appendix

Who
David Chiu
David Chiu
Vicky Hsu
David Chiu
John JR Fang

____________________________________________________________________
www.ali.com.tw
ALi Confidential
2

Contents
Contents ............................................................................................................................................. 3
1
Features ...................................................................................................................................... 4
2
Overview.................................................................................................................................... 7
3
USB Flash Disk.......................................................................................................................... 8
4
Digital Audio Device ................................................................................................................. 9
4.1 Power On/Off ……………………………………………………………………………...9
4.2 Change mode ....................................................................................................................... 9
5
Music Mode ............................................................................................................................. 10
5.1 Playback............................................................................................................................. 11
5.2 Pause .................................................................................................................................. 11
5.3 Stop .................................................................................................................................... 11
5.4 Select folder/file................................................................................................................. 11
5.5 Select file ........................................................................................................................... 11
5.6 Fast backward/forward....................................................................................................... 11
5.7 Playback Sub Menu ........................................................................................................... 11
5.8 A-B Repeat......................................................................................................................... 12
5.9 Adjust Volume.................................................................................................................... 12
6
Voice Recording Mode ............................................................................................................ 13
6.1 Record to a File.................................................................................................................. 14
6.2 Recording Sub-Menu ......................................................................................................... 14
6.3 Play the recorded file ......................................................................................................... 14
7
FM Mode ................................................................................................................................. 16
7.1 Adjust Frequency ............................................................................................................... 16
7.2 Automatic Search ............................................................................................................... 16
7.3 Edit Preset Frequency ........................................................................................................ 16
7.4 Select Preset Frequency ..................................................................................................... 16
7.5 Adjust Volume.................................................................................................................... 16
8
Setup Mode .............................................................................................................................. 17
8.1 Usb Mode........................................................................................................................... 18
8.2 Time ................................................................................................................................... 18
8.3 Power ................................................................................................................................. 18
8.4 Language............................................................................................................................ 19
8.5 Display ............................................................................................................................... 19
8.6 Recording........................................................................................................................... 19
8.7 Sys tools ............................................................................................................................. 20
8.8 Custom EQ......................................................................................................................... 20
8.9 Storage ............................................................................................................................... 20
9
Firmware Upgrade ................................................................................................................... 21
Appendix I: ................................................................................................................................ 23

Appendix II: ............................................................................................................................. 24

M5661 EV-Board User Manual
1

Features
Support internal memory (NAND flash) and external memory card
NAND flash type:
Brand
Part Number
Capacity
K9F1208U0A
K9F1G08U0M
K9F2G08U0M

256 MB
256 MB

K9K4G08U0M

512 MB

K9G4G08U0M

512 MB

TC58512FT

064 MB

TH58100FT

128 MB

TC58NVG0S3AFT00

128 MB

TH58NVG1S3AFT00

256 MB

TC58NVG1D4BTG00

256 MB

TC58NVG2D4BTG00

512 MB

SDTNGCHE0-512

064 MB

SDTNGEHE0-1024

128 MB

SDTNGEHE0-2048

SanDisk

128 MB

K9K2G08U0M

Toshiba

128 MB

K9K1G08U0M
Samsung

064 MB

256 MB

揚智機密不得洩漏
064 MB
HY27UA081G1M
128 MB
ALI CONFIDENTIAL
HY27UF081G2M
128 MB
NAND512W3A
064 MB
NO DISCLOSURE
NAND01GW3A
128 MB
Released Version for
HY27US08121M

Hynix
ST

External memory card type: SD, MMC,

Customer_X

Player:
Playback source: internal memory or external memory card
Support MP3 decoding:
Bit rate: 8K bps ~ 320K bps
Sampling rate: 8K ~48K
Channel: Stereo
Support WMA decoding:
Bit rate: 5K bps ~ 320K bps
Sampling rate: 8K ~48K
Channel: Stereo

____________________________________________________________________
www.ali.com.tw
ALi Confidential
4

M5661 EV-Board User Manual
Support IMA-ADPCM decoding:
Bit rate: 32K bps
Sampling rate: 8K
Channel: Mono
Support Lyrics display from
LRC text file format
Support artist/ title/ album display from
MP3 tag: V1.0, V2.2, V2.3, V2.4
WMA content description object
Support A-B repeat.
Support adjustable playback rate.
Support fast forward / backward playback.
Support long file-name file/folder listing and browsing.
Selectable repeat mode: no repeat, single repeat, repeat all, and random all.
Selectable equalizer mode: Normal / Pop / Rock / Classic / Jazz / Bass / User EQ.
Selectable virtual surround mode: enable or disable.
Voice Recorder
Record source: Line-In, or MIC, or FM
Record target: internal memory or external memory card
Selectable record mode: high quality, normal quality, or long-time mode
Support four type of MP3 encoding:
(1) 128K bps, 44.1K, stereo
(2) 64K bps, 22.05K, stereo
(3) 32K bps, 16K, mono
(4) 16K bps, 12K, mono
Support one IMA-ADPCM encoding mode:
(1) 32K bps, 8K, mono
The summary of file format with different source and quality mode
Line In/ FM
MIC
High
MP3, 128K bps, 44.1K, stereo MP3, 32K bps, 16K, mono
Normal
MP3, 64K bps, 22.05K, stereo MP3, 16K bps, 12K, mono
Long time MP3, 32K bps, 16K, mono
ADPCM, 32K bps, 8K, mono

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Support VAD in MP3 encoding mode.
Released Version for

FM Tuner
Frequency: 87.5 ~108 MHz
Tuner can adjust step by step or automatically search
User can set 10 preset bands

Customer_X

Clock
Time
Alarm
LCD
Selectable contrast
Selectable backlight time
____________________________________________________________________
www.ali.com.tw
ALi Confidential
5

M5661 EV-Board User Manual

Automatic power off
Selectable power off time
Enable or disable power off function in playback is selectable
Multi-language
Support Unicode
User interface can select Traditional Chinese, Simplified Chinese, or English.
Return to the environment last time automatically when power on

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
6

M5661 EV-Board User Manual

2

Overview
M5661 can operate in two types: USB flash disk or digital audio device.
If plugged to PC, it will become an USB flash disk. When it is stand-alone, it will become a
portable digital audio device.

LCD
Play
Volume Down

1

2

3

Volume Up

Previous

4

5

6

Next

Record

7

8

Mode

USB Port

Function

MIC
Line In Phone Out

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
7

M5661 EV-Board User Manual

3

USB Flash Disk
Plug the device to PC’s USB port, the LCD panel will display the following icon:

And the removable disk(s) icons will show up on “My Computer”:
( If External Flash Disk enabled ( MMC/SD), there will be two disk icons )

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
8

M5661 EV-Board User Manual

4 Digital Audio Device
4.1 Power On/Off
Press the play button (key2) can turn on the device, and press and hold this button will turn off
the device.
When power on, the LCD panel will display the following animation:









Then it will go to the mode directly (Music, Voice, FM, or Setup) when user powered off the
device last time.
Note:
1. The device can memorize the last mode. If it was turned off from FM mode, it will return to
FM mode when turning on.
2. The default mode is Music mode.

揚智機密不得洩漏
ALI CONFIDENTIAL
4.2 Change mode
Press the mode button (key 8) can change the mode, and the change sequence is as followed:
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
9

M5661 EV-Board User Manual

5

Music Mode

(16)
(5)(6)(7)

(8)(9) (11)(12)
(10)

(1)
(2)
(3)
(4)

(13)

(14)
(15)
(1)
(2)
(3)
(4)
(5)

Music mode icon
Current file number/Number of total files
Title/Artist/Album or filename
Lyrics
Status: Stop
Playback
Pause
Fast Forward
Fast Backward
(6) Time
(7) File format
(8) Bit rate
(9) Repeat: No repeat
Single repeat
All Repeat
Random repeat
A-B repeat
(10)
(11)
(12)
(13)
(14)

Alarm
External memory card
Battery
Key hold
Equalizer: Normal
Pop
Rock
Classic
Jazz
Bass
User EQ
(15) Virtual surround
(16) Volume indicator

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
10

M5661 EV-Board User Manual

5.1 Playback
When the device status is stop or pause, press the play button (key 2) to playback.

5.2 Pause
When the device status is playback, press the play button (key 2) will pause it.

5.3 Stop
When the device status is playback or pause, long press the function button (key 5) to stop it.

5.4 Select folder/file
Long press the function button (key 5) will enter folder/file browsing. User can browse all files
in the current folder. Using the previous button (key 4) and the next button (key 6) to move the
cursor up/down to the target object, then press the play button (key 2) to select the file. Then,
the device will go to playback mode and play audio from the selected file.(i.e. play from the
folder which has the selected file.). Press the function button (key 5) can abort browsing
folder/file, and go back to the playback mode.

5.5 Select file
Press the previous button (key 4) to select previous file, and press the next button (key 6) to
select next file. User can select previous or next file in any status.

5.6 Fast backward/forward
When the device status is playback, long press the previous button (key 4) or the next button
(key 6) will fast play backward/forward the current file.

5.7 Playback Sub Menu

揚智機密不得洩漏
ALI CONFIDENTIAL
(1) Change Repeat Mode
NO DISCLOSURE
Go to the playback sub-menu and select Repeat mode, there are four repeat modes on the list:
Released Version for
No Repeat: Just play the current file. Stop playback when done.

When the device status is playback, press the function key (key 5) will go to playback
sub-menu. Then, press previous button (key 4) or next button (key 6) to select an item, and
press play button (key5) to select it. The items of sub-menu include: repeat, equalizer, 3D
surround and play rate.

All: Repeatedly play all files, (starting from current file)
Single: Repeatedly play current file.
Random all: Repeatedly play a random file (randomly selected from all).

Customer_X

(2) Change Equalizer Mode
Go to the playback sub-menu and select Equalizer mode, there are seven Equalizer modes on
the list: Normal, Pop, Rock, Classic, Jazz, Bass, and User define.
(3) Virtual Surround
Go to the playback sub-menu and select Virtual Surround mode, user can enable or disable
the Virtual Surround function.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
11

M5661 EV-Board User Manual
(4) Change Play Rate
Go to the playback sub-menu and select Play Rate item, user can adjust the play rate. The
range of play rate is 0.67x ~ 1.33x.
The topology of playback sub-menu function
Repeat

No Repeat
Single
All
Random All

Equalizer

Normal
Pop
Rock
Classic
Jazz
Base
Custom EQ

3D

Off
On

Play Rate

1.00x
1.14x
1.33x
0.67x
0.80x

MUSIC

揚智機密不得洩漏
5.8 A-B Repeat
ALI CONFIDENTIAL
During playback, press the record button (key 7) to set the start point of the repeat section, and
press this button again can set the end point of the repeat section. The device will play the
section repeatedly. After that, press NO button again will cancel the A-B repeat mode.
the same DISCLOSURE
5.9 Adjust Volume
Released Version for
In any state, press the volume down button (key 1) to decrease the volume, or press the volume
up button (key 3) to increase volume.

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
12

M5661 EV-Board User Manual

6

Voice Recording Mode
In Voice Recording mode, user can record sound from Line In or MIC to digital files, and play
these files.
(4)(5)

(1)
(2)
(3)

(6) (8)(9)
(7)

(10)

(1) Voice mode icon
(2) Current file number/Number of total files
or source indicator during recording: Line In
Mic
(3) Filename
(4) Status: Stop
Playback
Pause
Record
(blinking)
Fast Forward
Fast Backward
(5) Time
(6) Repeat: No repeat
Single repeat
All Repeat
Random repeat
A-B repeat
(7) Alarm
(8) External memory card
(9) Battery
(10) Key hold

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
13

M5661 EV-Board User Manual

6.1 Record to a File
(1) General Recording Function
When the device status is stop or pause, press record button (key 7) will start recording.
During recording, press record button (key 7) can pause it, and press the same button (key
7) again will continue recording. Finally, press function button (key 5) to stop recording
and save the recording file.
(2) The Recording Folder and Filename format
The recording file will be saved in different folders, according to the recording quality and
voice source.
For example, the FM recording files will be saved in “FMIN” folder.
And, the recording filename contains the following information, voice source, serial
number, and file type.
It has the unified filename format: " MIC " / " LINE " + series number + " .MP3 " / " .WAV”,
such as “MIC00001.WAV”, “MIC00002.MP3”, “LINE0003.WAV”, “FM000001.MP3” …
(3) Auto Inset Recording Serial Number Name.
The serial number of recording filename increases every time. When filename already exits,
it will search for next available serial number to make up its filename.
(4) VAD Recording Function
When the recording voice is quieter than background sound, the device automatically
pauses recording and the icon
will disappear. Then, if the recording voice is louder than
background sound, it will automatically record and Blink the item
again. The
background sound means that the first sound after pressing the record button (key 7).

揚智機密不得洩漏
When the device status is stop, long press the function button (key 7) will go into the
ALI button (key 4) or next button (key 6) to move
recording sub-menu. Then press previous CONFIDENTIAL item,
and press play button (key2) to select it or press function button (key 5) to abort it. The items
of sub-menu are: Source, Quality NO DISCLOSURE
and VAD.
(1) Change the Source
Released Version for
Go to the recording sub-menu and select source item. Under this item, user can select “Line

6.2 Recording Sub-Menu

In” or “Mic” as the source.

Customer_X

(2) Change the Quality
Go to the recording sub-menu and select quality item. Under this item, user can select three
degree of quality: Long-time, Normal quality, and High quality.
(3) VAD Function Selection
Go to the recording sub-menu and select VAD item. Under this item, user can select
whether using VAD(voice active detection) function.

6.3 Play the recorded file
The operation of playback is as music mode.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
14

M5661 EV-Board User Manual

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
15

M5661 EV-Board User Manual

7

FM Mode
(3)

(4)

(1)

(2)

(1) FM mode icon
(2) Current frequency
(3) Stereo indictor
(4) Battery

7.1 Adjust Frequency
Press previous button (key 4) to decrease the frequency, and press next button (key 5) to
increase the frequency. Each step is 0.1 MHz.

7.2 Automatic Search
Long press previous button (key 4) will decrease the frequency and search a radio station
automatically. Long press next button (key 6) will search band will increase the frequency to
search a radio station.

7.3 Edit Preset Frequency
Long press function key (key 5) and the LCD panel will display preset number and frequency.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO “Automatic Search”, to select a frequency, and
As the operation of “Adjust Frequency” or DISCLOSURE
press the record button (key 7) to save the frequency to current preset number. After that, the
preset number will go to the nextReleased Version for
automatically, and let user to save next preset frequency. If
user want to edit specific preset number, press play button (key 2) to change the preset number.

Customer_X

Finally, press the function button (key5) to close the edit mode.

7.4 Select Preset Frequency

After edit preset frequency, user can change the frequency directly by select the preset number.
Just press the play button (key 2) to select the preset number.

7.5 Adjust Volume
In any state, press the volume down button (key 1) to decrease the volume, or press the
volume up button (key 3) to increase volume.

____________________________________________________________________
www.ali.com.tw
ALi Confidential
16

M5661 EV-Board User Manual

8

Setup Mode
In setup mode, user can change the system settings. The common operation of this mode is to
press the play button (key 2) to select, press the function button (key 5) to cancel, and press
the previous button (key 4) or the next button (key 6) to move item.
The topology of System Setup menu

USB Mode
Time

Power
Language

Pen Drive mode
DRM Downlaod mode
Adjust
Alarm
Adjust
On/Off

On
Off

English
Chinese (Trad)
Chinese (Simp)

Display

Contrast
Backlight

Record

Source

Sys Tools

Line In
MIC
Long Time
Normal Quality
High Quality
On
Off

揚智機密不得洩漏
Quality
ALI CONFIDENTIAL
NO DISCLOSURE
VAD
Released Version for
Del File

Customer_X

Format

Quick

Complete

Storage

Yes
No
Yes
No

Reset
System Info
Internal
SD/MMC Card

____________________________________________________________________
www.ali.com.tw
ALi Confidential
17

M5661 EV-Board User Manual

8.1 Usb Mode
(1) Pen Drive
Select “USB Mode Pen Drive”, the device will act as a USB pen drive when plugging
into USB port.
(2) DRM Download
Select “USB Mode DRM Download”, the device will act as a MTP device when
plugging into USB port. It is used to download the Janus-DRM-protected (Digital Right
Management) media files and license through WMP 10(Windows Media Player 10), and it
only support Windows XP SP1 above.

8.2 Time
(1) Adjust
Select “Time Adjust”, and the LCD panel will display current time.

Press the previous button (key 4) or next button (key 6) to move cursor, and then press the
volume down (key 1) or the volume up (key 3) to change the value. The time is set while
adjusting. In the end, press the play button (key 2) or the function button (key 5) to return
to Setup menu.
(2) Alarm
Select “Time Alarm

揚智機密不得洩漏
Adjust”, and the LCD panel will display current alarm time.
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

Press the previous button (key 4) or next button (key 6) to move cursor, and then press the
volume down (key 1) or the volume up (key 3) to change the value. The alarm time is set
while adjusting. In the end, press the play button (key 2) or the function button (key 5) to
return to Setup menu.
Select “Time Alarm On/Off On” to enable the alarm function; or
select ”Time Alarm On/Off Off” to disable
the alarm function.
When the alarm function is turned on, the LCD panel will display alarm icon to indicate it.

8.3 Power
Select the power item, and the LCD panel will display as follows:
____________________________________________________________________
www.ali.com.tw
ALi Confidential
18

M5661 EV-Board User Manual

Auto-Off: Auto Power Off setting
Press the previous button (key 4) or next button (key 6) to move cursor, and then press the
volume down (key 1) or the volume up (key 3) to change the value. If user adjust the number
to “020”, it means the device will power off automatically if the user doesn’t press any key in
twenty minutes. When the Auto-Off timer expires, system will check the item ”Always on in
playback”. If this item is checked and the device is playing songs, system won’t power off the
device. This setting is useful for sleeping mode.
When user wants to enjoy music while sleeping, and automatically power off the device when
all songs are played out. He can set " Auto Off " timer, and checked the flag " Always on in
playback "
.

8.4 Language
User can select language to change the system menu and information display. It supports three
kinds of languages including English, Chinese (Trad.), Chinese (Simp.).

8.5 Display
(1) Contrast
Select “Display Contrast”; press the previous button (key 4) or next button (key 6) to
change contrast, and then press the play button (key 2) or the function button (key 5) to
return to Setup menu.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for
Backlight”; press the previous button (key 4) or next button (key 6) to

(2) Backlight
Select “Display
change the backlight time, and then press the play button (key 2) or the function button
(key 5) to return to menu.

8.6 Recording

Customer_X

(1) Recording Source
Select “Record Source Line In” to set recording from “Line In” input;
Or select “Record Source MIC” to set recording from device’s built-in microphone.
(2) Record Quality
Select “Record Quality Long Time” for voice quality and smaller file size.
Select “Record Quality Normal Quality” for radio quality and normal file size.
Select “Record Quality High Quality” for CD quality and bigger file size.
____________________________________________________________________
www.ali.com.tw
ALi Confidential
19

M5661 EV-Board User Manual

(3) VAD functional selection
Select “Record VAD” to turn on/off VAD function.

8.7 Sys tools
(1) Del File
Select “Sys Tools Del File” to delete the files in player.
(2) Format
Select “Sys Tools Format Quick” to quickly format;
Select “Sys Tools Format Complete” to completely format as the FAT16 file system.
(3) Reset
Select “Sys Tools

Reset” to reset player system to the default setting.

(4) System Info
Select “Sys Tools System Info” to check the system information: Firmware version, Chip
version, and free space of the internal memory .

8.8 Custom EQ
Select the “Custom EQ” item to adjust the custom EQ. Press the previous button (key 4) or
next button (key 6) to move cursor, and then press the volume down (key 1) or the volume up
(key 3) to change the value.

8.9 Storage
Select “Storage Internal” to playback from or record to device’s internal memory. Select
“Storage SD/MMC Card” to playback from or record to device’s external SD/MMC card.
When the device is selected to use the external memory card to playback or recording, the
LCD panel will show a
disk icon to indicate that system is using external memory
card.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
20

M5661 EV-Board User Manual

9

Firmware Upgrade
Step1.
1. Select Config + FW or Upgrade ProgramModule only

2. Select
Nandflash Type
Step2.

揚智機密不得洩漏
ALI CONFIDENTIAL
3. Press it
NO DISCLOSURE
Released Version for

Customer_X

Select
Source Code

Press it

____________________________________________________________________
www.ali.com.tw
ALi Confidential
21

M5661 EV-Board User Manual

Step3.

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
22

M5661 EV-Board User Manual

Appendix I:
PCB Configuration for ALi M566x Evaluation Board With Normal mode flashdisk-based
LQFP128 H/W settings (PCB-default settings)

CN2 : ICE
Connector
NAND Flash
Socket
JP8, JP9, JP10 (1-2=1 ,2-3=0)
0 0 0 = & gt; Normal mode

1 1 1 = & gt; ICE mode to VDD D
JP1, JP2, JP3 (1-2=1, 2-3=0)
0 0 0 = & gt; Normal mode
0 1 0 = & gt; ICE mode
1 0 0 = & gt; Ext ROM mode

ALi
M566x

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

PB1 = & gt; HW
Reset Bottom

JP6 = & gt; USB5V
detect

J1 (1-2 = 1 , 2-3 = 0)
0 = & gt; 2 Bat & Li-Ion mode

1 = & gt; AAA Battery mode to
VDD D

To Enable FM mode,
Short J9, pin 1-2

Customer_X

ALi M566x Evaluation Board
With Normal mode flashdisk-based LQFP128
H/W settings (PCB-default settings)

____________________________________________________________________
www.ali.com.tw
ALi Confidential
23

AAA battery
0.9v ~ 1.5v

M5661 EV-Board User Manual

Appendix II:
ALi M5661x small-size demo board configuration

Front Side
Function Button

Previous

Next
Power/Play/Pause

Earphone out

LCD/LCM Panel & NAND
Flash Module (below)

USB
Port

Mode Change

Line-In
Record or A-B Repeat

Vol-Down

Vol-Up

Back Side
Hold/Protect

Battery Pack

Mic

FM
Module

ALi
M5661x

USB
Port

揚智機密不得洩漏
ALI CONFIDENTIAL
NO DISCLOSURE
Released Version for

Customer_X

____________________________________________________________________
www.ali.com.tw
ALi Confidential
24


ALI-M5661.rar > BootSequence.pdf

M5661 Boot-Up Sequence

M5661 Boot-Up Sequence

www.ali.com.tw

1

M5661 Boot-Up Sequence
Revision History
Version
1.1

Date
Mar.10, 2005

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.

Copyright © ALi Corporation, 2004. All rights reserved

www.ali.com.tw

2

M5661 Boot-Up Sequence
History

Date
04/06/2004
12/15/2004
3/10/2005

Version
0.9
1.0
1.1

www.ali.com.tw

Description
Internal reference
First release
Second edition release

3

M5661 Boot-Up Sequence

CONTENTS
1.

Introduction.................................................................................................................. 4

2.

Booting Sequence ......................................................................................................... 5

3.

Boot Loader .................................................................................................................. 8

4.

Dynamic Download Manager (DDM) .......................................................................11

5.

Program Module ........................................................................................................ 12

6.

Program Module Index ............................................................................................. 13

7.

Update Manager......................................................................................................... 14

1. Introduction
M5661’s firmware are stored in NAND flash memory, it dynamically download the
specified program from NAND flash to SRAM, and run it. Because NAND flash memory
is not a dynamic access program memory. Therefore, M5661 provides a special method to run
program from NAND flash .
2. Terms and Abbreviations
A. Boot Loader
Boot Loader is a MCU program burned in the embedded mask ROM. The Boot Loader is
the first program that will be started when power is on.

B. Dynamic Download Manager (DDM)
The Dynamic Download Manager is a MCU program that loads a Program Module from
NAND flash to SRAM, and starts it. Boot Loader has a DDM , each Program Module
has a DDM, too.

www.ali.com.tw

4

M5661 Boot-Up Sequence
C. Program Module
Because M5661 supports limited SRAM, so programmer has to divide the entire firmware
into several small programs. Each small program we call it “Program Module”. The
Program Module is a complete MCU program for a particular function. For example,
programmer can build a Program Module for “MP3 Player”, or for “FM Radio”.
Program Module is dynamically loaded by DMM from NAND flash memory when
another particular function is launched

D. Program Module Index
Program Module Index is table contains program index. Each program index points to a
Program Module. A valid index means the Program Module exits, vice versa, it doesn’t.
The Program Module Index is built by Update Manager when Program Module is
downloaded from PC. The Program Module Index locates in NAND flash, physical page
0, page 1, page2, and page3.

E. Update Manager
The Update Manager is a MCU program that downloads Program Module from PC and
burns it to NAND flash memory. The Update Manager is downloaded from PC first when
firmware update procedure starts.

3. Boot-Up Sequence
When device powers on, MCU starts running program from mask ROM (the mask ROM has a
MCU program, called, Boot Loader), that is, the Boot Loader is the first program to be started.
The Boot Loader will check the Program Module Index. If the index is valid, it will call the
Dynamic Download Manager (DDM) to load the default Program Module to SRAM and runs it.
After that, MCU will program control to SRAM and runs the default Program Module. When the
default Program Module needs to load another Program Module, it will call DDM to load the
indexed Program Module, and switch to it.
If the Boot Loader can’t get a valid Program Module Index, the reason could be 1) the last
firmware update procedure is incomplete, 2) the NAND flash is brand new, or 3) NAND flash
memory is erased, that is, there’s no any valid Program Module in NAND flash memory.
Therefore, Boot Loader cannot proceed to download the default Program Module, it has to stay
in Boot Loader, to wait for firmware update request from PC via USB port. When firmware update
process starts, the Update Manager will be downloaded to SRAM via USB port and be started.
www.ali.com.tw

5

M5661 Boot-Up Sequence
The Update Manager controls the whole irmware update procedure, it will receive Program
Module from USB port, write it to NAND flash, and verify it one by one, meanwhile, create the
Program Module Index. Update Manager is downloaded by the Windows-based MP Tool or ISP
Tool provided by ALi.

www.ali.com.tw

6

M5661 Boot-Up Sequence
The flow chart of Boot-Up sequence:
Power On

Force to update
program?

Yes

No
Yes

Program Module
Index is valid?
No

Execute DDM to
load default Program Module

Download Update Manager
from Host to SRAM

Context switch.

Context switch.
Execute Update Manager

Execute the Program Module

Update Program Modules

No

Need new
Program Module?
Yes

Execute DDM to
load new Program Module

Context switch to
execute the Program Module

No

Need new
Program Module?
Yes

www.ali.com.tw

7

M5661 Boot-Up Sequence
4. Boot Loader
The Boot Loader provides four major functions:
A. Force firmware update
The M5661 can force the Boot Loader to stay in Boot-Loader stage even if the Program
Module Index is valid. And awaits firmware update request from USB port. This is
triggered by a external hardware event, holding a key when power on
B. NAND flash read function
It provides a basic NAND flash read function to loads DDM from NAND flash to SRAM.
The Read function always access NAND lash memory by using 8-bit, 512-byte page mode,
even the NAND flash memory supports 2K-byte page mode.
C. USB function
Boot Loader acts as a simplified USB Mass Storage device to connect with PC. The device
can download Update Manager from PC by this function.
The USB Descriptors and product settings are stored in the NAND flash memory, to
support product information customization (they are changeable). Customers can set
product information as they require.
D. Auto-Check mechanism
It provides two auto-check mechanism for NAND flash and Boot Loader. One is to
auto-check which type of NAND flash memory is built-in, and another is to auto-check the
firmware code is available or not.
Before Boot Loader reads data from NAND flash, it will detect NAND flash chip ID to
decide which type of command Boot Loader should use. If Boot Loader can not recognize
the NAND flash chip ID, it will start a auto-detection mechanism to check which type of
command will fit this NAND flash chip. It means that the mechanism will try to read
NAND flash and make sure this process is reliable. By this mechanism, we may start our
program even though the NAND flash ID we do not support.
When firmware gets recognized NAND flash, it will use the Program Module Index to
check whether program in NAND flash is available or not. In order to ensure the data
reliability, there are four copies of Program Module Index stored in NAND flash physical
page 256, 257, 258, and 259. The detail format of Program Module Index can be found in
the section of Program Module Index.
If the Boot Loader can find a valid Program Module Index, that is, the program module
www.ali.com.tw

8

M5661 Boot-Up Sequence
is available. Then, the Boot Loader will call the DDM to download the default Program
Module. If the program is not available, the Boot Loader will wait for USB connection,
then downloading the Update Manager and switch to the Update Manage.

www.ali.com.tw

9

M5661 Boot-Up Sequence
The flow chart of Auto-Check mechanism:
Start

No

Support Nand
Flash ID ?

Nand Flash Check Mechanism

Yes
Force to update
program?

Yes

Yes

Check OK ?

No

No
Page 256 is valid
Program Module
Index?

Yes

No
Page 257 is valid
Program Module
Index?

Yes

No
Page 258 is valid
Program Module
Index?

Yes

No
Page 259 is valid
Program Module
Index?

Yes

No
Yes

Usb data in Nand
Flash OK?
No

Load data to SRAM

Use default USB data in ROM

USB connect ?

No

Yes
Execute DDM

Download default
Program Module to SRAM

Download Update Manager to
SRAM

No

Successfully
download?
Yes

Context switch.
Execute Program Module

www.ali.com.tw

Context switch.
Execute Update Manager

10

M5661 Boot-Up Sequence

E. Dynamic Download Manager (DDM)
The Dynamic Download Manager provides a function to switch the program modules.
This function can load the specified Program Module from NAND flash to SRAM, and
switch to it. Because DDM is used by Boot Loader (in mask ROM) and Program
Modules (in SRAM). Its variables must locate at fixed address.
There are two situations the DDM will be started:
1. Booting
When Boot Loader starts and the Program Module Index is available, the Boot
Loader will call the DDM to load default Program Module to SRAM and switch to it.
2. Switching Program Module
When firmware needs to run a procedure that is located in another Program Module,
firmware must jump back to the DDM, load the new Program Module to SRAM , and
jump to entry of the new loaded Program Module.

www.ali.com.tw

11

M5661 Boot-Up Sequence
5. Program Module
The Program Module is a MCU program for a particular feature. For example, “MP3 Player”
is a program module, and “FM Radio” is a program module, too. Programmer should build a
Program Module for a particular function. The total useable MCU program size is 40 K bytes
(program memory is in the SRAM), but the last 17 bytes will be overlap for context switch.
( Reserved ), That is the maximum size for a Program Module

SRAM
0x0000

0x0800

……
Program
Module A

Program
Module B

Program
Module C

0x9FEF
0x9FFF

www.ali.com.tw

12

M5661 Boot-Up Sequence
6. Program Module Index
The Program Module Index is a 512-byte data structure. It's wrote by Update Manager. There
are four copies of Program Module Index are stored in NAND flash.
The format of the Index:
Offset(Byte)
0~3
4~5
6~7
8~9
10~11
12~15

Description
This value of ID should be “0x56, 0x61, 0xAA, 0x55”.
Check ID
If this value is valid, it means Program Modules are ready.
Sector Number Start sector number of this Program Module.
Initial
(1 sector = 512 Bytes)
Program
Length
The length (sector) of this Program Module.
Module
Program Sector Number
Module 1 Length
Program Module 2




504~507
508~509
510~511

Name

Program Module 125
Reserved
00
Sector number of test
pattern

The data structure in NAND flash:
(a) 512-byte page mode
US
B
Inf
o.
0

Progra
m
Module
Index
256

Progra
m
Module
Index
257

Progra Progra Progra
m
m
m
Module Module Manage
Index Index 0r
258
259

Progra
m
Module
1
260

Progra
Progra Test Pattern
m
m

Module Module
2
N

Progra
m
Module
1
272

Progra
Progra Test Pattern
m
m

Module Module
2
N

Mass Storage Space

Sector 4096 …

(b) 2048-byte page mode
UD Progra
B m
Info Module
.
Index
0 256

Progra
m
Module
Index
260

www.ali.com.tw

Progra Progra Progra
m
m
m
Module Module Manage
Index Index r0
264
268

Mass Storage Space

Sector 4096 …

13

M5661 Boot-Up Sequence
7. Update Manager
The Update Manager is a MCU program that handles the program module download procedure.
This program will be downloaded to SRAM from PC via USB port in firmware update procedure.
The flow char of Program Module downloading procedure:
S ta r t U p d a te M e n a g e r

S ta r t to d o w n lo a d a
P ro g ra m M o d u le

R e c e iv e 5 1 2 b y te s o f
p r o g r a m c o d e f r o m H o s t,
a n d w r ite to N a n d F la s h
( s ta rt fro m N a n d F la s h s e c to r 2 6 0 )

R e a d b a c k 5 1 2 b y te s f o r
v e r if ic a tio n

V e r if y O K ?

No

Y es
No

F in is h th is
P r o g r a m M o d u le ?
Y es

No

F in is h a ll P r o g r a m
M o d u le ?
Y es
R e c e iv e P r o g r a m M o d u le
In d e x

W r ite a n d v e r if y

www.ali.com.tw

14


ALI-M5661.rar > New IC SAR ADC(brief).pdf

One Battery
Vbat
1.5
1.4
1.3
1.2
1.1
1
0.9
0.8
0.7
0.6
0.5

ideal SAR ADC actual SAR ADC
127.00
126
114.90
113
102.81
101
90.71
90
78.62
77
66.52
65
54.43
52
42.33
40
30.24
28
18.14
16
6.05
4

3
2.9
2.8
2.7
2.6
2.5
2.4
2.3
2.2
2.1
2
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2
1.1
1
0.9

ideal SAR ADC actual SAR ADC
127.00
127
120.95
121
114.90
115
108.86
109
102.81
102
96.76
96
90.71
90
84.67
84
78.62
77
72.57
71
66.52
65
60.48
59
54.43
53
48.38
47
42.33
41
36.29
35
30.24
29
24.19
23
18.14
17
12.10
11
6.05
5
0.00
0

Two Battery
Vbat

Li-Ion
Vbat
4.2
4.1
4
3.9
3.8
3.7
3.6
3.5
3.4
3.3
3.2
3.1
3
2.9
2.8
2.7
2.6
2.5
2.4
2.3
2.2
2.1
2
1.9
1.8
1.7
1.6
1.5
1.4
1.3
1.2

ideal SAR ADC actual SAR ADC
127.00
The voltage of the
122.77
measurement pin can NOT
118.53
be larger than 3.7V. In real
114.30
Li-Ion system, it need
110.07
105.83
101.60
101
97.37
97
93.13
93
88.90
89
84.67
84
80.43
80
76.20
76
71.97
72
67.73
67
63.50
63
59.27
59
55.03
55
50.80
50
46.57
46
42.33
42
38.10
38
33.87
33
29.63
29
25.40
24
21.17
20
16.93
15
12.70
11
8.47
7
4.23
3
0.00
0

NOTE: The SAR ADC setting of Li-Ion
here is for the case that the BAT_DCV1
pin is directly connected to Vbat.


ALI-M5661.rar > Flash Card Support.pdf

OK: qualified

N/A : Not availible

R: Ready for test or in testing

S: Spec. compatible, not qualified

SDK_1.50.04

SDK_1.08

SDK_1.09.10

PKG Type

SDK_1.06

Capacity

v0.80.07

Part Number

v0.80.05

Page

v0.40.10

Cell

Configuration

Brand

1/13/05

2/20/05

3/4/05

3/30/05

4/11/05

4/27/05

5/4/05

K9F1208U0M-Y,P

1

64MB

TSOP

Status
OK

Status
OK

Status
OK

Status
OK

Status
OK

Status
OK

1

64MB

TSOP

S

S

S

S

S

S

S

K9F1208U0A-V,F

1

64MB

WSOP

S

S

S

S

S

S

S

K9F1208U0B-Y,P

1

64MB

TSOP

S

S

S

S

S

S

S

K9F1208U0B-V,F

1

64MB

WSOP

S

S

S

S

S

S

S

K9K1G08U0M-Y

1

128MB

TSOP

OK

OK

OK

OK

OK

OK

OK

1

128MB

TSOP

S

S

S

S

S

S

S

1

128MB

WSOP

S

S

S

S

S

S

S

S

S

S

S

S

Comment

Status
OK

K9F1208U0A-Y,P

S

Small K9K1G08U0A-Y,P
Block K9K1G08U0A-V,F
K9T1G08U0M-Y,P

1

128MB

TSOP

S

K9T1G08U0M-V,F

1

128MB

WSOP

S

S

S

S

S

S

S

S

S

S

S

S

S

S

K9T1G08B0M-Y,P
SLC

1

128MB

TSOP

K9T1G08B0M-V,F
Samsung

Data Bus

Mode

M5661 & M5661P

1

128MB

WSOP

S

S

S

S

S

S

S

N/A

N/A

N/A

N/A

N/A

N/A

No Sample
No Sample

K9E2G08U0M-Y,P

1

256MB

TSOP

N/A

K9E2G08U0M-V,F

1

256MB

WSOP

N/A

N/A

N/A

N/A

N/A

N/A

N/A

OK

OK

OK

OK

OK

OK

K9F1G08U0M-Y,P

1

128MB

TSOP

OK

K9F1G08U0M-V,F

1

128MB

WSOP

S

S

S

S

S

S

S

K9F1G08U0A-Y,P

1

128MB

TSOP

S

S

S

S

S

S

S

K9F1G08U0A-V,F

1

128MB

WSOP

S

S

S

S

S

S

S

1

256MB

TSOP

OK

OK

OK

OK

OK

OK

OK

S

S

S

S

S

S

K9K2G08U0M-Y,P
Large
K9K2G08U0M-V,F
Block
K9F2G08U0M-Y,P

1

256MB

WSOP

S

1

256MB

TSOP

OK

OK

OK

OK

OK

OK

OK

OK

OK

OK

OK

OK

OK

N/A

N/A

N/A

OK

N/A

OK

K9K4G08U0M-Y,P

1

512MB

TSOP

OK

K9W8G08U1M-Y,P

1

1GB

TSOP

N/A

K9F4G08U0M-Y,P
K9K8G08U0M-Y,P

1

512MB

TSOP

N/A

N/A

N/A

N/A

OK

R

OK

N/A

N/A

N/A

OK

R

OK

R

R

R

1

1GB

TSOP

N/A

1

512MB

TSOP

N/A

R

R

R

Small
Block
MLC

Large K9G4G08U0M-YCB0
Block K9L8G08U0M-PCB0

1

1GB

TSOP

N/A

N/A

N/A

N/A

R

R

R

TC58512FT

1

64MB

TSOP

N/A

OK

OK

OK

OK

OK

OK

TC58DVM92A1FT

1

64MB

TSOP

N/A

N/A

N/A

S

S

S

S

Small TH58100FT
Block TC58DVG02A1FT

1

128MB

TSOP

N/A

OK

OK

OK

OK

OK

OK

1

128MB

TSOP

N/A

N/A

N/A

S

S

S

TC58DVG04B1FTI0

1

128MB

TSOP

TC58DVG14B1FT00

SLC

1

256MB

TSOP

TC58NVG0S3AFT
Toshiba

N/A

Large TH58NVG1S3AFT
Block TC58NVG1S3BFT00
TH58NVG2S3BFT

N/A
OK

OK

S
N/A
N/A

OK

OK

OK

OK

OK

1

128MB

TSOP

1

256MB

TSOP

OK

OK

OK

OK

OK

OK

OK

N/A

N/A

S

S

S

R

N/A

N/A

S

S

S

R

1

256MB

TSOP

N/A

1

512MB

TSOP

N/A

Small
Block
1

256MB

TSOP

N/A

R

R

R

OK

R

OK

1

512MB

TSOP

N/A

R

R

R

OK

R

OK

1

1GB

TSOP

N/A

N/A

N/A

N/A

R

R

R

1

2GB

TSOP

HN29V1G91T-30V

1

128MB

1

128MB

AGAND

R
N/A

N/A

N/A

N/A

N/A

N/A

N/A

TSOP

N/A

N/A

N/A

N/A

N/A

N/A

N/A

No Sample

N/A

N/A

N/A

N/A

N/A

N/A

No Sample

R

R

R

R

R

R

Infineon

Renasas

TC58NVG1D4BTG00
Large TC58NVG2D4BTG00
Block TH58NVG3D4BTG00
TH58NVG4D4BTG20

MLC

x8

anDisk

SLC

Large SDTNGEHE0-1024
Block SDTNGEFE0-2048
Small

SDTNGCHE0-512

1

256MB

TSOP

N/A

1

64MB

TSOP

N/A

Sa

MLC

Small
SDTNGCHE0-1024
Block
SDTNGCHE0-2048

1
1

Hynix

Small HY27US08121M-T,V
Block HY27UA081G1M-T,V
SLC

1
1

HY27UF081G2M-T,V

1

Large HY27UF081G2M-T,V
Block HY27UG082G2M-T,V

1

2

TSOP

N/A

N/A

N/A

S

S

S

S

TSOP
TSOP/WSO
64MB
P
TSOP/WSO
128MB
P
TSOP/WSO
128MB
P
TSOP/WSO
256MB
P
TSOP/WSO
256MB
P
512MB
TSOP

N/A

N/A

N/A

S

S

S

S

128MB
256MB

S

S

S

S

S

S

S

OK

OK

OK

OK

OK

OK

OK

N/A

N/A

N/A

OK

OK

OK

OK

N/A

N/A

N/A

S

OK

R

OK

N/A

N/A

N/A

S

OK

OK

OK

HY27UH084G2M-T

1

N/A

N/A

N/A

S

OK

R

OK

NAND128W3A

1

16MB

TSOP

N/A

N/A

N/A

N/A

N/A

N/A

N/A

Small NAND256W3A
Block NAND512W3A

1

32MB

TSOP

N/A

N/A

N/A

N/A

N/A

N/A

N/A

1

64MB

TSOP

N/A

R

R

R

R

R

R

NAND01GW3A

1

128MB

TSOP

N/A

S

S

SLC

S

S

S

S

N/A

S

S

S

NAND512W3B

1

64MB

TSOP

NAND01GW3B

1

128MB

TSOP

S

OK

S

OK

OK

S

OK

ST

Large
NAND02GW3B
Block
NAND04DW3B
NAND08GW3B

1

256MB

TSOP

S

1

512MB

TSOP

S

S

S

S

S

S

S

S

R

OK

OK

OK

1

1024MB

TSOP

1

256MB

TSOP

Small
Block
MLC
Large
Block
Small
Block

Micron

SLC

MT29F2G08
Large
MT29F4G08
Block
MT29F8G08
Small
Block

MLC
Large
Block

R

1

512MB

TSOP

R

1

512MB

TSOP

R

R
R

x16

Memory Card Support

OK
S
R
N/A

(qualified)
( Spec. compatible, not qualified yet)
(ready for test or in testing)
(Not availible)
MD - Micro Drive Card
SM - Smart Media Card
xD - xD Picture Card
xD - xD Picture Card
SD - Secure Digital Card
MMC - MultiMedia Card
MS - Memory Stick Card
MS Pro - Memory Stick Pro Card
New MS - New Memory Stick Card

12
29
6
13

23
25
7
9

14
27
11
8

23
23
10
9


ALI-M5661.rar > ProgGuide.pdf

M5661 Firmware Programming Guide

M5661 Firmware Programming Guide

www.ali.com.tw

1

M5661 Firmware Programming Guide

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.

Copyright © ALi Corporation, 2004. All rights reserved

www.ali.com.tw

2

M5661 Firmware Programming Guide

Version History
Date
12/15/2004
8/15/2005
10/22/2005
10/22/2005

Version
1.0
1.1
1.2
1.3

www.ali.com.tw

Description
First release
Update functions
Update functions and append OLED and Classification functions
Append the OledString function.

3

M5661 Firmware Programming Guide

CONTENTS
Copyright © ALi Corporation, 2004. All rights reserved ............................ 2
Version History................................................................................................. 3
1

Firmware Architecture ............................................................................. 6

2

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

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

2.19
2.20
2.21
2.22
2.23
2.24
2.25
2.26
2.27

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

2.28
2.29
2.30

UI PLAY DVR (UIPLAY.C) ............................................................................. 181
UI RECORD (UIREC.C)................................................................................... 184
UI FM (UIFM.C) ........................................................................................... 189

www.ali.com.tw

4

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

5

M5661 Firmware Programming Guide
1

Firmware Architecture

User
Interface

DDM

LCD

USB

ATA

Key

Playback

DVR

Record

FM

System

File System

Nand Flash

www.ali.com.tw

Initial

SD

6

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

See also
FsRecInit(void)

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

7

M5661 Firmware Programming Guide
Storage Path. On another point, the constant FS_FAT1_EXT1 indicates the same
Storage Path as FS_LRC and FS_FAT1_EXT2 is the same as FS_FAT if the constant
REC_PRE_SEARCH has defined.
Global variable
XBYTE gxbFsData[2048], gxbLyrics[2048], gxbFsFat[2048]
Every Storage Path is assigned a global array, so you can get the data from the
Storage Path by using this global array. For the relation between Storage Path and
Global Array is listed as below.
Storage Type

Relative Global Array

FS_DATA_0_0

gxbFsData[2048]

FS_LRC, FS_FAT1_EXT1

gxbLyrics[2048]

FS_FAT, FS_FAT1_EXT2

gxbFsFat[2048]

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 5’s 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

8

M5661 Firmware Programming Guide
NAND FLASH start sector you want to write.
BYTE bStorLen
Data length in sector you want to write.
BYTE bStorPath
Storage Path you want to write. For detail description, you can refer FsRead().
Global Variable
XBYTE gxbStorType
STOR_NAND: To read data from Nand Flash.
STOR_SD: To read data from SD card.
Return values
Bit type
Return TRUE if write data success, or else.
Example

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 can’t find the directory.
FALSE: The function wouldn’t create this directory if can’t find the directory.
Return values
Bit type
TRUE: Success.
FALSE: Can’t 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

9

M5661 Firmware Programming Guide
gxbMusicType:
The type of music, the value which can be assigned is following, M_MP3,
M_WMA_UNKNOWN, M_OGG, M_WAV, etc. For more defined constant of music type
are defined in const.h.
Example

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

M5661 Firmware Programming Guide
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().
Return values
Bit type
TRUE: format successfully.
FALSE: format fail or I/O error.
Example

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

M5661 Firmware Programming Guide
FsOpenFile()
This function would open an existed file.
bit FsOpenFile(BYTE bOpenType)
Parameters
BYTE bOpenType
This parameter to be decided by which type of file you want to open. The
parameter could have the const value defined in const.h as follows.
FIRST_FILE
NEXT_FILE
PREV_FILE
FIRST_PLAYBACK
NEXT_PLAYBACK
PREV_PLATBACK
LYRICS_FILE
The file you assign the LYRICS_FILE parameter to find a Lyrics file is on the same
directory of mp3, and the filename is the same with current mp3 filename which
defined in the global array gbFileName[0~7]. For another note, open a Lyrics file
will not change any information of current file.
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().
XBYTE gxbMusicType
The type of music, the value which can be assigned is following, M_MP3,
M_WMA_UNKNOWN, M_OGG, M_WAV, etc. For more defined constant of music type
are defined in const.h.

Return values
Bit type
TRUE: file open successfully.
FALSE: can’t find file or I/O read error.
Example

www.ali.com.tw

12

M5661 Firmware Programming Guide
See also

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: can’t 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: can’t 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

M5661 Firmware Programming Guide
FS_DATA_0_0, FS_FAT, FS_FAT1_EXT2, FS_LRC, FS_FAT1_EXT1
For more description, you can refer the function of FsRead().
XBYTE gxbMusicType
The type of music, the value which can be assigned is following, M_MP3,
M_WMA_UNKNOWN, M_OGG, M_WAV, etc. For more defined constant of music type
are defined in const.h.
Example

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

M5661 Firmware Programming Guide
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().
Example

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

M5661 Firmware Programming Guide
Example

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

SYS Functions

FsWrite( )
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) & gt; & gt; 12);
if(gxdwFileCurrentClu%1024==682)
dwCurrentWriteSec+=1;

www.ali.com.tw

16

M5661 Firmware Programming Guide
if(!FsWrite(dwCurrentWriteSec,1,FS_FAT))
return FALSE;
See also
FsInit() | FsRead()

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

M5661 Firmware Programming Guide
See also

NandRead()
Read function from Nand flash.
bit NandRead(void)
Parameters
None
Return values
Bit type
TRUE:
FALSE:
Global variables
gbSpecialRW:
gdwStorLba:

The sector number that will be read.

gbStorTransLen:

Number of sectors will be read.

gbStorPath:

The assigned area that data will be read to.

Example

See also

NandFinishJob()

bit NandFinishJob(void)
Parameters
None
Return values
Bit type
TRUE:
FALSE:
Global variables

Example

See also

www.ali.com.tw

19

M5661 Firmware Programming Guide
NandStepJob()
Speed up function for playback.
bit NandStepJob(void)
Parameters
None
Return values
Bit type
TRUE:
FALSE:
Global variables

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

M5661 Firmware Programming Guide
Global variables

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

M5661 Firmware Programming Guide
PhyBlockEraseAll()

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 - & gt; SRAM - & gt; gwConfigBlock
LBA 0~3: 0xD000

= & gt;

Config

LBA 4~7: 0xD800

= & gt;

BadBlockInfo

....
LBA 28~31:

0xD800

= & gt;

BadBlockInfo

void PhyWriteConfig(void)
Parameters
None
Return values
None
Global variables

Example

See also

ReadBadBlock()
Special ATAPI command: send bad block info to host.
void ReadBadBlock(BYTE bType)

www.ali.com.tw

22

M5661 Firmware Programming Guide
Parameters
BYTE bType
Return values
None
Global variables

Example

See also

ReadDevice()

void ReadDevice(void)
Parameters
None
Return values
None
Global variables

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

M5661 Firmware Programming Guide
Example

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:

DATA SRAM address.

wLen:

transfer len (unit is BYTE).

fWrite:

TRUE

= & gt;

WRITE

FALSE

= & gt;

READ

Return values
Bit type
TRUE:
FALSE:
Global variables

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

M5661 Firmware Programming Guide
Example

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()

void GetIniDefectBlock(void)
Parameters
None
Return values
None
Global variables

Example

See also

www.ali.com.tw

25

M5661 Firmware Programming Guide
NandFormatCapa()
Handle UFI command.
bit NandFormatCapa(XBYTE type)
Parameters
XBYTE type
Return values
Bit type
TRUE:
FALSE:
Global variables

Example

See also

2.2.2

www.ali.com.tw

SYS Functions

26

M5661 Firmware Programming Guide
2.3 SD (SD.c)
2.3.1

API Functions

SD_Init_400K()
SD Initialization.
bit SD_Init_400K(void)
Parameters
None
Return values
Bit type
TRUE:

SD/MMC card was initialized successfully.

FALSE:

SD/MMC card was not initialized successfully. (Include SD/MMC was not
inserted)

Global variables
gfSDinit:

Indicate that SD/MMC card had been initialized.

gxbSd_cmd:

The divisor to control the SD/MMC Clock ( & lt; 400KHZ).

gfMediumChange:

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:

All data transfer was completed.

FALSE:

Error occurs.

Global variables
gbStorTransLen:

The number of blocks to be transfer.

gbStorPath:

The address of Target (in SRAM).

gdwStorLba:

The LBA of Source (in SD/MMC Card).

www.ali.com.tw

27

M5661 Firmware Programming Guide
gxbSD_Error:

Error code.

gxbSDCardType:

SD_MODE(SD),MMC_MODE(MMC).

gfR1Err:

TRUE,R1 report error.

Example

See also

SD_Write()
Write data to SD. (data source: SRAM).
bit SD_Write(void)
Parameters
None
Return values
Bit type
TRUE:

All data transfer was completed.

FALSE:

Error occurs.

Global variables
gbStorTransLen:

The number of blocks to be transfer.

gbStorPath:

The address of Target (in SRAM).

gdwStorLba:

The LBA of Source (in SD/MMC Card).

gxbSD_Error:

Error code.

gxbSDCardType:

SD_MODE(SD),MMC_MODE(MMC).

gfR1Err:

TRUE,R1 report error.

Example

See also

SD_Det()
Check whether SD/MMC card is inserted or not.
bit SD_Det(void)
Parameters
None
Return values
Bit type
TRUE

www.ali.com.tw

SD/MMC card was installed.

28

M5661 Firmware Programming Guide
FALSE

SD/MMC card was not installed.

Global variables

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:

SD_MODE(SD),MMC_MODE(MMC).

gfSDWP:

TRUE, the SD/MMC card is write-protected.

Example

See also

www.ali.com.tw

29

M5661 Firmware Programming Guide
SDReadCapa()
ATAPI Function.
Send 8 bytes data to PC, including the number of blocks in card (4 bytes), the number
of bytes in a block (4bytes). When accepted Read-Capacity CMD (opcode=0x25).
void SDReadCapa(void)
Parameters
None
Return values
None
Global variables
gxdwSD_Blocknum:

The number of blocks in SD/MMC Card.

gxdwSD_Blocklen:

The number of bytes in a block.

Example

See also

SD_USBRead()
Read data from SD. (data Target: USB )
bit SD_USBRead(void)
Parameters
None
Return values
Bit type
TRUE:

All data was transfer to USB.

FALSE:

Error occurs.

Global variables
gdwCBWDataTransferLength:

The number of bytes to be transfer.

gxdwLBA_address:

The LBA of Source

gxdwSD_Blocknum:

The number of blocks in SD/MMC Card.

gxwSD_SecCnt:

Anytime the number of Blocks to be transferred ,when

(in SD/MMC Card).

SD_USBRead() is called.
gxbSDCardType:

SD_MODE(SD),MMC_MODE(MMC).

gfSplitCommand:

TRUE, the number of Blocks to be transfer is more
than 255.

gfR1Err:

TRUE,R1 report error.

gxbSD_Error:

Error code(the most significant nibble: SD CMD, the

www.ali.com.tw

30

M5661 Firmware Programming Guide
least significant nibble: error condition).
Example

See also

SD_USBWrite()
Write data from SD. (data Target: USB)
bit SD_USBWrite(void)
Parameters
None
Return values
Bit type
TRUE:

All data was transfer to USB.

FALSE:

Error occurs.

Global variables
gdwCBWDataTransferLength:

The number of bytes to be transfer.

gxdwLBA_address:

The LBA of Source

gxdwSD_Blocknum:

The number of blocks in SD/MMC Card.

gxwSD_SecCnt:

Anytime the number of Blocks to be transferred ,when

(in SD/MMC Card).

SD_USBRead() is called.
gxbSDCardType:

SD_MODE(SD),MMC_MODE(MMC).

gfSplitCommand:

TRUE, the number of Blocks to be transfer is more
than 255.

gfR1Err:

TRUE,R1 report error.

gxbSD_Error:

Error code(the most significant nibble: SD CMD, the
least significant nibble: error condition).

Example

See also

2.3.2

www.ali.com.tw

SYS Functions

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

M5661 Firmware Programming Guide
Parameters
None
Return values
Bit type
TRUE:
FALSE:
Global variables

Example
Please see PlayEngine( ) example.
See also

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

M5661 Firmware Programming Guide
See also

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

M5661 Firmware Programming Guide
Use this command to stop current playing job.
P_RESTART
Use this command to repeat playing same music file (single repeat mode).
P_AB_REPT_START
Use this command to inform playing engine the start point of AB-repeat
segment.
P_AB_REPT_END
Use this command to inform playing engine the endpoint of AB-repeat
segment.
P_AB_REPT_RETURN_A
Use this command to let playing engine jump to start point of AB-repeat
segment.
P_AB_REPT_RESET
No action.
P_NOP
Use this command to drive playing engine to check output buffer status, and
perform bit stream decoding.
P_RND_NEXT
This command let playing engine select next music file and standby.
P_RND_FIRST
This command let playing engine select first music file and standby.
P_RND_START
This command let playing engine start to play current selected file.
Return values
Bit type
TRUE: Command executed OK.
FALSE: There’s some error occurs during command execution.
Global variables
Omitted.
Example

See also

2.4.2

www.ali.com.tw

SYS Functions

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

M5661 Firmware Programming Guide
if(ReInit())
{
ReStart();
}
See also
ReInit( ) | ReEngine( )

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

See also
ReInit( ) | ReStart( )

FsRead()
Call storage read function.
bit FsRead(DWORD dwStorLba, BYTE bStorLen, BYTE bStorPath)

www.ali.com.tw

37

M5661 Firmware Programming Guide
Parameters
DWORD dwStorLba
BYTE bStorLen
BYTE bStorPath
Return values
Bit type
TRUE:
FALSE:
Global variables
gxbStorType:

Read from which storage.

Example

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

www.ali.com.tw

SYS Functions

38

M5661 Firmware Programming Guide
2.6 ImaAdpcm (ImaAdpcm.c)
2.6.1

API Functions

ImaAdpcmEncInit( )
Initial buffer read/write pointer, and ADPCM encode engine’s 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 & lt; BUFFER_SIZE; i ++)
{
ImaAdpcmEncode( PcmBuffer[i] );
}
See also
ImaAdpcmDecode()

ImaAdpcmDecode( )
Use ADPCM to decode a sample.

www.ali.com.tw

39

M5661 Firmware Programming Guide
void ImaAdpcmDecode(void)
Parameters
None
Return values
None
Global variables

Example

See also
ImaAdpcmEncode( )

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

M5661 Firmware Programming Guide
Return values
None
Global variables

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

www.ali.com.tw

SYS Functions

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:

Key pressed repeat counter.

gxbKeyId:

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:

Key pressed repeat counter.

gxbKeyId:

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

M5661 Firmware Programming Guide
See also

2.7.2

www.ali.com.tw

SYS Functions

43

M5661 Firmware Programming Guide
2.8 FM (FmChip.c)
2.8.1

API Functions

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

M5661 Firmware Programming Guide
Parameters
None
Return values
None
Global variables

Example

See also
FmDataInit()

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

1: Up

0: Down

Return values
Bit type
Global variables

Example

www.ali.com.tw

45

M5661 Firmware Programming Guide
See also

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

www.ali.com.tw

SYS Functions

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

www.ali.com.tw

SYS Functions

47

M5661 Firmware Programming Guide
2.10

LCD (Lcd.c)

Index

Mnemonic — Name

Type

Default

FEFAh

LDC_CLK_CTRL — LCD Clock Control Register

R/W

00h

FF08h

MODE SELECT2 — Mode Select Register2

R/W

00h

FF34h

GPIOC_DAT

R/W

00h

FF35h

GPIOC_DIR

R/W

00h

FFD0h

LCDCTRL — LCD Control Register

R/W

00h

FFD1h

LCD_PAR_RDDAT — LCD Parallel Read Data Register

R/W

00h

FFD2h

LCD_WRDAT — LCD Write Data Register

R/W

00h

LCD Clock Control/Division Registers (FEFAh)
FEFAh

LCD_CLK_CTRL — LCD Clock Control Register

D7

D6

Reserved

D5

D4

D3

SYS_DIV2 AUDIO_DI Reserved
V2

SYS_DIV2
1: Enable.
0: Disable.

D1

CLKEN

CLKSEL

Type

Default

R/W

D0

00h

SYS_CLK Divide 2 Enable

AUDIO_DIV2
1: Enable.
0: Disable.

D2

AUDIO_CLK Divide 2 Enable

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

MODE SELECT2 — Mode Select Register 2 (FF08h)
FF08h
D7

MODE_SEL2 — Mode Select Register2
D6

D5

FORCE_RO LCD_SERE LCD_PARE
MCSJ

N

N

D4

D3

I2CS_EN

I2CM_EN

D2
I2S1_PIN_S
EL

D1

D0

Type

Default

I2S2_EN

I2S1_EN

R/W

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

M5661 Firmware Programming Guide
1: I2C Matster Enable.
0: I2C Matster Disable.
Bit 2: I2S1_PIN_SEL
This bit is used to switch the I2S-1 function onto alternate pin.
1: Switch the pins of I2S1 to GPIOC[3:1]
0: Switch the pins of I2S1 to GPIOG[3:1]
Bit 0: I2S2_EN
I2S-2 Enable
1: I2S-2 Enable.
0: I2S-2 Disable.
Bit 0: I2S1_EN
I2S-1 Enable
1: I2S-1 Enable.
0: I2S-1 Disable.

GPIOC — GPIOC
FF35h)

Data Port and Direction Registers (FF34h —

FF34h
D7

GPIOC_DAT — GPIOC Data Port
D6

D5

D4

D3

D0

GPIOC_DAT[7:0]
FF35h
D7

Default
00h

Type

Default

R/W

D1

Type
R/W

D2

00h

GPIOC_DIR — GPIOC Direction Register
D6

D5

D4

D3

D2

D1

D0

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

LCDCTRL — LCD Control Register (FFD0h)
FFD0h

PARLCD —

Parallel LCD Control Register

D6

D5

D4

D3

D2

D1

D0

Type

Default

CS polarity

D7

DOE

RD

WR

A0

CS

R/W

00h

Bit 7-6: Reserved
Bit 5: CS_POR
0: Low active
1: High active

LCD Chip Select Polarity

Bit 4: DOE
0: disabling
1: enabling

LCD Parallel Data Output Enabling

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

M5661 Firmware Programming Guide
Bit 0: CS
LCD Parallel A0 Signal
This bit control GPIOC[4] when LCD_EN is enabling

LCD_PAR_RDDAT — LCD Parallel Read Data Register (FFD1h)
FFD1h

PARLCD_RDAT — Parallel LCD Read Data

D7

D6

D5

D4

D3

D1

D0

LCD_PAR_RDDAT[7:0]

Type

Default

R/W

D2

00h

Type

Default

R/W

00h

Bit 7-0: LCD_PAR_RDDAT
LCD Parallel Read Data
The register reflects GPIOF[7:0] status when LCD_EN is enabling.

LCD_WRDAT — LCD Write Data Register (FFD2h)
FFD2h

LCD_WRDAT — Parallel LCD Write Data/Serial LCD Data Register

D7

D6

D5

D4

D3

D2

D1

D0

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]

2.10.1 API Functions

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

M5661 Firmware Programming Guide
Note: You should not call this function again when bus has shared for LCD. That would
let system crashed.
void LcdCtrlEn(void)
Parameters
None
Return values
None
Global variable

Example

See also
LcdCtrlDis()

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

See also
LcdCtrlEn()

LcdSendCommand ( )
Send command to LCD.
void LcdSendCommand(BYTE bCommandVal)
Parameters
BYTE bCommandVal
Commands form DB7-DB0.

www.ali.com.tw

51

M5661 Firmware Programming Guide
Return values
None
Global variable

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

See also
LcdReadData() | LcdGoto()

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

M5661 Firmware Programming Guide
See also
LcdWriteData() | LcdGoto()

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

See also
LcdWriteData() | LcdReadData()

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

M5661 Firmware Programming Guide
LcdClearAll( )
Clean LCD.
void LcdClearAll (void)
Parameters
None
Return values
None
Global variable

Example

See also
LcdClearPage()

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

See also
LcdClearAll()

LcdScrollText( )
Scroll data on LCD.

www.ali.com.tw

54

M5661 Firmware Programming Guide
void LcdScrollText(BYTE bPage1, BYTE bColNum1, BYTE bPage2, BYTE bColNum2)
Parameters
BYTE bPage1
Specifies the scrolled page number of the left side.
BYTE bColNum1
Specifies the scrolled column number of the top side.
BYTE bPage2
Specifies the scrolled page number of the right side.
BYTE bColNum2
Specifies the scrolled page number of the bottom side.
Return values
None
Global variable

Example

See also

LcdCopyPage()
Copy a page data to another page.
void LcdCopyPage(BYTE bPage1,BYTE bPage2)
Parameters
BYTE bPage1:

source page

BYTE bPage2:

target page

Return values
None
Example

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

M5661 Firmware Programming Guide
Parameters
BYTE bPage
Specifies the display page number.
BYTE bColNum
Specifies the display column number.
BYTE bHeight
Specifies the display height.
BYTE bWidth
Specifies the display width.
Return values
None
Global variable

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

M5661 Firmware Programming Guide
skipped
BYTE gxbLcdDispLimPix
If some data have been skipped (over the limit column), how many pixels have
been displayed.

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

M5661 Firmware Programming Guide
LcdShowString(bString,0,0,3);
See also
LcdShowSysString()

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

See also
LcdShowString()

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

M5661 Firmware Programming Guide
Return values
none
Global variable

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

M5661 Firmware Programming Guide
operate with LcdShowString() function. If you call LcdShowSysString, you just need to
set column number as LCD_AUTO_CENTER_COL.
BYTE LcdCenterColumn(BYTE bNum)
Parameters
BYTE bNum
String length (pixel)
Return values
BYTE type
The center column number
Global variable

Example

See also
LcdShowSysString() | LcdShowString()

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

M5661 Firmware Programming Guide
LcdShowAnimation( )
Show one picture (for animation).
Note: This function use pm107 data. Use 1 sector (512 bytes) per picture.
void LcdShowAnimation(BYTE bPicNum, BYTE bPage, BYTE bColNum, BYTE bHeight,
BYTE bWidth)
Parameters
BYTE bPicNum
Specifies the picture number in pm107.
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

Example
The following example will show 5 pictures.
for(bI=0;bI & lt; 5;bI++)
{
for(wDelayTime=0;wDelayTime & lt; 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

M5661 Firmware Programming Guide
Global variable
XBYTE gxbMusicType
Point out the music tag type
XBYTE gxbLcdTagStatus
Set the tag state flag
bit 1-3: Which tag is shown
LCD_TAG_TURN_DEFAULT:
Default state, changing new song, or unknown tag state.
LCD_TAG_TURN_FILEONLY:
No tag, only show File name
LCD_TAG_TURN_TITLE:
Showing tag title
LCD_TAG_TURN_ARTIST:
Showing tag artist
LCD_TAG_TURN_ALBUM:
Showing tag album

Example

See also
LcdScrollTag()

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

See also
LcdShowTagTitle()

www.ali.com.tw

62

M5661 Firmware Programming Guide
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

See also
LcdSetLyricDone() | LcdScrollLyric()

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

See also
LcdShowLyrics() | LcdSetLyricDone()

www.ali.com.tw

63

M5661 Firmware Programming Guide
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

See also
LcdShowLyrics() | LcdScrollLyric()

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

See also
LcdScrollFileList() | LcdShowClassList()

LcdScrollFileList()
Scroll long file name in file list.

www.ali.com.tw

64

M5661 Firmware Programming Guide
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

See also
LcdShowFileList()

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

See also
LcdShowFileList()

LcdShowDirName()
Display dir-name.
void LcdShowDirName(void)

www.ali.com.tw

65

M5661 Firmware Programming Guide
Parameters
None
Return values
None
Global variable

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

M5661 Firmware Programming Guide
See also

2.10.2 SYS Functions
LcdReadStatus( )
Load LCD state.
BYTE LcdReadStatus(void)
Parameters
None
Return values
byte type (LCD Status)
Bit7

Busy flag (1:busy 0:normal)

Bit6

ADC (1:normal direction 0:reverse direction)

Bit5

Display On/Off (1:Display Off 0:Display On)

Bit4

Restb (1:being reset 0:not reset)

Bit0-3 Don't care
Example

See also
LcdWaitBusy()

LcdWaitBusy( )
Wait while LCD is busy
bit LcdWaitBusy(void)
Parameters
None
Return values
Bit type
TRUE: Not busy
FALSE: Time out for waiting
Example

See also
LcdReadStatus()

BYTE_DELAY( )
Add command delay time
void BYTE_DELAY(BYTE bDelay)
Parameters
BYTE bDelay
Delay time.

www.ali.com.tw

67

M5661 Firmware Programming Guide
Return values
None
Example

See also

LcdTurnTag( )
Switch Tag on LCD (Title- & gt; Artist- & gt; 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

See also
LcdShowFileList()

www.ali.com.tw

68

M5661 Firmware Programming Guide
2.11

Oled (Oled.c)

2.11.1 API Functions

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

See also
OledCtrlDis()

OledCtrlDis( )
Switch share bus for Nand Flash control.

www.ali.com.tw

69

M5661 Firmware Programming Guide
void LcdCtrlDis(void)
Parameters
None
Return values
None
Global variable

Example

See also
OledCtrlEn()

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

See also
OLED_SET_DAT(),OLED_SET_STS(),OLED_WRITE(bData), OLED_READ(bData).

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

M5661 Firmware Programming Guide
Example

See also
OLED_SET_DAT(),OLED_SET_STS(),OLED_WRITE(bData), OLED_READ(bData).

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

Example
OLED_SET_DAT();
OLED_READ(bData); //dummy read

www.ali.com.tw

71

M5661 Firmware Programming Guide
OLED_READ(bData); //read 1 byte data from OLED
OLED_SET_STS();
OLED_READ(bStatus); //read oled status
See also
OLED_SET_DAT(),OLED_SET_STS(),OLED_WRITE(bData), OLED_READ(bData)

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

See also
BACKLIGHT_ON(),BACKLIGHT_OFF()

OledDisplayFade()
Display fade in or display fade out.

www.ali.com.tw

72

M5661 Firmware Programming Guide
void OledDisplayFade(BOOL fFadeIn,WORD wDelay)
Parameters
BOOL fFadeIn
TRUE : Display fade in
FALSE: Display fade out
WORD wDelay
Fade delay
Return values
None
Global variable

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

See also
BACKLIGHT_OFF(),OledSetContrast().

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

M5661 Firmware Programming Guide
Parameters
BYTE bPage
Specifies the scrolled page number.
Return values
None
Global variable
None
Example
None
See also
BACKLIGHT_OFF(),OledSetContrast().

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

M5661 Firmware Programming Guide
Parameters
None
Return values
None
Global variable

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

M5661 Firmware Programming Guide
OledReverse ( )
Reverse color in specific rectangular area.
void OledReverse(BYTE bColStart,BYTE bRowStart,BYTE bWidth,BYTE bHeight)
Parameters
BYTE bColStart
Start column of the target area.
BYTE bRowStart
Start row of the target area.
BYTE bWidth
Width of the target area.
BYTE bHeight
Height of the target area.
Return values
None
Global variable

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

M5661 Firmware Programming Guide
BYTE GxbMaskRight
BYTE GxbMaskTop
BYTE GxbMaskBottom
Above global variables are defined the mask window.
BYTE gfMaskInside
TRUE: mask inside
FALSE: mask ouside
Example

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

See also
OledDrawRect ();

OledDrawRect ()
Draw rectangle with foreground color

www.ali.com.tw

77

M5661 Firmware Programming Guide
void OledDrawRect(BYTE bColStart, BYTE bRowStart, BYTE bWidth, BYTE bHeight)
Parameters
BYTE bColStart
BYTE bRowStart
BYTE bWidth
BYTE bHeight
Above parameters determine a rantangle to draw.
Return values

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

M5661 Firmware Programming Guide
See also

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

See also
OledShowIcon()

www.ali.com.tw

79

M5661 Firmware Programming Guide
OledReadIconToSram()
Read the data form Oled display sram and store in specific MCU sram
void OledReadIconToSram(WORD wSramAdd,BYTE bColStart,BYTE bRowStart,BYTE
bWidth,BYTE bHeight);
Parameters
WORD wSramAdd
Sram addres you want to store in.
Note: This function uses DMA access, and be sure that SRAM address must be in
the range of 0xc000~0xe000(8K), and data size(bWidth*bHeight*2) can not large
then 2k in once calling.
About the SRAM address, strongly recommand to use the 0xC800~0xCFFF
PS.

gxbLyrics[2048] _AT_ (SRAM_LYRICS_ADDR);

//C800-CFFF

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

M5661 Firmware Programming Guide
Return values
None
Global variable
None
Example
Send sram data 0xc800~0xc400(1K) to SM
OledDMASramToSM(0xc800-0xc000,1024);
See also

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

M5661 Firmware Programming Guide
FALSE:display the bitmap without background.
BYTE gxbLcdLimitCol
It dosen’t display if the display column large than gxbLcdLimitCol,please refer to
example.
WORD gxwFGColor
Display foreground color
WORD gxwBGColor
Display background color
BYTE gfMaskInside
TRUE: mask inside
FALSE: mask ouside
Example
Displaying a bitmap icon of “5” upon a image with background color.
gfIconMaskEn=FALSE
gfTransparent=FALSE;
gxwFGColor = OLED_GREEN;
gxwBGColor = OLED_RED;
OledShowBitsIcon(BITMAP_ADDRESS,5,10,8,2);
Displaying a bitmap icon of “5” upon a image without background color.
gfIconMaskEn=FALSE;
gfTransparent=TRUE;
gxwFGColor = OLED_GREEN;
gxwBGColor = OLED_RED;
OledShowBitsIcon(BITMAP_ADDRESS,5,10,8,2);
See also

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

" IconData.h " )

BYTE bColStart
BYTE bRowStart
Icon will be displayed start column and start row.

www.ali.com.tw

82

M5661 Firmware Programming Guide
Return values
None
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 that the icon information (width,height) will be got from binary files. so, don't
not care about it. IconGenerator will automatically add the some information about
bmp to binary file.
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
Show Icon with mask enable
gfIconMaskEn=TRUE;
gfMaskInside=TRUE;
gxbMaskLeft=64;
gxbMaskRight=96;
gxbMaskTop=0;
gxbMaskBottom=32;
OledShowIcon(FULL_SCREEN_PIC,0,0);
See also
OledShowBitsIcon(),OledDMASramToSM()

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

M5661 Firmware Programming Guide
BYTE bNumLen
Display length
Return values
None
Global variable

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

M5661 Firmware Programming Guide
Note: Animation binary data is stored in “107AnimBGR_v03.bin”,and it will be
download to our device as private area data.This function will get required data and
imformation while playing animation. IconGenerator application also convert bmp
to oled displaying format.
BYTE bFrameNum
Display frame number
BYTE bColStart
BYTE bRowStart
Display start position
WORD wDelayTime
Display delay between every image frame
Return values
None
Global variable

Example

www.ali.com.tw

85

M5661 Firmware Programming Guide
2.12

OledString (OledString.c)

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

M5661 Firmware Programming Guide
BYTE StrShowSysString(WORD wStrNum,BYTE bColStart,BYTE bRowStart) large
Parameters
BYTE wStrNum
The system string code number. It should be defined in “SysStrDef.h”
BYTE bColStart
Specifies the display column number.
BYTE bRowStart
Specifies the display row number.
Return values
The length of system string (pixel)
Global variable

Example

See also
StrShowSysString() , LcdShowString()

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

See also
LcdGetStrLen().

www.ali.com.tw

87

M5661 Firmware Programming Guide
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
Global variable
XBYTE gxbMusicType
Point out the music tag type
XBYTE gxbLcdTagStatus
Set the tag state flag
bit 1-3: Which tag is shown
LCD_TAG_TURN_DEFAULT:
Default state, changing new song, or unknown tag state.
LCD_TAG_TURN_FILEONLY:
No tag, only show File name
LCD_TAG_TURN_TITLE:
Showing tag title
LCD_TAG_TURN_ARTIST:
Showing tag artist
LCD_TAG_TURN_ALBUM:
Showing tag album
Example

See also
LcdScrollTag()

LcdScrollTag()
Scroll Tag on LCD. You should call LcdShowTagTitle() first.
void LcdScrollTag(void)
Parameters
None
Return values
None

www.ali.com.tw

88

M5661 Firmware Programming Guide
Global variable
XBYTE gxbLcdTagStatus
Set the tag state flag, see LcdShowTagTitle() function
Example

See also
LcdShowTagTitle()

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

See also
LcdSetLyricDone() | LcdScrollLyric()

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

M5661 Firmware Programming Guide
Return values
None
Global variable
XBYTE gxbLcdLyricStatus
Set lyric state, see LcdShowLyrics() function.
Example

See also
LcdShowLyrics() | LcdSetLyricDone()

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

See also
LcdShowLyrics() | LcdScrollLyric()

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

M5661 Firmware Programming Guide
Return values
None
Global variable

Example

See also
LcdScrollFileList() | LcdShowClassList()

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

See also
LcdShowFileList()

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

M5661 Firmware Programming Guide
Global variable

Example

See also
LcdShowFileList()

LcdShowDirName()
Display dir-name.
void LcdShowDirName(void)
Parameters
None
Return values
None
Global variable

Example

See also

2.13

IDMA (Idma.c)

2.13.1 API Functions

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. It’s word unit, for example, if source data is 99 bytes, wLen=33.
Return values
None

www.ali.com.tw

92

M5661 Firmware Programming Guide
Global variable
None
Example

See also
IdmaPioPmR() | IdmaPmW()

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. It’s word unit, for example, if target data is 99 bytes, wLen=33.
Return values
None
Global variable

Example

See also
IdmaPioPmW()

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

M5661 Firmware Programming Guide
WORD wLen
Data Length. It’s 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 24bits mode this arguments would be ignore.
Return values
None
Global variable

Example

See also
IdmaPioDmyR() | IdmaDmyW()

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. It’s 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

M5661 Firmware Programming Guide
Global variable

Example

See also
IdmaPioDmyW() | IdmaDmyR()

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 (L→H)” 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)

If you use pure IDMA sequence would write “01 00 03 02 (L→H)” to DSP DMX:
H←
02 03

00

→L (DMX)
01

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

01

→L (SRAM)
00

The IdmaDmxW() function will write data to DMX (add zero value in low byte):
H←
03 02

00

01

00

→L (DMX)
00

It’s real to transfer 16bits data to 24bits. The zero value will auto drop by IdmaDmxR()
function.
The IdmaDmxPioW() function will write data to DMX (add zero value in high byte):
H←
00 03

02

00

01

→L (DMX)
00

It’s for writing 24bits data but small value. You can do the same job by setting
fWidth24=TRUE and use a double-word variable. But it’s 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

M5661 Firmware Programming Guide
just need a word variable to read/write it.

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. It’s 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

See also
IdmaPioDmxR() | IdmaDmxW()

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 (L→H)” in DSP DMX. The first word
data should be “0x0100” for us.
H←
03 02

01

→L (DSP DMX)
00

If you use pure IDMA sequence to get data, it would be the same data with DMX.
H←
03 02

www.ali.com.tw

01

→L (SRAM)
00

96

M5661 Firmware Programming Guide
↑(Word Pointer)
If you use 8051 word pointer to point first word, it will point to 00, low byte in SRAM.
We will get the value 0x0001, not 0x0100.
To solve this problem, this function will reverse high-low byte data every 2 bytes. You
can read word data to DMX by calling this function immediately and not need to reverse
data. If you want to read serial byte data to DMX, this function would make error about
sequence. Use IdmaDmxR() function instead of this function.

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

It’s correct to read it by setting fWidth24=TRUE and use a double-word variable. If we
have known the highest byte is always zero, it’s 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. It’s real to transfer 24bits data to 16bits. For example, if source 16bits data
in SRAM is:
H←
04 03

02

→L (SRAM)
01

The IdmaDmxW() function will write data to DMX (add zero value in low byte):
H←
04 03

00

02

01

→L (DMX)
00

So the IsmaDmyR() function should drop the lowest byte zero value to get correct value.
H←
04 03

02

→L (SRAM)
01

void IdmaPioDmxR(WORD wSourceAddr, void *pbTargetAddr, WORD wLen, BOOL
fWidth24)
Parameters
WORD wSourceAddr
Source data address was in DSP-DMX.
void *pbTargetAddr
Target data address in SRAM.
WORD wLen
Data Length. It’s word unit, for example, if source data is 96 bytes:
24bits source data: wLen=32.
16bits source data: wLen=48.

www.ali.com.tw

97

M5661 Firmware Programming Guide
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

See also
IdmaPioDmxW() | IdmaDmxR()

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. It’s word unit, for example, if source data is 99 bytes, wLen=33.
Return values
None
Global variable

Example

See also
IdmaPioPmW()

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

M5661 Firmware Programming Guide
Parameters
WORD wDSPAddr
Target data address in DSP-DMY.
WORD wLen
Data Length. It’s 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

See also
IdmaPioDmyW() | IdmaDmyR()

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. It’s word unit, for example, if source data is 99 bytes, wLen=33.
Return values
None
Global variable

Example

www.ali.com.tw

99

M5661 Firmware Programming Guide
See also
IdmaPioDmyR() | IdmaDmyW()

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. It’s 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

See also
IdmaPioDmxW() | IdmaDmxR()

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

M5661 Firmware Programming Guide
WORD wLen
Data Length. It’s word unit, for example, if source data is 99 bytes, wLen=33.
Return values
None
Global variable

Example

See also
IdmaPioDmxR() | IdmaDmxW()

2.13.2 SYS Functions

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,
it’s 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. It’s word unit, for example, if source data is 96 bytes, wLen=48.
Return values
None
Global variable

Example

See also
IdmaPioDebugR()

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, it’s

www.ali.com.tw

101

M5661 Firmware Programming Guide
useless for us. The function is only for debugging.
API void IdmaPioDebugR(WORD wSourceAddr, void *pbTargetAddr, WORD wLen)
Parameters
WORD wSourceAddr
Source data address was in DSP-DMX.
void pbTargetAddr
Target data address in SRAM.
WORD wLen
Data Length. It’s word unit, for example, if source data is 96 bytes, wLen=48.
Return values
None
Global variable

Example

See also
IdmaPioDebugW()

2.14

USB (Usb.c)

2.14.1 API Functions

CheckReceiveCBW()
Check CBW in EP0.
void CheckReceiveCBW(void)
Parameters
None
Return values
None
Global variable

Example

See also

www.ali.com.tw

102

M5661 Firmware Programming Guide
GetPacketData()
Get descriptor packet data.
BYTE GetPacketData(WORD wIndex)
Parameters
WORD wIndex
Return values
BYTE type
Global variable

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

M5661 Firmware Programming Guide

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

2.14.2 SYS Functions

www.ali.com.tw

104

M5661 Firmware Programming Guide

2.15

USBHost (USBHost.c)

2.15.1 API Functions

UmsRequestSense()
Send Inquiry command.
void UmsRequestSense(void)
Parameters
None
Return values
None
Global variable

Example

See also

www.ali.com.tw

105

M5661 Firmware Programming Guide
UsbHostCopyRw()
Divide Read/Write operation into 3 phases. (Command, Data, Status.)
bit UsbHostCopyRw(bit Readflag,BYTE bType)
Parameters
Bit Readflag
BYTE bType
Return values
Bit type
TRUE:
FALSE:
Global variable
gdwStorLba:

The sector number that will be read.

gbStorTransLen:

Number of sectors will be read.

gbStorPath:

The assigned area that data will be read to.

Example

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

M5661 Firmware Programming Guide
bit UsbHostInit(void)
Parameters
None
Return values
Bit type
TRUE:
FALSE:
Global variable

Example

See also

UsbHostIsWriteProtect()
Determine Write Protect function.
bit UsbHostIsWriteProtect(void)
Parameters
None
Return values
Bit type
TRUE:
FALSE:

Write-Protect.
Normal.

Global variable

Example

See also

UsbHostRead()
Host read function.
bit UsbHostRead(void)
Parameters
None
Return values
Bit type

www.ali.com.tw

107

M5661 Firmware Programming Guide
TRUE:
FALSE:
Global variable
gdwStorLba:

The sector number that will be read.

gbStorTransLen:

Number of sectors will be read.

gbStorPath:

The assigned area that data will be read to.

Example

See also

UsbHostWrite()
Host writes function.
bit UsbHostWrite(void)
Parameters
None
Return values
Bit type
TRUE:
FALSE:
Global variable
gdwStorLba:

The sector number that will be read.

gbStorTransLen:

Number of sectors will be read.

gbStorPath:

The assigned area that data will be read to.

Example

See also

www.ali.com.tw

108

M5661 Firmware Programming Guide

2.16

USB Host Common (USBHostCommon.c)

2.16.1 API Functions

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

M5661 Firmware Programming Guide
Parameters
None
Return values
Bit type
TRUE:
FALSE:
Global variable

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

M5661 Firmware Programming Guide
FALSE:
Global variable

Example

See also

2.17

USB Host Fat (USBHostFat.c)

2.17.1 API Functions

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

M5661 Firmware Programming Guide
FatAnalyseDisk()
Analyses partition information on a disk.
BYTE FatAnalyseDisk(BYTE DiskIndex)
Parameters
BYTE DiskIndex
Decide USB disk or IDE disk.
Return values
BYTE type
Global variable

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

M5661 Firmware Programming Guide
Parameters
None
Return values
DWORD type
If the file exists, it's offset will be returned else 1 will be returned. If error occurs,
it will return -1
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
2, Delete the dir given by pFileEntry and all those after
it. (DEL_ALL_DIR)
Return values
BYTE type
True if succeed, otherwise False.
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
See also

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

M5661 Firmware Programming Guide
Parameters
BYTE DiskIndex:
Return values
BYTE type
0: failure, otherwise: number of logical partition.
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
Example

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

M5661 Firmware Programming Guide
UINext()
Get the next dir or file. When reach end, the offset won't change.
BYTE UINext(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

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

M5661 Firmware Programming Guide
Return values
BYTE type:
True was success else FALSE.
Global variable

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

M5661 Firmware Programming Guide
Example

See also

www.ali.com.tw

124

M5661 Firmware Programming Guide
2.18

ATA (Ata.c)

2.18.1 API Functions

DoAtaCommand()

void DoAtaCommand(void)
Parameters
None
Return values
None
Global variable

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

2.18.2 SYS Functions

www.ali.com.tw

125

M5661 Firmware Programming Guide
2.19

Common (Common.c)

2.19.1 API Functions

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

M5661 Firmware Programming Guide
Return values
None
Global variable

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

M5661 Firmware Programming Guide
FileTypeCheck()
Compare file name and file type.
bit FileTypeCheck(PBYTE pbFileName)
Parameters
PBYTE pbfileName
Return values
Bit type
TRUE:

File name match file type.

FALSE: File name not match file type.
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
See also

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

M5661 Firmware Programming Guide
Return values
None
Global variable

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

M5661 Firmware Programming Guide
Example

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

M5661 Firmware Programming Guide
Parameters
BYTE bStorage
Return values
Bit type
TURE:
FALSE:
Global variable

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

M5661 Firmware Programming Guide
Example

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

M5661 Firmware Programming Guide
bit SramCheck(void)
Parameters
None
Return values
Bit type
TRUE:

data ready.

FALSE:

data not ready.

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

M5661 Firmware Programming Guide
Void *pbData:
Point to a variable that the data value of variable will be writes.
Return values
None
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
WriteSClockToSram()
Get secure clock offset from DCV SRAM.
void WriteSClockToSram(void)
Parameters
None
Return values
None
Global variable

Example

See also

2.19.2 SYS Functions

www.ali.com.tw

138

M5661 Firmware Programming Guide
2.20

DDM (DDM.c)

2.20.1 API Functions

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:

Nand flash type variable.

gf16bit:

Nand flash type variable.

gfAddress4Cycle:

Nand flash type variable.

Example

See also

www.ali.com.tw

139

M5661 Firmware Programming Guide
2.20.2 SYS Functions

2.21

Drm (Drm.c)

2.21.1 API Functions

DrmGetDeviceCertificate()

void DrmGetDeviceCertificate(void)
Parameters
None
Return values
None
Global variable

Example

See also

DrmGetLicenseStat()

void DrmGetLicenseStat(void)
Parameters
None
Return values
None
Global variable

Example

See also

DrmGetSecureClock()

www.ali.com.tw

140

M5661 Firmware Programming Guide
void DrmGetSecureClock(void)
Parameters
None
Return values
None
Global variable

Example

See also

DrmGetSecureTimeChallenge()

void DrmGetSecureTimeChallenge(void)
Parameters
None
Return values
None
Global variable

Example

See also

DrmGetSyncList()

void DrmGetSyncList(void)
Parameters
None
Return values
None
Global variable

Example

www.ali.com.tw

141

M5661 Firmware Programming Guide
See also

DrmSetLicenseResponse()

void DrmSetLicenseResponse(void)
Parameters
None
Return values
None
Global variable

Example

See also

DrmSetSecureTimeResponse()

void DrmSetSecureTimeResponse(void)
Parameters
None
Return values
None
Global variable

Example

See also

TurnTextTime()

void TurnTextTime(DWORD *dwSetTime)
Parameters
DWORD *dwSetTime

www.ali.com.tw

142

M5661 Firmware Programming Guide
Return values
None
Global variable

Example

See also

TurnTimeText()

void TurnTimeText(DWORD dwGetTime)
Parameters
DWORD dwGetTime
Return values
None
Global variable

Example

See also

2.21.2 SYS Functions

www.ali.com.tw

143

M5661 Firmware Programming Guide
2.22

IntCodec (IntCodec.c)

2.22.1 API Functions

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()

BYTE IntCdcGetAdcGain(void)
Parameters
None

www.ali.com.tw

144

M5661 Firmware Programming Guide
Return values
Byte type
Global variable

Example

See also

IntCdcPowerDownPa()

void IntCdcPowerDownPa(void)
Parameters
None
Return values
None
Global variable

Example

See also

IntCdcRStringPowerOn()

void IntCdcRStringPowerOn(void)
Parameters
None
Return values
None
Global variable

Example

See also

www.ali.com.tw

145

M5661 Firmware Programming Guide
IntCdcSetPaGain()

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()

void IntCdcSetSampleRate(void)
Parameters
None
Return values
None
Global variable

www.ali.com.tw

146

M5661 Firmware Programming Guide
Example

See also

2.22.2 SYS Functions

www.ali.com.tw

147

M5661 Firmware Programming Guide
2.23

ExtCodec (ExtCodec.c)

2.23.1 API Functions

ExtCdcCtrl()

void ExtCdcCtrl(BYTE bCommand)
Parameters
BYTE bCommand
Return values
None
Global variable

Example

See also

ExtCdcSetSampleRate()

void ExtCdcSetSampleRate(void)
Parameters
None
Return values
None
Global variable

Example

See also

2.23.2 SYS Functions

www.ali.com.tw

148

M5661 Firmware Programming Guide
2.24

Mtp (Mtp.c)

2.24.1 API Functions

CardDetect()

void CardDetect(void)
Parameters
None
Return values
None
Global variable

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()

void MemoryCopy(IN PBYTE pbTargetBuf, IN PBYTE pbSourceBuf, IN WORD wCpyLen)

www.ali.com.tw

149

M5661 Firmware Programming Guide
Parameters
PBYTE pbTargetBuf
PBYTE pbSourceBuf
WORD wCpyLen
Return values
None
Global variable

Example

See also

MtpDeviceInit()

void MtpDeviceInit(void)
Parameters
None
Return values
None
Global variable

Example

See also

MtpFinishJob()

void MtpFinishJob(void)
Parameters
None
Return values
None
Global variable

www.ali.com.tw

150

M5661 Firmware Programming Guide
Example

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

M5661 Firmware Programming Guide
Parameters
PBYTE pBuf:
The pointer of DataBuf.
DWORD wLen:
DataBuf Length in Bytes.
Return values
None
Global variable

Example

See also

2.24.2 SYS Functions

www.ali.com.tw

152

M5661 Firmware Programming Guide
2.25

SaveSetting (SaveSetting.c)

2.25.1 API Functions

RestoreDefaultSetting()
Restore default setting from Nand Flash private area.
void RestoreDefaultSetting(void)
Parameters
None
Return values
None
Global variable

Example

See also

2.25.2 SYS Functions

www.ali.com.tw

153

M5661 Firmware Programming Guide
2.26

UI Common (UiCommon.c)

2.26.1 Registers
DCV_INT_FLAG — INT0 Flag Register (FF1Ah)
FF1Ah
D7

INT0_FLAG — INT0 Flag Register
D6

D5

D4

D3

D0

Bit 7: PASCPPR_INT

00h

Type

Default

R/W

00h

DCV Battery Brown Out Detect Interrupt Flag

Bit 0: DCV_BRN_DET

Default

DCV-RTC Interrupt Flag

Bit 1: DCV_BAT_BRN_DET

Type

ALARM Interrupt Flag

Bit 2: DCV_RTC_INT

00h

PASCPNL Interrupt Flag

Bit 3: ALARM_INT

Default

PASCPNR Interrupt Flag

Bit 4: PASCPNL_INT

Type

PASCPPL Interrupt Flag

Bit 5: PASCPNR_INT

00h

PASCPPR Interrupt Flag

Bit 6: PASCPPL_INT

Default

R/W

R/W

D1

Type

R/W

D2

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

DCV Brown Out Detect Interrupt Flag

DCV_ADDR — DCV Address Register (FFD4h)
FFD4h
D7

DCV_ADDR — DCV Address Register
D6

D5

D4

D3

D2

D1

D0

DCV_ADDR

Bits 7-0: DCV Address Register
DCV_WRDATA — DCV Write Data Register (FFD5h)
FFD5h
D7

DCV_WRDATA — DCV Write Data Register
D6

D5

D4

D3

D2

D1

D0

DCV_WRDATA[7:0]
Bits 7-0: DCV Write Data Register
DCV_RDDATA — DCV Read Data Register (FFD6h)
FFD6h
D7

DCV_RDDATA — DCV Read Data Register
D6

D5

D4

D3

DCV_RDDATA[7:0]

D2

D1

D0

Bits 7-0: DCV Read Data Register
DC-DC Registers

www.ali.com.tw

154

M5661 Firmware Programming Guide
Index

Mnemonic — Name

Type

Default

15h

RTC Timer/Counter Register 0

R/W

00h

16h

RTC Timer/Counter Register 1

R/W

00h

17h

RTC Timer/Counter Register 2

R/W

00h

18h

RTC Timer/Counter Register 3

R/W

00h

19h

Alarm Register 0

R/W

00h

1Ah

Alarm Register 1

R/W

00h

1Bh

Alarm Register 2

R/W

00h

1Ch

Alarm Register 3

R/W

00h

RTC Timer/Counter Register 0
15h
Bit 7

RTC0 — The First Byte of the 32-bit RTC Register
Bit 6

Bit 5

Bit 4

Bit 3

Bit 1

Bit 0

RTC[7:0]

Bit 7~0: RTC[7:0]
register.

Type

Default

R/W

Bit 2

00h

A write access the RTC counter register, while a read access the RTC timer

RTC Timer/Counter Register 1
16h
Bit 7

RTC1 —The Second Byte of the 32-bit RTC Register
Bit 6

Bit 5

Bit 4

Bit 3

Bit 1

Bit 0

RTC[15:8]

Bit 7~0: RTC[15:8]
register.

Type

Default

R/W

Bit 2

00h

A write access the RTC counter register, while a read access the RTC timer

RTC Timer/Counter Register 2
17h
Bit 7

RTC2 —The Third Byte of the 32-bit RTC Register
Bit 6

Bit 5

Bit 4

Bit 3

Bit 1

Bit 0

RTC[23:16]

Bit 7~0: RTC[23:16]
register.

Type

Default

R/W

Bit 2

00h

A write access the RTC counter register, while a read access the RTC timer

RTC Timer/Counter Register 3
18h
Bit 7

RTC3 —The Fourth Byte of the 32-bit RTC Register
Bit 6

Bit 5

Bit 4

Bit 3

RTC[31:24]

Bit 7~0: RTC[31:24]
register.

www.ali.com.tw

Bit 2

Bit 1

Bit 0

Type

Default

R/W

00h

A write access the RTC counter register, while a read access the RTC timer

155

M5661 Firmware Programming Guide
Alarm Register 0
19h
Bit 7

ALARM0 —The First Byte of the 32-bit Alarm Register
Bit 6

Bit 5

Bit 4

Bit 3

ALARM0[7:0]

00h

Type

Default
00h

Type

Default

R/W

Bit 0

Default

R/W

Bit 1

Type
R/W

Bit 2

00h

Type

Default

R/W

00h

Bit 7~0: ALARM0[7:0] Set alarm register
Alarm Register 1
1Ah
Bit 7

ALARM1 —The Second Byte of the 32-bit Alarm Register
Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

Bit 0

ALARM0[15:8]

Bit 7~0: ALARM1[15:8]

Set alarm register

Alarm Register 2
1Bh
Bit 7

ALARM2 —The Third Byte of the 32-bit Alarm Register
Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

Bit 0

ALARM0[23:16]

Bit 7~0: ALARM2[23:16]

Set alarm register

Alarm Register 3
1Ch
Bit 7

ALARM3 —The Fourth Byte of the 32-bit Alarm Register
Bit 6

Bit 5

Bit 4

Bit 3

Bit 2

Bit 1

ALARM0[31:24]

Bit 7~0: ALARM2[23:16]

Bit 0

Set alarm register

2.26.2 API Functions

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

M5661 Firmware Programming Guide
Global variable
Many variables be assigned value, see source code for details.

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

See also
UiShowBattSts()

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

M5661 Firmware Programming Guide
XBYTE gxbFlashTime
Control for display 8 times
See also
UiNormalCheck()

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

M5661 Firmware Programming Guide
UiShowAlarmPic( )
If alarm switch turned on, show an alarm icon.
void UiShowAlarmPic( )
Parameters
None
Return values
None
Global variable

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

See also
UiNormalCheck()

UiNormalCheck( )
Check system state. (VBus, KeyHold, Battery, Alarm, SD card...)
void UiNormalCheck(void )
Parameters
None
Return values
None
Global variable

See also
UiShowAutoPowerOff() | UiShowBattSts() | UiCheckCardRemoved() | UiShowKeyHold

www.ali.com.tw

159

M5661 Firmware Programming Guide
UiCheckBackLight( )
Check and control backlight turn on/off. For code size, this function will check Power Off,
too.
Note: This function must to be called after you get a key value.
void UiCheckBackLight(BYTE bKey)
Parameters
BYTE bKey
User input key value.
Return values
None
Global variable

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

M5661 Firmware Programming Guide
See also
UiSysGetAlarmTime() | UiSysSetAlarmTime()

UiSysGetAlarmTime( )
Get DCV alarm time.
void UiSysGetAlarmTime( )
Parameters
None
Return values
None
Global variable
XDWORD gxdwAlarmTime
Alarm time
Example

See also
UiSysFixAlarmTime() | UiSysSetAlarmTime()

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

See also
UiSysFixAlarmTime() | UiSysGetAlarmTime()

UiSysGetNowTimeText( )
Transfer time counter number to global string array gxbStringEditTime.
void UiSysGetNowTimeText(DWORD dwGetTime)

www.ali.com.tw

161

M5661 Firmware Programming Guide
Parameters
DWORD dwGetTime
Number of Time counter.
Return values
None
Global variable
XDWORD gxbStringEditTime
Time String.
Example

See also

UiShowKeyHold( )
If key hold, show a key hold icon on screen.
void UiShowKeyHold()
Parameters
None
Return values
None
Global variable

Example

See also
UiNormalCheck()

UiGoVolMenu( )
Go to volume control state.
void UiGoVolMenu()
Parameters
None
Return values
None
Global variable

www.ali.com.tw

162

M5661 Firmware Programming Guide
Example

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

See also
UiShowSubMenuNum()

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

M5661 Firmware Programming Guide
Example

See also
UiDrawSubMenu()

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 & lt; =5;bI++)
UiShowUdefEqVal(bI,gxbUserDefEq[bI]);
See also
UiEditUDefEq() | UiShowUDefEqSel() | UiClearUDefEqSel() | UiDrawUserDefEq

www.ali.com.tw

164

M5661 Firmware Programming Guide
UiEditUdefEq( )
Edit the user define EQ value.
void UiEditUdefEq(BYTE bEditOption)
Parameters
BYTE bEditOption
UI_EDIT_EQ_UP: Normal scale EQ volume up.
UI_EDIT_EQ_DOWN: Normal scale EQ volume down.
UI_EDIT_ALL_EQ_UP: All scale EQ volume up.
UI_EDIT_ALL_EQ_DOWN: All scale EQ volume down.
Return values
None
Global variable
XBYTE gxbSelUserDefEq
User selects which scale number.
Example

See also
UiShowUdefEqVal | UiShowUDefEqSel() | UiClearUDefEqSel() | UiDrawUserDefEq

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

See also
UiShowUdefEqVal | UiEditUDefEq() | UiClearUDefEqSel() | UiDrawUserDefEq

UiClearUDefEqSel( )
Clear a selected frame that user select user define EQ musical scale.
UiShowUDefEqSel() function didn’t clear the selected frame because it didn’t remember

www.ali.com.tw

165

M5661 Firmware Programming Guide
user select which scale. Main program should call this function first.
void UiClearUDefEqSel()
Parameters
None
Return values
None
Global variable
XBYTE gxbSelUserDefEq
User selects which scale number
Example

See also
UiShowUdefEqVal | UiEditUDefEq() | UiShowUDefEqSel() | UiDrawUserDefEq

UiDrawUserDefEq( )
Display user defines EQ edit.
void UiDrawUserDefEq()
Parameters
None
Return values
None
Global variable

Example

See also
UiShowUdefEqVal | UiEditUDefEq() | UiShowUDefEqSel() | UiClearUDefEqSel()

UiGoRecQtyMenu( )
Go to record quality menu state.
void UiGoRecQtyMenu()
Parameters
None
Return values
None
Global variable

www.ali.com.tw

166

M5661 Firmware Programming Guide
Example

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

M5661 Firmware Programming Guide
Parameters
None
Return values
None
Global variable

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

See also
UiLoadScreen()

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

M5661 Firmware Programming Guide
Example

See also
UiSaveScreen()

www.ali.com.tw

169

M5661 Firmware Programming Guide
2.27

UI Play (UiPlay.c)

2.27.1 Simple Architecture

UI Play
Play Module Initial

Super Loop

Common
State Job

Error
Handle

Base on
State and
User Input
Control Job

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 didn’t 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 3→2→5 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 engine’s 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 it’s time to show the lyric. UI should display a new
lyric now.
www.ali.com.tw

172

M5661 Firmware Programming Guide
LRC_STS_FORCE_DISP_STR:
Next lyric will come soon. UI should speed up scrolling lyric for showing next lyric.

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)
www.ali.com.tw

175

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, don’t call this function to avoid system crash.
Play module display
Just call UiReDrawMusicPlayer() function to do this job.

www.ali.com.tw

176

M5661 Firmware Programming Guide
2.27.13.2

Super Loop(Common State Job)

Common State Job
Get Key

Check Backlight (power off)

Volume Control

Lyric and Tag Display

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.

Base on State and User Input Control Job
See next section.
Error Handle
If gxbErrCode is non-zero, call UiErrHandle() function to control error.

2.27.13.3

www.ali.com.tw

Super Loop (Wait/Pause State Job)

177

M5661 Firmware Programming Guide
Wait/Pause State Job
Common State Job

Main Menu

Send Command to Play
Engine Base on User Input

Error Handle

Base on User Input Sending Command to Play Engine
When system state is wait or pause, UI’s 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

Super Loop (Play State Job)
Play State Job
Common State Job

UI_NO_MENU
×××
UiGoNoMenu()
Key 5

Key 5

Key 4

Key 6

Key 2
UI_MUSIC_MENU
UI_MUSIC_REPEAT_MENU
UiGoMusicMenuRepeat()

UI_REPEAT_MENU
???
UiGoMusicRepeatMenu()

Key 2
Set Repeat Mode

Key 5
Key 4

Key 6

Key 4

Key 6

Key 2
UI_MUSIC_MENU
UI_MUSIC_EQ_MENU
UiGoMusicMenuEQ()

UI_EQ_MENU
???
UiGoMusicEqMenu()

Key 2
Set EQ Mode

Key 5
Key 4

Key 6

Key 4

Key 6

Key 2
UI_MUSIC_MENU
UI_MUSIC_3D_MENU
UiGoMusicMenu3D()

UI_3D_MENU
???
UiGoMusic3DMenu()

Key 2
Set 3D Mode

Key 5

Error Handle
Description
When system state is play, UI’s 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

M5661 Firmware Programming Guide
means the value in this state isn’t important (don’t care). The symbol “???” means
the value isn’t fixed (dependent on user input or other states).
UI No Menu State
Default state. No menu appear, and sub menu state is don’t care. UI should send
command to play engine base on user input.
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”.
Ui Music Menu State
Music menu appear, and sub menu default state is repeat menu.
Menu sub state list is:
UI_MUSIC_REPEAT_MENU
UI_MUSIC_EQ_MENU
UI_MUSIC_3D_MENU
User could press “Key 4” or “Key 5” to change sub menu state.
Ui Repeat Menu State
Repeat mode select menu appear, and sub menu state is the repeat mode value that
user selected.
Menu sub state list is:
UI_REPEAT_NO_MENU
UI_REPEAT_ONE_MENU
UI_REPEAT_ALL_MENU
UI_REPEAT_RND_ALL_MENU
UI_REPEAT_RND_MENU
UI_REPEAT_LIST_MENU
User could press “Key 4” or “Key 5” to change sub menu state.
PS. This define is effected by UI_USE_RND_PLAY_ONE_EN and
UI_USE_PLAY_LIST_EN define in UiCommon.h
Ui EQ Menu State
EQ mode select menu appear, and sub menu state is the EQ mode value that user
selected.
Menu sub state list is:
UI_EQ_NORMAL_MENU
UI_EQ_POP_MENU
UI_EQ_CLASSIC_MENU
UI_EQ_ROCK_MENU
UI_EQ_DANCE_MENU
UI_EQ_BASS_MENU
UI_EQ_UDEF_MENU
User could press “Key 4” or “Key 5” to change sub menu state.
PS. This define is effected by UI_USE_USER_EQ define in TypeDef.h
Ui 3D Menu State
3D Mode select menu appear, and sub menu state is the 3D mode value that user
selected.
Menu sub state list is:

www.ali.com.tw

179

M5661 Firmware Programming Guide
UI_3D_ON_MENU
UI_3D_OFF_MENU
User could press “Key 4” or “Key 5” to change sub menu state.

2.27.14 API Functions

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 don’t 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

M5661 Firmware Programming Guide
2.28

UI Play DVR (UiPlay.c)

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

M5661 Firmware Programming Guide
Play State Job
Common State Job

UI_NO_MENU
×××
UiGoNoMenu()
Key 5

Key 7
Long

Key 4

Key 6

Key 2

Key 5

UI_REC_MENU
UI_REC_FROM_MENU
UiGoRecMenuFrom ()

UI_FROM_MENU
???
UiGoRecFromMenu()

Key 2
Set Record Source

Key 5
Key 4

Key 6

Key 4

Key 6

Key 2
UI_REC_MENU
UI_REC_QTY_MENU
UiGoRecQtyMenu()

UI_QTY_MENU
???
UiGoRecQtyMenu()

Key 2
Set Record Quality

Key 5
Key 4

Key 6

Key 2
UI_MUSIC_MENU
UI_MUSIC_REPEAT_MENU
UiGoMusicMenuRepeat()

UI_REPEAT_MENU
???
UiGoMusicRepeatMenu()

Key 2
Set Repeat Mode

Key 5

Error Handle

2.28.4 UI Play DVR Super Loop
Description
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 “×××”
means the value in this state isn’t important (don’t care). The symbol “???” means
the value isn’t fixed (dependent on user input or other states).
PS. The record menu could be affected by UI_USE_REC_SOURCE in UiCommon.h
UI No Menu State
Default state. No menu appear, and sub menu state is don’t care. UI should send
command to play engine base on user input.
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”.
Ui Music Menu State
Music menu appear, and sub menu state is always repeat menu.
Ui From Menu State
Record source mode select menu appear, and sub menu state is the record source

www.ali.com.tw

182

M5661 Firmware Programming Guide
value that user selected.
Menu sub state list is:
UI_FROM_MIC_MENU
UI_FROM_LINE_MENU
User could press “Key 4” or “Key 5” to change sub menu state.
Ui QTY Menu State
Record quality mode select menu appear, and sub menu state is the record quality
value that user selected.
Menu sub state list is:
UI_QTY_HIGHT
UI_QTY_NORMAL
UI_QTY_LONG
User could press “Key 4” or “Key 5” to change sub menu state.

www.ali.com.tw

183

M5661 Firmware Programming Guide
2.29

UI Record (UiRec.c)

2.29.1 Simple Architecture

UI Record
Record Module Initial

Super Loop

Common
State Job

Error
Handle

Base on
State and
User Input
Control Job

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
UiShowRecTime()
Display recording time

, etc…)

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.

2.29.6 Flow Description
2.29.6.1 Record Module Initial

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

M5661 Firmware Programming Guide
2.29.6.2 Super Loop(Common State Job)

Common State Job
Get Key

Check Backlight (power off)

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)
Normal Check
Check system state. Except v-bus detecting, just call UiNormalCheck() function to do
this job. Because UI must send “R_STOP” command to record engine before swaping
to USB module, it should handle v-bus detecting alone.

Base on State and User Input Control Job
See next section.
Error Handle
If gxbErrCode is non-zero, call UiErrHandle() function to control error.

2.29.6.3 Super Loop(Record State Job)
Record State Job
Common State Job

Play DVR or FM

Send Command to Record

module

Engine Base on User Input

Error Handle

www.ali.com.tw

187

M5661 Firmware Programming Guide
Base on User Input Sending Command to Play Engine
In record module, UI’s job is simple. Just send command to play engine base on user
input. When user stop to record, UI should send “R_STOP” command to record engine
and return to Play DVR or FM module.

2.29.7 API Functions

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

M5661 Firmware Programming Guide
2.30

UI FM (UiFM.c)

2.30.1 Simple Architecture

UI FM
FM Module Initial

Super Loop

Common
State Job

Error
Handle

Base on
State and
User Input
Control Job

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. It’s 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

Check Backlight (power off)

Volume Control

Display Stereo State

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.

Base on State and User Input Control Job
See next section.
Error Handle
If gxbErrCode is non-zero, call UiErrHandle() function to control error.

www.ali.com.tw

192

M5661 Firmware Programming Guide
2.30.6 UI FM Super Loop
FM Job
Common State Job

Swap to Record Module

Key 7

UI_NO_MENU
×××
UiGoNoMenu()

Key 2

Key 2
UI_SEL_PRESET_MENU
xxx
xxx

Key 5
Long

Select Preset

FM Chip Control

Key 2
UI_SAVE_PRESET_MENU
xxx
xxx

Select Preset

Set Frequency or Search
Station

Key 7
Save Preset

Key 5
Key 4
Key 7 Long

Key 6

UI_QTY_MENU
???
UiGoRecQtyMenu()

Key 2
Set Record Quality

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 isn’t important (don’t care). The symbol “???” means
the value isn’t 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 don’t 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

M5661 Firmware Programming Guide
UI Select Preset Menu State
Select preset channel bar appear, and sub menu state is don’t care. UI should set FM
frequency when user select another preset channel.
Ui Save Preset Menu State
Select preset channel bar appear, and sub menu state is don’t care. UI should save
the frequency when user press “Key 7”.
Ui QTY Menu State
Record quality mode select menu appear, and sub menu state is the record quality
value that user selected.
Menu sub state list is:
UI_QTY_HIGHT
UI_QTY_NORMAL
UI_QTY_LONG
User could press “Key 4” or “Key 5” to change sub menu state.

2.30.7 API Functions

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 don’t care. UI should send
command to play engine base on user input.
void UiGoNoMenu(void)
Parameters
None

www.ali.com.tw

194

M5661 Firmware Programming Guide
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

195

M5661 Firmware Programming Guide
2.31

UI System (UiSys.c)

2.31.1 Simple Architecture

Time

Adjust
Alarm

Adjust
On/Off

On
Off

Power
Setup

Language

English
Chinese(Trad)
Chinese(Simp)

Display

Contrast
Backlight

Record

Source
Quality

User Define EQ
Storage

Line In
MIC
Long Time
Normal Quality
High Quality

Internal
SD/MMC Card
MS Card
xD Card

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

www.ali.com.tw

Small Loop Job

196

M5661 Firmware Programming Guide

Small Loop Job
Get Key

Check Backlight (power off)

Normal Check

Base on State and User Input Control Job

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.

Base on State and User Input Control Job
Base on menu state and user input to change state or set value.

2.31.4 Architecture Definitions

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

M5661 Firmware Programming Guide

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. It’s 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:Don’t 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

M5661 Firmware Programming Guide
2.31.10 Backlight Setting

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

See section “Ui Common (UiCommon.c)” and “Ui Play DVR (UiPlay.c)” above.
2.31.12 User Define EQ Setting

See section “Ui Play (UiPlay.c)” above.
2.31.13 Storage 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

M5661 Firmware Programming Guide
UiGoNoMenu()
Default state. No menu appear, and sub menu state is don’t 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

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

M5661 Firmware Programming Guide
Global variable

Example

See also

www.ali.com.tw

201

M5661 Firmware Programming Guide

2.32

UI File List (UiFileList.c)

2.32.1 API Functions

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 don’t 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

M5661 Firmware Programming Guide

2.33

UI Play Common (UIPlayCommon.c)

2.33.1 API Functions

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

M5661 Firmware Programming Guide
UiDrawBasicMusicMenu()
Show basic music menu.
void UiDrawBasicMusicMenu(void)
Parameters
None
Return values
None
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
void UiNextMenuItem(void)
Parameters
None
Return values
None
Global variable

Example

See also

UiPlayLyricControl()
Lyric function.
void UiPlayLyricControl(void)
Parameters
None
Return values
None
Global variable

Example

See also

void UiPrevMenuItem(void)

void UiPrevMenuItem(void)
Parameters
None
Return values
None
Global variable

Example

www.ali.com.tw

206

M5661 Firmware Programming Guide
See also

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

M5661 Firmware Programming Guide
Return values
None
Global variable

Example

See also

www.ali.com.tw

208

M5661 Firmware Programming Guide
2.34

UI Play Menu (UIPlayMenu.c)

2.34.1 API Functions

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 don’t 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

M5661 Firmware Programming Guide
Parameters
None
Return values
None
Global variable

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

M5661 Firmware Programming Guide

2.35

UI Play Menu2 (UIPlayMenu2.c)

2.35.1 API Functions

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 don’t 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

M5661 Firmware Programming Guide
void UiShowMusicMenuText(void)
Parameters
None
Return values
None
Global variable

Example

See also

www.ali.com.tw

212

M5661 Firmware Programming Guide

2.36

UI Usb Device (UIUsbDevice.c)

2.36.1 API Functions

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

M5661 Firmware Programming Guide

2.37

UI Usb Host (UIUsbHost.c)

2.37.1 API Functions

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

M5661 Firmware Programming Guide
UiShowWakeUp()
Show alarm display.
void UiShowWakeUp(void)
Parameters
None
Return values
None
Global variable

Example

See also

www.ali.com.tw

215

M5661 Firmware Programming Guide
2.38

UI Class List (UIClassList.c)

2.38.1 API Functions

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

M5661 Firmware Programming Guide
See also

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

M5661 Firmware Programming Guide
See also

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

M5661 Firmware Programming Guide
CdbGetClassHeader()
Load and copy class info header
BOOL CdbGetClassHeader (DWORD dwCdbPoint)
Parameters
DWORD dwCdbPoint
Reading address in class database
Return values
Bit type
TRUE: successfully.
FALSE: faile
Global variable
stCdbClassInfo:
To store the header info
Example

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

M5661 Firmware Programming Guide

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

M5661 Firmware Programming Guide

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

M5661 Firmware Programming Guide
2.38.2 SYS Functions
CdbUpdateDirInfo( )
Updat dir info in class database
void CdbUpdateDirInfo(DWORD dwDirInfAdd, WORD wParentDirNum)
Parameters
DWORD dwDirInfAdd
The address in class database.
WORD wParentDirNum
The parent’s dir info number
Return values
None
Global variable

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

M5661 Firmware Programming Guide
The sector of the dir entry
Return values
WORD type
Success: Dir info number
Failed: 0
Global variable

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

M5661 Firmware Programming Guide
Global variable

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

M5661 Firmware Programming Guide
Example

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

See also
CdbNewNode()

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

M5661 Firmware Programming Guide
Parameters
BYTE bSearchType
The searching type to find his parent node
BYTE bClassMode:
The class mode of the node
Return values
Bit type
TRUE: successfully.
FALSE: failed
Global variable
gxdwCdbEmptyPoint:
The empty address in class database. The variable will point to next empty address
after calling the function.
Example

See also
CdbNewNode()

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

M5661 Firmware Programming Guide
Global variable
DWORD gdwCdbAddPoint:
The address of the first parent node which you want to scan
Example

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

See also
CdbFindAndBulitClass()

www.ali.com.tw

227

M5661 Firmware Programming Guide
CdbSetUnknownTag( )
If tag is unknow, set a default unknow string in buffer
void CdbSetUnknownTag(void)
Parameters
None
Return values
None
Global variable

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

See also
CdbReadSector()

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

M5661 Firmware Programming Guide
Point to source data memory
Return values
Bit type
TRUE: successfully.
FALSE: failed
Global variable

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

M5661 Firmware Programming Guide
See also

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

M5661 Firmware Programming Guide
The address in class database
DWORD dwNewLink
The new address in class database
Return values
None
Global variable

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

M5661 Firmware Programming Guide
CdbSearchDataCache( )
Search CDB data cache for building database
BOOL CdbSearchDataCache(PBYTE pbClassStrBuf)
Parameters
PBYTE pbClassStrBuf
The class string buffer
Return values
BOOL Type:
CDB_SEARCH_CACHE_HIT: Data found in data cache
CDB_SEARCH_CACHE_MISS: Data not found in data cache
Global variable
gxbCdbCacheModuleNum:
Select data cache module
Example

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

M5661 Firmware Programming Guide
Return values
None
Global variable

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

M5661 Firmware Programming Guide
FALSE: failed
Global variable

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

M5661 Firmware Programming Guide
See also

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