void main(void) { manuel = 0; count = 0; time = 402; PLLInit(); PeriphInit(); TimerInit(); //Output Compare TIM_TIOS_IOS0 = TRUE; // Enable Output compare Port 0 // Configure time for Output Compare 0 TIM_TC0 = TIM_TCNT + 10; //Enable Timer Interrupt Output Compare 0 TIM_TIE_C0I = TRUE; // SCI - 2 = Enable recieve interrupt, C = Enable Recieve/Transmit SCI0CR2 = 0x2C; PORTA = 0x00; EnableInterrupts; for(;;) { if(sciRxReady) { count = strcmp(sciRxBuffer, "Sudo!!"); if(!count){ PORTA_PA0 = 1; TIM_TIE_C0I = FALSE; } else{ PORTA_PA0 = 0; TIM_TIE_C0I = TRUE; } (void) memset(&sciRxBuffer[0], 0, sizeof(sciRxBuffer)); sciRxIndex = 0; sciRxReady = FALSE; } if(sciRxOverflow) { PORTA_PA1 = 1; SendString(SCI_0, "Buffer overflow!\r\n\0"); SendString(SCI_0, "Erasing buffer!\r\n\0"); (void) memset(&sciRxBuffer[0], 0, sizeof(sciRxBuffer)); sciRxIndex = 0; sciRxOverflow = FALSE; } else{ PORTA_PA1 = 0; } if (manuel){ PORTA_PA3 = 1; } else{ PORTA_PA3 = 0; } } /* loop forever */ } /* please make sure that you never leave main */
//***************************************************************************** // //! \brief VS1003 Example. //! //! \param None. //! //! This function is to give an example of using VS10xx to play audio file. //! we use VS1003 as the decoder. This chip can decode WAV,MP3,WMA,MIDI audio //! files and also can record audio. But we don't give out the record functions //! since it relates much to file manipulation and seldom used. If you need this //! function, please refer to VS10xx datasheet on VLSI's official page. //! //! \return None. // //***************************************************************************** void VS10xxExample(void) { unsigned char i,s; unsigned short usDataCnt, usAudioDecTime = 0; unsigned int ulFileSize = 0, ulFileCursor = 0; AudioFileInfo tFLIF; xSysCtlClockSet(72000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ); xSysCtlDelay( 1000000 ); PeriphInit(); VS10xxSineTest(0x24, 5000000); VS10xxSineTest(0x85, 5000000); // // Open MP3 file // s = CH376FileOpen("/01.MP3"); mStopIfError(s); // // Set start volume, balance and Bass Treble Enhancement // VS10xxSetVolume( 77 ); VS10xxSetBalance( 0 ); VS10xxBassTrebleEnhance(0, 12, 0, 10); // // Get file size. (Optional) // ulFileSize = CH376GetFileSize( ); // // Single song loop // while( 1 ) { CH376ByteRead( ucBuff, 512, &usDataCnt ); // // Send audio stream to VS1003 // for(i=0;i<16;i++) { VS10xxWriteData( ucBuff + i*32 ); } ulFileCursor += usDataCnt; if(ulFileCursor == 4096) { // // Get and print file information // VS10xxGetAudioInfo(&tFLIF); printf("\n\rFile type: %d\n\rBit rate: %d kbps\n\rSample rate: %dHz", tFLIF.eFileType, tFLIF.usBitRate, tFLIF.ucSampleRate); printf("\n\rMP3 ID: %d\n\rMP3 layer: %d\n\rOther information: %x\n\r", tFLIF.ucMp3ID, tFLIF.ucMp3Layer, tFLIF.ucOtherInfo); } if((ulFileCursor % 10240) == 0) { // // Get and print decode time // usAudioDecTime = VS10xxGetDecodeTime(); printf("\rplayed time: %2d:%2ds", usAudioDecTime/60, usAudioDecTime%60); } // // If file come to the end. // if( usDataCnt==0 ) { ulFileCursor=0; // // Move file pointer to the beginning of the file // CH376ByteLocate( 0 ); // // Reset decode time // VS10xxResetDecodeTime(); } // // Key scan // switch(JoystickKeyRead()) { case JOYSTICK_KEY_SELECT: ucKeySelFlag = !ucKeySelFlag; if(ucKeySelFlag) xGPIOSPinWrite( LED_PIN, 1 ); else xGPIOSPinWrite( LED_PIN, 0 ); break; case JOYSTICK_KEY_UP: if(!ucKeySelFlag) { // // Volume increase // if(sucVolLevel<9) sucVolLevel++; VS10xxSetVolume(ucVolumeLevel[sucVolLevel]); } else { // // Treble increase // if(ssTrebleA < 7) ssTrebleA++; VS10xxBassTrebleEnhance(ssTrebleA, 12, ssBassA, 10); } break; case JOYSTICK_KEY_DOWN: if(!ucKeySelFlag) { // // Volume decrease // if(sucVolLevel!=0) sucVolLevel--; VS10xxSetVolume(ucVolumeLevel[sucVolLevel]); } else { // // Treble decrease // if(ssTrebleA > -8) ssTrebleA--; VS10xxBassTrebleEnhance(ssTrebleA, 12, ssBassA, 10); } break; case JOYSTICK_KEY_LEFT: if(!ucKeySelFlag) { // // Balance decrease // if(ssVolBalance>-254) ssVolBalance--; VS10xxSetBalance(ssVolBalance); } else { // // bass decrease // if(ssBassA>0) ssBassA--; VS10xxBassTrebleEnhance(ssTrebleA, 12, ssBassA, 10); } break; case JOYSTICK_KEY_RIGHT: if(!ucKeySelFlag) { // // balance increase // if(ssVolBalance<254) ssVolBalance++; VS10xxSetBalance(ssVolBalance); } else { // // Bass increase // if(ssBassA<15) ssBassA++; VS10xxBassTrebleEnhance(ssTrebleA, 12, ssBassA, 10); } break; default : break; } } // CH376FileClose(FALSE); }