Facebook
From dv, 7 Years ago, written in C.
Embed
Download Paste or View Raw
Hits: 245
  1. #include "stm32f4xx.h"
  2. #include "system_stm32f4xx.h"
  3. #include "stm32f4xx_rcc.h"
  4. #include "stm32f4xx_gpio.h"
  5. #include "delay.h"
  6. #include "spi_sd.h"
  7. #include "ff.h"
  8. #include "diskio.h"
  9. #include "mp3codec.h"
  10. #include "mp3_config_pins.h"
  11. #include "vs1011_rejestry.h"
  12. #include "typy_zmiennych.h"
  13. #include "integer.h" //typy zmiennych dla fatfs
  14.  
  15. FATFS fatfs; ///* Work area (file system object) for logical drive */
  16. FIL plik;  ///* File object */
  17. FRESULT fresult; /* FatFs return code */
  18.  
  19. UINT zapisanych_bajtow = 0;
  20. UINT odczytanych_bajtow = 0;
  21. char * buffor = "123456789abcdefghijklmnoprstuwxyz\r\n";
  22. u_int8 buffor2[56000];
  23. //u_int8 buffor3[56000];
  24.  
  25. u_int8 i=0,k=0;
  26.  
  27. int main( void )
  28. {
  29.     SystemInit();
  30.     SPI_SD_Init();
  31.     MP3_CONFIG_PIN();
  32.  
  33.     GPIO_InitTypeDef gpio; // obiekt gpio z konfiguracja portow GPIO
  34.  
  35.     RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOD,ENABLE);  // uruchomienie zegara modulu GPIO
  36.  
  37.     GPIO_StructInit(&gpio); // domyslna konfiguracja
  38.     gpio.GPIO_Pin = GPIO_Pin_12 | GPIO_Pin_13; // konfigurujemy pin 5
  39.     gpio.GPIO_PuPd = GPIO_PuPd_NOPULL;
  40.     gpio.GPIO_Mode = GPIO_Mode_OUT;
  41.     gpio.GPIO_Speed = GPIO_Speed_50MHz;
  42.     GPIO_Init(GPIOD, &gpio); // inicjalizacja modulu GPIOA
  43.  
  44.     delay_init( 168 );
  45.     delay_ms(10);
  46.     fresult = f_mount( 0, &fatfs );
  47.     if (fresult == FR_OK)
  48.     {
  49.         GPIO_SetBits(GPIOD, GPIO_Pin_12); // zapalenie diody sygnalizuje ze nastapilo poprawne zamontowanie karty
  50.  
  51.     }
  52.  
  53.     fresult = f_open( &plik, "odpal.wav",FA_READ);
  54.        fresult = f_read(&plik, buffor2, sizeof buffor2, &odczytanych_bajtow);  /* Read a chunk of source file */
  55.        fresult = f_close(&plik);
  56.        ustaw_dekoder_mp3();
  57.  
  58.     while(1)
  59.     {
  60.         SendStreamForDecode(buffor2,odczytanych_bajtow);
  61.     }
  62.     ResetSDIMode();
  63.         return 0;
  64. }
  65.  
  66. void SysTick_Handler()
  67. {
  68.         disk_timerproc();
  69. }