Interface for using the "Life Time TImer" functionality of the Periodic Interrut Timer on Teensy 4.x microcontrollers. The module uses Channel 0 and 1 of the 4 PIT channels.
More...
#include <lifetime_timer.hpp>
|
| PIT_LifetimeTimer () |
|
void | init () __attribute__((always_inline)) |
| Sets up Timer 0 and Timer 1 channels for Lifetime timing - chained configuration. This function also makes a call to enable PIT timers. The timers are aet at maximum values and will start downcounting once PIT_LifetimeTimer::start() method is called. More...
|
|
void | start () __attribute__((always_inline)) |
| Starts the timers for down counting. More...
|
|
void | stop () __attribute__((always_inline)) |
| Stops the timers from counting. The timers values will freeze. More...
|
|
void | reset () __attribute__((always_inline)) |
| Stops the timers and resets the timer back to the init value (max) - 0xFFFFFFFFFFFFFF. More...
|
|
uint64_t | read_val () __attribute__((always_inline)) |
| Returns the complete 64-bit timing value. More...
|
|
uint32_t | read_low_val () __attribute__((always_inline)) |
| Returns the lower 32-bit half of the 64-bit timing value. More...
|
|
uint32_t | read_high_val () __attribute__((always_inline)) |
| Returns the higher 32-bit half of the 64-bit timing value. More...
|
|
uint64_t | elapsed64 () __attribute__((always_inline)) |
| Returns the elapsed duration from the start call of the timer. The return is the complete 64bit value. More...
|
|
uint32_t | elapsed32 () __attribute__((always_inline)) |
| Returns the elapsed duration from the start call of the timer. The return is the lower 32-bit half elapsed time value. More...
|
|
Interface for using the "Life Time TImer" functionality of the Periodic Interrut Timer on Teensy 4.x microcontrollers. The module uses Channel 0 and 1 of the 4 PIT channels.
- Attention
- The module has no checks on the use of CH0 and CH1 by external drivers, however, the interface enforces a singleton template and can only be constructed once.
-
The module does not set the clock frequency and uses either the default or the one set globally (as is the only use case) by external drivers outside its scope.
-
Source : Code adapted from IMXRT Manual Page 2977.
- Todo:
- Resolve Singleton template - constexpr static issue.
◆ PIT_LifetimeTimer()
PIT_LifetimeTimer::PIT_LifetimeTimer |
( |
| ) |
|
|
inline |
◆ elapsed32()
uint32_t PIT_LifetimeTimer::elapsed32 |
( |
| ) |
|
|
inline |
Returns the elapsed duration from the start call of the timer. The return is the lower 32-bit half elapsed time value.
- Warning
- If the elapsed duration is greater than the 32-bit rollover time, then the quantity returned is meaningless. Hence, use of this function should be reserved for measuring small time durarions.
◆ elapsed64()
uint64_t PIT_LifetimeTimer::elapsed64 |
( |
| ) |
|
|
inline |
Returns the elapsed duration from the start call of the timer. The return is the complete 64bit value.
◆ init()
void PIT_LifetimeTimer::init |
( |
| ) |
|
|
inline |
Sets up Timer 0 and Timer 1 channels for Lifetime timing - chained configuration. This function also makes a call to enable PIT timers. The timers are aet at maximum values and will start downcounting once PIT_LifetimeTimer::start() method is called.
- Attention
- Reference : Code adapted from IMXRT Manual Page 2977.
-
The timers will operate at the clock frequency set for PIT timers outside this library.
◆ read_high_val()
uint32_t PIT_LifetimeTimer::read_high_val |
( |
| ) |
|
|
inline |
Returns the higher 32-bit half of the 64-bit timing value.
◆ read_low_val()
uint32_t PIT_LifetimeTimer::read_low_val |
( |
| ) |
|
|
inline |
Returns the lower 32-bit half of the 64-bit timing value.
◆ read_val()
uint64_t PIT_LifetimeTimer::read_val |
( |
| ) |
|
|
inline |
Returns the complete 64-bit timing value.
◆ reset()
void PIT_LifetimeTimer::reset |
( |
| ) |
|
|
inline |
Stops the timers and resets the timer back to the init value (max) - 0xFFFFFFFFFFFFFF.
◆ start()
void PIT_LifetimeTimer::start |
( |
| ) |
|
|
inline |
Starts the timers for down counting.
◆ stop()
void PIT_LifetimeTimer::stop |
( |
| ) |
|
|
inline |
Stops the timers from counting. The timers values will freeze.
The documentation for this class was generated from the following file: