VLSI Solution Oy VLSI Solution Oy Evaluation MP3 Player Source Code Documentation

Main Page | Class List | File List | Class Members | File Members | Related Pages

vs10xx.h File Reference

Headers for interfacing with the mp3 player chip. More...

#include "board.h"

Include dependency graph for vs10xx.h:

Include dependency graph

This graph shows which files directly or indirectly include this file:

Included by dependency graph

Go to the source code of this file.

Defines

#define VS_WRITE_COMMAND   0x02
 VS10xx SCI Write Command byte is 0x02.

#define VS_READ_COMMAND   0x03
 VS10xx SCI Read Command byte is 0x03.

#define SPI_MODE   0x0 /**< VS10xx register */
 VS10xx register.

#define SPI_STATUS   0x1 /**< VS10xx register */
 VS10xx register.

#define SPI_BASS   0x2 /**< VS10xx register */
 VS10xx register.

#define SPI_CLOCKF   0x3 /**< VS10xx register */
 VS10xx register.

#define SPI_DECODE_TIME   0x4 /**< VS10xx register */
 VS10xx register.

#define SPI_AUDATA   0x5 /**< VS10xx register */
 VS10xx register.

#define SPI_WRAM   0x6 /**< VS10xx register */
 VS10xx register.

#define SPI_WRAMADDR   0x7 /**< VS10xx register */
 VS10xx register.

#define SPI_HDAT0   0x8 /**< VS10xx register */
 VS10xx register.

#define SPI_HDAT1   0x9 /**< VS10xx register */
 VS10xx register.

#define SPI_AIADDR   0xa /**< VS10xx register */
 VS10xx register.

#define SPI_VOL   0xb /**< VS10xx register */
 VS10xx register.

#define SPI_AICTRL0   0xc /**< VS10xx register */
 VS10xx register.

#define SPI_AICTRL1   0xd /**< VS10xx register */
 VS10xx register.

#define SPI_AICTRL2   0xe /**< VS10xx register */
 VS10xx register.

#define SPI_AICTRL3   0xf /**< VS10xx register */
 VS10xx register.

#define SM_DIFF   0x01 /**< VS10xx register */
 VS10xx register.

#define SM_JUMP   0x02 /**< VS10xx register */
 VS10xx register.

#define SM_RESET   0x04 /**< VS10xx register */
 VS10xx register.

#define SM_OUTOFWAV   0x08 /**< VS10xx register */
 VS10xx register.

#define SM_PDOWN   0x10 /**< VS10xx register */
 VS10xx register.

#define SM_TESTS   0x20 /**< VS10xx register */
 VS10xx register.

#define SM_STREAM   0x40 /**< VS10xx register */
 VS10xx register.

#define SM_PLUSV   0x80 /**< VS10xx register */
 VS10xx register.

#define SM_DACT   0x100 /**< VS10xx register */
 VS10xx register.

#define SM_SDIORD   0x200 /**< VS10xx register */
 VS10xx register.

#define SM_SDISHARE   0x400 /**< VS10xx register */
 VS10xx register.

#define SM_SDINEW   0x800 /**< VS10xx register */
 VS10xx register.

#define SM_ADPCM   0x1000 /**< VS10xx register */
 VS10xx register.

#define SM_ADPCM_HP   0x2000 /**< VS10xx register */
 VS10xx register.

#define Mp3WriteRegister(addressbyte, highbyte, lowbyte)
 Write VS10xx register.

#define Mp3SetVolume(leftchannel, rightchannel)
 Set VS10xx Volume Register.


Functions

void VsSineTest ()
 Execute VS1011/VS1002 Sine Test Function.

void Mp3Reset ()
 Reset VS10xx.

void Mp3SoftReset ()
 Soft Reset of VS10xx (Between songs).

unsigned int Mp3ReadRegister (unsigned char addressbyte)
 Read the 16-bit value of a VS10xx register.

void SendZerosToVS10xx ()
 Send 2048 zeros.

unsigned char PlayDiskSectors (unsigned int nSectorsToPlay)
 Play disk sectors from disk.

void AvailableProcessorTime ()
 This is called when there is free processor time, implement externally.


Variables

xdata unsigned char playingState
 Playing State Global, 0=normal playing, 1=abort playing.


Detailed Description

Headers for interfacing with the mp3 player chip.

Interfacing the New Way, not handling BSYNC -> not compatible with VS1001.

Definition in file vs10xx.h.


Define Documentation

#define Mp3SetVolume leftchannel,
rightchannel   ) 
 

Value:

{\ Mp3WriteRegister(11,(leftchannel),(rightchannel));}
Set VS10xx Volume Register.

Definition at line 79 of file vs10xx.h.

Referenced by AvailableProcessorTime().

#define Mp3WriteRegister addressbyte,
highbyte,
lowbyte   ) 
 

Value:

{ \ Mp3SelectControl(); \ SPIPutCharWithoutWaiting(VS_WRITE_COMMAND); \ SPIPutChar((addressbyte)); \ SPIPutChar((highbyte)); \ SPIPutChar((lowbyte)); \ SPIWait(); \ Mp3DeselectControl(); \ }
Write VS10xx register.

Definition at line 68 of file vs10xx.h.

Referenced by AvailableProcessorTime(), LoadPatch(), LoadUserCode(), Mp3DeselectData(), Mp3SelectData(), PlayCurrentFile(), and Record().

#define SM_ADPCM   0x1000 /**< VS10xx register */
 

VS10xx register.

Definition at line 48 of file vs10xx.h.

#define SM_ADPCM_HP   0x2000 /**< VS10xx register */
 

VS10xx register.

Definition at line 49 of file vs10xx.h.

#define SM_DACT   0x100 /**< VS10xx register */
 

VS10xx register.

Definition at line 44 of file vs10xx.h.

#define SM_DIFF   0x01 /**< VS10xx register */
 

VS10xx register.

Definition at line 36 of file vs10xx.h.

#define SM_JUMP   0x02 /**< VS10xx register */
 

VS10xx register.

Definition at line 37 of file vs10xx.h.

#define SM_OUTOFWAV   0x08 /**< VS10xx register */
 

VS10xx register.

Definition at line 39 of file vs10xx.h.

Referenced by PlayCurrentFile().

#define SM_PDOWN   0x10 /**< VS10xx register */
 

VS10xx register.

Definition at line 40 of file vs10xx.h.

#define SM_PLUSV   0x80 /**< VS10xx register */
 

VS10xx register.

Definition at line 43 of file vs10xx.h.

#define SM_RESET   0x04 /**< VS10xx register */
 

VS10xx register.

Definition at line 38 of file vs10xx.h.

#define SM_SDINEW   0x800 /**< VS10xx register */
 

VS10xx register.

Definition at line 47 of file vs10xx.h.

#define SM_SDIORD   0x200 /**< VS10xx register */
 

VS10xx register.

Definition at line 45 of file vs10xx.h.

#define SM_SDISHARE   0x400 /**< VS10xx register */
 

VS10xx register.

Definition at line 46 of file vs10xx.h.

#define SM_STREAM   0x40 /**< VS10xx register */
 

VS10xx register.

Definition at line 42 of file vs10xx.h.

#define SM_TESTS   0x20 /**< VS10xx register */
 

VS10xx register.

Definition at line 41 of file vs10xx.h.

#define SPI_AIADDR   0xa /**< VS10xx register */
 

VS10xx register.

Definition at line 29 of file vs10xx.h.

Referenced by Record().

#define SPI_AICTRL0   0xc /**< VS10xx register */
 

VS10xx register.

Definition at line 31 of file vs10xx.h.

Referenced by Record().

#define SPI_AICTRL1   0xd /**< VS10xx register */
 

VS10xx register.

Definition at line 32 of file vs10xx.h.

Referenced by AvailableProcessorTime(), and Record().

#define SPI_AICTRL2   0xe /**< VS10xx register */
 

VS10xx register.

Definition at line 33 of file vs10xx.h.

Referenced by Record().

#define SPI_AICTRL3   0xf /**< VS10xx register */
 

VS10xx register.

Definition at line 34 of file vs10xx.h.

Referenced by Record().

#define SPI_AUDATA   0x5 /**< VS10xx register */
 

VS10xx register.

Definition at line 24 of file vs10xx.h.

#define SPI_BASS   0x2 /**< VS10xx register */
 

VS10xx register.

Definition at line 21 of file vs10xx.h.

Referenced by AvailableProcessorTime().

#define SPI_CLOCKF   0x3 /**< VS10xx register */
 

VS10xx register.

Definition at line 22 of file vs10xx.h.

Referenced by Mp3ReadRegister(), and Record().

#define SPI_DECODE_TIME   0x4 /**< VS10xx register */
 

VS10xx register.

Definition at line 23 of file vs10xx.h.

Referenced by ScreenSetPlayTime().

#define SPI_HDAT0   0x8 /**< VS10xx register */
 

VS10xx register.

Definition at line 27 of file vs10xx.h.

Referenced by Record().

#define SPI_HDAT1   0x9 /**< VS10xx register */
 

VS10xx register.

Definition at line 28 of file vs10xx.h.

Referenced by Record().

#define SPI_MODE   0x0 /**< VS10xx register */
 

VS10xx register.

Definition at line 19 of file vs10xx.h.

Referenced by Mp3DeselectData(), Mp3SelectData(), PlayCurrentFile(), and Record().

#define SPI_STATUS   0x1 /**< VS10xx register */
 

VS10xx register.

Definition at line 20 of file vs10xx.h.

#define SPI_VOL   0xb /**< VS10xx register */
 

VS10xx register.

Definition at line 30 of file vs10xx.h.

#define SPI_WRAM   0x6 /**< VS10xx register */
 

VS10xx register.

Definition at line 25 of file vs10xx.h.

#define SPI_WRAMADDR   0x7 /**< VS10xx register */
 

VS10xx register.

Definition at line 26 of file vs10xx.h.

#define VS_READ_COMMAND   0x03
 

VS10xx SCI Read Command byte is 0x03.

Definition at line 16 of file vs10xx.h.

#define VS_WRITE_COMMAND   0x02
 

VS10xx SCI Write Command byte is 0x02.

Definition at line 13 of file vs10xx.h.


Function Documentation

void AvailableProcessorTime  ) 
 

This is called when there is free processor time, implement externally.

The basic task of this function is to implement the player user interface.

Local variables:

  • volume: Current volume setting

  • bass: Current bass enhancer setting

  • treble: Current treble enhancer setting

  • reclevel: Current recording level setting

  • uiReturnDelay: Counts down to returning to UI mode 0 (title screen)

Bass/Treble setting calculation

There are 2 or 4 adjustments possible:

  • Bass Frequency (1011B/E, 1002, 10x3) : 2..15 -> 20..1500 Hz
  • Bass boost (1011B/E, 1002, 10x3) : 0..15 -> 0ff..+15dB)
  • Treble Frequency (1011E, 10x3) : 0..15 -> 0..15kHz
  • Treble level (1011E, 10x3) : -8..+7 -> -12..+10.5dB

In this software, all are adjusted based from a single setting (0..128) for bass and another for treble. You may wish to allow user to control frequency and level separately or set fixed frequencies for a known speaker type. This algorithm increases the frequency range of adjustment with the increasing level.

Definition at line 328 of file player.c.

References displayStyle, displayTitle, displayValue, DS_NO_YES, DS_PERCENTAGE, DS_RAWTEXT, DS_TEXT, KEY_BUTTON, KEY_FARLEFT, KEY_FARRIGHT, lcdFont_barchars, lcdFont_vertical_barchars, LcdReset(), LcdSelectFont(), Mp3ReadRegister(), Mp3SetVolume, Mp3WriteRegister, playingState, PS_CUE, PS_END_OF_SONG, PS_NEXT_SONG, PS_NORMAL, PS_PREVIOUS_SONG, PS_RECORDING, PS_REWIND, ScreenSetPlayTime(), SPI_AICTRL1, SPI_BASS, SPIPutChar, SPIWait, UI_BASS, UI_CUE, UI_END_OF_MODES, UI_INFO, UI_RECLEVEL, UI_RETURN_DELAY, UI_SPEC, UI_STOP, UI_TITLE, UI_TREBLE, UI_VOLUME, uiMode, UpdateDisplay(), and userInterfaceDelayElapsed.

Referenced by GetAVIBlock(), and Record().

