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

📄 frankmp3.c

📁 Frank s MP3 Player Source Files
💻 C
📖 第 1 页 / 共 2 页
字号:
    { &f_array[4],    &f_array[2],  (char*)&Func3Name[0],   IRcode_next },
    { &f_array[5],    &f_array[3],  (char*)&Func4Name[0],   IRcode_back },
    { &f_array[0],    &f_array[4],  (char*)&Func5Name[0],   IRcode_mode }
};

// Defines for indexing into these structures. If you change the functions structure typedef you MUST change these.
#define     IRNextFunc    0           /* Function structure index for pointer to next function structure */
#define     IRPrevFunc    2           /* Function structure index for pointer to previous function structure */
#define     IRFuncString  4           /* Function structure index for pointer to function description string */
#define     IRFuncEEPROM  6           /* Function structure index for eeprom training data offset */
// End of IR training functions structures.



/* function prototypes for functions in this file */
void FeedSTcodec(void);
u16 CountMP3files (void);
void BuildFastFindTable (void);
u08 FindNthMP3(u16 N);
void PC_init (void);
void FSC_init (void);
void LCD_init (void);
u08 sta013_writeTWI (u08 waddr, u08 wdata);
void StopOnError (u08 errorcode);
void USB_init (void);
void CheckUSB (void);
void uart0_putwaitstr(u08 *c);
void uart1_putwaitstr(u08 *c);
void uart0_putwaitPROGstr(u08 *c);
void uart1_putwaitPROGstr(u08 *c);
void PrintASCIIword (u16 num, u08 uart);
void PlayControl (void);
void PlayControl_Idle (void);
void PlayControl_FindNextFile (void);
void PlayControl_Play (void);
void PlayControl_Delay (void);
void PlayControlStop (void);
void FileNameOnLCD (void);
void DisplayUART1rx (void);
void HandleButtons (void);
void SwitchOff (void);
void MuteSTcodec (void);
void unMuteSTcodec (void);
void EEPROM_Write (u16 addr, u08 data);
u16 GetRandomNumber (u16 maxnum);
void TimersInit (void);
void CntMP3files (void);
void DisplayReady (void);
void DisplayWait (void);
void DisplayName (void);
void DisplayRandomRpt (void);
void GetLongFileName (void);
void PrintStackPointer (void);
void PrintDebugInfo (void);
void DumpAndHang (void);
void DumpEEPROM (void);
u08 DumpDirectory (void);
void PrintDebugCommands(void);
void InsertCharInString(u08 *location, u08 character);
void DeleteCharFromString(u08 *location);
void FormatFileNameString (u08 TruncEnd);
void LED_ON (void);
void LED_OFF (void);
void LCD_LIGHT_ON (void);
void LCD_LIGHT_OFF (void);
void ClearLCDlines (u08 startline, u08 numlines);
void PositionLCDcursor (u08 linenum, u08 columnnum);
u08 NextFileNumber (void);
u08 PrevFileNumber (void);
void PCChangeFileNumber (u16 TrackChange, u08 Direction);
u08 PlayFileAndDisplay (void);
void InitRandomVariables(void);
void MenuMain(void);
void MenusInit (void);
void IRInit (void);
void IR_CheckTimeout (void);
void TrainIRfunction (u16 eepromaddr);
void IR_decode (void);
u08 FindNthDir (u16 N);
void DisplayDirName (void);
void FakeRootDotDir (void);
void GetCurrentDirName (void);
u16 DivRound (u16 x, u16 y);
u08 AbsDiff8 (u08 a, u08 b);
void CycleStepSize (void);
u08 ReadPortsExpectHigh (u08 MaskPA, u08 MaskPB, u08 MaskPC, u08 MaskPD, u08 MaskPE, u08 MaskPF, u08 MaskPG);
u08 ReadPortsExpectLow (u08 MaskPA, u08 MaskPB, u08 MaskPC, u08 MaskPD, u08 MaskPE, u08 MaskPF, u08 MaskPG);
void PrintTestPortError (u08 errorcode);
void TestPortBits (void);
void TestHarddisk (void);
void TestWriteHarddisk (void);
void TestReadHarddisk (void);



