27#define DLL_EXPORT __declspec(dllexport)
29#define DLL_EXPORT extern
70#define AHP_DEBUG_INFO 0
71#define AHP_DEBUG_ERROR 1
72#define AHP_DEBUG_WARNING 2
73#define AHP_DEBUG_DEBUG 3
112#define AHP_XC_VERSION 0x144
114#define XC_BASE_RATE ((int)57600)
116#define AHP_XC_PLL_FREQUENCY 400000000
118#define AHP_XC_LEDS_MASK 0x3
DLL_EXPORT void ahp_xc_set_test_flags(uint32_t index, int32_t test)
Enable tests on the current line.
DLL_EXPORT void ahp_xc_set_voltage(uint32_t index, unsigned char value)
Set the supply voltage on the current line.
DLL_EXPORT unsigned char ahp_xc_get_test_flags(uint32_t index)
Get the current status of the test features.
DLL_EXPORT void ahp_xc_select_input(uint32_t index)
Select the input on which to issue next command.
DLL_EXPORT int32_t ahp_xc_send_command(xc_cmd cmd, unsigned char value)
Send an arbitrary command to the AHP XC device.
DLL_EXPORT void ahp_xc_set_leds(uint32_t index, int32_t leds)
Switch on or off the led lines of the correlator.
DLL_EXPORT void ahp_xc_set_channel_cross(uint32_t index, off_t value, size_t size, size_t step)
Set the channel of the selected input (for cross-correlation)
DLL_EXPORT int32_t ahp_xc_set_capture_flags(xc_capture_flags flags)
Set integration flags.
DLL_EXPORT uint32_t ahp_xc_get_version(void)
Obtain the current libahp-xc version.
Definition ahp_xc.h:749
DLL_EXPORT unsigned char ahp_xc_get_leds(uint32_t index)
Get the current status of the leds on line.
DLL_EXPORT xc_capture_flags ahp_xc_get_capture_flags()
Get integration flags.
DLL_EXPORT void ahp_xc_set_frequency_divider(unsigned char value)
Set the clock divider for autocorrelation and crosscorrelation.
DLL_EXPORT uint32_t ahp_xc_current_input()
Returns the currently selected input on which next command will be issued.
DLL_EXPORT void ahp_xc_set_channel_auto(uint32_t index, off_t value, size_t size, size_t step)
Set the channel of the selected input (for auto-correlation)
DLL_EXPORT int32_t ahp_xc_connect_fd(int32_t fd)
Connect to a serial port or other stream associated to the given file descriptor.
DLL_EXPORT int32_t ahp_xc_get_correlation_order()
Get the crosscorrelation order.
DLL_EXPORT void ahp_xc_disconnect(void)
Disconnect from the serial port or descriptor opened with ahp_xc_connect.
DLL_EXPORT void ahp_xc_set_correlation_order(uint32_t order)
Set the crosscorrelation order.
DLL_EXPORT int32_t ahp_xc_get_fd()
Obtain the serial port file descriptor.
DLL_EXPORT int32_t ahp_xc_connect(const char *port)
Connect to a serial port.
DLL_EXPORT uint32_t ahp_xc_is_detected(void)
Report if a correlator was detected.
DLL_EXPORT void ahp_xc_set_baudrate(baud_rate rate)
Obtain the current baud rate.
DLL_EXPORT uint32_t ahp_xc_is_connected(void)
Report connection status.
DLL_EXPORT int32_t ahp_xc_get_baudrate(void)
Obtain the current baud rate.
DLL_EXPORT void ahp_xc_end_autocorrelation_scan(uint32_t index)
End an autocorrelation scan.
DLL_EXPORT void ahp_xc_start_autocorrelation_scan(uint32_t index)
Initiate an autocorrelation scan.
DLL_EXPORT ahp_xc_packet * ahp_xc_alloc_packet(void)
Allocate and return a packet structure.
DLL_EXPORT ahp_xc_sample * ahp_xc_copy_samples(ahp_xc_sample *src, uint64_t nlines, size_t size)
Allocate and return a copy of the passed samples array.
DLL_EXPORT void ahp_xc_end_crosscorrelation_scan(uint32_t index)
End a crosscorrelation scan.
DLL_EXPORT int32_t ahp_xc_scan_autocorrelations(ahp_xc_scan_request *lines, uint32_t nlines, ahp_xc_sample **autocorrelations, int32_t *interrupt, double *percent)
Scan all available delay channels and get autocorrelations of each input.
DLL_EXPORT void ahp_xc_start_crosscorrelation_scan(uint32_t index)
Initiate a crosscorrelation scan.
DLL_EXPORT int32_t ahp_xc_scan_crosscorrelations(ahp_xc_scan_request *lines, uint32_t nlines, ahp_xc_sample **crosscorrelations, int32_t *interrupt, double *percent)
Scan all available delay channels and get crosscorrelations of each input with others.
DLL_EXPORT int32_t ahp_xc_get_packet(ahp_xc_packet *packet)
Grab a data packet.
DLL_EXPORT void ahp_xc_free_packet(ahp_xc_packet *packet)
Free a previously allocated packet structure.
DLL_EXPORT ahp_xc_sample * ahp_xc_alloc_samples(uint64_t nlines, size_t size)
Allocate and return a samples array.
DLL_EXPORT void ahp_xc_free_samples(uint64_t nlines, ahp_xc_sample *samples)
Free a previously allocated samples array.
DLL_EXPORT ahp_xc_packet * ahp_xc_copy_packet(ahp_xc_packet *packet)
Allocate and return a copy of a packet structure.
DLL_EXPORT void ahp_set_app_name(char *name)
set the application name
DLL_EXPORT char * ahp_get_app_name()
get the application name
DLL_EXPORT void ahp_set_debug_level(int32_t value)
set the debug level
DLL_EXPORT void ahp_set_stderr(FILE *f)
set the error log stream
DLL_EXPORT int32_t ahp_get_debug_level()
get the debug level
DLL_EXPORT void ahp_set_stdout(FILE *f)
set the output log stream
#define AHP_XC_VERSION
This library version.
Definition ahp_xc.h:112
DLL_EXPORT int32_t ahp_xc_has_crosscorrelator(void)
Returns the cross-correlation capability of the device.
DLL_EXPORT uint32_t ahp_xc_get_nbaselines(void)
Obtain the correlator total baselines.
DLL_EXPORT int32_t ahp_xc_get_properties(void)
Probe for a correlator and take its properties.
DLL_EXPORT uint32_t ahp_xc_get_packetsize(void)
Obtain the serial packet size.
DLL_EXPORT double ahp_xc_get_frequency(void)
Obtain the correlator maximum readout frequency.
DLL_EXPORT int32_t ahp_xc_intensity_crosscorrelator_enabled()
Return non-zero if intensity crosscorrelation was enabled.
DLL_EXPORT uint32_t ahp_xc_get_crosscorrelator_lagsize(void)
Obtain the correlator lag buffer size for crosscorrelations.
DLL_EXPORT uint32_t ahp_xc_get_bps(void)
Obtain the correlator bits per sample.
DLL_EXPORT int32_t ahp_xc_has_psu(void)
Returns if the device offers internal PSU line.
DLL_EXPORT int32_t ahp_xc_has_cumulative_only()
Returns if the device has cumulative correlators only.
DLL_EXPORT int32_t ahp_xc_get_crosscorrelation_index(int32_t *lines, int32_t order)
Return the cross-correlation index of the polytopes correlating the lines array.
DLL_EXPORT double ahp_xc_get_sampletime(void)
Obtain the sampling time.
DLL_EXPORT uint32_t ahp_xc_get_delaysize(void)
Obtain the correlator maximum delay value.
DLL_EXPORT uint32_t ahp_xc_get_npolytopes(int32_t order)
Obtain the correlator total polytopes for arbitrary degree of coherence orders.
DLL_EXPORT double ahp_xc_get_packettime(void)
Obtain the serial packet transmission time.
DLL_EXPORT char * ahp_xc_get_header(void)
Obtain the correlator header.
DLL_EXPORT uint32_t ahp_xc_get_nlines(void)
Obtain the correlator number of lines.
DLL_EXPORT void ahp_xc_enable_crosscorrelator(int32_t enable)
Enable the cross-correlation capability of the device.
DLL_EXPORT void ahp_xc_enable_intensity_crosscorrelator(int32_t enable)
Enable the intensity cross-correlation feature.
DLL_EXPORT int32_t ahp_xc_get_line_index(int32_t idx, int32_t order)
Return the cross-correlation index of the polytopes correlating the lines array.
DLL_EXPORT uint32_t ahp_xc_get_autocorrelator_lagsize(void)
Obtain the correlator lag buffer size for autocorrelations.
DLL_EXPORT int32_t ahp_xc_has_leds(void)
Returns if the device has led lines to drive.
xc_header_flags
AHP XC header flags.
Definition ahp_xc.h:125
xc_cmd
The XC firmare commands.
Definition ahp_xc.h:151
baud_rate
Baud rate multipliers.
Definition ahp_xc.h:139
xc_test_flags
The XC firmware commands.
Definition ahp_xc.h:191
xc_capture_flags
The XC capture flags.
Definition ahp_xc.h:173
@ HAS_CUMULATIVE_ONLY
Indicates that the correlator has cumulative correlators only.
Definition ahp_xc.h:133
@ HAS_PSU
Indicates that the correlator has an internal PSU PWM driver on 2nd flag bit.
Definition ahp_xc.h:131
@ HAS_CROSSCORRELATOR
Indicates that the correlator can cross-correlate its inputs.
Definition ahp_xc.h:127
@ HAS_LEDS
Indicates if the correlator has led lines available to drive.
Definition ahp_xc.h:129
@ SET_INDEX
Set the current input line index for following commands.
Definition ahp_xc.h:155
@ CLEAR
Clear autocorrelation and crosscorrelation delays.
Definition ahp_xc.h:153
@ ENABLE_TEST
Enables tests on current input.
Definition ahp_xc.h:165
@ SET_VOLTAGE
Set the indexed input voltage, requires HAS_PSU in header.
Definition ahp_xc.h:161
@ SET_LEDS
Set on or off current line leds, requires HAS_LEDS.
Definition ahp_xc.h:157
@ SET_DELAY
Set the autocorrelator or crosscorrelator delay.
Definition ahp_xc.h:163
@ SET_BAUD_RATE
Set the readout and command baud rate.
Definition ahp_xc.h:159
@ ENABLE_CAPTURE
Enable capture flags.
Definition ahp_xc.h:167
@ TEST_ALL
All tests enabled.
Definition ahp_xc.h:203
@ SCAN_AUTO
Autocorrelator continuum scan.
Definition ahp_xc.h:195
@ TEST_STEP
Set channel scan step.
Definition ahp_xc.h:201
@ TEST_NONE
No extra signals or functions.
Definition ahp_xc.h:193
@ SCAN_CROSS
Crosscorrelator continuum scan.
Definition ahp_xc.h:197
@ TEST_BCM
BCM modulation on voltage led.
Definition ahp_xc.h:199
@ CAP_EXTRA_CMD
Enable extra commands.
Definition ahp_xc.h:183
@ CAP_RESET_TIMESTAMP
Reset timestamp.
Definition ahp_xc.h:181
@ CAP_ALL
All flags enabled.
Definition ahp_xc.h:185
@ CAP_ENABLE
Enable capture.
Definition ahp_xc.h:177
@ CAP_EXT_CLK
Enable external clock.
Definition ahp_xc.h:179
@ CAP_NONE
No extra signals or functions.
Definition ahp_xc.h:175
DLL_EXPORT double * ahp_xc_get_2d_projection(double alt, double az, double *baseline)
Get 2d projection for intensity interferometry.
DLL_EXPORT uint64_t ahp_xc_max_threads(uint64_t value)
Set or get the maximum number of concurrent threads.
Correlations structure.
Definition ahp_xc.h:209
int num_indexes
number of nodes in this correlation
Definition ahp_xc.h:211
double lag
Time lag offset.
Definition ahp_xc.h:217
int64_t imaginary
Q samples count.
Definition ahp_xc.h:221
double phase
Phase of this sample.
Definition ahp_xc.h:227
int * indexes
Indices of the nodes.
Definition ahp_xc.h:213
uint64_t counts
Pulses count.
Definition ahp_xc.h:223
double magnitude
Magnitude of this sample.
Definition ahp_xc.h:225
int64_t real
I samples count.
Definition ahp_xc.h:219
double * lags
Time locations of the nodes.
Definition ahp_xc.h:215
Packet structure.
Definition ahp_xc.h:261
uint64_t n_lines
Number of lines in this correlator.
Definition ahp_xc.h:265
uint64_t n_baselines
Total number of baselines obtainable.
Definition ahp_xc.h:267
uint64_t bps
Bits capacity in each sample.
Definition ahp_xc.h:271
uint64_t auto_lag
Autocorrelators channels per packet.
Definition ahp_xc.h:275
const char * buf
Packet buffer string.
Definition ahp_xc.h:285
void * lock
Packet lock mutex.
Definition ahp_xc.h:283
ahp_xc_sample * crosscorrelations
Crosscorrelations in the current packet.
Definition ahp_xc.h:281
double timestamp
Timestamp of the packet (seconds)
Definition ahp_xc.h:263
uint64_t tau
Bandwidth inverse frequency.
Definition ahp_xc.h:269
ahp_xc_sample * autocorrelations
Autocorrelations in the current packet.
Definition ahp_xc.h:279
uint64_t * counts
Counts in the current packet.
Definition ahp_xc.h:277
uint64_t cross_lag
Crosscorrelators channels per packet.
Definition ahp_xc.h:273
Sample structure.
Definition ahp_xc.h:249
ahp_xc_correlation * correlations
Correlations array, of size lag_size in an ahp_xc_packet.
Definition ahp_xc.h:255
double lag
Lag offset from sample time.
Definition ahp_xc.h:251
uint64_t lag_size
Maximum lag in a single shot.
Definition ahp_xc.h:253
Scan request structure.
Definition ahp_xc.h:233
off_t cur_chan
Current channel.
Definition ahp_xc.h:243
size_t step
Separation between channels.
Definition ahp_xc.h:241
off_t start
Start channel.
Definition ahp_xc.h:237
uint32_t index
Line index.
Definition ahp_xc.h:235
size_t len
Number of channels.
Definition ahp_xc.h:239