NEW DATABASE - 350 MILLION DATASHEETS FROM 8500 MANUFACTURERS
AT89RFD-08 4385F AT89C51SND2C AT89RFD08 AT89C51SND1C AT73C213 AT91RM9200-DK - Datasheet Archive
. Software User Guide Table of Contents Section 1 Introduction
AT89RFD-08 AT89RFD-08 Reference Design . Software User Guide Table of Contents Section 1 Introduction . 1-1 Section 2 Functional Description . 2-2 2.1 2.2 Features.2-3 Description of the Environment .2-4 Section 3 Communication Protocol. 3-6 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 Communication Protocol .3-6 Frame Format .3-6 Remote Controller - AT8xC51SND2C Command Set List .3-7 Player's Operating Modes.3-11 Error Management .3-12 UART Layer .3-12 Player Management .3-13 File Transfer .3-17 Application Note - Streaming Mode .3-20 Section 4 Installation. 4-27 4.1 4.2 4.3 Architecture .4-27 Firmware Configuration.4-29 Mass Storage Driver .4-33 Section 5 Firmware Architecture Design . 5-34 5.1 5.2 Firmware functions.5-34 Firmware Description .5-35 Section 6 Protocol Frame Description . 6-41 6.1 6.2 6.3 6.4 6.5 6.6 6.7 6.8 Player's Status .6-41 System Command .6-43 Voice Recorder Interface Command.6-52 Player Command .6-53 File System Commands .6-58 Streaming Memory Driver Interface Command .6-63 Custom Command .6-66 Player's Response Frame.6-71 Section 7 Technical Support. 7-77 7.1 1 4385F 4385FMP306/06 Document Change Log .7-77 AT89RFD-08 AT89RFD-08 User Guide Section 1 Introduction The AT89C51SND2C AT89C51SND2C easily adds MP3 music playing feature to any application. This product has fully integrated stand-alone: Hardwired MPEG I/II-Layer 3 decoder with a C51 microcontroller core handling data flow MP3-player control Stereo Audio DAC Mono Audio Power Amplifier for speaker control The AT89C51SND2C AT89C51SND2C demonstration firmware is part of the AT89C51SND2C AT89C51SND2C starter kit. This document is the user's guide of the AT89C51SND2C AT89C51SND2C demonstration firmware based on the reference design board AT89RFD08 AT89RFD08. It describes the MP3 Player firmware, the Machine-Machine Interface and how to communicate with UART link to remote control the MP3 player. The voice recorder functions are not yet available on AT8xC51SND2C, however this firmware can be port to a AT89C51SND1C AT89C51SND1C and external DAC like ATMEL AT73C213 AT73C213. 1.0.0.1 Typical MP3 Applications MP3-Player PDA, Camera, Mobile Phone Car Audio/Multimedia Home Audio/Multimedia Toys Industrial Applications 1.0.0.2 License AT89RFD-08 AT89RFD-08 User Guide Refer to End User License Agreement in License.doc file in the accompanying CDROM. 1-1 4385F 4385FMP306/06 Section 2 Functional Description The AT8xC51SND2C Reference Design Board AT89RFD-08 AT89RFD-08 can be connected to the Atmel AT91RM9200-DK AT91RM9200-DK Board in order to use the AT8xC51SND2C as a slave device controlled by a AT91RM9200 AT91RM9200 acting as a host via UART connection. Figure 2-1. Typical Application with UART connection VDD VSS VSS AT89RFD-08 AT89RFD-08 Rx Tx VSS Tx (J12.28) Rx (J12.27) AT91RM9200-DK AT91RM9200-DK Note: To connect AT91RM9200-DK AT91RM9200-DK and AT89RFD-08 AT89RFD-08 boards, please refer to the Hardware User's Guides and check Rx and Tx signals are crossed between boards. AT89RFD-08 AT89RFD-08 User Guide 2-3 4385F 4385FMP306/06 Functional Description 2.1 Features The AT89C51SND2C AT89C51SND2C module provides: MP3 music playing capability from Nand Flash (NF) from MMC or SD card, The MP3 player software can be remote controlled from an external Controller using standard commands such as: Play, stop, pause, next, previous, Select memory, File System Navigation, System configuration (sound, audio input and output.). USB mass storage capability from NF/MMC/SD connected to AT89C51SND2C AT89C51SND2C. File transfer (from/to host/Player memory) AT89C51SND2C AT89C51SND2C Firmware upgrade through USB (USB device firmware upgrade). 2.2 Description of the Environment 2-4 4385F 4385FMP306/06 List of system Interfaces: AT89RFD-08 AT89RFD-08 User Guide Functional Description Figure 2-2. General System Architecture Storage Device Remote Controller Physical Layer (UART) NOR Flash (Firmware Storage) Stereo Headset RST/ Speaker SD / MMC Player AT8xC51SND2 USB Host Interface Power Supply Nand Flash AT89RFD-08 AT89RFD-08 User Guide 2-5 4385F 4385FMP306/06 Functional Description 2.2.1 USB AT8xC51SND2C USB interface complies to the USB 2.0 Full Speed specifications. The USB bus is used to download music using bulk transfer. The system supports Mass Storage on the following platforms: Win98 with Atmel driver, Win2000/ME/XP. These platforms do not provide multi-drive (multiple USB Logical Unit) support, except Win2000 Service Pack 3 that allows multi-drive support. 2.2.2 NandFlash Supported Nand Flash are described in firmware package. Note: 2.2.3 SD / MMC Card Memory cards are controlled by AT8xC51SND2C and can be considered as removable disk drives: copying from any PC storage media to the memories is then possible. Note: 2.2.4 Audio Output Refer to nf_readme.txt file. Only SD Card and MMC cards with block size of 512 bytes and compliant with Secure Digital Card Specification and MultiMediaCard System Specification Version 3.1 are accepted. SD card is used in 1-bit mode (like MMC card). 4-bit mode is not supported. Stereo Headset (32 Ohm) Loud Speaker (8 Ohm) 2.2.5 Audio Input An external mono audio input signal and an external stereo input signal can be connected to AT8xC51SND2C. Refer to AT8xC51SND2C datasheet to connect audio mono auxiliary positive and negative input (AUXP and AUXN), and stereo Line-in input (LINEINL, LINEINR). 2.2.6 Remote Controller The physical link between Remote Controller and AT8xC51SND2C is UART (default baudrate is 115200 bps) plus one or more GPIOs for data link handshaking when needed. Note: 2.2.7 Power Management On AT89RFD-08 AT89RFD-08 board with reference firmware, if P4.1 is connected to P4.2, the default baudrate is 38400 bps. To prevent system malfunctions during periods of insufficient power supply voltage, AT8xC51SND2C voltage supply shall be monitored by a voltage supervisor. Note: Refer to Atmel Document `External Brown-out Protection for C51 Microcontrollers with Active High Reset Input'. Power supply requested in Player mode: 2.7V 3.6V Power supply requested in USB mode: 3.0V 3.6V Audio power amplifier voltage AUDVBAT for loud speaker shall be 3.2V to 5.5V. Refer to AT8xC51SND2C datasheet. The communication protocol provides POWERDOWN and WAKEUP commands to optimize the system power consumption. 2.2.8 Reset 2-6 4385F 4385FMP306/06 AT8xC51SND2C reset pin RST shall be controlled by Remote Controller. AT89RFD-08 AT89RFD-08 User Guide Section 3 Communication Protocol The MP3 player software is remotely controlled using simple `user interface like' commands such as Play or Stop commands. The communication protocol provides an abstraction of the physical layer between the Remote Controller and the Player. 3.1 Communication Protocol The communication protocol is a half-duplex protocol between a host Remote Controller and the AT8xC51SND2C (Player) over a UART interface. Note: 3.2 Frame Format In the following discussion, Remote Controller is considered as a `master' and Player as a `slave'. All the commands at physical layer level shall respect the following frame format: Figure 3-1. Communication Protocol Frame Format Frame Start 7Eh Channel FFh Protocol Command Data Length Data CheckSum The frame format breaks down into the following information: · · Channel (1 byte): logical channel number, if not used: FFh. · Protocol command (1 byte.) · Data Length (1byte): data length in byte excluding the Checksum byte. · AT89RFD-08 AT89RFD-08 User Guide Frame Start (1 byte): Synchronization character 7Eh. Checksum (1 byte): Frame checksum: 8 least significant bit of the sum of: Channel + Protocol Command + Data Length + Data. 3-7 4385F 4385FMP306/06 Communication Protocol In the following discussion, the Channel parameter is considered to customize a specific command and is not used in the default firmware mode (FFh). 3.3 Remote Controller AT8xC51SND2C Command Set List There are several command types: System Command: these commands allow to configure the system. Voice Recorder Command: Not yet available on AT8xC51SND2C. These commands allow to record WAV file (only on AT8xC51SND1C). Player Command: these commands allow to access all the Player's functions. File System Command: these commands allow to navigate in selected memory: file and directory architecture for the Card Memory. Streaming Memory Driver Interface Command: these commands allow the Remote Controller to stream MP3 music upon Player's requests. Custom Command: these commands allow the Remote Controller to do specific requests. Table 3-1. System Command Protocol Command Command Data SYSTEM_RESET 00h No SYSTEM_CONFIG 01h - SYSTEM_GET_STATUS 02h No Asks the Player Status byte SYSTEM_AUDIO_OUTPUT 03h 1 Byte Select Player Audio Output: · Headset · Power Amplifier SYSTEM_SELECT_MEMORY 04h 1 Byte Select Memory: · NandFlash · Card (SD/ MMC) connected to AT8xC51SND2C · Remote Controller memory in streaming mode When FAT is mounted, FNA is set in Player's status (refer to Table 6-1). SYSTEM_SET_SOUND 05h 5 Bytes Set digital sound and digital equalization. Refer to set sound command description SYSTEM_POWER_DOWN 06h No Power Down the Player SYSTEM_WAKEUP 07h No Wake-up the Player. Warning: this command requires AT8xC51SND2C RXD line connected to INTO pin (P3.2) in hardware. Refer to Table 6-12. SYSTEM_USB_DETACH 08h No Ask the Player to perform an USB Mass Storage detach. SYSTEM_USB_CONNECT 09h No Ask the Player to perform an USB Mass Storage PC Connection. SYSTEM_ISP 0Ah No Ask the Player to enter in ISP Mode (firmware upgrade) - only for AT89C51SND2C AT89C51SND2C. SYSTEM_VOLUME_UP 0Bh No Analog Gain control volume up SYSTEM_VOLUME_DOWN 0Ch No Analog Gain control volume down 3-8 4385F 4385FMP306/06 Description Software reset the AT8xC51SND2C. There is no answer for this command. Refer to Player Reset section. Reserved to configure the player in a pre-defined state AT89RFD-08 AT89RFD-08 User Guide Communication Protocol Protocol Command Command Data Description SYSTEM_PLAYER_MODE 0Dh 1 Byte Set Player mode on selected memory: · Repeat / No Repeat · Play Single · Play Dir · Play Disk · Explorer Mode (see all file type *.*, useful for file transfer) SYSTEM_AUDIO_INPUT 0Eh 1 Byte Enable Player Audio Input · None / disable previous selected input · Mono Input · Stereo Input SYSTEM_ENTER_HID_MODE 0Fh No Ask the Player to enter the HID mode: bridge USB - UART. Table 3-2. Voice Recorder Interface Command (only available on AT8xC51SND1C) Protocol Command Command Data VOICEREC_START_REC 20h No Voice Recorder start recording VOICEREC_STOP_REC 21h No Voice Recorder stop Recording Note: Description The Voice Recorder Interface is using the AT8xC51SND1C ADC and is not available on AT8xC51SND2C. Table 3-3. Player Command Protocol Command Command Data PLAYER_PLAY 50h No If current file name is a MP3/WAV* file, play or resume pause selected MP3/WAV* file from Selected Memory. If current file name is a directory, enter this directory and select the first MP3/WAV*. A new Play command is needed to play this new MP3 file. PLAYER_STOP 51h No Stop playing current MP3/WAV* file PLAYER_PAUSE 52h No Pause current MP3/WAV* file PLAYER_NEXT 53h No Select Next MP3/WAV* file on Selected Memory PLAYER_PREVIOUS 54h No Select Previous MP3/WAV* file on Selected Memory PLAYER_SETMARKERA 55h No Set A marker for repeat AB feature PLAYER_SETMARKERB 56h No Set B marker for repeat AB feature PLAYER_STOPAB 57h No Stop AB repeat mode PLAYER_GET_TIME 58h No Get Playing time since beginning of the file. PLAYER_GETINDEXNUMBER 59h No Get Number of file in current directory or root directory. PLAYER_ENTER_ROOT_DIR 5Ah No Select the first MP3 files available in root directory. PLAYER_SET_FILTER 5Bh No Set filter to have no directory seen. PLAYER_GET_FILE_LIST 5Ch No Get file names list in current directory or root directory. PLAYER_GET_LIST_DATE 5Eh Yes Get file names and creation date list in current directory or root directory. PLAYER_PLAY_INDEX_MP3 5Fh Yes Play MP3 file selected by index (directory are not seen). AT89RFD-08 AT89RFD-08 User Guide Description 3-9 4385F 4385FMP306/06 Communication Protocol Table 3-4. File System Command Protocol Command Command Data Description FS_NEXT 60h No Select next file from selected memory FS_PREVIOUS 61h No Select previous file from selected memory FS_ENTER_DIR 62h No Enter selected directory FS_EXIT_DIR 63h No Exit current directory FS_GET_NAME 64h No Get name of selected file or directory on selected memory FS_FORMAT 65h No Format on selected memory FS_FCREATE 66h Yes Create a file on selected memory FS_FREAD_BLOCK 67h Yes Read data block to current created file FS_FWRITE_BLOCK 68h No Write data block from selected file FS_FWRITE_LAST_BLOCK 6Dh No Write last data block from selected file FS_FCLOSE 69h No Read or write close current file transfer FS_GETMEMFREESPACE 6Ah No Get memory free space available FS_GETFILESIZE 6Bh No Get current file size FS_GETFILEPOS 6Ch No Get current file position FS_FDELETE 6Eh No Get current file position FS_GETFILEDATE 6Fh No Get file date information. Table 3-5. Streaming Memory Driver Interface Command (Streaming only) Protocol Command SMDI_GET_DIR SMDI_REQUEST * SMDI_COMMAND Command 70h 71h 72h Data Description No Get Player Streaming Memory Driver Interface Request Yes Player Response to Remote Controller SMDI_GET_MDIR command Yes Remote Controller Streaming Memory Driver Interface Command (read_request, write_request) Table 3-6. Custom Command Protocol Command Command AUDIO_SET_GAIN 91h Yes Set Audio Gain. AUDIO_SET_PA_LP 92h Yes Set Power Amplifier mode for low power. CUSTOM_UART_SET_BAUDRAT E 93h Yes Change UART baudrate from Remote Controller. CUSTOM_GET_SYS_VERSION 94h AUDIO_ACTIVE_INPUT_IN_USB 97h Data no Description Get Player firmware version. Yes Enable / Disable audio input (mono/stereo) during USB mass storage mode. CUSTOM_USB_ATTACH 9Bh Yes Enable / Disable USB auto attach mode. CUSTOM_SYSTEM_VOLUME F0h Yes Set Analog Volume (master gain) 3-10 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Communication Protocol Protocol Command Command Data Description Yes Get MP3 file playing total time length. F3h Yes Select first file in current directory and play it. F4h Yes Select last file in current directory and play it. CUSTOM_PLAYER_GET_TOTAL_ TIME F1h CUSTOM_PLAYER_FIRST CUSTOM_PLAYER_LAST Table 3-7. Player Response (*) Protocol Command Command Data Description SYSTEM_ACK * 80h 1 Byte General Player acknowledge to Remote Controller's command. Data is the current AT8xC51SND2C Status byte. SYSTEM_NACK * 81h 1 Byte Player non- acknowledge to Remote Controller's command. Data is the current AT8xC51SND2C Status byte. FS_NAME * 82h Yes PLAYER_TIME * 83h 3 Bytes PLAYER_INDEXNUMBER * 86h Yes Number of files in current directory. PLAYER_VOLUME * 87h Yes Player current analog and digital volume. FS_FREAD_BLOCK_DATA * 84h Block FS_FREAD_BLOCK_DATA_END * 85h No Player response to FS_FREAD_BLOCK command when end of file is reached. Player returns then in IDLE state. FS_FILEDATE * 89h Yes File date creation information. FS_MEMFREESPACE * 8Ah Block FS_FILESIZE * 8Bh Yes Send current file size. FS_FILEPOS * 8Ch Yes Send current file position. FS_END_OF_LIST * 8Dh Yes Player has reached the end of the list after PLAYER_GET_LIST command. SYSTEM_MOUNTED* 8Fh No Player has finished file system FAT install on selected memory. CUSTOM_PLAYER_TOTALTIME * E0h Yes MP3 total time length. CUSTOM_PLAYER_END_OF_FILE * E1h Yes Player has reached the end of file. Notes: AT89RFD-08 AT89RFD-08 User Guide Player current file name. Player current playing time (minute and second since beginning of the file). Send data block to Remote Controller's command FS_FREAD_BLOCK. Free space available on selected memory. 1. * means that the frame is a Player Response to Remote Controller request. 2. * WAV file only available on AT8xC51SND1C with Voice Recorder. 3-11 4385F 4385FMP306/06 Communication Protocol 3.4 Player's All the commands sent by the Remote Controller can change the Player's current operOperating Modes ating mode. Figure 3-2. Player's Operating Modes START Power on Reset Hardware Reset HID Bridge USB/UART BOOT SYSTEM_ POWERDOWN Available Command in IDLE Mode: FS_GET_NAME FS_EXIT_DIR FS_FORMAT FS_NEXT / FS_PREVIOUS SYSTEM_X SYSTEM_ENTER _HID SYSTEM_ WAKEUP Initialization SYSTEM_SELECT _MEMORY Status Not Playing IDLE Status USB Connection USB Transfer POWER DOWN SYSTEM_ USB_CONNECT SYSTEM_USB _DISCONNECT Status Not Playing FileNameAvailable MemoryError INIT Status => Memory Error or FileNameAvailable means that INIT is finished. PLAYER_PLAY PLAYER_STOP Status Playing FileNameAvailable PLAYER MASS STORAGE SYSTEM_USB _CONNECT PLAYER_STOP PLAYER_PREVIOUS PLAYER_X FS_GET_NAME Limitations: During Mass Storage operating mode, if MP3 file need to be played, it is advised not to play the MP3 and let the user finish the USB mode. Refer to Table 6-12. SYSTEM_USB_DETACH Command Format 3-12 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Communication Protocol 3.5 Error Management 3.5.1 Command Time-out When a communication handling error occurs (for example data length does not correspond to the actual frame size), the AT8xC51SND2C reception state machine is resetted after TimeResumeCommand ms. If the Remote Controller does not receive any status from Player, it shall wait TimeResumeCommand ms before sending the GET_STATUS frame. 3.5.2 Bad CheckSum If Remote Controller sends command with bad checkSum: there is a Player Answer Acknowledge with Command Error. Remote Controller has to retry the command. Checksum error shall be tolerated in streaming mode to achieve real-time constraints. 3.6 UART Layer UART Physical layer is: RXD signal TXD signal The data byte consists of 10 bits: 1 start-bit 8 data-bit 1 stop-bit The default firmware baudrate is 115200 bps. Serial data is transmitted on the TXD pin and received on the RXD pin. Note: 3.6.1 Polling Strategy To connect Remote Controller and AT89RFD-08 AT89RFD-08 boards, please refer to Hardware User's Guide Boards and check Rx and Tx signals are crossed for each board. The protocol implementation does not allow the Player to initiate the communication or to indicate its status update. Therefore, the Remote Controller shall have a polling management using the GET_STATUS command to get the up-to-date Player status. Refer to Table 6-1. Player STATUS Description. Here is a the principle of use of the communication protocol with UART layer: Remote Controller sends GET_STATUS command to Player, Player answers ACK_STATUS to Remote Controller to inform about its status. Figure 3-3. Protocol communication principle of use ACK + STATUS Controller_Rx Controller_Tx AT89RFD-08 AT89RFD-08 User Guide SYSTEM_ GET_STATUS ACK + STATUS COMMAND 3-13 4385F 4385FMP306/06 Communication Protocol 3.7 Player Management 3.7.1 Player Reset After a Player warm or cold reset, Remote Controller shall wait on its RX line the SYSTEM_ACK frame. This means that the AT8xC51SND2C is ready to communicate. Figure 3-4. Warm Reset C o n tro lle r_ R x C o n tro lle r_ T x S YST E M _AC K S YST E M _R E S E T G ET _ST A T U S A T 8XC 51S N D 2 R es et an d in it Table 3-8. Hardware Reset Controller_Rx SYSTEM _ACK Controller_Tx AT8xC51SND2 Hardware Reset Note: 3.7.2 Player's Status GET_STATUS AT8XC51SND2 AT8XC51SND2 Initialization At AT8xC51SND2C power-up, Remote Controller shall wait to receive the SYSTEM_ACK frame on its RX line. Player status byte reflects in real time all the events that occur in the AT8xC51SND2C: memory error, playing or not, new file name available, USB events. Remote Controller should have a polling management with the GET_STATUS command to refresh the Player's status. The Player's Status Byte contains informations like: Playing or idle Memory Error USB Connection USB File Transfer New File Name available Streaming request: the Player needs MP3 data from Remote Controller for streaming CheckSum Error 3-14 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Communication Protocol The SYSTEM_ACK_STATUS frame response is the acknowledge for the received frame and the corresponding command processed. Note: 3.7.3 Remote Controller`s MMI Algorithm Refer to Table 6-1. Player STATUS Description Figure 3-5. Remote Controller MMI Algorithm NO NO Frame sent ? YES Frame received ? Frame received is Com Channel Request ? OR SMDIOR set in status byte ? If User'sAction, send Command Frame YES YES Send [GET_SMDIR] Frame to get the streaming request NO Decode Received Frame and Update : - Player Status - Controller Display - User's available command YES Next Possible Action ? Send Frame NO AT89RFD-08 AT89RFD-08 User Guide 3-15 4385F 4385FMP306/06 Communication Protocol 3.7.3.1 Example 1 Table 3-9. Example: select memory and get name of current file S e le c t/In s ta ll th e m e m o r y a n d g e t th e n a m e o f th e c u r r e n t file /d ir e c to r y C o n tro lle r P la ye r S YS TEM _G E T_STATUS STATU S S YS TE M _AC K + C a rd In s e rtio n SYSTEM _SEL ECT_M EM O R Y (C A R D ) P la y e r in s ta lls F ile S y s te m o n s e le c te d m e m o ry . STATU S S YS TE M _AC K + e r y O K a n d F ile n a m E D (s ta tu s = M e m o SYSTEM _M O UNT v a ila b le a F ile y s te m is m o u n te d . M e m o ry is K O o r N e w file n a m e is a v a ila b le . S YS TEM _G E T_STATUS o r y O K a n d file + STA TU S = M em SYSTEM _AC K n a m e a v a ila b le FS _G E T_N A M C o n tro lle r can now d is p la y th e n a m e o f th e file 3-16 4385F 4385FMP306/06 E e o f th e file + STATUS + Nam SYSTEM _NAM E AT89RFD-08 AT89RFD-08 User Guide Communication Protocol 3.7.3.2 Example 2 Figure 3-6. Example: Play a MP3 file P la y M P 3 o n M M C / S D C a rd C o n tr o lle r P la ye r SYSTEM _G E T_STATU S STATU S S YSTE M _AC K + C a rd In s e rtio n SYSTEM _SEL ECT_MEM OR Y (C A R D ) OK && FN A T A T U S = M e m o ry S SYSTEM _AC K + ry O K & & F N A STATUS = M em o SYSTEM _AC K + P LA YER _PLA F A T in s ta lle d Y r y O K & & P la y in g STATUS = M em o SYSTEM _AC K + P LA YER _STO P y in g ry O K & & N o t P la STATUS = M em o SYSTEM _AC K + C a rd re m o v e d SYSTEM _G E T_STATU S ry E r ro r STATU S = M em o SYSTEM _AC K + AT89RFD-08 AT89RFD-08 User Guide 3-17 4385F 4385FMP306/06 Communication Protocol 3.8 File Transfer The File Transfer mode is used to transfer file from/to Remote Controller to/from Player Memory. START Power on Reset Hardware Reset BOOT FS_FWRITE_BLOCK FS_FWRITE_LAST_BLOCK FS_FREAD_BLOCK Initialization FS_FCREATE FILE TRANSFER FS_FCLOSE IDLE . 3.8.1 Protocol Communication Use Available Command in FILE TRANSFER Mode: FS_FREAD_BLOCK FS_FWRITE_BLOCK FS_FWRITE_LAST_BLOCK SYSTEM_RESET FS_FCLOSE The following commands: FS_FCREATE FS_FWRITE_BLOCK FS_WRITE_LAST_BLOCK FS_FREAD_BLOCK FS_FCLOSE FS_READ_BLOCK_DATA * FS_READ_BLOCK_DATA_END * are the basic file transfer interface functions for the Remote Controller. Note: 3-18 4385F 4385FMP306/06 * means that the frame is a Player Response to Remote Controller request. AT89RFD-08 AT89RFD-08 User Guide Communication Protocol 3.8.1.1 Example 1 Figure 3-7. Transfer a File From Remote Controller to Player Selected Memory T r a n s fe r in g A F ile F r o m R e m o te C o n tr o lle r to P la ye r C o n tr o lle r P la ye r F S _ F C R E A T E (N a m e o f F ile , N u m b e r o f b lo c k to tra n s fe r ) P la y e r c re a te s th e file o n s e le c te d m e m o ry (in ro o t d ir). N o w w a itin g fo r d a ta . US SYSTEM _AC K + STAT F S _ F W R IT E _ B L O C K + d a ta STATU S S YSTE M _AC K + F S _ F W R IT E _ LAS T_BLO C K + d a ta STATU S S YSTE M _AC K + P la y e r p ro g ra m m s n o w th e m e m o ry a n d p re p a re N o w w a itin g fo r d a ta . P la y e r p ro g ra m s th e la s t b lo c k o f d a ta . F ile is c lo s e d . N o n e e d to s e n d th e F S _ F C L O S E fra m e . During the file write transfer, after the FS_FCREATE command, no other commands than FS_FWRITE_BLOCK, FS_FWRITE_LAST_BLOCK or FS_FCLOSE are allowed to finish the file transfer because the AT8xC51SND2C is an optimized transfer mode. To create the file "wr_test.mp3" (total size 1312 Bytes: 2 block of 512 bytes + last block 288 bytes): Send FS_FCREATE (3 blocks, `w' `r' `_' `t' `e' `s' `t' `.' `m' `p' `3' `\0') Wait for response SYSTEM_ACK* frame. Send FS_FWRITE_BLOCK + 1st block of data (512 bytes), Wait for response SYSTEM_ACK* frame. Send FS_FWRITE_BLOCK + 2nd block of data (512 bytes) Wait for response SYSTEM_ACK* frame. send FS_FWRITE_LASTBLOCK (288 bytes) + last block of data (288 bytes) Wait for response SYSTEM_ACK* frame. The file is now created. Note: AT89RFD-08 AT89RFD-08 User Guide If Player response is SYSTEM_NACK to any command during this procedure, the Player will return into the IDLE state and the file creation procedure will be aborted. 3-19 4385F 4385FMP306/06 Communication Protocol 3.8.1.2 Example 2 Figure 3-8. Example: Transfer a File From Player to Remote Controller T r a n s fe r in g A F ile F r o m P la ye r to R e m o te C o n tr o lle r C o n tr o lle r P la ye r FS_G ETNAM E F S _ N A M E (F ile N a m e ) FS_FREAD_B FS_FREA LO C K (B lo c k ) D_BLO C K_DATA FS_FREAD_B FS _FR E A D _B LO LO C K o D a ta ) C K _ D A T A _ E N D (N P la y e r re a d a n d s e n d th e firs t b lo c k o f d a ta . E n d o f file re a c h e d . F ile is c lo s e d . N o n e e d to s e n d th e F S _ F C L O S E fra m e . The FS_READ_BLOCK read the file until the end of the sector size in memory. To know the total file size, the Remote Controller shall send the FS_GETFILE_SIZE command. 3-20 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Communication Protocol 3.9 Application Note - Streaming Mode It is possible to modify the AT89RFD-08 AT89RFD-08 firmware to obtain a streaming mode. In streaming mode, Remote Controller sends MP3 data according the communication protocol. Source code of streaming mode is only given as an example that can be easily modified according to the communication protocol and host constraints. Note: For firmware details, refer to 4.2.10 Streaming Mode. The streaming mode is used to access the Remote Controller memory with the followings benefits: Linear File System Any storage type connected to the Remote Controller can be accessed: NorFlash, NandFlash. Figure 3-9. Streaming Mode Player Remote Controller MP3 In Streaming mode, Remote Controller has to manage data flow control. When Player has a MP3 data request (internal buffer full or internal buffer empty for MP3 data), it can used asynchronous request like CCR (communication channel request). 3.9.1 3.9.1.1 Communication Channel Request (CCR) CCR is used to signify the Remote Controller that the Player have a new status or request and can not wait the next Remote Controller GET_STATUS polling command. CCR Software Implementation 2 asynchronous bytes send to Remote Controller. CCR can be implemented in software or in hardware to be more efficiency. Figure 3-10. CCR Software Implementation Controller_Rx Controller_Tx 3.9.1.2 CCR Hardware Implementation AT89RFD-08 AT89RFD-08 User Guide Frame Start STATUS or SMDI _REQUEST Frame Start GET_STATUS or GET_SMDIR 1 hardware signal to signify the Remote Controller a request. 3-21 4385F 4385FMP306/06 Communication Protocol Figure 3-11. CCR hardware implementation Player Remote Controller Rx Tx Tx Rx MP3 CCR Here is a the principle of use of the CCR: Player's status is updated, Player set CCR Remote Controller sends GET_STATUS command to Player, Player answers ACK_STATUS frame to Remote Controller who now knows the real state of the Player. CCR is only used in streaming mode when SMDIOR is set in Player's status (refer to Table 6-1 for Player's status description). To be more effective, the Remote Controller can send a GET_SMDIR instead of GET_STATUS command. Here is a the principle of use of the CCR in this case: Player's status is updated with SMDIOR, Player set CCR Remote Controller sends SMDI_GET_MDIR command to Player, Player answers SMDI_REQUEST. To enter the streaming mode, the Remote Controller shall send the SELECT_MEMORY `streaming' command to the Player. Then send the PLAYER_PLAY command. Refer to Player's Status description in Appendix and to Protocol frame description for streaming mechanism description. When the end of file is reached, the Remote Controller shall send the PLAYER_STOP command. 3.9.2 Protocol Communication Use The following commands: SMDI_GET_MDIR SMDI_REQUEST SMDI_COMMAND can be used as the basic driver interface functions for the Remote Controller to get Player streaming request and send the streaming data packet: When Player have a streaming request to Remote Controller, SMDIOR is set in Player's status byte. CCR is used by Player if possible. Remote Controller sends the SMDI_GET_MDIR command to get the request. Player's response is SMDI_REQUEST with READ parameter. 3-22 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Communication Protocol Remote Controller sends the SMDI_COMMAND with READ parameter and the according MP3 data packet. Each time the Player has a streaming request, Remote Controller shall send SMDI_GET_MDIR command to get the request, then send the corresponding command SMDI_COMMAND with right parameters. Figure 3-12. Example of Streaming MP3 P la y M P 3 S tr e a m in g C o n tr o lle r P la ye r SYSTEM _SEL ECT_MEM OR Y (S T R E A M IN G) STATU S S YSTE M _AC K + P la y e r n e e d M P 3 d a ta . S ta tu s b y te is u p d a te d w ith S M D IO R s e t CCR SYSTEM _G E T_STATU S to 1 A T U S = S M D IO R ST SYSTEM _AC K + S M D I_ G E T _ D IR (R E A D S M D I_ R E Q U E S T S M D I_ R E A D (M ) P3 DATA PAC KET) a m in g .m p 3 ") S T A T U S (F N A " s tre SYSTEM _AC K + P LA YER _PLA P la y e r c a n n o w s ta rt to p la y ! Y STATU S S YSTE M _AC K + AT89RFD-08 AT89RFD-08 User Guide 3-23 4385F 4385FMP306/06 Communication Protocol Figure 3-13. Example of Streaming MP3 with CCR is only used by the Player when SMDIOR is set. P la y M P 3 S tr e a m in g (C C R is o n ly u s e d b y P la ye r w h e n S M D IO R is s e t) C o n tr o lle r P la ye r SYSTEM _SEL ECT_MEM OR Y (S T R E A M IN G) STATU S S YSTE M _AC K + P la y e r n e e d M P 3 d a ta . S ta tu s b y te is u p d a te d w ith S M D IO R s e t CCR S M D I_ G E T _ D IR (R E A D ) S M D I_ R E Q U E S T S M D I_ R E A D (M P3 DATA PAC KET) tre a m in g .m p 3 " ) S T A T U S (F N A " S SYSTEM _AC K + P LA YER _PLA P la y e r c a n n o w s ta rt to p la y ! Y STATU S S YSTE M _AC K + 3-24 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Communication Protocol Figure 3-14. Example Streaming MP3 (Inside the Player: System and SMDI) P la y M P 3 S tr e a m in g (C C R is o n ly u s e d b y P la ye r w h e n S M D IO R is s e t) P la ye r C o n tr o lle r S y s te m SYSTEM _ SELECT_M E M O R Y (S T R E A M IN G SM DI ) TATU S SYSTEM _AC K + S PLAYER_PLAY SYSTEM _AC K + STATUS P la y e r n e e d M P 3 d a ta s . S ta tu s b y te is u p d a te d w ith S M D IO R s e t CCR S M D I_ G E T _ M S M D I_ R E Q U E S M D I_ R E A D (M D IO R S T (R E A D ) P3 DATA PAC KET) SYSTEM _AC K + STATUS P la y e r c a n n o w s ta rt to p la y ! CCR S M D I_ G E T _ M D IO R S M D I_ R E Q U E S T (R S M D I_ R E A D (M P3 DATA PAC KET) SYSTEM _AC K End of F ile EAD) + STATU S PLAYER_STO P SYSTEM _AC K + STATUS 3.9.3 Real Time Constraints 3.9.3.1 MP3 In streaming mode, the first bytes sent to the Player shall start as a MP3 frame synchronization. The first 12 bits shall be set to 1. 3.9.3.2 Warning To achieve the MP3 streaming, Remote Controller shall respect all the real time constraints depending of UART baudrate and MP3 bitrate. If the Remote Controller does not respect enough MP3 data at right time, Player will not be able to play the MP3 correctly. Refer to Table 3-10 for MP3 frame size description. The frequency sample of this MP3 shall be configured in AT8xC51SND2C firmware. (refer to 4.2.5 Memory type). 3.9.3.3 MP3 Bitrate AT89RFD-08 AT89RFD-08 User Guide Depending of link baudrate, the system {Remote Controller & Player} can achieve to stream different MP3 bitrates. 3-25 4385F 4385FMP306/06 Communication Protocol Table 3-10. MPEG1/2 Layer III Frame Size (= byte / Frame) FS(KHz) \ Bitrate (kbit/s) 32 40 48 56 64 128 32 144 180 216 252 288 576 44.1 104 130 156 182 208 417 48 96 120 144 168 192 384 Table 3-11. MPEG1/2 Layer II Frame Time Length FS (KHz) Frame Time Length (ms) 32 36 44.1 26 48 24 For example, to stream a 32Kbits/s MP3 bitrate at 44.1KHz, the Remote Controller shall send 104 bytes in 26 ms. 3.9.3.4 UART baudrate If the Remote Controller is an ARM micro controller, UART shall be configured, depending of the baudrate, with the oversampling activated. To achieve streaming at specific MP3 bitrate, best is to change the MP3 packet size transferred to a multiple of the MP3 frame size if possible. In AT8xC51SND2C firmware, the default MP3 packet size is set to 128 bytes. Remote Controller real time constraints in streaming mode is to send enough MP3 packets to Player before the end of the time allowed. Refer to Table 3-12. Bandwidth required (= Kbits/s). Table 3-12. Bandwidth required (= Kbits/s) FS(KHz) \ Bitrate (kbit/s) 32 40 48 56 64 128 32 60 70 95 115 125 250 44.1 70 85 100 120 135 260 48 75 90 110 130 145 270 Table 3-13. UART baudrate versus MP3 bitrate MP3 Bitrate (kbits/s) UART Baudrate Kbits/s 48 56 64 128 Yes Yes Yes No No No 500 Kbit/s 4385F 4385FMP306/06 40 115.2 Kbit/s 3-26 32 Yes Yes Yes Yes Yes No AT89RFD-08 AT89RFD-08 User Guide Communication Protocol Table 3-14. Real Time Constraints Value Items Description TimeEffectiveCommand 40 ms max. Maximum Time between Remote Controller command and Player response before timeout. TimeResumeCommand AT89RFD-08 AT89RFD-08 User Guide Value 90 ms. When a communication handling error occurs (for example data length does not correspond to the actual frame size), the AT8xC51SND2C reception state machine is resetted after TimeResumeCommand ms.TimeResumeCommand can be defined in project configuration file. 3-27 4385F 4385FMP306/06 Section 4 Installation The firmware package is delivered in a zip file: snd2c-xxxx-yyy-zzz-A_B_C.zip that extracts in an Atmel\ directory. Please also read the readme.txt file for firmware description. 4.1 Architecture 4.1.0.1 Overview Figure 1-1 shows the organization of the Atmel\snd2c-xxxx-yyy-zzz-A_B_C directory. The following sections detail the content of the sub-directories. Figure 1-1. Atmel\snd2c-xxxx-yyy-zzz-A_B_C Directory Organization Atmel\snd2c-xxxx-yyy-zzz-A_B_C \ doc \ lib_mcu \ lib_mem \ modules \ lib_storage \ lib_refd \ usb_ms_drv The project name is defined as follow: snd2c-xxx-yyy-zzz-A_B_C where xxx-yyy-zzz is: refd-stream-sd for reference design based project tag. A_B_C is the version number of the package. A, B and C are digits. · A gives the major revision number. · B gives the minor revision number and a state of the revision: AT89RFD-08 AT89RFD-08 User Guide even number: stable version odd number: non stable version (used during developments) 4-29 4385F 4385FMP306/06 Installation · C gives the patch revision number. In addition to subdirectories, the snd2c-refd-stream-sd\ directory contains all the firmware core files and some important companion files giving information on the demonstration firmware. Please read these files carefully. This directory contains the KeilTM µ-vision2 project files, the executable file in IntelTM ".hex" format, the config.h file. Depending on the demo, more than one ".hex" and µ-vision2 project files can be found under this directory: Figure 4-1. snd2c-xxxx-yyy-zzz-A_B_C\ File Organization Atmel\snd2c-xxxx-yyy-zzz-A_B_C \CHANGES.txt INSTALL.txt LICENSE.txt NEWS.txt README.txt config.h main.c startup.a51 system_task.c system_task.h isp.a51 player_xxx.uv2 player_yyy.hex where player_xxx can be: · · usb_ms_drv Directory player-uartlink-nf1x-2kb-sd: Player with Nand Flash (1x, 2kb page size) and MMC/SD Card. Supported file system is FAT12-FAT16 FAT12-FAT16. · 4.1.0.2 player-uartlink-nf1x-512b-sd: Player with Nand Flash (1x, 512b page size) and MMC/SD Card. Supported file system is FAT12-FAT16 FAT12-FAT16 and FAT32 FAT32. player-uartlink-streaming-sd: Player with Streaming and MMC/SD card. Source code of streaming mode is given as an example that can be easily modified according to the communication protocol and host constraints. The win_drv directory contains the Windows 98TM driver for the USB mass storage application. The readme files gives advice on how to install drivers on windows 98TM platform and how to mount the removable disk on LinuxTM platform. Figure 4-2. usb_ms_drv Directory Organization usb_ms_drv\ atusbms.zip \ readme.txt \ readme_linux.pdf 4.1.0.3 lib_mcu Directory 4-30 4385F 4385FMP306/06 The lib_mcu directory is organized into sub-directories that contain the low-level drivers of the AT89C51SND2C AT89C51SND2C peripherals. The lib_mcu directory also contains the following files: AT89RFD-08 AT89RFD-08 User Guide Installation · mcu_drv.h: this header file contains macro functions able to configure c51 core features such as clock mode, ERAM size, global interrupt, etc. and mask definitions for special function registers of the AT8xC51SND2C product. · compiler.h: this header file contains new type definitions, general purpose constants and macro functions for compiler dependant syntax. · mcu.h: this header file contains special function registers and bit definition of the AT8xC51SND2C products. 4.1.0.4 lib_refd Directory The lib_refd directory contains the reference design board definitions. · board.h: this header file contains board definitions 4.1.0.5 lib_mem Directory The lib_mem directory is organized in sub-directories that contain the high-level drivers of memories or cards that can be connected to the AT8xC51SND2C products. Note: For NAND Flash based application, some companion files give information on the demonstration firmware (reserved disk space feature or NAND Flash installation for example). NAND flash directories contain also a nf_readme.txt file. Please read these files carefully. 4.1.0.6 lib_storage Directory The lib_storage directory contains the libraries for SBC mass storage support. In order to standardize the interfaces and to keep confidentiality on these modules, embedded SCSI modules can be delivered in library form (source code not delivered). 4.1.0.7 modules Directory The modules directory is organized in sub-directories that contain files such as tasks header and source files. 4.2 Firmware Configuration There are two files that are used to configure the firmware: · config.h located under snd2c-xxxx-yyy-zzz-A_B_C\ directory used to configure the library and the drivers as detailed in each header files. · 4.2.1 USB IDs the board.h located under lib_refd\ directory used to configure the component information of the board. Three IDs are available for configuration by the user in config.h file: Vendor ID Product ID Release Number ID According to USB Organization: "Vendor ID (VID) is owned by the vendor company and is assigned and maintained by the USB-IF only. E-mail admin@usb.org for more information on USB-IF membership and obtaining a VID". Atmel allows limited usage of its VID (03EBh) during product development phase. Customer use of the Atmel Vendor ID is not guaranteed by Atmel. The customer must use its own Vendor ID for production. 4.2.2 USB Mass Storage Strings AT89RFD-08 AT89RFD-08 User Guide Six strings are available for configuration by user in config.h file. Those strings are printed during USB drivers installation and during disk drivers status report in host system: 4-31 4385F 4385FMP306/06 Installation USB_MANUFACTURER_NAME: unicode character string (default "ATMEL") USB_MN_LENGTH: number of unicode character (default "5") USB_PRODUCT_NAME: unicode characters string (default "MP3 STORAGE") USB_PN_LENGTH: number of unicode characters (default "11" ) USB_SERIAL_NUMBER: unicode characters string USB_SN_LENGTH: number of unicode character SBC_VENDOR_ID: 8 ASCII characters string (default 03EBh, ATMEL VID) SBC_PRODUCT_ID:16 ASCII characters string (default 2010h, ATMEL PID) SBC_REVISION_ID: 4 ASCII characters string (default "1.00") Default number of USB logical unit in firmware is one (= number of drive seen by Windows explorer). This number can be updated to 2 logical units with Remote Controller command. It is necessary to select one memory (NandFlash or MMC/SD card) from Remote Controller (refer to SYSTEM_SELECT_MEMORY command) to enter USB mass storage mode. To have 2 logical unit (= number of drive seen by Windows explorer), please refer to command SYSTEM_CONFIG. 4.2.3 UART The UART baudrate is defined in the config.h file. The default baudrate value is 115200 bps (theoretical value) and 111 111 bps (physical value). #define BAUDRATE 115200 /* 111111 bps Serial Speed*/ To achieve the best MP3 bitrate streaming, this baudrate have to be configured as the higher common baudrate between AT8xC51SND2C and Remote Controller. Communication time-out (COM_TIMEOUT) is also defined in the config.h file. If GPIO P4.1 is connected to P4.2, the default baudrate is 38400 bps. This enable to easily change the baudrate without any command. 4.2.4 File system Demonstration firmware supports file system FAT12/16 FAT12/16 or/and FAT32 FAT32. File system configuration is done in the config.h file. #define MEM_CHIP_FS #define MEM_CARD_FS FS_FAT_12_16_32 FS_FAT_12_16_32 /* chip memory FS */ /* card memory FS*/ For further information, please read fs_readme.txt file under \modules\files directory. 4.2.5 Memory type Demonstration firmware supports different memories: · NAND Flash · MMC / SD card · External / Streaming Memory (streaming driver required) connected to Remote Controller such as NandFlash or NorFlash (Streaming mode is seen by the firmware as a standard on-board memory). Memory type definition must be set in config.h file. There is two kinds of memory management: On-board memory 4-32 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Installation Card memory This allows 3 combinations: · project with on-board memory alone. · project with card memory alone: for this project, after USB mass storage exit, the default memory selected will be the on-board memory. If there is no on-board memory (nand flash) connected, the Player will set the MERROR bit in status. The Remote Controller shall send the command SYSTEM_SELECT_MEMORY (CARD) to re-select the card memory slot. · project with both on-board memory and card. For example: #define MEM_CHIP_TYPE CHIP_NF // NandFlash #define MEM_CARD_TYPE CARD_SD // both MMC and SD card Note: 4.2.6 SND2 IRQ IO There is 4 drivers for Nand Flash, depending on memory type and board configuration. 1) nf_1x_512b: This driver supports one nand flash memory with a page size of 512bytes. 2) nf_2x_512b: This driver supports two parallel nand flash memory with a page size of 512bytes. 3) nf_1x_2kb:This driver supports one nand flash memory with a page size of 2kbytes. To include one of this driver in your project, you have to modify the file location in compiler. File to change are: nf.c, nf_drv.c, nf_drv_load.a51. The SND2_IRQ IO (default P4_3 GPIO) is used for interrupt request from AT8xC51SND2C to Controller. This IO is cleared when status is updated by: initialization finished, USB connection/detach, end of file reached when playing, Memory format is OK. This IO is set when status is read by any command by the Remote Controller (SYSTEM_GET_STATUS command for example). 4.2.7 Audio Gain The Audio gain default value are: MP3 VOLUME LEFT: MP3 digital volume left channel (default value: settings Medium: 0Fh) MP3 VOLUME RIGHT: MP3 digital volume right channel (default value: settings medium: 0Fh) MP3 BASS (default value: settings medium: 0Fh) MP3 MEDIUM (default value: settings medium: 0Fh) MP3 TREBBLE (default value: settings medium: 0Fh) Line out (default value i: 02h, -3 dB). Power Amplifier (default value: 07h, +2 dB). Line in (default value: 08h, -9 dB). Auxiliary in (default value: 07h, -6 dB). Dac Master Gain (default value: 0Ch, -6 dB). All these values can be updated with commands from Remote Controller. 4.2.8 Clock AT89RFD-08 AT89RFD-08 User Guide Default crystal value is 16 MHz. 4-33 4385F 4385FMP306/06 Installation 4.2.9 AT8xC51SND1C This firmware is portable to AT8xC51SND1C with Voice Recorder command and external DAC. The voice recorder functions are not available on AT8xC51SND2C. 4.2.10 Streaming Mode Source code of streaming mode is given as an example that can be easily modified according to the communication protocol and host constraints. Streaming feature can be activated when chip memory is defined to streaming memory. Streaming memory driver is then required. Note: #define MEM_CHIP_TYPE CHIP_STREAM Frequency sample of the streaming MP3 on Remote Controller memory shall be previously defined in config.h file. Default value is FS = 44.1 KHz. In AT8xC51SND2C firmware, the default MP3 data packet number of byte is set to 128 bytes. 4.3 Mass Storage Driver 4.3.1 Windows Drivers No specific mass storage driver installation is requested when using Windows 2000TM 2000TM, Windows METM, and Windows XPTM. Each system loads the generic mass storage driver when plugging the development board to the PC. As no generic driver is available under Windows 98SETM 98SETM system, Atmel has developed its own mass storage driver to support this operating system. This driver is based on 3 files: atusbms.sys, atusbpdr.pdr and atusbms.inf. Install information is provided in readme.txt file under usb_ms_drv directory. 4.3.2 Linux Drivers Install information for linux is provided in readme_linux.pdf file under usb_ms_drv directory. 4-34 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Section 5 Firmware Architecture Design 5.1 Firmware functions System performs the followings functions: · MP3 playing capability on memory (nand flash, SD or MMC Card): Play, Pause, Next, Previous, Format · File system functions that enables Remote Controller to navigate on memories Next File or Directory, Previous File or Directory, Enter Directory, Exit Directory, Get Name of the current file · Embedded FAT12/16 FAT12/16 or FAT32 FAT32 system on AT8xC51SND2C that enables to access Remote Controller memory such as NandFlash. · System Configuration for: · MP3 Sound Parameters on AT8xC51SND2C Wake-up and Power-Down functions USB mass storage capability from MMC/SD connected to AT8xC51SND2C · USB Connection and Detach USB File Transfer Firmware upgrade through USB by the Remote Controller Here is the details of firmware implementation architecture. Figure 5-1. System Functional Design AT8xC51SND2C firmware is divided in the following tasks: AT89RFD-08 AT89RFD-08 User Guide 5-35 4385F 4385FMP306/06 Firmware Architecture Design System Task Machine Machine Interface (MMI) Task Command Data Control Data Flow Remote Controller Physical Access Memories Co Memory Management Task d an m m ta Co Da Command Data mm Da and ta Data Flow Memories Player Task USB Link USB Host MP3 Flow USB Mass Storage Task DAC + PA AT8xC51SND2 MMI task Memory task Player Task USB task System task 5.2 Firmware Description All these tasks have a dedicated mailbox for events with the System task. The system task manages all the received events and changes the operating mode accordingly. 5.2.1 System Task This is the main task of the system which manages all the events sent by the others modules or tasks: MMI Management Memory Management Player Management USB Management 5-36 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Firmware Architecture Design 5.2.2 Player Task Player task manages the MP3 Play and file management: Figure 5-2. Player Task Functional Design Player_task Command / Control (by System) Player management Player Information to System (playing status) Audio / Data Flow (from memory) File System The constraints of Player task is to get one MP3 frame (1044 bytes) each 26 ms with MP3 encoded 320 Kbit/s at 44.1 KHz frequency sample. Player_task is interfaced with a FAT File System that access to: · 5.2.3 Machine Machine Interface (MMI) Task Card memory: MMC / SD Card directly by the drivers on AT8xC51SND2C · Chip memory: Nand/Nor Flash connected to AT8xC51SND2C or to the Remote Controller. The MMI module manages the input/output with the Remote Controller through the Protocol communication: · Send information and Data according to the Communication Protocol. · Receive Information and Data according to the Communication Protocol. · Send received command to System task Note: Refer to Protocol communication description for the events and commands description. The MMI task is interfaced with the Player Task and the layer driver (UART). AT89RFD-08 AT89RFD-08 User Guide 5-37 4385F 4385FMP306/06 Firmware Architecture Design Figure 5-3. Communication Task Functional Design Communication Module Control from System Command to System MMI Frame received Frame Send Error Send Frame Command to SMDI driver (Streaming) Data Flow (UART) UART Communication Driver 5.2.3.1 Streaming Memory Driver Interface (SMDI) This is the principle of streaming driver that can contain all the function to read and initialize the Streaming Memory. Figure 5-4. Player logical access to Remote Controller's Nand/Nor Flash - Streaming Feature Remote Controller Nand/Nor Flash (dedicated to music storage) Physical Layer Player AT8xC51SND2 Nand/Nor Flash Driver Logical Layer Player Init Read Memory Interface Driver Streaming Memory Interface Driver (SMDI) Communication Layer (UART) Communication Layer (UART) Controller - Player Physical Link 5.2.3.2 UART Layer The UART layer provides the System: frame transmission from the MMI module frame reception and send information to MMI communication with SMDI driver in Streaming mode (packet transfer) 5-38 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Firmware Architecture Design Figure 5-5. MMI Software Interface System Task System Operating Modes Management System Commands Player events Player Management Player Task FS Module File System Management MMI commands Memories Interface Streaming Memory Driver Interface (SMDI) MP3 Data Packet Management NF/SD/MMC Driver Communication Management Machine Machine Interface Communication (MMI) File Transfer Acces Streaming Acces to data packet UART Driver 5.2.4 USB Mass Storage Task The USB modules manages all USB events: · SCSI Commands Block · USB Enumeration · USB Low Level Driver The USB Mass Storage events sent to System task are: · STORAGE_EVT_ERROR · STORAGE_EVT_CONNECTION · AT89RFD-08 AT89RFD-08 User Guide STORAGE_NO_EVENT · STORAGE_EVT_DISCONNECTION 5-39 4385F 4385FMP306/06 Firmware Architecture Design Figure 5-6. USB Mass Storage Functional Design USB Mass Storage Data to Memory (Mass Storage) USB Communication Task SBC Mangement USB Status Information System Commands Data Flow USB Driver USB Host 5.2.5 Memory Task This is all the memory management: · Drivers Interface with the system: install, uninstall check presence select memory · initialization format Memory Status Management. The memory task manages all Memories events: 5-40 4385F 4385FMP306/06 memory install (event MEMORY_EVT_INSTALLED) memory error (event MEMORY_EVT_ERROR) AT89RFD-08 AT89RFD-08 User Guide Firmware Architecture Design Figure 5-7. Memory Task Functional Design Memory Management System Control Memory Task Memory Information Memory events to System Data Flow Memories Driver 5.2.6 Display Task The display task is optional and can be added for debug purpose: LCD LED The Display task is also used to manage MP3 Playing time. AT89RFD-08 AT89RFD-08 User Guide 5-41 4385F 4385FMP306/06 Section 6 Protocol Frame Description Note: 6.1 Player's Status * means the frame is a Player response. STATUS byte is the reflect in real-time of AT8xC51SND2C`s system status. Table 6-1. Player STATUS Description 7 6 5 4 3 2 1 0 OPM ERROR MERROR MNF USB_CON USB_TRANS - FNA Bit Number Bit Mnemonic Description OPM Operating Mode This is bit is set when playing music. This bit is cleared when Player is in idle mode (not playing) ERROR Command Error This bit is set when a checksum error occurs with the last Remote Controller command. This bit is cleared when there is no error with the last frame. 7 6 MERROR 5 MNF 4 USB_CON 3 USB_TRANS 2 AT89RFD-08 AT89RFD-08 User Guide Memory Error This bit is set when selected memory is KO This bit is cleared when selected memory is OK. Memory Not Formatted This bit is set when selected memory is not formatted. This bit is cleared when selected memory is OK. USB Connection This bit is set when an USB connection occurred. This bit is cleared when there is no USB connection. USB Transfer This bit is set when an USB data transfer is being processed. This bit is cleared when there is no USB transfer. 6-43 4385F 4385FMP306/06 Protocol Frame Description Bit Number Bit Mnemonic Description - Reserved. This bit can be used for Streaming Memory Driver Interface Operation Request (only for streaming feature) This bit can be set when Player requests a Memory Driver Interface Operation Request to Remote Controller. This bit can be cleared when Player does not request a Memory Driver Interface Operation Request. FNA File name available. This bit is set when new file name is available. This bit is cleared when Remote Controller has read the new file name. This bit is set when new FAT is installed on memory after a SYSTEM_SELECT_MEMORY command. 1 0 STATUS byte is in byte 0 of data field of SYSTEM_ACK frame Player's response. In case of Status ERROR, the Remote Controller should re-send the command again else retry its command after Time-out. 6-44 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description 6.2 System Command 6.2.0.1 SYSTEM_RESET Command Reset the AT8xC51SND2C. There is no answer for this command. After a Player warm or cold reset, Remote Controller shall wait on its RX line the followings response SYSTEM_ACK frame. This means that the AT8xC51SND2C is ready to communicate. Table 6-2. SYSTEM_RESET Frame Format Frame Start Not used, 7Eh Note: 6.2.0.2 SYSTEM_CONFIG Command Channel FFh Protocol Command Data Length 00h 00h Data No CheckSum Yes As Audio analog capacitors (Headset and Power Amplifier) need to be discharged before Player Reset, the rest can occurs after 1 or 2s. This time can be adjusted in Player firmware. The SYSTEM_CONFIG command configure the player information like: USB number of logical unit (mass storage) USB VID update USB PID update Default number of USB logical unit in firmware is one. Table 6-3. SYSTEM_CONFIG Frame Format Frame Start Channel Not used, 7Eh FFh Protocol Command Data Length 01h 05h SYSTEM_CONFIG Parameters Data Yes CheckSum Yes Description USB Number of logical unit Byte 0 - for Nand flash only project: 01h (1 logical unit) - for MMC/SD card only project: 02h (1 logical unit) - for Nandflash and MMC/SD card project: 03h (2 logical units) USB Vendor ID Byte 1:2 Atmel VID is 03EBh (default value) Byte 1: MSB(VID) Byte 2: LSB(VID) USB Product ID Byte 2:3 Atmel PID is 2010h (default value) Byte 2: MSB(PID) Byte 3: LSB(PID) 6.2.0.3 SYSTEM_GET_STATUS The SYSTEM_GET_STATUS frame can be send at any time to ask AT8xC51SND2C Command status. AT89RFD-08 AT89RFD-08 User Guide 6-45 4385F 4385FMP306/06 Protocol Frame Description AT8xC51SND2C frame response is SYSTEM_ACK frame. Table 6-4. SYSTEM_GET_STATUS Frame Format Frame Start FFh Data Length 02h Not used, 7Eh 6.2.0.4 Protocol Command Channel 00h Data No CheckSum Yes SYSTEM_AUDIO_OUTP Select Player Audio Output: UT Command Headset Power Amplifier The default firmware configuration is Headset and Power Amplifier activated. Table 6-5. SYSTEM_AUDIO_OUTPUT Frame Format Frame Start Channel Not used, 7Eh FFh Protocol Command Data Length 03h 01h Data AUDIO_OUTPUT (1 byte) CheckSum Yes Table 6-6. AUDIO_OUTPUT Format Audio Output AUDIO_OUTPUT Parameter Value (1 byte) None 00h Headset 01h Reserved 02h Headset and Power Amplifier 03h Note: 6.2.0.5 The Audio output "None" will power off the Audio Headset capacitors (from VDD/2 to 0V). The Audio output None shall be used only before a hardware reset to avoid any `plop' on audio headset. SYSTEM_SELECT_ME Select Memory and mount file system FAT on memory. Player response is MORY Command SYSTEM_ACK frame. When FAT is installed on selected memory, player's status byte is updated with: FNA set (File name available, Table 6-1. Player STATUS Description). This flag is set when FAT install is OK. Then Player is ready to process the `PLAY' command. MERROR set (Memory Error, Table 6-1. Player STATUS Description). This flag is set when memory initialization is KO or card is not present (for memory card slot). MNF is set (Memory not formatted, Table 6-1. Player STATUS Description). This flag is set when selected memory is not formatted. 6-46 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description Table 6-7. SYSTEM_GET_STATUS Frame Format Frame Start 7Eh Channel Not used, FFh Protocol Command 04h Data Length 01h CheckSu m Data Select Memory and install file system on: · On-Board Player Memory Yes (Nand Flash) · Card (SD/ MMC card) · Streaming Memory Table 6-8. Data Parameter for Select Memory Command Memory to Select Data Parameter Value (1 byte) Memory Card (SD / MMC) 01h On Board Player Memory: Nand Flash 02h On Board Player Memory: Nand Flash Reserved Zone 82h Streaming (only in Streaming Mode) 03h NandFlash with Reserved zone Nand flash reserved zone is a special memory zone in nand flash that can be used to store data or MP3 files: The reserved zone is selected with the command SYSTEM_SELECT_MEMORY [82h]. Once the reserved zone in nand flash is selected, the file system FAT is mounted on this zone. The reserved zone can now be played (MP3 files) or be seen through USB mass storage. Note: The first time this command is sent to the Player, the reserved zone will not be formatted. It is necessary to send the FS_FORMAT command. To return in the normal nand flash zone, send the command SYSTEM_SELECT_MEMORY [02h]. The file system FAT is mounted on normal memory. Note: AT89RFD-08 AT89RFD-08 User Guide The first you will exit the reserved zone to the normal zone, the normal zone will be no more formatted. It is necessary to send the FS_FORMAT command. 6-47 4385F 4385FMP306/06 Protocol Frame Description Figure 6-1. Nand Flash with Reserved Zone Nand Flash SYSTEM_SELECT_MEMORY [02h] SYSTEM_SELECT_MEMORY [82h] Note: 6.2.0.6 Normal Zone (zone 1) Reserved Zone (zone 2) The default size for reserved zone space is 10 Mo. SYSTEM_SET_SOUNDSystem Set Sound Command is used to configure AT8xC51SND2C Sound system after Command a POWERDOWN Command or a general system RESET. Player response is PLAYER_VOLUME* frame. Frame Start Channel Protocol Command Data Length Data CheckSu m Byte 0: MP3 DIGITAL VOLUME LEFT Not used, 7Eh FFh 05h 05h Byte 1: MP3 DIGITAL VOLUME RIGHT Yes Byte 2: MP3 BASS Byte 3: MP3 MEDIUM Byte 4: MP3 TREBBLE Data are 5 bytes of Volume settings MP3 VOLUME LEFT: MP3 digital volume left channel MP3 VOLUME RIGHT: MP3 digital volume right channel MP3 BASS MP3 MEDIUM MP3 TREBBLE Each of these 5 bytes must be in the following: · 4385F 4385FMP306/06 Settings Medium: 0Fh · 6-48 Settings Minimum: 00h · Settings Maximum: 1Fh AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description Table 6-9. System Set Sound Data Command Byte Number Byte Mnemonic Description 0 MP3VOR MP3 Volume Right Channel 2 MP3BASS MP3 Bass equalization 3 MP3MED MP3 Medium equalization 4 6.2.0.7 MP3 Volume Left Channel 1 Note: MP3VOL MP3TRE MP3 Treble equalization All value set to FFh will not be updated in Player. Example: MP3VOL set to FFh means tMP3VOL will keep its previous value. SYSTEM_POWER_DO SYSTEM_POWER_DOWN command enables the Remote Controller to power down WN Command AT8xC51SND2C system. The Audio capacitors are discharged before entering the power down mode, this takes around 1.7sec. That means the Remote Controller should not send any command between the reception of the SYSTEM_ACK reponse and the effective player power down (1.7sec later). The AT8xC51SND2C is then placed in a very low power state. To wake it up, refer to SYSTEM_WAKEUP command. Table 6-10. SYSTEM_POWER_DOWN Command Format Frame Start 7Eh Note: 6.2.0.8 SYSTEM_WAKEUP Command Channel Not used, FFh Protocol Command Data Length 06h 00h Data No CheckSum Yes To avoid audio capacitors discharge in power down mode, refer to command CUSTOM_SYSTEM_SLEEP (power down with audio capacitors charged). SYSTEM_WAKEUP Command is a special command: it is 1ms of logical 0 on the Remote Controller Tx line (0V). It wakes the AT8xC51SND2C to wake-up and exit from Power-down mode only if AT8xC51SND2C RX line is connected to AT8xC51SND2C external interrupt INT0 pin in hardware. Note: INTO (P3.2) pin is an external interrupt that enable the AT8xC51SND2C to wake up if a low level is applied on it. Figure 6-2. AT8xC51SND2 Configuration for SYSTEM_WAKEUP Command AT8xC51SND2C Resistor 0 ohm INTO / P3.2 RXD TXD AT89RFD-08 AT89RFD-08 User Guide 6-49 4385F 4385FMP306/06 Protocol Frame Description Table 6-11. SYSTEM_WAKEUP command Controller_Rx SYSTEM _ACK Controller_Tx (connected to INT0) 1ms SYSTEM _POWERDOWN AT8XC51SND2 AT8XC51SND2 Power Down Mode 6.2.0.9 Initialization SYSTEM_USB_DETAC Request the Player to perform a USB detach. H Command Warning: during USB data transfer, performing a USB detach can corrupted the current data transferred on the memory. In USB mode, the Remote Controller must check the USB_CONNECTED status bit in AT8xC51SND2C Status byte to be informed of a manual USB detach. Table 6-12. SYSTEM_USB_DETACH Command Format Frame Start 7Eh Channel Not used, FFh Protocol Command Data Length 08h 00h Data No CheckSum Yes 6.2.0.10 SYSTEM_USB_CONN SYSTEM_USB_CONNECT is a Remote Controller command to Player for asking an ECT Command USB Connection. Table 6-13. SYSTEM_USB_CONNECT Command Format Frame Start 7Eh 6.2.0.11 SYSTEM_ISP Channel Not used, FFh Protocol Command Data Length 09h 00h Data No CheckSum Yes Ask the Player to enter in ISP Mode (firmware upgrade). This command is available only if Player is in IDLE mode. Table 6-14. SYSTEM_ISP command format Frame Start 7Eh Note: Channel Not used, FFh Protocol Command Data Length 0Ah 00h Data No CheckSum Yes Refer to AT89C51SND2 AT89C51SND2 USB Bootloader for more information. 6.2.0.12 SYSTEM_VOLUME_U Analog gain volume up (one step). Player response is PLAYER_VOLUME* frame. P 6-50 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description Table 6-15. SYSTEM_VOLUME_UP command format Frame Start Protocol Command Data Length 0Bh Channel 00h Not used, 7Eh FFh Data CheckSum No Yes 6.2.0.13 SYSTEM_VOLUME_D Analog gain volume down (one step). Player response is PLAYER_VOLUME* frame. OWN Table 6-16. SYSTEM_VOLUME_DOWN command format Frame Start Protocol Command Data Length 0Ch Channel 00h Not used, 7Eh FFh Data CheckSum No Yes 6.2.0.14 SYSTEM_PLAYER_M Set player mode for the selected memory: ODE Repeat / No Repeat the Play mode Play modes: Play single file Play Dir Play Disk For the streaming mode, the Player enter the No repeat and play single file mode. Table 6-17. Player Mode 7 6 5 4 3 2 1 0 REPEAT - - FILETYP2 FILETYP1 FILETYP0 MOD1 MOD0 Bit Bit Number Mnemonic 7 REPEAT Description Repeat Mode Clear for no repeat mode. Set for repeat mode. 6:5 - 4:2 FILETYP Reserved Player File type Set to 000b to see MP3 files only, set to 100b to see all files extensions on selected memory (file transfer mode). 1:0 MOD Play mode. Refer to Table 6-18. Play Mode (MOD 1:0). Table 6-18. Play Mode (MOD 1:0) Player Mode (PLAYER_MODE) MOD0 Play Single File 0 0 Play Dir 0 1 Play Disk AT89RFD-08 AT89RFD-08 User Guide MOD1 1 0 6-51 4385F 4385FMP306/06 Protocol Frame Description Table 6-19. Player File Type (FILETYP 4:2) Player File Type (FILETYPE) FILETYP2 FILETYP1 FILETYP0 Mp3 Files only.* 0 0 0 All files extensions are visible. (Explorer mode for file transfer) 1 0 0 Note: * MP3 and WAV files for AT8xC51SND1C and Voice Recorder feature. Table 6-20. SYSTEM_PLAYER_MODE command format Frame Start Channel Protocol Command Data Length Data 0Dh 01h Byte 0: PLAYER _MODE Not used, 7Eh FFh CheckSum Yes 6.2.0.15 SYSTEM_AUDIO_INP Select Player Audio Input Channel: UT None Mono Input (AUXN, AUXP) Stereo Input (LINEL,LINER) The Select Input `None' is a Mono/ Stereo output disable function. When Input channel have to be closed, Remote Controller shall send the Select Input `None'. Default analog gain value for Mono and Stereo input shall be defined in AT8xC51SND2C project file config.h. Table 6-21. SYSTEM_AUDIO_OUTPUT Command Format Frame Start 7Eh Channel Not used, FFh Protocol Command Data Length 0Eh 01h Data AUDIO_INTPUT (1 byte) CheckSum Yes Table 6-22. AUDIO_INPUT Format Audio Input Selected AUDIO_INPUT Parameter Value (1 byte) None 00h Mono 01h Stereo 02h 6.2.0.16 SYSTEM_ENTER_HID Ask the Player to enter the HID mode (only available with UART link). The Player shall _MODE be in IDLE state to enter HID mode (no Mass Storage, no Playing). When connected in this way, the Player acts only as USB-UART bridge. This mode allow the Remote Controller to send and receive any binary/protocol information from/to UART. To exit from this mode, Remote Controller have to perform an hardware Player Reset or unplug the USB cable. 6-52 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description Table 6-23. SYSTEM_ENTER_HID_MODE Command Format Frame Start 7Eh Channel Protocol Command Data Length 0Fh 00h Not used, FFh Data No CheckSum Yes Figure 6-3. Player USB-UART Bridge PC Player Remote Controller PC Application with simple interface (`putchar', `getchar') Player RESET Brigde USB / UART UART AT89RFD-08 AT89RFD-08 User Guide Atmel HID.DLL USB USB HID Class 6-53 4385F 4385FMP306/06 Protocol Frame Description 6.3 Voice Recorder Interface Command Only available on AT8xC51SND1C and AT73C213 AT73C213. 6.3.0.17 VOICEREC_START_R Voice Recorder start recording. EC Command Table 6-24. VOICEREC_START_REC command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 20h 00h Data No CheckSum Yes 6.3.0.18 VOICEREC_STOP_RE Voice Recorder stop recording. C Command Table 6-25. VOICEREC_STOP_REC command Frame Start 7Eh Note: 6-54 4385F 4385FMP306/06 Channel If not used, FFh Protocol Command Data Length 21h 00h Data No CheckSum Yes The voice recorder interface is not available on AT8xC51SND2C. AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description 6.4 Player Command These commands allow to access all the player's function. 6.4.0.19 PLAYER_PLAY Command If current file name is a MP3/WAV* file, play selected MP3/WAV* file from Selected Memory. If current file name is a directory, enter this directory and select the first MP3/WAV*. A new Play command is needed to play this new MP3 file. Table 6-26. PLAYER_PLAY command Frame Start 7Eh Note: 6.4.0.20 PLAYER_STOP Command Note: 50h 00h Data No CheckSum Yes Channel If not used, FFh Protocol Command Data Length 51h 00h Data No CheckSum Yes * WAV file only available on AT8xC51SND1C. Pause playing current MP3/WAV* file. Table 6-28. PLAYER_PAUSE command: Frame Start 7Eh Note: Channel If not used, FFh Protocol Command Data Length 52h 00h Data No CheckSum Yes * WAV file only available on AT8xC51SND1C. Select Next MP3/WAV* file on selected memory. Table 6-29. PLAYER_NEXT command: Frame Start 7Eh Note: 6.4.0.23 PLAYER_PREVIOUS Command FFh Data Length Stop playing current MP3/WAV* file. Table 6-27. PLAYER_STOP command 7Eh 6.4.0.22 PLAYER_NEXT Command If not used, Protocol Command * WAV file only available on AT8xC51SND1C. Frame Start 6.4.0.21 PLAYER_PAUSE Command Channel Channel If not used, FFh Protocol Command Data Length 53h 00h Data No CheckSum Yes * WAV file only available on AT8xC51SND1C. Select Previous MP3/WAV* file on Selected Memory. Table 6-30. PLAYER_PREVIOUS command Frame Start 7Eh Note: Channel If not used, FFh Protocol Command Data Length 54h 00h Data No CheckSum Yes * WAV file only available on AT8xC51SND1C 6.4.0.24 PLAYER_SETMARKE Set A marker for repeat AB feature. RA Command AT89RFD-08 AT89RFD-08 User Guide 6-55 4385F 4385FMP306/06 Protocol Frame Description Table 6-31. PLAYER_SETMARKERA Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 55h 00h Data No CheckSum Yes 6.4.0.25 PLAYER_SETMARKE Set B marker for repeat AB feature. RB Command Table 6-32. PLAYER_SETMARKERB Command Frame Start 7Eh 6.4.0.26 PLAYER_STOPAB Command If not used, FFh Protocol Command Data Length 56h 00h Data No CheckSum Yes Stop AB repeat mode. Table 6-33. PLAYER_STOPAB Command Frame Start 7Eh 6.4.0.27 PLAYER_GET_TIME Command Channel Channel If not used, FFh Protocol Command Data Length 57h 00h Data No CheckSum Yes Get Player playing time since the beginning of the file. Table 6-34. PLAYER_GET_TIME Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 58h 00h Data No CheckSum Yes Player response is PLAYER_TIME* frame. 6.4.0.28 PLAYER_GETINDEXN Get numbers of files in current directory or root directory. UMBER Command Table 6-35. PLAYER_GETINDEXNUMBER Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 59h 00h Data No CheckSum Yes Player response is PLAYER_INDEXNUMBER* frame. 6.4.0.29 PLAYER_ENTER_RO Select first available MP3 files in the root directory. Player response is SYSTEM_ACK or OT_DIR Command SYSTEM_NACK frame (no MP3 file found or low level error). Table 6-36. PLAYER_ENTER_ROOT_DIR Command Frame Start 7Eh 6-56 4385F 4385FMP306/06 Channel If not used, FFh Protocol Command Data Length 5Ah 00h Data No CheckSum Yes AT89RFD-08 AT89RFD-08 User Guide 6.4.0.30 PLAYER_SET_FILTER Set file filters (no directory, only MP3 files are seen). This command has be sent before Command the SYSTEM_SELECT_MEMORY command because the filter are used during file system FAT install. Table 6-37. PLAYER_SET_FILTER Command Frame Start Channel Protocol Command Data Length Data CheckSum Byte 0: Filter 7Eh If not used, FFh 5Bh 01h - 00h No filter - 01h Filter directory (no directory seen only MP3 files) Yes 6.4.0.31 PLAYER_GET_FILE_L Get file name list in current directory or root directory. IST Command Table 6-38. PLAYER_GET_FILE_LIST Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length Data 5Ch 00h No CheckSum Yes Player response is: FS_NAME* frame for each file name in current directory FS_END_OF_LIST* frame when end of list is reached. First file of the list is then selected and become current file. Example: Remote Controller sends PLAYER_FILE_GET_LIST command Player sends 3 FS_NAME* frame because there is 3 files in current directory. When all the files names are send, Player sends FS_END_OF_LIST* frame. The sequence can be aborted by any other command send to the Player (for example SYSTEM_GET_STATUS command). After get list aborted, it is necessary to re-send the new command. The PLAYER_GET_FILE_LIST command changes the PLAYER mode to PLAYER_PLAY_DIR mode. Note: Refer to SYSTEM_PLAYER_MODE command for description of PLAYER_PLAY_DIR mode. 6.4.0.32 PLAYER_PLAY_INDE Select file indicated with `File_Index' parameter and play it if it is a MP3 file. X Command Play `0' will play the first file. Play `2' will play the third file. Table 6-39. PLAYER_PLAY_INDEX Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length Data 5Dh 01h Byte 0: File_Index 6.4.0.33 PLAYER_GET_LIST_D Get file name list and creation date in current directory or root directory. ATE Command CheckSum Yes Protocol Frame Description Table 6-40. PLAYER_GET_FILE_LIST Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length Data 5Eh 00h No CheckSum Yes Player response is: FS_NAME* then FS_FILEDATE* frames for each file name in current directory FS_END_OF_LIST* frame when end of list is reached. First file of the list is then selected and become current file. Example: Remote Controller sends PLAYER_FILE_GET_LIST command Player sends 3x {FS_NAME* FS_FILEDATE*} frame because there is 3 files in current directory. When all the files names are send, Player sends FS_END_OF_LIST* frame. The sequence can be aborted by any other command send to the Player (for example SYSTEM_GET_STATUS command). After get list aborted, it is necessary to re-send the new command. The PLAYER_GET_FILE_LIST command changes the PLAYER mode to PLAYER_PLAY_DIR mode. 6.4.0.34 PLAYER_PLAY_INDE Select MP3 indicated with `MP3_Index' parameter and play it if it is a MP3 file. X_MP3 Command Play `0' will play the first MP3. Play `2' will play the third MP3. Table 6-41. PLAYER_PLAY_INDEX_MP3 Command Frame Start 7Eh 6-58 4385F 4385FMP306/06 Channel If not used, FFh Protocol Command Data Length Data 5Fh 01h Byte 0: MP3_Index CheckSum Yes AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description 6.5 File System Commands 6.5.0.35 FS_NEXT Command Refer to SYSTEM_PLAYER_MODE command for description of PLAYER_PLAY_DIR mode These commands allow to navigate in selected memory: file and directory architecture. Select next file from selected memory. Table 6-42. FS_NEXT command Frame Start 7Eh 6.5.0.36 FS_PREVIOUS Command 7Eh 7Eh 7Eh 7Eh Note: AT89RFD-08 AT89RFD-08 User Guide 00h No CheckSum Yes Channel If not used, FFh Protocol Command Data Length 61h 00h Data No CheckSum Yes Channel If not used, FFh Protocol Command Data Length 62h 00h Data No CheckSum Yes Channel If not used, FFh Protocol Command Data Length 63h 00h Data No CheckSum Yes File System Get Name of Current File or Directory on Selected Memory. The Player response is a SYSTEM_NAME that contains the name of the current file. Table 6-46. FS_GET_NAME command Frame Start 6.5.0.40 FS_FORMAT Command 60h Data File System Exit Directory on Selected Memory. Table 6-45. FS_EXIT_DIR command Frame Start 6.5.0.39 FS_GET_NAME Command FFh Data Length File System Enter Directory on selected memory and select the first found file / directory. Table 6-44. FS_ENTER_DIR command Frame Start 6.5.0.38 FS_EXIT_DIR Command If not used, Protocol Command Select previous file from selected memory. Table 6-43. FS_PREVIOUS command Frame Start 6.5.0.37 FS_ENTER_DIR Command Channel Channel If not used, FFh Protocol Command Data Length 64h 00h Data No CheckSum Yes When selected root or directory is empty, the returned file name is `\0'. Format Selected Memory. Player response is SYSTEM_ACK* or SYSTEM_NACK* frame. 6-59 4385F 4385FMP306/06 Protocol Frame Description It is necessary to send the SYSTEM_ SELECT_MEMORY once (to select the memory) before sending the FS_FORMAT command. Player status can be viewed in Status Byte (Memory Error or File Name Available). If the Player firmware supports FAT12-16 FAT12-16 and FAT 32, the FS_FORMAT command is FAT12-16 FAT12-16 format by default. Table 6-47. FS_FORMAT command Frame Start 6.5.0.41 FS_FCREATE Command Data Length 65h 00h If not used, 7Eh Note: Protocol Command Channel FFh Data CheckSum No Yes Depending of the memory type and size, Player response can be up to several seconds. NandFlash 32 Mo: ~6 seconds, SD card: ~4 seconds. Create a File in root dir in Selected Memory. Once this file is created, Player is waiting for `Number of Blocks' x FS_FWRITE_BLOCK commands. Table 6-48. FS_FCREATE command Frame Start Channel Protocol Command Data Length Data CheckSum Byte 0 MSB(Number of blocks) 7Eh If not used, FFh 66h Byte 1 LSB(Number of blocks) Nh Byte 2:N-1 File Name (must finish with `\0'). Yes Block size: Depending of transfer link, size of a block can change. For the UART link, block size is always equal to sector size 512 bytes. The block size can be changed in Player firmware. Block size is not a parameter in FS_FCREATE command. Number of Blocks Parameter: this is File length in Block. For a 2384 Bytes File, it is necessary to transfer 5* FS_WRITE_BLOCK commands (Number of Blocks = 5) with stuffing bytes in last command FS_WRITE_BLOCK. The File_Name is a ASCII long filename with extension already formatted: "song1.mp3". Example: File_name `S','O','N','G','1', `.','M', `P', `3' `\0'. File name length is limited to 8 characters. Extension is limited to 3 characters. To create a File: FS_CREATE (Number of blocks, File name), (Number of blocks-1) x FS_WRITE_BLOCK (512 bytes data), FS_WRITE_LAST_BLOCK (Number of bytes < 512), Player response is then SYSTEM_ACK. File is created. 6.5.0.42 FS_FWRITE_BLOCK Command Frame Start 7Eh 6-60 4385F 4385FMP306/06 Write data in current created file (need previous FS_FCREATE command). The number of FS_WRITE_BLOCK command the Remote Controller shall send to Player is defined by Number of Blocks Parameter (refer to FS_FCREATE command). Table 6-49. FS_FWRITE_BLOCK command Channel If not used, FFh Protocol Command Data Length Data 68h 00h - CheckSum Yes Data BLock Byte 0:1FFh => 512 Bytes data (no checksum on data) AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description Data are 512 Bytes. Checksum is only for command, not for data (specific to FS_FWRITE_BLOCK). The command FS_FWRITE_LAST_BLOCK is used for the last block transfer. 6.5.0.43 FS_FWRITE_LAST_BL Write data in current created file (need previous FS_FCREATE command). This comOCK Command mand is used for the last block transferred. Parameters of FS_FWRITE_BLOCK is the number of byte to finish the file write. Table 6-50. FS_FWRITE_BLOCK command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 6Dh 02h Data CheckSum Byte 0: MSB (Number of Bytes to write) Byte 1: LSB (Number of Bytes to write) Data BLock Byte 0:Xh => X-1 Bytes data Yes (no checksum on data) The command FS_FWRITE_LAST_BLOCK is used for the last block transfer. After the latest FS_FWRITE_LAST_BLOCK command, it is not necessary to send FS_FCLOSE command as Player will return in IDLE state. Player response is SYSTEM_ACK*. File is created. 6.5.0.44 FS_FREAD_BLOCK Command This Command allows Remote Controller to read current selected file in memory. Table 6-51. FS_FREAD_BLOCK command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length Data 67h 00h No CheckSum Yes With UART link, data length parameter is equal to 1 block. Data block size is 512 Bytes, coming after the Player response frame: FS_FREAD_BLOCK_DATA*. Checksum is only for command, not for data. Player response to FS_FREAD_BLOCK command is FS_READ_BLOCK_DATA*. Once end of file is reached, Player response to FS_READ_BLOCK command is FS_READ_BLOCK_DATA_END*. Remote Controller can stop reading file at any moment by sending the FS_FCLOSE command. Note: 6.5.0.45 FS_FCLOSE Command (*) means that the frame is a player response. Close current file (close read or close write file). This command is used to stop any read or write file transfer. This command is not necessary: when reading file and end of file is reached (FS_READ_BLOCK_DATA_END* response). when writing the last block of the file. Table 6-52. FS_FCLOSE command Frame Start 7Eh AT89RFD-08 AT89RFD-08 User Guide Channel If not used, FFh Protocol Command Data Length 69h 00h Data No CheckSum Yes 6-61 4385F 4385FMP306/06 Protocol Frame Description 6.5.0.46 FS_GETMEMFREESP Get selected memory free space left. ACE 6.5.0.47 Table 6-53. FS_GETMEMFREESPACE command Frame Start 7Eh Protocol Command Data Length 6Ah Channel 00h If not used, FFh Data No CheckSum Yes Player response is FS_MEMFREESPACE* frame. 6.5.0.48 FS_GETFILESIZE Get current file size in Byte. 6.5.0.49 Table 6-54. FS_GETFILESIZE command Frame Start Channel If not used, 7Eh FFh Protocol Command Data Length 6Bh 00h Data No CheckSum Yes Player response is FS_FILESIZE* frame. Note: Directory size is 0. 6.5.0.50 FS_GETFILEPOS Get current file position (playing operating mode only). 6.5.0.51 Table 6-55. FS_GETFILEPOS command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 6Ch 00h Data No CheckSum Yes Player response is FS_FILEPOS frame. 6.5.0.52 FS_FDELETE Delete the current selected file. 6.5.0.53 Table 6-56. FS_FDELETE command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 6Eh 00h Data No CheckSum Yes Player response is SYSTEM_ACK or SYSTEM_NACK frame. 6.5.0.54 FS_GETFILEDATE Get file creation date information. 6.5.0.55 Table 6-57. FS_GETFILEDATE command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 6Fh 00h Data No CheckSum Yes Player response is FS_FILEDATE* frame. 6-62 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description 6.6 Streaming Memory Driver Interface Command - Only for Streaming Mode 6.6.0.56 We assume that the Flash Driver (on Remote Controller system) contains all the basic and necessary functions to open, close, read and write the Flash Memory according to the implemented file system. The following commands SMDI_GET_MDIR, SMDI_REQUEST and SMDI_COMMAND are the basic driver interface functions for the Remote Controller to get Player streaming request and send the streaming data packet: When Player have a streaming request to Remote Controller, SMDIOR is set in Player's status byte. Remote Controller sends the SMDI_GET_MDIR command to get the request. Player's response is SMDI_REQUEST with READ parameter Remote Controller sends the SMDI_COMMAND with READ parameter and the MP3 data packet. 6.6.0.57 SMDI_GET_MDIR Command Get Streaming Memory Driver Interface Request Command. This command is sent by the Remote Controller when Player's status byte have SMDIOR set in its status byte. This command asks the Player its current streaming driver interface command requested. Player's response to SMDI_GET_MDIR is SMDI_REQUEST frame according to Table 6-59. Table 6-58. SMDI_GET_MDIR command . Frame Start 7Eh 6.6.0.58 SMDI_REQUEST Response * Channel If not used, FFh Protocol Command Data Length 70h 00h Data No CheckSum Yes Streaming Memory Driver interface Request Response. This command is sent by the Player in response to Remote Controller SMDI_GET_MDIR command. This interface is simple and easy to implement: Read packet (Table 6-60): packets are transferred from Remote Controller to Player (streaming mode) Write packet (Table 6-61): packets are transferred from Player to Remote Controller. Size of packet is defined in the Player's project config.h file. In AT8xC51SND2C firmware, the default MP3 packet size is set to 128 bytes. AT89RFD-08 AT89RFD-08 User Guide 6-63 4385F 4385FMP306/06 Protocol Frame Description Table 6-59. SMDI_REQUEST command Frame Start Protocol Command Channel Data Length CheckSu m Data Byte 0: Player Status If not used, 7Eh 71h FFh Byte 1: SMDI Request N Byte 2: number of data to read Yes Bytes 3:6: Reserved Data are: · 1 byte of Command · N Bytes of Data Parameters Command Byte 1 Byte 2 SMDI Request Number of data to read Byte 3:6 Byte 7:N-1 Number of Data to read in byte Byte 2:5 Reserved - Byte 1: Number of Data to write in byte Byte 2:5 Reserved Data to write READ_PACKET _REQUEST 00h WRITE_PACKET _REQUEST 01h Table 6-60. SMDI_REQUEST command for READ_PACKET function Frame Start Channel Protocol Command Data Length 7Eh If not used, 71h 06h FFh CheckSu m Data READ_PACKET_R EQUEST (1 byte) Number of Byte to read (1 byte) Player Status (1 byte) Byte 3:6 Reserved Yes Table 6-61. SMDI_REQUEST command for WRITE_PACKET function Frame Start Channel 7Eh If not used, Protocol Command Data Length Byte 1 71h FFh 6.6.0.59 SMDI_COMMAND Command Byte 0 Player Status Byte 2 WRITE_PACKE T_REQUEST Number of Byte to write (1 byte) N CheckSu m Data (1 byte) Byte 3:6 Reserved Data to write (N-7 Byte) Yes Remote Controller Streaming Memory Driver Interface Command. Precondition: Must follow a Player Streaming Memory Driver Interface Request (SMDIR). Player Response to SMDI command Read is an SYSTEM_ACK frame. 6-64 4385F 4385FMP306/06 AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description Table 6-62. SMDI_COMMAND command Frame Start Channel 7Eh If not used, FFh Protocol Command Data Length N 72h (1 byte) CheckS um Data SMDI Number of SMDI Parameter(N-1 Comma data to read bytes) nd (Byte 1) (Byte 2:N-1) (Byte 0) SMDI Command Number of data to read Data Byte 0 Byte 1 Byte 2:N-1 READ 00h WRITE 01h AT89RFD-08 AT89RFD-08 User Guide Yes Number of Data to read in Byte MAX = FFh Bytes (1 byte) Reserved Data to Read (FFh Bytes) Reserved. 6-65 4385F 4385FMP306/06 Protocol Frame Description 6.7 Custom Command 6.7.0.60 AUDIO_SET_GAIN Set Audio Gain: Line out (default value in firmware: 02h, -3 dB). Power Amplifier (default value in firmware: 07h, +2 dB). Line in (default value in firmware: 08h, -9 dB). Auxiliary in (default value in firmware: 07h, -6 dB). Dac Master Gain (default value in firmware: 0Ch, -6 dB). Refer to AT8xC51SND2C datasheet (chapter DAC and PA Interface) for audio gain description and register value. Table 6-63. AUDIO_SET_GAIN command Frame Start 7Eh 6-66 4385F 4385FMP306/06 Channel If not used, FFh Protocol Command Data Length 91h 02h Data Byte 0: Gain Selector Byte 1: Gain Value CheckSum Yes AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description Table 6-64. AUDIO_SET_GAIN parameter Gain Selector Gain Value Corresponding Register in datasheet 00000000b => 0 dB Line Out Gain 00h . 00000010b => -3 dB LLOG, RLOG . 00100000b => mute 00000000b => -22 dB 00000001b => + 20 dB . Power Amplifier Gain 00001000b => -1 dB 01h 00001011b => -10 dB APAGAIN . 00001111b => -22 dB 00000000b => +20 dB . Line In Gain 02h 00000101b => 0 dB . RLIG, LLIG 00001100b => -3 dB . 00010001b => mute 00000000b => +20 dB . Aux In Gain 03h 00000101b => 0 dB . AUXG 00001100b => -3 dB . 00010001b => mute 00000000b => +12 dB . DAC Master Gain 04h 00001000b => 0 dB . RMPG, LMPG 00001010b => -3 dB . 00100000b => mute Note: All audio gain value are described in AT8xC51SND2C datasheet. Refer to register description for more details. Player response to AUDIO_SET_GAIN is SYSTEM_ACK. DAC Master Gain parameter can also be updated with: SYSTEM_VOLUME_UP command SYSTEM_VOLUME_DOWN command Note: 6.7.0.61 AUDIO_PA_LP AT89RFD-08 AT89RFD-08 User Guide PLayer response to SYSTEM_VOLUME_UP or SYSTEM_VOLUME_DOWN command is PLAYER_VOLUME* Response. DAC Master Gain is Byte 5 in PLAYER_VOLUME* response. Set Player power amplifier (PA) Low power mode (for speaker). 6-67 4385F 4385FMP306/06 Protocol Frame Description Table 6-65. AUDIO_PA_LP command Frame Start Channel If not used, 7Eh FFh Protocol Command Data Length 92h 01h Data CheckSum Byte 0: - 00h exit PA low power mode Yes - 01h enter PA low power mode Player response is SYSTEM_ACK or SYSTEM_NACK. 6.7.0.62 CUSTOM_SET_UART_ Custom change UART baudrate. BAUDRATE Table 6-66. CUSTOM_SET_UART_BAUDRATE Command Command Frame Start Channel Protocol Command Data Length 7Eh If not used, 93h 03h CheckSu m Data Byte 0: SCON_REG Byte 1: SMOD_SPD_REG FFh Yes Byte 2: BRG0_REG Table 6-67. Parameter Value / Baudrate Baudrate SCON_REG Value SMOD_SPD Value BRG0_VALUE 38400 bps 40h 03h F3h 11500 bps 40h 02h F7h Player response is: SYSTEM_ACK* frame at previous baudrate, followed by: SYSTEM_ACK* frame at new baudrate. It is advised to send the SYSTEM_GET_STATUS after the baudrate change to confirm the change. 6.7.0.63 CUSTOM_GET_SYS_V Get Player firmware versions. ERSION Command Note: Example for 1.6.4 firmware: "V1.6.4" 6.7.0.64 Table 6-68. CUSTOM_GET_SYS_VERSION command Frame Start Channel If not used, 7Eh FFh Protocol Command Data Length 94h 00h Data No CheckSum Yes Player response is CUSTOM_SYS_VERSION* frame. 6.7.0.65 CUSTOM_SYSTEM_S Ask the Player to enter in power down mode (keep audio capacitors charged). LEEP Command Note: To avoid any extra-power consumption in power down mode because of keeping audio capacitors charged, refer to SYSTEM_POWER_DOWN command. Table 6-69. CUSTOM_SYSTEM_SLEEP command Frame Start 7Eh 6-68 4385F 4385FMP306/06 Channel If not used, FFh Protocol Command Data Length 95h 00h Data No CheckSum Yes AT89RFD-08 AT89RFD-08 User Guide Protocol Frame Description 6.7.0.66 AUDIO_ACTIVE_INPU Enable / Disable Linein or Auxin input during USB mass storage. T_IN_USB Table 6-70. AUDIO_ACTIVE_INPUT_IN_USB Command Command Frame Start Channel Protocol Command Data Length Data CheckSum Byte 0: 7Eh If not used, FFh 97h - 00h => No input - Disable 01h - 01h => active Auxin Yes - 02h => Active Linein Player response is SYSTEM_ACK or SYSTEM_NACK. 6.7.0.67 AUDIO_ACTIVE_INPU Enable / Disable Linein or Auxin input during USB mass storage. T_IN_USB Table 6-71. AUDIO_ACTIVE_INPUT_IN_USB Command Command Frame Start Channel Protocol Command Data Length Data CheckSum Byte 0: 7Eh If not used, FFh 97h - 00h => No input - Disable 01h - 01h => active Auxin Yes - 02h => Active Linein Player response is SYSTEM_ACK or SYSTEM_NACK. 6.7.0.68 CUSTOM_USB_ATTA Disable / Enable USB mass storage auto attach. CH When USB auto attach is enabled, if USB cable is plugged, Player will enter automatically mass storage. When USB auto attach is disabled, if USB cable is plugged, Player will not enter automatically mass storage. Note: USB auto attach is enable by default. Table 6-72. CUSTOM_USB_ATTACH command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length 9Bh 01h Data CheckSum Byte 0: - 00h Auto attach enable Yes - 01h Auto attach disable Player response is SYSTEM_ACK or SYSTEM_NACK. 6.7.0.69 CUSTOM_GETTOTAL Get MP3 file total play time. TIME Command Note: The player response is only right when MP3 file is Constant bit rate MP3. Table 6-73. CUSTOM_GETTOTALTIME Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length Data F1h 00h No CheckSum Yes Player response is CUSTOM_TOTALTIME* frame. 6.7.0.70 CUSTOM_PLAYER_L Go to the last file of current directory. AST Command AT89RFD-08 AT89RFD-08 User Guide 6-69 4385F 4385FMP306/06 Protocol Frame Description Table 6-74. CUSTOM_PLAYER_LAST Command Frame Start 7Eh Channel If not used, FFh Protocol Command Data Length Data F4h 00h No CheckSum Yes Player response is SYSTEM_ACK or SYSTEM_NACK. 6.7.0.71 CUSTOM_PLAYER_FI Go to firsts file of current directory. RS