コード例 #1
0
int main(void)
{

	/**
	 * 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. 
	 */

	/* Begin adding your custom code here */
	*pREG_PORTG_DIR|=0x8000;
	*pREG_PORTG_DIR|=0x4000;
	*pTCNTL   = 1;                                   /* Turn on timer, TMPWR                           */
	*pTSCALE  = 0;                                   /* Load scale                                     */
	*pTCOUNT  = 500000;//200000;                              /* Load counter                                   */
	*pTPERIOD = 500000;//200000;                              /* Load counter into period as well               */
     UART::init();
	    adi_rtl_register_dispatched_handler(ADI_RTL_CORE_IID(INT_TMR),
	    		                            OS::system_timer_isr,
	                                        NULL);
	    adi_rtl_activate_dispatched_handler(ADI_RTL_CORE_IID(INT_TMR));



	    adi_rtl_register_dispatched_handler (ADI_RTL_CORE_IID(INT_IVG14),
	   	    		                     context_switcher_isr,
	   	                                 NULL);
	    adi_rtl_activate_dispatched_handler(ADI_RTL_CORE_IID(INT_IVG14));

	   SetupGPTimer(0,TimerMemory,TimerHandler,&hTimer,5000000,1000000);
	   adi_sec_SetCoreID(INTR_TIMER0_TMR0, ADI_SEC_CORE_0);
	   *pTCNTL   = 0x7;
	   adi_tmr_EnableDataInt(&hTimer,true);
    OS::run();
	return 0;
}
コード例 #2
0
ファイル: test_Core0.cpp プロジェクト: John-Titor/scmrtos
void SetupGPTimer(unsigned int nTimerNum,void *const pMemory,ADI_CALLBACK pfCallback, ADI_TMR_HANDLE *const phTimer,
		          uint32_t nPeriod,uint32_t nWidth)
{
	ADI_TMR_RESULT 	 eTmrResult;
/* Open the timer */
           if( (eTmrResult = adi_tmr_Open (nTimerNum,
                       		pMemory,
                       		ADI_TMR_MEMORY,
                       		pfCallback,
                       		NULL,
                       		phTimer)) != ADI_TMR_SUCCESS)
            {
                /* Failed to open the timer handle the error here */
            }

           /*
            * Use the GP timer's API's to configure and enable the timer
            *
            */
           eTmrResult = adi_tmr_EnableDataInt(*phTimer,false);
           eTmrResult = adi_tmr_EnableStatusInt(*phTimer,false);
       	/* Set the mode to PWM OUT */
           eTmrResult = adi_tmr_SetMode(*phTimer, ADI_TMR_MODE_CONTINUOUS_PWMOUT);

           /* Set the IRQ mode to get interrupt after counts till TMR_PERIOD register value */
           eTmrResult = adi_tmr_SetIRQMode(*phTimer, ADI_TMR_IRQMODE_PERIOD);
           /* Set the Period */
           eTmrResult = adi_tmr_SetPeriod(*phTimer,nPeriod);

           /* Set the timer width */
       	   eTmrResult = adi_tmr_SetWidth(*phTimer, nWidth);

       	   /* Enable the timer */
       	   eTmrResult = adi_tmr_Enable(*phTimer, true);


}