Altera HWLIB  16.0
The Altera HW Manager API Reference Manual
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Groups
Counters Interface

Description

This functional group handles setting and reading the general purpose timer counters and the global timer.

Functions

ALT_STATUS_CODE alt_gpt_counter_set (ALT_GPT_TIMER_t tmr_id, uint32_t val)
 
uint32_t alt_gpt_counter_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_reset_value_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_maxcounter_get (ALT_GPT_TIMER_t tmr_id)
 
ALT_STATUS_CODE alt_gpt_prescaler_set (ALT_GPT_TIMER_t tmr_id, uint32_t val)
 
uint32_t alt_gpt_prescaler_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_freq_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_time_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_time_millisecs_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_time_microsecs_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_curtime_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_curtime_millisecs_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_curtime_microsecs_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_curtime_nanosecs_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_maxtime_get (ALT_GPT_TIMER_t tmr_id)
 
uint32_t alt_gpt_maxtime_millisecs_get (ALT_GPT_TIMER_t tmr_id)
 

Function Documentation

ALT_STATUS_CODE alt_gpt_counter_set ( ALT_GPT_TIMER_t  tmr_id,
uint32_t  val 
)

For tmr_id = CPU_PRIVATE_TMR, OSC1_TMR0, OSC1_TMR1, SP_TMR0, or SP_TMR1, sets the countdown value of the specified timer and the value that the counter will reset to (in rollover mode) or if restarted (in one-shot mode). It does not automatically start the counter.
For tmr_id = CPU_GLOBAL_TMR, this function sets the auto-increment value instead, which is similar in function to setting the reset value of the other timers. The effect of this function is identical to using alt_globaltmr_autoinc_set().

Parameters
tmr_idThe timer identifier.
valThe 32-bit counter value to load.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_E_BAD_ARGInvalid input argument.
uint32_t alt_gpt_counter_get ( ALT_GPT_TIMER_t  tmr_id)

For tmr_id = CPU_PRIVATE_TMR, OSC1_TMR0, OSC1_TMR1, SP_TMR0, or SP_TMR1, returns the current counter value of the specified timer.
For tmr_id = CPU_GLOBAL_TMR, returns the 32 low-order bits of the counter and is identical to the result returned by alt_globaltmr_counter_get_low32(). Use alt_globaltmr_get() to obtain the full 64-bit timer value.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current 32-bit counter value.
uint32_t alt_gpt_reset_value_get ( ALT_GPT_TIMER_t  tmr_id)

For tmr_id = CPU_PRIVATE_TMR, OSC1_TMR0, OSC1_TMR1, SP_TMR0, or SP_TMR1, returns the counter value that is set to be reloaded when the specified timer hits zero.
For tmr_id = CPU_GLOBAL_TMR, returns the value that will autoincrement the comparator value, which defines the time until the next comparator interrupt is triggered. This is similar in function to the reset value of the other timers. It is identical to the result returned by alt_globaltmr_autoinc_get().
The value returned does not take into CPU_PRIVATE_TMR and CPU_GLOBAL_TMR. The prescaler value may be obtained with alt_gpt_prescaler_get().

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe reset counter value currently set.
0An error occurred.
uint32_t alt_gpt_maxcounter_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the maximum counter value available for the specified timer. Valid for CPU_PRIVATE_TMR, OSC1_TMR0, OSC1_TMR1, SP_TMR0, SP_TMR1, and CPU_GLOBAL_TMR.
The value returned does not factor in the value of the clock prescaler available for CPU_PRIVATE_TMR and CPU_GLOBAL_TMR.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe maximum counter value available for this timer.
0An error occurred.
ALT_STATUS_CODE alt_gpt_prescaler_set ( ALT_GPT_TIMER_t  tmr_id,
uint32_t  val 
)

Sets the clock prescaler value of the specified timer. Valid for CPU_PRIVATE_TMR and CPU_GLOBAL_TMR. Returns an error if called with a tmr_id of OSC1_TMR0, OSC1_TMR1, SP_TMR0, or SP_TMR1 since they have no prescaler.

Parameters
tmr_idThe timer identifier.
valThe 32-bit prescaler value to load. Valid range is 0-255.
Return values
ALT_E_SUCCESSThe operation was successful.
ALT_E_ERRORThe operation failed.
ALT_E_BAD_ARGInvalid input argument.
uint32_t alt_gpt_prescaler_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the clock prescaler value of the specified timer. Valid for CPU_PRIVATE_TMR and CPU_GLOBAL_TMR. Returns zero if called with a tmr_id of OSC1_TMR0, OSC1_TMR1, SP_TMR0, or SP_TMR1 since they have no prescaler.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe prescaler value. Valid range is 1-256. Zero indicates an error.
uint32_t alt_gpt_freq_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the integer portion of the current countdown frequency of the specified timer. This is equal to 1/period of the specified timer.

Parameters
tmr_idThe timer identifier.
Return values
unint32_tThe integer portion of the repeat frequency of the given timer, measured in Hertz (cycles per second).
uint32_t alt_gpt_time_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the current period of the specified timer measured in seconds. If the result is less than 64, alt_gpt_millisecs_get() will give a more precise result.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current period of the given timer, measured in seconds.
uint32_t alt_gpt_time_millisecs_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the current period of the specified timer measured in milliseconds.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current period of the given timer, measured in milliseconds. Returns 0 if result cannot fit in 32 bits. alt_gpt_time_get() can be used to obtain measurements of longer periods. alt_gpt_microsecs_get() can be used to obtain more precise measurements of shorter periods.
uint32_t alt_gpt_time_microsecs_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the current period of the specified timer measured in milliseconds.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current period of the given timer, measured in microseconds. Returns 0 if result cannot fit in 32 bits. alt_gpt_millisecs_get() and alt_gpt_time_get() can be used to obtain measurements of longer periods.
uint32_t alt_gpt_curtime_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the current time until the specified timer counts down to zero, measured in seconds.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current 32-bit counter value.
uint32_t alt_gpt_curtime_millisecs_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the current time until the specified timer counts down to zero, measured in milliseconds.
Returns 0xFFFFFFFF if the value is too large to be expressed in 32 bits.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current 32-bit counter value.
uint32_t alt_gpt_curtime_microsecs_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the current time until the specified timer counts down to zero, measured in microseconds.
Returns 0xFFFFFFFF if the value is too large to be expressed in 32 bits.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current 32-bit counter value.
uint32_t alt_gpt_curtime_nanosecs_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the current time until the specified timer counts down to zero, measured in nanoseconds.
Returns 0xFFFFFFFF if the value is too large to be expressed in 32 bits.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe current 32-bit counter value.
uint32_t alt_gpt_maxtime_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the maximum available period of the specified timer measured in seconds.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe maximum period of the given timer, measured in seconds. Returns 0 if result cannot fit in 32 bits.
uint32_t alt_gpt_maxtime_millisecs_get ( ALT_GPT_TIMER_t  tmr_id)

Returns the maximum available period of the specified timer measured in milliseconds.

Parameters
tmr_idThe timer identifier.
Return values
uint32_tThe maximum period of the given timer, measured in milliseconds. Returns 0 if result cannot fit in 32 bits.