/* * Main function. Called when startup code is done with * copying memory and setting up clocks. */ int audioToMp3(void) { GPIO_InitTypeDef GPIO_InitStructure; // SysTick interrupt each 1ms RCC_GetClocksFreq(&RCC_Clocks); SysTick_Config(RCC_Clocks.HCLK_Frequency / 1000); // GPIOD Peripheral clock enable RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); // Configure PD12, PD13, PD14 and PD15 in output pushpull mode GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13 | GPIO_Pin_14 | GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOD, &GPIO_InitStructure); // Initialize USB Host Library USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks); for(;;) { if(0==exitMp3) { USBH_Process(&USB_OTG_Core, &USB_Host); if (enum_done >= 2) { enum_done = 0; play_directory("", 0); } } //exit and disable peripherals else { //RTC_AlarmCmd(RTC_Alarm_A,DISABLE); DAC_Cmd(DAC_Channel_1, DISABLE); DAC_DMACmd(DAC_Channel_1, DISABLE); //DMAEN1 DMA_Cmd(DMA1_Stream5, DISABLE); TIM_Cmd(TIM6, DISABLE); exitMp3 = 0; mp3PlayingFlag = 0; break; } } }
int main(void) { SystemInit(); /* GPIOD Periph clock enable */ RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD, ENABLE); /* Configure PD12, PD13, PD14 and PD15 in output pushpull mode */ GPIO_InitStructure.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13| GPIO_Pin_14| GPIO_Pin_15; GPIO_InitStructure.GPIO_Mode = GPIO_Mode_OUT; GPIO_InitStructure.GPIO_OType = GPIO_OType_PP; GPIO_InitStructure.GPIO_Speed = GPIO_Speed_100MHz; GPIO_InitStructure.GPIO_PuPd = GPIO_PuPd_NOPULL; GPIO_Init(GPIOD, &GPIO_InitStructure); USBH_Init(&USB_OTG_Core, USB_OTG_FS_CORE_ID, &USB_Host, &USBH_MSC_cb, &USR_Callbacks); while(1) { USBH_Process(&USB_OTG_Core, &USB_Host); if (l==0) { l=0; //play_directory("", 0); // Filewrite(); } if (enum_done >= 2) { enum_done = 0; play_directory("", 0); } } }