00328 { 00329 00333 static xdata unsigned char volume = 20; 00334 00336 static xdata unsigned char bass = 0; 00337 00339 static xdata unsigned char treble = 64; //middle setting = 0 00340 00342 static xdata unsigned char reclevel = 50; 00343 00344 unsigned int i; //temp variable 00345 00346 static bit bassUpdateNeeded; 00347 00351 static unsigned char uiReturnDelay=0; 00352 00353 if (!userInterfaceDelayElapsed){ 00354 return; /* Not yet time to do user interface stuff */ 00355 } 00356 00357 userInterfaceDelayElapsed = 0; 00358 00359 00360 // User Interface Modes 00361 // Return to UI_TITLE after long period of button inactivity 00362 00363 if (uiReturnDelay == 0){ 00364 if ((uiMode != UI_SPEC)&&(uiMode != UI_CUE)) 00365 uiMode = UI_TITLE; 00366 else{ 00367 } 00368 }else{ 00369 uiReturnDelay--; 00370 } 00371 00372 00373 00374 if (uiMode==UI_SPEC) //No spectrum analyzer 00375 uiMode++; 00376 00377 00378 00379 00380 if (uiMode==UI_INFO) 00381 uiMode++; //Nothing interesting currently in screen UI_INFO. 00382 if (uiMode==UI_STOP) 00383 uiMode++; //Nothing interesting currently in screen UI_STOP. 00384 00385 /* Screen updates */ 00386 switch(uiMode){ 00387 00388 case UI_TITLE: //Playing time, song title 00389 00390 displayStyle = DS_TEXT; 00391 ScreenSetPlayTime(); 00392 00393 if (playingState==PS_RECORDING){ 00394 displayStyle = DS_PERCENTAGE; 00395 } 00396 00397 break; 00398 00399 case UI_STOP: //Ask if the user wants to stop 00400 displayStyle = DS_NO_YES; 00401 strcpy (displayTitle, "Stop? "); 00402 break; 00403 00404 case UI_CUE: //Ask if the user wants to fast forward or rewind 00405 displayStyle = DS_RAWTEXT; 00406 strcpy (displayTitle, "REW/CUE <- ->"); 00407 00408 //i = Mp3ReadRegister(SPI_HDAT1); 00409 //displayTitle[5] = lcd_hexchars[i>>12]; 00410 //displayTitle[6] = lcd_hexchars[(i>>8)&0x0f]; 00411 //displayTitle[7] = lcd_hexchars[(i>>4)&0x0f]; 00412 //displayTitle[8] = lcd_hexchars[i&0x0f]; 00413 00414 break; 00415 00416 case UI_VOLUME: //Show volume bar 00417 LcdSelectFont(lcdFont_barchars); 00418 displayStyle = DS_PERCENTAGE; 00419 strcpy(displayTitle,"Volume: "); 00420 displayValue = (100-(volume>>1)); 00421 if (displayValue<0) displayValue = 0; 00422 break; 00423 00424 case UI_BASS: //Show bass bar 00425 LcdSelectFont(lcdFont_barchars); 00426 displayStyle = DS_PERCENTAGE; 00427 strcpy(displayTitle,"Bass: "); 00428 displayValue = (bass/5)*4; 00429 if (displayValue<1) displayValue = 1; 00430 break; 00431 00432 case UI_TREBLE: //Show treble bar 00433 LcdSelectFont(lcdFont_barchars); 00434 displayStyle = DS_PERCENTAGE; 00435 strcpy(displayTitle,"Treble: "); 00436 displayValue = (treble/5)*4; 00437 if (displayValue<1) displayValue = 1; 00438 break; 00439 00440 case UI_RECLEVEL: //Show recording level 00441 00442 if (playingState==PS_RECORDING){ 00443 LcdSelectFont(lcdFont_barchars); 00444 displayStyle = DS_PERCENTAGE; 00445 strcpy(displayTitle,"RecLevel"); 00446 displayValue = (reclevel); 00447 if (reclevel==0){ 00448 strcpy(displayTitle,"RecLevel <Auto> "); 00449 displayStyle = DS_RAWTEXT; //Reveal the "auto" text 00450 } 00451 }else{ 00452 //Not in recording 00453 displayStyle = DS_NO_YES; 00454 strcpy (displayTitle, "Record? "); 00455 } 00456 break; 00457 00458 00459 case UI_SPEC: // Spectrum analyzer 00460 00461 if (playingState == PS_RECORDING){ 00462 uiMode++; //Don't show specana when recording 00463 } 00464 00465 LcdSelectFont(lcdFont_vertical_barchars); 00466 displayStyle = DS_RAWTEXT; 00467 ScreenSetPlayTime(); 00468 00469 // Request to read Spectrum Analyzer register 00470 Mp3WriteRegister(7, 0x18, 0x04); 00471 00472 // Read Spectrum Analyzer registers 00473 { 00474 for (i=0;i<8;i++) { //for each band i in [0..7] 00475 signed char thisband = Mp3ReadRegister(6); 00476 00477 /* thisband now has spectrum value 0..63. We adjust it a little 00478 for best image on the evakit LCD. You also get peak values 00479 etc from the chip but we don't use them in the evakit screen. 00480 we use 8 bands, but up to 23 are obtainable from the chip. */ 00481 00482 thisband &= 63; /* mask all but level info */ 00483 thisband >>= 1; /* LCD resolution is not high */ 00484 thisband -= 3; /* base offset */ 00485 if (i==0) thisband -= 2; /* decrease bass bar level */ 00486 if (i==6) thisband += 1; /* increase treble bar level */ 00487 if (i==7) thisband += 1; /* increase treble bar level */ 00488 if (thisband>7) thisband = 7; /* high limit */ 00489 if (thisband<0) thisband =' '; /* low limit */ 00490 00491 displayTitle[i+8] = thisband; //Store to display mem 00492 00493 }//for each band 00494 } 00495 break; 00496 00497 } //switch(uiMode) 00498 00499 // Buttons handler 00500 // Perform mode-dependent button handling 00501 00502 if ((KEY_BUTTON) && (uiReturnDelay < UI_RETURN_DELAY-20)){ 00503 LcdReset(); 00504 uiMode++; 00505 uiReturnDelay = UI_RETURN_DELAY; 00506 } 00507 00508 switch(uiMode){ 00509 00510 case UI_TITLE: 00511 case UI_SPEC: 00512 00513 if (KEY_FARRIGHT){ 00514 playingState = PS_NEXT_SONG; /* Request */ 00515 } 00516 if (KEY_FARLEFT){ 00517 playingState = PS_PREVIOUS_SONG; /* Request */ 00518 } 00519 break; 00520 00521 00522 case UI_VOLUME: 00523 00524 if (KEY_FARLEFT){ 00525 uiReturnDelay = UI_RETURN_DELAY; 00526 if (volume++ == 254) volume = 254; //Change + limit to 254 (minimum vol) 00527 Mp3SetVolume(volume,volume); 00528 } 00529 00530 if (KEY_FARRIGHT){ 00531 uiReturnDelay = UI_RETURN_DELAY; 00532 if (volume-- == 0) volume = 0; //Change + limit to 0 (maximum volume) 00533 Mp3SetVolume(volume,volume); 00534 } 00535 break; // UI_VOLUME 00536 00537 case UI_BASS: 00538 case UI_TREBLE: //BASS and TREBLE use the same VS10xx register 00539 bassUpdateNeeded = 0; 00540 00541 //First let's see if a key is pressed; does the user want to set level? 00542 00543 if (uiMode==UI_BASS){ //BASS screen is active 00544 00545 if (KEY_FARLEFT){ 00546 bassUpdateNeeded = 1; 00547 if (bass-- == 0) bass = 0; //Change + limit to 0 (OFF setting) 00548 } 00549 if (KEY_FARRIGHT){ 00550 bassUpdateNeeded = 1; 00551 if (bass++ == 127) bass = 127; //Change + limit to 127 (max setting) 00552 } 00553 00554 }else{ //TREBLE screen is active 00555 00556 if (KEY_FARLEFT){ 00557 bassUpdateNeeded = 1; //SCI_BASS is for both bass and treble 00558 if (treble-- == 0) treble = 0; //Change + limit to 0 (OFF setting) 00559 } 00560 if (KEY_FARRIGHT){ 00561 bassUpdateNeeded = 1; //SCI_BASS is for both bass and treble 00562 if (treble++ == 127) treble = 127; //Change + limit to 127 (max) 00563 } 00564 00565 } 00566 00567 00568 if (bassUpdateNeeded){ 00569 unsigned int newBassRegister; 00570 00571 //User has pushed button to alter bass/treble register 00572 //calculate new value 00573 00589 //Let's start from bass frequency setting. 00590 //min(0) should give 2 (20Hz), max(127) should give 15 (150Hz) 00591 newBassRegister = (bass + 23) / 10; //into bits 3..0, clear hibits 00592 00593 //Bass boost level. 00594 //min(0) should give 0, max(127) should give 15 00595 newBassRegister |= (bass>>3)<<4; //insert to bits 7..4 00596 00597 //Then the treble frequency 00598 //min(0) should give 15(15kHx), max(127) should give 2(2kHz) 00599 newBassRegister |= (((148-treble)>>3)+2)<<8; //insert into bits 11..8 00600 00601 //Finally the treble value (-8..7) 00602 //min(0) should give -8, max(127) should give 7; 00603 newBassRegister |= ((treble>>3)-8)<<12; //insert into bits 15..12 00604 00605 00606 uiReturnDelay = UI_RETURN_DELAY; 00607 00608 if (Mp3ReadRegister(SPI_BASS)!=newBassRegister){ 00609 Mp3WriteRegister(SPI_BASS,newBassRegister>>8,newBassRegister&0xff); 00610 } 00611 00612 //i = newBassRegister; 00613 //displayTitle[4] = lcd_hexchars[i>>12]; 00614 //displayTitle[5] = lcd_hexchars[(i>>8)&0x0f]; 00615 //displayTitle[6] = lcd_hexchars[(i>>4)&0x0f]; 00616 //displayTitle[7] = lcd_hexchars[i&0x0f]; 00617 00618 00619 } 00620 00621 break; // UI_BASS and UI_TREBLE 00622 00623 00624 case UI_RECLEVEL: 00625 00626 if (playingState==PS_RECORDING){ 00627 if (KEY_FARRIGHT){ 00628 uiReturnDelay = UI_RETURN_DELAY; 00629 if (reclevel++ == 100){ 00630 reclevel = 100; 00631 } 00632 Mp3WriteRegister(SPI_AICTRL1, 00633 ((int)reclevel*32)>>8,((int)reclevel*32)&0xff); 00634 SPIPutChar(0);SPIWait(); 00635 } 00636 00637 if (KEY_FARLEFT){ 00638 uiReturnDelay = UI_RETURN_DELAY; 00639 if (reclevel-- == 0){ 00640 reclevel = 0; 00641 } 00642 Mp3WriteRegister(SPI_AICTRL1, 00643 ((int)reclevel*32)>>8,((int)reclevel*32)&0xff); 00644 SPIPutChar(0);SPIWait(); 00645 } 00646 }else{ 00647 //Not in recording 00648 if (KEY_FARRIGHT){ 00649 //Enter recording mode 00650 playingState=PS_RECORDING; //request to record 00651 } 00652 } 00653 break; // UI_RECLEVEL 00654 00655 case UI_STOP: 00656 00657 if (KEY_FARRIGHT){ 00658 playingState = PS_END_OF_SONG; /* Request to abort playing */ 00659 } 00660 break; // UI_STOP 00661 00662 case UI_CUE: 00663 00664 if (playingState == PS_NORMAL){ /* Only control when PS_NORMAL */ 00665 if (KEY_FARRIGHT){ 00666 uiReturnDelay = UI_RETURN_DELAY; /* Don't go back to title just yet */ 00667 playingState = PS_CUE; /* Request */ 00668 } 00669 if (KEY_FARLEFT){ 00670 uiReturnDelay = UI_RETURN_DELAY; 00671 playingState = PS_REWIND; /* Request */ 00672 } 00673 } 00674 00675 break; // UI_SKIP 00676 00677 case UI_END_OF_MODES: 00678 uiMode = UI_TITLE; 00679 break; // UI_END_OF_MODES 00680 00681 00682 } //End Switch 00683 00684 00685 // Draw screen 00686 UpdateDisplay(); 00687 }

Here is the call graph for this function:

unsigned int Mp3ReadRegister unsigned char  addressbyte  ) 
 

