• AVR Freaks

SST26 SQI Only Read Data Problem

Author
ugurortac
New Member
  • Total Posts : 2
  • Reward points : 0
  • Joined: 2018/05/21 05:26:48
  • Location: 0
  • Status: offline
2018/07/31 08:12:58 (permalink)
0

SST26 SQI Only Read Data Problem

I using Microchip EF Starter Kit and Harmony. APP_SQI_STATE_SST26_READ_DONE inside  appData.operationComplete flag is always false.
 
But works good if the write operation is performed first. I need the only read mamory.
 

#include "app.h"

APP_DATA appData;
static uint32_t __attribute__ ((coherent, aligned (16))) app_sst26_write_buffer[XFER_SIZE];
static uint32_t __attribute__ ((coherent, aligned (16))) app_sst26_read_buffer[XFER_SIZE];

void APP_SST26EventHandler
(
 DRV_SST26_EVENT event,
    DRV_SST26_COMMAND_HANDLE commandHandle,
    uintptr_t contextHandle
)
{
 switch(event)
    {
  case DRV_SST26_EVENT_COMMAND_COMPLETE:
  {
   appData.operationComplete = true;

   break;
        }
  
        case DRV_SST26_EVENT_COMMAND_ERROR:
  {
   appData.operationComplete = false;
   
   break;
  }

        default:
   
   break;
    }
}

static void SST26_Task(void)
{
 SYS_FS_MEDIA_GEOMETRY * sst26Geometry;
 uint32_t eraseBlockSize, writeBlockSize, readBlockSize;

    switch (appData.sst26StateMachine)
    {
        default:

  case APP_SQI_STATE_SST26_GET_GEOMETRY:
  {
   sst26Geometry = DRV_SST26_GeometryGet(appData.handleSST26);
   
   eraseBlockSize = (sst26Geometry->geometryTable +2)->blockSize;
   writeBlockSize = (sst26Geometry->geometryTable +1)->blockSize;
   readBlockSize = sst26Geometry->geometryTable->blockSize;
   
   appData.eraseStartBlock = SST26_BLOCK_START_ADDRESS/eraseBlockSize;
   appData.writeStartBlock = SST26_BLOCK_START_ADDRESS/writeBlockSize;
   appData.readStartBlock = SST26_BLOCK_START_ADDRESS/readBlockSize;
   
   appData.numEraseBlocks = (XFER_SIZE > eraseBlockSize)? XFER_SIZE/eraseBlockSize : 1;
   appData.numWriteBlocks = XFER_SIZE/writeBlockSize;
   appData.numReadBlocks = XFER_SIZE/readBlockSize;
   
   appData.sst26StateMachine = APP_SQI_STATE_SST26_READ;
   
   break;
  }

  case APP_SQI_STATE_SST26_READ:
  {
   appData.operationComplete = false;
   
   DRV_SST26_Read(appData.handleSST26, &appData.cmdHandleSST26, app_sst26_read_buffer, appData.readStartBlock, appData.numReadBlocks);
   
   if(DRV_SST26_COMMAND_HANDLE_INVALID != appData.cmdHandleSST26)
   {
    appData.sst26StateMachine = APP_SQI_STATE_SST26_READ_DONE;
   }
   else
   {
   }

   break;
  }

  case APP_SQI_STATE_SST26_READ_DONE:
  {
   if (appData.operationComplete)
   {
    appData.compareStatus = memcmp(app_sst26_read_buffer, app_sst26_write_buffer, XFER_SIZE);
    
                
    if (appData.compareStatus == 0)
    {
     appData.sst26StateMachine = APP_SQI_STATE_DONE;
    }
    else
    {
     appData.sst26StateMachine = APP_SQI_STATE_ERROR;
    }
   }

   break;
  }
  
  case APP_SQI_STATE_ERROR:
        
   break;
  
  case APP_SQI_STATE_DONE:
        
   break;
  
    }
}


void APP_Initialize ( void )
{
    appData.state = APP_STATE_INIT;

    appData.handleSST26 = DRV_HANDLE_INVALID;

}



void APP_Tasks ( void )
{
    switch ( appData.state )
    {
 
        case APP_STATE_INIT:
        {
            bool appInitialized = true;
       
            if (DRV_HANDLE_INVALID == appData.handleSST26)
            {
                appData.handleSST26 = DRV_SST26_Open(DRV_SST26_INDEX_0, DRV_IO_INTENT_READWRITE);
                appInitialized &= (DRV_HANDLE_INVALID != appData.handleSST26);
            }
        
            if (appInitialized)
            {
    
    DRV_SST26_EventHandlerSet(appData.handleSST26, APP_SST26EventHandler, 0);

               
                appData.sst26StateMachine = APP_SQI_STATE_SST26_GET_GEOMETRY;
            
                appData.state = APP_STATE_SERVICE_TASKS;
            }
            break;
        }

        case APP_STATE_SERVICE_TASKS:
        {
           
            SST26_Task();
        
            break;
        }
      
        default:
        {
          
            break;
        }
    }
}

 
I check the problem drv_sst26.c inside code block DRV_SST26_TRANSFER case "done" flag is always false.
 
 case DRV_SST26_TRANSFER:
            {
                bufferObj = dObj->currentBufObj;
                cmdStatus = gSst26XferFuncPtr[bufferObj->opType](dObj, &bufferObj->buffer[0], bufferObj->blockStart, bufferObj->nBlocks);
                if (cmdStatus == DRV_SQI_COMMAND_COMPLETED)
                {
                    bufferObj->status = DRV_SST26_COMMAND_COMPLETED;
                    /* The operation has completed. */
                    dObj->state = DRV_SST26_PROCESS_QUEUE;
                    done = true;
                    event = DRV_SQI_EVENT_COMMAND_COMPLETE;
                }
                else if (cmdStatus == DRV_SQI_COMMAND_ERROR_UNKNOWN)
                {
                    /* The operation has failed. */
                    bufferObj->status = DRV_SST26_COMMAND_ERROR_UNKNOWN;
                    dObj->state = DRV_SST26_ERROR;
                    done = true;
                    event = DRV_SQI_EVENT_COMMAND_ERROR;
                }
                else
                {
                    /* Continue to remain in the same state. */
                }

                if (done)
                {
                    bufferObj->inUse = false;
                    DRV_SST26_UpdateQueue (dObj);

                    clientObj = (DRV_SST26_CLIENT_OBJECT *)bufferObj->hClient;
                    if(clientObj->eventHandler != NULL)
                    {
                        /* Call the event handler */
                        clientObj->eventHandler(event, bufferObj->commandHandle, clientObj->context);
                    }
                }
                break;
            }
 
 
 
#1
Jump to:
© 2019 APG vNext Commercial Version 4.5