This functional group handles setting and reading various parameters of the global 64-bit incrementing counter. There is one 64-bit continuously incrementing counter for all CPU cores and it is clocked by PERIPHCLK. This section manages the comparator value, compare enable, auto-increment value, auto-increment enable, and interrupt enable for the CPU that this code is running on (referenced as CPU_GLOBAL_TMR).
ALT_STATUS_CODE alt_globaltmr_uninit |
( |
void |
| ) |
|
Uninitialize the Global timer module
ALT_STATUS_CODE alt_globaltmr_init |
( |
void |
| ) |
|
Initialize the Global timer module
ALT_STATUS_CODE alt_globaltmr_stop |
( |
void |
| ) |
|
Stops the global timer counter compare function for this CPU and disables its interrupt. It does not stop the global timer itself. This function is identical to calling alt_gpt_tmr_stop() with a tmr_id of CPU_GLOBAL_TMR.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_STATUS_CODE alt_globaltmr_start |
( |
void |
| ) |
|
Starts the global timer compare function for this CPU, enables its interrupt function and, if free-running mode is selected also enables its auto-increment function. If the global timer is not yet running, it starts the timer. This function is identical to calling alt_gpt_tmr_start() with a tmr_id of CPU_GLOBAL_TMR.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_STATUS_CODE alt_globaltmr_get |
( |
uint32_t * |
highword, |
|
|
uint32_t * |
lowword |
|
) |
| |
Returns the current counter value of the 64-bit global timer.
- Parameters
-
highword | Location used to return the most significant 32-bit word of the current global timer count. |
lowword | Location used to return the least significant 32-bit word of the current global timer count. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
uint64_t alt_globaltmr_get64 |
( |
void |
| ) |
|
Returns the current counter value of the 64-bit global timer. This function is identical to alt_globaltmr_get() except that the value is returned as a 64-bit unsigned integer rather than as two 32-bit words.
- Return values
-
uint64_t | The current value of the 64-bit counter. |
uint32_t alt_globaltmr_counter_get_low32 |
( |
void |
| ) |
|
uint32_t alt_globaltmr_counter_get_hi32 |
( |
void |
| ) |
|
ALT_STATUS_CODE alt_globaltmr_comp_set |
( |
uint32_t |
highword, |
|
|
uint32_t |
loword |
|
) |
| |
Sets the value of the 64-bit global timer comparator for this CPU. The global timer increments its count and when it reaches this value or above, it triggers the following actions. If the interrupt is enabled, it forwards an interrupt request to the core. If free-run mode is selected, it adds the auto-increment value to the value of the global counter and the resulting sum is saved as the new comparator value.
- Parameters
-
highword | The 32 MSBits of the new comparator value. |
loword | The 32 LSBits of the new comparator value. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
ALT_STATUS_CODE alt_globaltmr_comp_set64 |
( |
uint64_t |
compval | ) |
|
Sets the value of the 64-bit global timer comparator for this CPU. The global timer increments its count and when it reaches this value or above, it triggers the following actions. If the interrupt is enabled, it forwards an interrupt request to the core. If free-run mode is selected, it adds the auto-increment value to the value of the global counter and the resulting sum is saved as the new comparator value.
- Parameters
-
compval | The new comparator value to set. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
ALT_STATUS_CODE alt_globaltmr_comp_get |
( |
uint32_t * |
highword, |
|
|
uint32_t * |
lowword |
|
) |
| |
Returns the current 64-bit global timer comparator value for this CPU. The global timer increments its count and when it reaches this value or above, it triggers the following actions. If the interrupt is enabled, it forwards an interrupt request to the core. If free-run mode is selected, it adds the auto-increment value to the value of the global counter and the resulting sum is saved as the new comparator value. This value will increase by the auto-increment value each time the global timer reaches the comparator value.
- Parameters
-
highword | Pointer to location to store the 32 MSBits of the comparator value. |
lowword | Pointer to location to store the 32 LSBits of the comparator value. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
uint64_t alt_globaltmr_comp_get64 |
( |
void |
| ) |
|
Returns the current 64-bit global timer comparator value for this CPU. The global timer increments its count and when it reaches this value or above, it triggers the following actions. If the interrupt is enabled, it forwards an interrupt request to the core. If free-run mode is selected, it adds the auto-increment value to the value of the global counter and the resulting sum is saved as the new comparator value. This value will increase by the auto-increment value each time the global timer reaches the comparator value. This function is identical to alt_globaltmr_comp_get() except that the value is returned in a 64-bit unsigned integer rather than as two 32-bit words.
- Return values
-
uint64_t | The 64-bit value of the global timer comparator. |
ALT_STATUS_CODE alt_globaltmr_comp_mode_start |
( |
void |
| ) |
|
Enables the comparison function of the global timer for this CPU.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
ALT_STATUS_CODE alt_globaltmr_comp_mode_stop |
( |
void |
| ) |
|
Disables the comparison function of the global timer for this CPU.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
bool alt_globaltmr_is_comp_mode |
( |
void |
| ) |
|
Returns the comparison mode selection of the global timer for this CPU.
- Return values
-
FALSE | Comparison mode is not enabled. |
TRUE | Comparison mode is enabled. |
uint32_t alt_globaltmr_prescaler_get |
( |
void |
| ) |
|
Returns the clock prescaler value of the global timer.
- Return values
-
uint32_t | The prescaler value. Valid range is 0-255. Actual clock divisor ratio is this number plus one. |
ALT_STATUS_CODE alt_globaltmr_prescaler_set |
( |
uint32_t |
val | ) |
|
Sets the clock prescaler value of the global timer.
- Parameters
-
val | The 8-bit prescaler value to load. Valid range is 0-255. Actual clock divisor ratio is this number plus one. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
ALT_STATUS_CODE alt_globaltmr_autoinc_set |
( |
uint32_t |
inc | ) |
|
Sets a 32-bit global timer auto-increment value in the global timer block for this CPU. The global timer continually increments its count and when it reaches the value set in the comparator register or above, if both comparison and free-run modes are selected, it adds the value set by this function to the comparator value and saves it as the new comparator value. This count then sets the time delay until the next global timer compare value is reached.
- Parameters
-
inc | Auto-increment value to set. |
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
uint32_t alt_globaltmr_autoinc_get |
( |
void |
| ) |
|
Returns the global timer auto-increment value for this CPU. When the global timer reaches the comparator value, if both comparison and free-run modes are selected this value is added to the previous comparator value and saved as the new comparator value.
- Return values
-
uint32_t | The current comparator auto-increment value. |
ALT_STATUS_CODE alt_globaltmr_autoinc_mode_start |
( |
void |
| ) |
|
Enables the auto-increment function of the global timer for this CPU.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
ALT_STATUS_CODE alt_globaltmr_autoinc_mode_stop |
( |
void |
| ) |
|
Disables the auto-increment function of the global timer for this CPU.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
bool alt_globaltmr_is_autoinc_mode |
( |
void |
| ) |
|
Returns the auto-increment selection of the global timer for this CPU.
- Return values
-
FALSE | Auto-increment mode is not enabled. |
TRUE | Auto-increment mode is enabled. |
uint32_t alt_globaltmr_maxcounter_get |
( |
void |
| ) |
|
Returns the maximum counter value available for CPU_GLOBAL_TMR.
The value returned does not factor in the value of the clock prescaler.
- Return values
-
uint32_t | The maximum counter value available for this timer. |
0 | An error occurred. |
ALT_STATUS_CODE alt_globaltmr_int_disable |
( |
void |
| ) |
|
Disables the interrupt from the global timer module. Identical to calling alt_gpt_int_disable() with tmr_id of CPU_GLOBAL_TMR.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
ALT_STATUS_CODE alt_globaltmr_int_enable |
( |
void |
| ) |
|
Enables the interrupt of the global timer module. Identical to calling alt_gpt_int_enable() with tmr_id of CPU_GLOBAL_TMR. If global timer is not already running, this function attempts to start it.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
bool alt_globaltmr_int_is_enabled |
( |
void |
| ) |
|
Return TRUE if the interrupt of the global timer module is enabled and FALSE if the interrupt is disabled or masked. Identical to calling alt_gpt_int_is_enabled() with tmr_id of CPU_GLOBAL_TMR.
- Return values
-
TRUE | The timer interrupt is currently enabled. |
FALSE | The timer interrupt is currently disabled. |
ALT_STATUS_CODE alt_globaltmr_int_clear_pending |
( |
void |
| ) |
|
Clear the pending interrupt status of the global timer module. Identical to calling alt_gpt_int_clear_pending() with tmr_id of CPU_GLOBAL_TMR.
- Return values
-
ALT_E_SUCCESS | The operation was successful. |
ALT_E_ERROR | The operation failed. |
ALT_E_BAD_ARG | Invalid input argument. |
bool alt_globaltmr_int_is_pending |
( |
void |
| ) |
|
Read the state (pending or not) of the interrupt of the global timer module without changing the interrupt state. Identical to calling alt_gpt_int_is_pending() with tmr_id of CPU_GLOBAL_TMR.
- Return values
-
TRUE | The timer interrupt is currently pending. |
FALSE | The timer interrupt is not currently pending. |
bool alt_globaltmr_int_if_pending_clear |
( |
void |
| ) |
|
Read the state of the interrupt of the global timer module and if the interrupt is set, clear it. Identical to calling alt_gpt_int_is_pending_and_clear() with tmr_id of CPU_GLOBAL_TMR.
- Return values
-
TRUE | The timer interrupt was pending. |
FALSE | The timer interrupt was not pending. |