Read the 16-bit value of a VS10xx register.

Definition at line 88 of file vs10xx.c.

References Delay(), MP3_DREQ, Mp3DeselectControl, Mp3DeselectData(), Mp3PutInReset, Mp3ReleaseFromReset, SPI_CLOCKF, and SPIPutCharWithoutWaiting.

Referenced by AvailableProcessorTime(), Record(), and ScreenSetPlayTime().

00088 { 00089 //ConsolePutChar(13); 00090 00091 Mp3PutInReset(); 00092 Delay(1); 00093 00094 /* Send dummy SPI byte to initialize atmel SPI */ 00095 SPIPutCharWithoutWaiting(0xFF); 00096 00097 /* Un-reset MP3 chip */ 00098 Mp3DeselectControl(); 00099 Mp3DeselectData(); 00100 Mp3ReleaseFromReset(); 00101 00102 while (!MP3_DREQ)

Here is the call graph for this function:

void Mp3Reset  ) 
 

Reset VS10xx.

Definition at line 126 of file vs10xx.c.

Referenced by main().

00134 :"); 00135 ConsolePutUInt(Mp3ReadRegister(SPI_CLOCKF)); 00136 ConsolePutChar(13); 00137 #endif 00138 00139 00140 Mp3WriteRegister(SPI_WRAMADDR, 0xc0, 0x13); 00141 ConsoleWrite("0xC013:"); 00142 ConsolePutUInt (Mp3ReadRegister(SPI_WRAM)); 00143 ConsolePutUInt (Mp3ReadRegister(SPI_WRAM)); 00144 ConsolePutChar(13); 00145 00146 00147 /* Switch on the analog parts */ 00148 Mp3SetVolume(20,20); 00149 00150 SPISetFastClock(); 00151 ConsoleWrite ("Init: VS10XX\r"); 00152 00153 } 00154 00155 00157 void VsSineTest(){ 00158 00159 ConsoleWrite("Not For VS1053!"); /* Needs adjustment */ 00160 00161 /* Reset MP3 chip */ 00162 Mp3PutInReset(); /* Pull xRESET low -> hardware reset */ 00163 Delay(100); /* 100 ms delay */ 00164 00165 /* Send dummy SPI byte to initialize SPI of Atmel microcontroller */ 00166 SPIPutCharWithoutWaiting(0xFF); 00167 00168 /* Un-reset MP3 chip */ 00169 Mp3DeselectControl(); /* Pull xCS high */ 00170 Mp3DeselectData(); /* Pull xDCS high */ 00171 Mp3ReleaseFromReset(); /* Pull xRESET high */ 00172 Delay(100); /* 100 ms delay */ 00173 00174 GREEN_LED = LED_ON; 00175 RED_LED = LED_ON; 00176 00177 /* VS10xx Application Notes, chapter 4.8 ---------------------------------*/ 00178 /* As an example, let's write value 0x0820 to register 00 byte by byte */ 00179 Mp3SelectControl(); /* Now SPI writes go to SCI port */ 00180 SPIPutChar(0x02); /* Send SPI Byte, then wait for byte to be sent. */ 00181 SPIPutChar(0x00); /* 0x02 was WRITE command, 0x00 is register number */ 00182 SPIPutChar(0x08); /* This byte goes to MSB */ 00183 SPIPutChar(0x20); /* ..and this is LSB. (0x20=Allow Test Mode) */ 00184 SPIWait(); /* Wait until Atmel MCU signals SPI write complete */ 00185 Mp3DeselectControl(); /* Now SPI writes don't go to SCI port */ 00186 00187 while (!MP3_DREQ) /* Wait for DREQ = 1 */ 00188 ; /* Do nothing while waiting for DREQ = 1 */ 00189 00190 /* Send a Sine Test Header to Data port */ 00191 Mp3SelectData(); /* Now SPI writes go to SDI port */

