Пример #1
0
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;
}
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;
}