DIY Auto-Correlator 1.0
Auto-Correlator Card implementation using Teensy 4.x microcontrollers.
Public Member Functions | Static Public Member Functions | Public Attributes | Static Public Attributes | List of all members
PITController< ChID > Class Template Reference

Interface for PIT timers on Teensy 4.x microcontrollers. More...

#include <pit.hpp>

Public Member Functions

 PITController ()
 
void start () __attribute__((always_inline))
 Start counting on the timer. More...
 
void stop () __attribute__((always_inline))
 stop counting on the timer. More...
 
Error_t set_gate_time (double gt_microseconds) __attribute__((flatten))
 Sets the gate time after which the counter returns to zero and marks the end of onegate interval. More...
 
double period_error_us () const __attribute__((always_inline))
 Returns the error in the gate timing period due to the finite resolution of the timers. @Return Error in microseconds. More...
 
double tick_period_us () __attribute__((always_inline))
 Returns the value of one Tick - Minimum resolution of the timer. More...
 
void interrupt () __attribute__((always_inline))
 Enable Interruptsthat are triggered after one gate time completion. More...
 
void no_interrupt () __attribute__((always_inline))
 Disable Interrupts that are triggered after one gate time completion. More...
 
void clear_interrupt_flag () __attribute__((always_inline))
 Clears the interrupt flag and hence prepares the timer for the next gate interval. The clearing has to be done manually. If the flag is not cleared, the interrupt will be called again and again. More...
 
void sel_FBUS_clock () __attribute__((always_inline))
 Sets the clock source frequency of all PIT channels to the value F_BUS_ACTUAL (= F_CPU_ACTUAL / 4 ) which is nominally 150 MHz. The exact value depends on the CPU clock rate. More...
 
void sel_24MHz_clock () __attribute__((always_inline))
 Sets the source clock frequency of all PIT channels to 24 MHz which is the default oscillator clock. This setting is also the default state, if no clock is selected. More...
 

Static Public Member Functions

static void enable_PITs () __attribute__((always_inline))
 Enable all PIT channels. More...
 
static void disable_PITs () __attribute__((always_inline))
 Disable all PIT Channels. More...
 
static void pause_resume_PITs () __attribute__((always_inline))
 Pause/Resume - Toggle all PIT Channels. More...
 
unsigned static int get_xbar_in_pin () __attribute__((always_inline))
 Returns the correspoding XBAR1-A Input Pins for the corresponding channel TRIGGER signal. More...
 
static void set_interrupt (void(*isr_fn)(), unsigned int priority) __attribute__((always_inline))
 Sets a common ISR and its priority for all PIT Channels. More...
 

Public Attributes

double Actual_period = 0
 Actual Time Period set by the device due to finite resolution. More...
 
double Req_period = 0
 Time Period requested by the user. More...
 
uint32_t Clk_freq = uint32_t(24 * 1e6)
 Clock frequency used by the timer. Initalized to 24MHz → default oscillator clock. More...
 
uint32_t LoadVal = 0
 The value loaded in to the counter during after overflow. More...
 

Static Public Attributes

static constexpr const uint32_t PIT_MAX_COUNTER = 4294967295
 Constant - Maximum possible counter value. 32 bit counter. More...
 

Detailed Description

template<unsigned int ChID>
class PITController< ChID >

Interface for PIT timers on Teensy 4.x microcontrollers.

Constructor & Destructor Documentation

◆ PITController()

template<unsigned int ChID>
PITController< ChID >::PITController ( )
inline

Member Function Documentation

◆ clear_interrupt_flag()

template<unsigned int ChID>
void PITController< ChID >::clear_interrupt_flag ( )
inline

Clears the interrupt flag and hence prepares the timer for the next gate interval. The clearing has to be done manually. If the flag is not cleared, the interrupt will be called again and again.

◆ disable_PITs()

template<unsigned int ChID>
static void PITController< ChID >::disable_PITs ( )
inlinestatic

Disable all PIT Channels.

◆ enable_PITs()

template<unsigned int ChID>
static void PITController< ChID >::enable_PITs ( )
inlinestatic

Enable all PIT channels.

◆ get_xbar_in_pin()

template<unsigned int ChID>
unsigned static int PITController< ChID >::get_xbar_in_pin ( )
inlinestatic

Returns the correspoding XBAR1-A Input Pins for the corresponding channel TRIGGER signal.

Attention
Reference - Manual Page 63.
This function does not initalize the xbar channels. It only returns the corresponding pin.

◆ interrupt()

template<unsigned int ChID>
void PITController< ChID >::interrupt ( )
inline

Enable Interruptsthat are triggered after one gate time completion.

◆ no_interrupt()

template<unsigned int ChID>
void PITController< ChID >::no_interrupt ( )
inline

Disable Interrupts that are triggered after one gate time completion.

◆ pause_resume_PITs()

template<unsigned int ChID>
static void PITController< ChID >::pause_resume_PITs ( )
inlinestatic

Pause/Resume - Toggle all PIT Channels.

◆ period_error_us()

template<unsigned int ChID>
double PITController< ChID >::period_error_us ( ) const
inline

Returns the error in the gate timing period due to the finite resolution of the timers. @Return Error in microseconds.

◆ sel_24MHz_clock()

template<unsigned int ChID>
void PITController< ChID >::sel_24MHz_clock ( )
inline

Sets the source clock frequency of all PIT channels to 24 MHz which is the default oscillator clock. This setting is also the default state, if no clock is selected.

Warning
This will change the clock source for all 4 PITs and also the 2 GPTs.

◆ sel_FBUS_clock()

template<unsigned int ChID>
void PITController< ChID >::sel_FBUS_clock ( )
inline

Sets the clock source frequency of all PIT channels to the value F_BUS_ACTUAL (= F_CPU_ACTUAL / 4 ) which is nominally 150 MHz. The exact value depends on the CPU clock rate.

Warning
This will change the clock source for all 4 PITs and also the 2 GPTs.

◆ set_gate_time()

template<unsigned int ChID>
Error_t PITController< ChID >::set_gate_time ( double  gt_microseconds)
inline

Sets the gate time after which the counter returns to zero and marks the end of onegate interval.

Attention
In case of an error, the gate time is set to the maximum.
The clock source must be selected before calling this function.

◆ set_interrupt()

template<unsigned int ChID>
static void PITController< ChID >::set_interrupt ( void(*)()  isr_fn,
unsigned int  priority 
)
inlinestatic

Sets a common ISR and its priority for all PIT Channels.

Note
All PIT channels share a single ISR on Teensy 4.x micro-controllers.

◆ start()

template<unsigned int ChID>
void PITController< ChID >::start ( )
inline

Start counting on the timer.

◆ stop()

template<unsigned int ChID>
void PITController< ChID >::stop ( )
inline

stop counting on the timer.

◆ tick_period_us()

template<unsigned int ChID>
double PITController< ChID >::tick_period_us ( )
inline

Returns the value of one Tick - Minimum resolution of the timer.

Member Data Documentation

◆ Actual_period

template<unsigned int ChID>
double PITController< ChID >::Actual_period = 0

Actual Time Period set by the device due to finite resolution.

◆ Clk_freq

template<unsigned int ChID>
uint32_t PITController< ChID >::Clk_freq = uint32_t(24 * 1e6)

Clock frequency used by the timer. Initalized to 24MHz → default oscillator clock.

◆ LoadVal

template<unsigned int ChID>
uint32_t PITController< ChID >::LoadVal = 0

The value loaded in to the counter during after overflow.

◆ PIT_MAX_COUNTER

template<unsigned int ChID>
constexpr const uint32_t PITController< ChID >::PIT_MAX_COUNTER = 4294967295
staticconstexpr

Constant - Maximum possible counter value. 32 bit counter.

◆ Req_period

template<unsigned int ChID>
double PITController< ChID >::Req_period = 0

Time Period requested by the user.


The documentation for this class was generated from the following file: