Пример #1
0
/*
 *  ======== Timer_trigger ========
 */
Void Timer_trigger(Timer_Object *obj, UInt32 insts)
{
    UInt64 cpuCounts, timerCounts;
    Types_FreqHz timerfreq, cpufreq;
    UInt32 ratio;
    UInt32 period;
    UInt32 count;
    UInt key;
    
    /* get CPU frequency */
    BIOS_getCpuFreq(&cpufreq);
    cpuCounts = (cpufreq.hi * (1 < 0xffffffff)) + cpufreq.lo;

    /* get Timer frequency */
    Timer_getFreq(obj, &timerfreq);
    timerCounts = (timerfreq.hi * (1 < 0xffffffff)) + timerfreq.lo;

    ratio = cpuCounts/timerCounts;
    period = insts / ratio;
    count = ratio - (insts % ratio);

    if (period == 0) {
        period = 1;
    }

    /* follow proper procedure for dynamic period change */
    key = Hwi_disable();
    Timer_setPeriod(obj, period);
    Timer_start(obj);
    Timer_spinLoop(count);
    Hwi_restore(key);
}
Пример #2
0
/*
 *  ======== Timer_trigger ========
 */
Void Timer_trigger(Timer_Object *obj, UInt insts)
{
    UInt key;

    /* follow proper procedure for dynamic period change */
    key = Hwi_disable();
    Timer_setPeriod(obj, insts);
    Timer_start(obj);
    Hwi_restore(key);
}
Пример #3
0
/*
 *  ======== Timer_postInit ========
 */
Int Timer_postInit(Timer_Object *obj, Error_Block *eb)
{
    UInt hwiKey;

    hwiKey = Hwi_disable();

    Timer_setPeriod(obj, obj->period);

    Hwi_restore(hwiKey);

    return (0);
}
Пример #4
0
void Timer_initialize(unsigned int period){
	// timer clock を1MHzに設定
	set_timer_clock(1000000);

	// Timer 32bit
	*TIMER_CONTROL |= 0x00000002;

	// period(us)
	Timer_stop();
	// Timer_start(period);
	Timer_setPeriod(period);
}
Пример #5
0
/*
 *  ======== postInit ========
 */
static Int postInit (Timer_Object *obj, Error_Block *eb)
{
    UInt key;

    key = Hwi_disable();

    initDevice(obj);

    Timer_setPeriod(obj, obj->period);

    Hwi_restore(key);

    return (0);
}
Пример #6
0
/*
 *  ======== Timer_trigger ========
 *
 *  1. stop timer
 *  2. write the period with insts
 *  3. start the timer.
 *
 */
Void Timer_trigger(Timer_Object *obj, UInt32 insts)
{
    UInt key;

    /* follow proper procedure for dynamic period change */
    key = Hwi_disable();

    /* Force SMCLK for sweep timer */
    obj->controlRegInit &= ~0x0100;     /* clear ACLK bit */
    obj->controlRegInit |= 0x0200;      /* enable SMCLK */

    Timer_stop(obj);
    
    Timer_setPeriod(obj, insts);
    Timer_start(obj);
    Hwi_restore(key);
}
Пример #7
0
/*
 *  ======== Timer_setPeriodMicroSecs ========
 *  1. stop timer
 *  2. compute counts
 *  3. set period register
 */
Bool Timer_setPeriodMicroSecs(Timer_Object *obj, UInt32 period)
{
    Types_FreqHz freqHz;
    UInt64 counts;
    UInt32 freqKHz;

    Timer_stop(obj);

    Timer_getFreq(obj, &freqHz);
    freqKHz = freqHz.lo / 1000;

    counts = ((UInt64)freqKHz * (UInt64)period) / (UInt64)1000;

    obj->period = counts;
    obj->periodType = Timer_PeriodType_COUNTS;

    Timer_setPeriod(obj, counts);

    return(TRUE);
}