6#include "./../code/software/monitor_channel.hpp"
7#include "./../code/software/histogram.hpp"
10#include "./../code/hardware/pins.hpp"
11#include "./../code/hardware/utilities.hpp"
12#include "./../code/hardware/ledpanel.hpp"
13#include "./../code/hardware/errors.hpp"
14#include "./../code/hardware/pit.hpp"
15#include "./../code/hardware/qtmr1.hpp"
16#include "./../code/hardware/perf_counter.hpp"
37 IMXRT_TMR1.CH[0].SCTRL &= ~TMR_SCTRL_IEF;
43 IMXRT_TMR1.CH[0].CNTR = 0;
50 #if ISR_PIN_TOGGLE == 1
51 digitalToggleFast(ISR_TEST_TOOGLE_PIN);
69 #if ENABLE_PERFORMANCE_COUNTERS == 1
74 #if ENABLE_SYNC_CODE == 1
75 Serial.write((uint8_t*)&(
sync_code),
sizeof(int32_t));
79 #if ENABLE_COUNT_RATE == 1
80 float mean = count_rate_mon.output();
81 Serial.write((uint8_t*)&(mean),
sizeof(
float));
85 #if (ENABLE_POINTS_NORM == 1) && (ENABLE_ACF_CALC == 1)
86 Serial.write((uint8_t*)&(
multitau.MeanMonitor.Count),
sizeof(
float));
90 #if ENABLE_MEAN_NORM == 1
91 float_t accumulate =
multitau.MeanMonitor.accumulate();
92 Serial.write((uint8_t*)&(accumulate),
sizeof(float_t));
96 #if ENABLE_ACF_CALC == 1
102 #if ENABLE_PC_HISTOGRAM == 1
108 #if ENABLE_PERFORMANCE_COUNTERS == 1
109 float_t pf_serial = Serialpf.mean();
110 Serial.write((uint8_t*)&(pf_serial),
sizeof(float_t));
112 #if ENABLE_ACF_CALC == 1
113 float_t pf_acf = ACFpf.mean();
114 Serial.write((uint8_t*)&(pf_acf),
sizeof(float_t));
146 #if ISR_PIN_TOGGLE == 1
147 pinMode(ISR_TEST_TOOGLE_PIN, OUTPUT);
153 PI_t.sel_FBUS_clock();
166 extern uint32_t
serial_max_count(
double Gate_time_u,
double Serial_out_time_ms);
172 Errors::Validate(Errors::Auto_MultiTau_Input_Validator<LIN_CORRS, SERIES_SIZE, BIN_RATIO>());
177 Serial.begin(115200);
185 asm volatile (
"dsb");
187 for(
unsigned int i = 0; i < CHANNEL_SIZE; i++)
220 asm volatile (
"dsb");
232 #if ENABLE_COUNT_RATE == 1
236 #if ENABLE_PC_HISTOGRAM == 1
240 #if ENABLE_ACF_CALC == 1
241 #if ENABLE_PERFORMANCE_COUNTERS == 1
247 #if ENABLE_PERFORMANCE_COUNTERS == 1
static Error_t Precison_Threshold(double error_val, double error_limit)
Receives error value and error threshold and returns an appropriate error state.
Definition: errors.hpp:44
static void Validate(const Error_t error)
Receives an error state and sets up the corresponding LED indicator.
Definition: errors.hpp:31
void init_pins() __attribute__((always_inline))
Sets the Primary and Secondary inputs for Capture Mode, routed through XBAR. Reference XBAR and IOMUX...
Definition: qtmr1.hpp:185
void start() __attribute__((always_inline))
Starts up-counting from the set counter value.
Definition: qtmr1.hpp:24
void init() __attribute__((always_inline))
Definition: qtmr1.hpp:107
Error_t
Enumarates the error codes thrown by the different modules.
Definition: errors.hpp:17
#define PIT_CHANNEL_IN_USE
Definition: types.hpp:12
void gt_setup()
Setup function for Initalization and setup.
Definition: featureline1.hpp:138
void isr_fn()
ISR function used for processing counter values.
Definition: featureline1.hpp:31
void gt_loop()
Loop function that processes the updates from the counters.
Definition: featureline1.hpp:208
void serial_out()
Outputs the data struct to the serial buffer.
Definition: featureline1.hpp:65
const double Gate_time_us
Serial output is done after these many updates (default → overriden in the setup function).
Definition: global.cpp:29
TMR1Controller TTL_c
TTL_c Resource.
Definition: global.cpp:19
uint32_t SerialOut_After
Definition: global.cpp:28
const int32_t sync_code
Gate time precision error due to finite precision of timers.
Definition: global.cpp:31
float array[CHANNEL_SIZE]
Definition: global.cpp:33
const double Allowed_period_error_us
The gate time of TTL_C in microseconds (us)
Definition: global.cpp:30
volatile unsigned int Update_count
Stores the number of updates made on the correlator channels since the last serialout.
Definition: global.cpp:25
PITController< PIT_CHANNEL_IN_USE > PI_t
PI_t Resource.
Definition: global.cpp:18
volatile bool Update_flag
Indicates if a new value has arrived from the counting module.
Definition: global.cpp:24
volatile counter_t Counter_val
Stores the value read from the counter.
Definition: global.cpp:23
LEDSet< 5 > LEDPanel({LED_BUILTIN, LED_RED, LED_GREEN, LED_WHITE, LED_BLUE})
Definition: multitau.py:1
const int LOOP_LED
Definition: pins.hpp:30
const int SETUP_LED
Definition: pins.hpp:29
const int TTL_C_PULSE_INPUT_PIN
Definition: pins.hpp:19
uint32_t serial_max_count(double Gate_time_us, double Serial_out_time_ms)
Definition: utilities.cpp:7