-->
Page 1 of 1

To read and write SPI Flash using Freertos SDk in ESP8266

PostPosted: Thu Feb 25, 2016 11:38 am
by Mohanraj M
Hi,
I need to read and write data from SPI flash. I am using spi_flash_read and spi_flash_write API's for read and write data. Both read and write data returns success response but unable to print the read data which was stored. Please provide me a solution to get the data which was saved.
Code: Select allsave_data(const char *name)
{
   char buff[4]={0};
   int result = -1;
   uint64_t temp;
   char *start;
   strcpy(buff,name);
   result = spi_flash_write(0x5C000,(uint32*)&buff,1);
   if(result == SPI_FLASH_RESULT_ERR)
        {
                printf("\nWrite failed...\n");
        }
        else if(result == SPI_FLASH_RESULT_OK)
        {
                printf("\nWrite success...\n");
                read_data();
        }
}


read_data()
{
   int result = -1;
   char buff[5] = {0};
   result= spi_flash_read(0x5C000,(uint32*)&buff,5);
   if(result == SPI_FLASH_RESULT_ERR)
   {
      printf("\nRead failed...321\n");   
   }
   else if(result == SPI_FLASH_RESULT_OK)
   {
      printf("\nRead success...\n");
      printf("Data  : %s\n",buff);  /*PRINTS A GARBAGE VALUE*/
   }
}