Example #1
0
void Step()
{
    DSPCore_CheckExceptions();

    g_dsp.step_counter++;

#if PROFILE
    g_dsp.err_pc = g_dsp.pc;

    ProfilerAddDelta(g_dsp.err_pc, 1);
    if (g_dsp.step_counter == 1)
    {
        ProfilerInit();
    }

    if ((g_dsp.step_counter & 0xFFFFF) == 0)
    {
        ProfilerDump(g_dsp.step_counter);
    }
#endif

    u16 opc = dsp_fetch_code();
    ExecuteInstruction(UDSPInstruction(opc));

    if (DSPAnalyzer::code_flags[g_dsp.pc - 1] & DSPAnalyzer::CODE_LOOP_END)
        HandleLoop();
}
void main ( void )
{
	ADI_ETHER_HANDLE   hEthernet;
	ADI_ETHER_RESULT   etherResult;
	ADI_ETHER_DEV_INIT EtherInitData[MAX_NETWORK_IF] = { { true, &memtable[0] }, { true, &memtable[1] }}; // data-cache,driver memory
	uint32_t reg_data;
	int i, nEtherDevUsed;
	char *ether_stack_block;

	ADI_GPIO_RESULT gpio_result;
	uint32_t gpioMaxCallbacks;
	int nRet;


	/**
	 * Initialize managed drivers and/or services that have been added to
	 * the project.
	 * @return zero on success
	 */
	adi_initComponents();
	
	/**
	 * The default startup code does not include any functionality to allow
	 * core 0 to enable core 1. A convenient way to enable core 1 is to use the
	 * 'adi_core_1_enable' function.
	 */
	adi_core_1_enable();
	
	/* Begin adding your custom code here */
	g_AuxiTMIsFirstUpdated = 1;
	
	/* init CGU first time */
	CGU_Init ( MULTIPLIER_SEL, CCLK_SEL, DDRCLK_SEL );				/* CCLK=16.384*iMultiplier /1 Mhz, 16.384*iMultiplier/iDDCLKSel Mhz DDR2 CLK */
	
#if defined(__DEBUG_FILE__)
    /* open the debug file */
    pDebugFile = fopen(__DEBUG_FILE_NAME__, "w");
    if (pDebugFile == 0)
    {
    	fclose(pDebugFile);
    	return;
    }
#elif defined(__DEBUG_UART__)
    Init_UART();
#endif

    Init_PTPAuxin();

	/* configures the switches */
#if BF609_EZ_BRD
	
	DEBUG_STATEMENT ( "Configuring switches for the ethernet operation \n\n" );
	ConfigSoftSwitches();
	
#endif
	
	/* open ethernet device */
	nEtherDevUsed = ( user_net_num_ifces > MAX_NETWORK_IF ) ? MAX_NETWORK_IF : user_net_num_ifces;

#if BF609_EZ_BRD
	nEtherDevUsed = 1;
#endif

	DEBUG_STATEMENT ( " init EMAC\n\n" );

	for ( i = 0; i < nEtherDevUsed; i++ )
	{
		etherResult = adi_ether_Open ( g_pDevEntry[i], &EtherInitData[i], g_pEthCallBack[i], &hEthernet );
		if ( etherResult != ADI_ETHER_RESULT_SUCCESS )
		{
			DEBUG_STATEMENT ( "adi_ether_Open: failed to open ethernet driver\n\n" );
			return ;
		}
		
		g_hDev[i] = hEthernet;
		
		/* get the mac address */
		memcpy ( ( ( ADI_EMAC_DEVICE * ) hEthernet )->MacAddress, user_net_config_info[i].hwaddr, 6 );

		/* allocate memory  */
		ether_stack_block = heap_malloc ( i+1, g_contEthHeapSize[i] );
		if ( ether_stack_block == NULL )
		{
			DEBUG_PRINT ( " heap_malloc: in heap %d, failed to allocate memory to the stack \n\n" , i+1);
			return ;
		}
		
		/* init buf mem */
		nRet = InitBuff ( g_contEthHeapSize[i],
				ether_stack_block, hEthernet,
				&user_net_config_info[i] );
		if( nRet<0 )
		{
			DEBUG_STATEMENT ( " InitBuff: failed to enable Init Buffs\n\n" );
			return ;
		}

		/* Enable the MAC */
		etherResult = adi_ether_EnableMAC ( hEthernet );
		if ( etherResult != ADI_ETHER_RESULT_SUCCESS )
		{
			DEBUG_STATEMENT ( " adi_ether_EnableMAC: failed to enable EMAC\n\n" );
			return ;
		}
	}
	
	//enable EMAC INT
	adi_int_EnableInt ( ( (ADI_EMAC_DEVICE *)g_hDev[0])->Interrupt, true);
	adi_int_EnableInt ( ( (ADI_EMAC_DEVICE *)g_hDev[1])->Interrupt, true);

	/* activate rx channel DMA */
	enable_rx ( g_hDev[0] );
	enable_rx ( g_hDev[1] );
	/* activate tx channel DMA */
	enable_tx ( g_hDev[0] );
	enable_tx ( g_hDev[1] );

	//enable emac0 tx,rx
	enable_emac_tx_rx (  g_hDev[0] );

	//enable emac1 tx,rx
	enable_emac_tx_rx (  g_hDev[1] );

	//enable
	Enable_Time_Stamp_Auxin_Interrupt();

	//
	HandleLoop();

	return ;

}//main