void Mp3SoftReset  ) 
 

Soft Reset of VS10xx (Between songs).

Definition at line 110 of file vs10xx.c.

References MP3_DREQ.

Referenced by main(), and Record().

00120 :"); 00121 ConsolePutUInt(Mp3ReadRegister(SPI_CLOCKF)); 00122 ConsolePutChar(13);

unsigned char PlayDiskSectors unsigned int  nSectorsToPlay  ) 
 

Play disk sectors from disk.

Starting from current value in global variable sectorAddress, sends a number of disk sectors to vs10xx and returns.

How many sectors to send between ff/rew commands

Definition at line 249 of file vs10xx.c.

References Address::l, PlayAvi(), PrepareToReadDiskSector(), and sectorAddress.

Referenced by PlayCurrentFile().

00249 { 00250 00252 unsigned char fallbackCount = 0; 00253 00254 00255 #ifdef AVIPLAY 00256 if (!PlayAvi()) return 0; //try to play AVI file soundtrack starting from 00257 //current sector, if avifile is played, return. 00258 #endif 00259 00260 00261 PrepareToReadDiskSector(sectorAddress.l); 00262 while (nSectorsToPlay--){ 00263 00264 AvailableProcessorTime(); 00265 00266 ReadDiskSector(sectorAddress.l); 00267 00268 /* If playing state is something else than "play normally", 00269 exit returning the request number. */ 00270 if ((playingState==PS_END_OF_SONG)|| 00271 (playingState==PS_NEXT_SONG)|| 00272 (playingState==PS_RECORDING)|| 00273 (playingState==PS_PREVIOUS_SONG)){ 00274 return playingState; 00275 } 00276 00277 00278 /* === REWIND / FAST FORWARD FUNCTIONALITY CODE BEGINS === */ 00279 /* If you don't implement rewind / fast forward, leave these lines out */ 00280 00281 if (playingState==PS_FALLBACK_N){ 00282 if ((--fallbackCount)==0){ 00283 playingState=PS_NORMAL; 00284 } 00285 } 00286 00287 if (playingState==PS_FALLBACK_1){ 00288 /* Now we should have brand new sector in memory ready for sending to 00289 VS1003, so let's send zeroes between old and new data. */ 00290 ConsoleWrite("(Zeros)"); 00291 SendZerosToVS10xx(); 00292 ConsoleWrite("->Fallback to normal"); 00293 fallbackCount = 24; 00294 playingState = PS_FALLBACK_N; 00295 } 00296 00297 00298 if (playingState==PS_CUE){ //Request to start fast forward 00299 if (Mp3ReadRegister(SPI_HDAT1)==((int)'W'<< 8)+'m'){ 00300 ConsoleWrite("\rWmCUE->Wait"); 00301 Mp3WriteRegister(SPI_AICTRL2, 0x12, 0x34); 00302 playingState = PS_CUE_WAIT1003; 00303 }else{ 00304 playingState = PS_CUE_ACTION; 00305 } 00306 } 00307 00308 if (playingState==PS_CUE_WAIT1003){ //Wait for permission to break data flow 00309 if (Mp3ReadRegister(SPI_AICTRL2)==0x2345){ //permission granted 00310 ConsoleWrite("->Action"); 00311 playingState = PS_CUE_ACTION; 00312 } 00313 } 00314 00315 if (playingState==PS_CUE_ACTION){ 00316 if (nSectorsToPlay>128){ 00317 sectorAddress.l += 128; //Skip sectors 00318 nSectorsToPlay -= 128; 00319 //adjust vs1003 song left 00320 ConsoleWrite("->Fallback(5)"); 00321 playingState = PS_FALLBACK_1; //Sector already in memory still goes. 00322 } 00323 } 00324 00325 if (playingState==PS_REWIND){ //Request to start fast forward 00326 Mp3WriteRegister(SPI_AICTRL2, 0x12, 0x34); 00327 playingState = PS_REW_WAIT1003; 00328 } 00329 00330 if (playingState==PS_REW_WAIT1003){ //Wait for permission to break data flow 00331 if (1){ 00332 if (1 || (Mp3ReadRegister(SPI_AICTRL2)==0x2345)){ //permission granted 00333 sectorAddress.l -= 128; 00334 nSectorsToPlay += 128; 00335 playingState = PS_FALLBACK_1; //Sector already in memory still goes. 00336 } 00337 } 00338 } 00339 00340 00341 /* === END OF REWIND / FAST FORWARD FUNCTIONALITY CODE === */ 00342 00343 00344 00345 sectorAddress.l++; 00346 if (nSectorsToPlay){ 00347 /*Do not seek after the last sector*/ 00348 PrepareToReadDiskSector(sectorAddress.l); 00349 } 00350 00351 Mp3SelectData(); 00352 00353 dataBufPtr = diskSect.raw.buf; 00354 while (dataBufPtr < diskSect.raw.buf+512){ 00355 00356 if (!MP3_DREQ){ 00357 GREEN_LED = LED_ON; 00358 while (!MP3_DREQ){ 00359 Mp3DeselectData(); 00360 AvailableProcessorTime(); 00361 Mp3SelectData(); 00362 } 00363 } 00364 GREEN_LED = LED_OFF; 00365 00366 /* Send 32 octets of disk block data to VS10xx */ 00367 00368 //Mp3WriteRegister (SPI_MODE, 0x0C, 0x00); /* Newmode, No L1-2 */ 00369 00370 SPIPutCharWithoutWaiting(*dataBufPtr++); 00371 SPIWait(); 00372 SPIPutChar(*dataBufPtr++); 00373 SPIPutChar(*dataBufPtr++); 00374 SPIPutChar(*dataBufPtr++); 00375 SPIPutChar(*dataBufPtr++); 00376 SPIPutChar(*dataBufPtr++); 00377 SPIPutChar(*dataBufPtr++); 00378 SPIPutChar(*dataBufPtr++); 00379 SPIPutChar(*dataBufPtr++); 00380 SPIPutChar(*dataBufPtr++); 00381 SPIPutChar(*dataBufPtr++); 00382 SPIPutChar(*dataBufPtr++); 00383 SPIPutChar(*dataBufPtr++); 00384 SPIPutChar(*dataBufPtr++); 00385 SPIPutChar(*dataBufPtr++); 00386 SPIPutChar(*dataBufPtr++); 00387 SPIPutChar(*dataBufPtr++); 00388 SPIPutChar(*dataBufPtr++); 00389 SPIPutChar(*dataBufPtr++); 00390 SPIPutChar(*dataBufPtr++); 00391 SPIPutChar(*dataBufPtr++); 00392 SPIPutChar(*dataBufPtr++); 00393 SPIPutChar(*dataBufPtr++); 00394 SPIPutChar(*dataBufPtr++); 00395 SPIPutChar(*dataBufPtr++); 00396 SPIPutChar(*dataBufPtr++); 00397 SPIPutChar(*dataBufPtr++); 00398 SPIPutChar(*dataBufPtr++); 00399 SPIPutChar(*dataBufPtr++); 00400 SPIPutChar(*dataBufPtr++); 00401 SPIPutChar(*dataBufPtr++); 00402 SPIPutChar(*dataBufPtr++); 00403 SPIWait(); 00404 00405 //Mp3WriteRegister (SPI_MODE, 0x08, 0x00); /* Newmode, No L1-2 */ 00406 00407 00408 } 00409 00410 00411 SPIWait(); 00412 Mp3DeselectData(); 00413 } 00414 00415 00416 return 0; //OK Exit 00417 }

Here is the call graph for this function:

void SendZerosToVS10xx  ) 
 

