int main(void) { // open the device AFP_Error = ADIM29W64DEntryPoint.adi_pdd_Open( NULL, // DevMgr handle 0, // pdd entry point NULL, // device instance NULL, // client handle callback identifier ADI_DEV_DIRECTION_BIDIRECTIONAL,// data direction for this device NULL, // DevMgr handle for this device NULL, // handle to DmaMgr for this device NULL, // handle to deferred callback service NULL ); // client's callback function // setup the device so the DSP can access it if (SetupForFlash() != NO_ERR) return FALSE; // allocate AFP_Buffer if (( AFP_Error = AllocateAFPBuffer()) != NO_ERR) return FALSE; // get sector map if (( AFP_Error = GetSectorMap())!= NO_ERR) return FALSE; // get flash manufacturer & device codes, title & desc if (( AFP_Error = GetFlashInfo()) != NO_ERR) return FALSE; // command processing loop while ( !bExit ) { // the plug-in will set a breakpoint at "AFP_BreakReady" so it knows // when we are ready for a new command because the DSP will halt // // the jump is used so that the label will be part of the debug // information in the driver image otherwise it may be left out // since the label is not referenced anywhere asm("AFP_BreakReady:"); asm("nop;"); if ( FALSE ) asm("jump AFP_BreakReady;"); // Make a call to the ProcessCommand AFP_Error = ProcessCommand(); } //Clear the AFP_Buffer FreeAFPBuffer(); //Close the Device AFP_Error = ADIM29W64DEntryPoint.adi_pdd_Close(NULL); return TRUE; }
ERROR_CODE SetToPageMode(void) { SetupForFlash(); GetCodes(); *pEBIU_AMGCTL = 0x0000; /* disable the Async Memory */ /* Set the mode to async Mode (0-async mode, 1-flash mode, 2-page mode, 3-burst mode) */ *pEBIU_MODE = ( B0MODE_PAGE | B1MODE_PAGE | B2MODE_PAGE | B3MODE_PAGE ); *pEBIU_FCTL = ( PGWS | BCLK ); *pEBIU_AMGCTL = ( AMCKEN | AMBEN ); /* enable the Async Memory */ ssync(); SetRCR ( uwRCR_Default ); ResetFlash(); return NO_ERR; }
ERROR_CODE SetToBurstMode(void) { u16 uwRCRtmp; SetupForFlash(); GetCodes(); *pEBIU_AMGCTL = 0x0000; /* disable the Async Memory */ /* Set the mode to async Mode (0-async mode, 1-flash mode, 2-page mode, 3-burst mode) */ *pEBIU_MODE = ( B0MODE_BURST | B1MODE_BURST | B2MODE_BURST | B3MODE_BURST ); *pEBIU_FCTL = ( BCLK ); *pEBIU_AMGCTL = ( AMCKEN | AMBEN ); /* enable the Async Memory */ ssync(); uwRCRtmp = uwRCR_Default & 0x05F0; uwRCRtmp |= 0x0003; uwRCRtmp |= 3 << 11; SetRCR ( uwRCRtmp ); ResetFlash(); return NO_ERR; }
int main(void) { SECTORLOCATION *pSectorInfo; ERROR_CODE Result; // result /* open flash driver */ AFP_Error = m25p16_Open(); // setup the device so the DSP can access it if (SetupForFlash() != NO_ERR) return FALSE; // get flash manufacturer & device codes, title & desc if( AFP_Error == NO_ERR ) { AFP_Error = GetFlashInfo(); } // get the number of sectors for this device if( AFP_Error == NO_ERR ) { AFP_Error = GetNumSectors(); } if( AFP_Error == NO_ERR ) { // malloc enough space to hold our start and end offsets pSectorInfo = (SECTORLOCATION *)malloc(AFP_NumSectors * sizeof(SECTORLOCATION)); } // allocate AFP_Buffer if( AFP_Error == NO_ERR ) { AFP_Error = AllocateAFPBuffer(); } // get sector map if( AFP_Error == NO_ERR ) { AFP_Error = GetSectorMap(pSectorInfo); } // point AFP_SectorInfo to our sector info structure if( AFP_Error == NO_ERR ) { AFP_SectorInfo = (int*)pSectorInfo; } // command processing loop while ( !bExit ) { // the plug-in will set a breakpoint at "AFP_BreakReady" so it knows // when we are ready for a new command because the DSP will halt // // the jump is used so that the label will be part of the debug // information in the driver image otherwise it may be left out // since the label is not referenced anywhere asm("AFP_BreakReady:"); asm("nop;"); if ( FALSE ) asm("jump AFP_BreakReady;"); // Make a call to the ProcessCommand AFP_Error = ProcessCommand(); } // Clear the AFP_Buffer FreeAFPBuffer(); if( pSectorInfo ) { free(pSectorInfo); pSectorInfo = NULL; } // Close the Device AFP_Error = m25p16_Close(); if (AFP_Error != NO_ERR) return FALSE; return TRUE; }