int main(void)
{

    USB_init();				/* basically just initializes Cypress USB interface chip */
    General_init();		    /* general initializations */
    LED_ON();				/* turn the front LED on - let's look alive! */
    LCD_LIGHT_ON();         // and the lcd backlight
    UART_init();		    /* initialize the UARTs */
    ButtonPress = 0;        /* no pushbutton currently pressed */
    IRInit();               // init the IR (remote control) receiver / decoder routines
	sei();                  /* enable interrupts */

    IDE_init();			    /* initialize the IDE interface */
    TimersInit();			/* start any counter/timers running */
    Q_init_all();		    /* initialize the queues */

    LCD_init();				/* initialize the LCD display */    
	DisplayName();          /* write player's name string on LCD display */
	DisplayWait();    		/* display "please wait" on the LCD */

    Delayms(250);			/* allow the harddrive to settle (250 ms) */
    FAT32_init();		    /* now initialize the code's fat32 various parameters */
    GetFatParams();		    /* get the basic FAT32 parameters off the drive */
    
    FSC_init();				/* initialize the FeedSTcodec routine variables & defaults */
    PC_init();				/* initialize the PlayControl routine variables & defaults, writes to LCD */
           
    uart0_putwaitPROGstr(PSTR("\r\n\nStart. ? for help.\r\n"));		/* debug port message */


	// Recount files and rebuild FastFind table etc if required (if eeprom stored dir cluster # invalid).
	CURRENT_DIRCL = (((u32)EEPROM_ReadC(DIRcluster3))<<24) + (((u32)EEPROM_ReadC(DIRcluster2))<<16) + \
                    (((u32)EEPROM_ReadC(DIRcluster1))<<8) + (u32)EEPROM_ReadC(DIRcluster0);
    if ((CURRENT_DIRCL == 0) || (CURRENT_DIRCL == 0xffffffff)) { // if invalid directory cluster # in eeprom then...
        CURRENT_DIRCL = 2;                                  // point to root directory starting cluster
        EEPROM_Write(DIRcluster0, (u08)(CURRENT_DIRCL));	// write root dir cluster number low-byte into eeprom
        EEPROM_Write(DIRcluster1, (u08)(CURRENT_DIRCL>>8));
        EEPROM_Write(DIRcluster2, (u08)(CURRENT_DIRCL>>16));
        EEPROM_Write(DIRcluster3, (u08)(CURRENT_DIRCL>>24)); // write root dir cluster number high-byte in eeprom
        CntMP3files();			                             // count how many MP3s in the root directory
        BuildFastFindTable();                                // build the FastFind table for the root directory
        }

    MenusInit();            // Perform any menu functions initializations
	DisplayReady();			/* make it clear to user we're ready to rock'n'roll */
    IDE_AutoPD();		    /* allow the drive to auto power-down */

	        
        
    /* This is the main loop */
    /* Yes there are a lot of StreamFileC's and FeedSTcodec's, but that's because I want to */
    /* ensure most of the CPU time is spent doing those two things; they are the "heart" of */
    /* the player and very sensitive to any delays. */
    
    while (1) {
    	StreamFileC();				/* read files off disk and into queue */
    	FeedSTcodec();				/* read MP3 files out of queue & give to STA013 */
    	PlayControl();				/* control the MP3 player (start, stop, etc) */
    	FeedSTcodec();				/* read MP3 files out of queue & give to STA013 */
    	StreamFileC();				/* read files off disk and into queue */
        IR_CheckTimeout();          // checks for IR received sequence timeout
    	FeedSTcodec();				/* read MP3 files out of queue & give to STA013 */
    	HandleButtons();			/* detects & responds to pushbuttons */	
    	StreamFileC();				/* read files off disk and into queue */
    	FeedSTcodec();				/* read MP3 files out of queue & give to STA013 */
    }
} 





void StopOnError (u08 errorcode)
/* Jump to this routine if you detect an error that you cannot handle. */
/* This routine will print a message out the debug port with the passed-in */
/* error number, then halt (ie loop forever). */
{
	// Print message on LCD display
	UART1_TxCharWaitC(0x5c);
	UART1_TxCharWaitC(0x40);
	UART1_TxCharWaitC(32);
	UART1_TxCharWaitC(0x30);					/* clear lcd display */		

	// Print stuff on debug terminal
	uart0_putwaitPROGstr(PSTR("\n\r\n\nERROR: $"));
	UART_PutHexWaitC(errorcode);
	uart0_putwaitPROGstr(PSTR("\n\r"));
    PrintDebugInfo();                           // print a bunch of debugging info
    IDE_Standby();		    					/* allow the drive to auto power-down */

	while (1);
}



// Include the other C files that make up this software. This must be at the end.
#include "mp3init.c"
#include "mp3srial.c"
#include "mp3pc.c"
#include "mp3menus.c"



⌨️ 快捷键说明

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