Send 2048 zeros.

Todo:
Timeouts for all DREQ busy loop waits!

Definition at line 263 of file vs10xx.c.

References playingState, PS_END_OF_SONG, PS_NEXT_SONG, PS_PREVIOUS_SONG, PS_RECORDING, and sectorAddress.

Referenced by PlayCurrentFile().

00273 {

void VsSineTest  ) 
 

Execute VS1011/VS1002 Sine Test Function.

Definition at line 195 of file vs10xx.c.

References GREEN_LED, LED_OFF, and RED_LED.

00225 { 00226 Mp3SelectData(); 00227 SPIPutCharWithoutWaiting(0); 00228 for (temp.i=0; temp.i<1048; temp.i++){ /* TESTING 1048 TESTING */ 00229 while (!MP3_DREQ) 00230 ; 00231 SPIPutChar(0); 00232 } 00233 SPIWait(); 00234 Mp3DeselectData(); 00235 } 00236 00237 //Link in experimental AVI file sound track playing 00238 #define AVIPLAY 00239 00240 #ifdef AVIPLAY 00241 #include "aviplay.c" 00242 #endif 00243 00244 00245 00249 unsigned char PlayDiskSectors (unsigned int nSectorsToPlay){ 00250 00252 unsigned char fallbackCount = 0; 00253 00254 00255 #ifdef AVIPLAY 00256 if (!PlayAvi()) return 0; //try to play AVI file soundtrack starting from 00257 //current sector, if avifile is played, return. 00258 #endif 00259 00260


Variable Documentation

xdata unsigned char playingState
 

Playing State Global, 0=normal playing, 1=abort playing.

Definition at line 53 of file vs10xx.h.

Referenced by AvailableProcessorTime(), main(), PlayCurrentFile(), Record(), ScreenSetPlayTime(), and SendZerosToVS10xx().


All software copyright 2000-2004 VLSI Solution OY. Redistribution of these software modules are limited to promotional use only and only with the VS1011 / VS1002 / VS1003 MP3-Evakit evaluation boards. Free or commercial use of these software modules in MP3 players is ok if the product includes MP3 decoder chip(s) from VLSI. You can request the complete (compilable) package from mp3@vlsi.fi