H.Rick

HAL_SPI_Transmit question ?

Discussion created by H.Rick on Mar 5, 2017
Latest reply on Mar 8, 2017 by H.Rick

Everybody,

 

I want to transmit data, one byte at the time with HAL_SPI_Transmit, how can I do that ?

Here's what I had done, it's doing the job but not yet correct...what do I miss here ?

Thanks

while ((f_eof(&MyFile) ==0))  
  //for(byte_counter=0;byte_counter<3516;byte_counter++)
     {        
              /* Read all lines and display it */
              fr= f_read(&MyFile, line, 512, &num_read);
          
               
                  if(fr == FR_OK)
                    {
                               count=0;
                      printf("Open ZHEN011.MP3 FR_OK!\n");               
                               //sprintf_P( temp_buffer, PSTR(" \n fr inside if==>%u"), fr );
                               //usart_pstr(temp_buffer);
                         
                          while(count<512)
                               {
                                    if (HAL_GPIO_ReadPin(GPIOE, MP3_DREQ) == 1)  //send data  honoring DREQ
                                    {
                                         //usart_pstr("DREQ = 1");
                                        
                                         for(j=0;j<32;j++)                         //32 Bytes each time
                                         {
                                              printf("Play MP3 song!");
                                              //VS1053B_WriteDAT(line[count]);
                                              Mp3SelectData();
                                              HAL_SPI_Transmit(&hspi1,line,count,1000);
                                              Mp3DeselectData();
                                           Mp3DeselectControl();
                                              count++;
                                         }
                                    }
                              }

                     }
                    
      }//end byte counter

Outcomes