#include <stdio.h>
#include <limits.h>
#include <bitlib.h>
#define MY_DEVICES 1
#define MY_PROBE_FILE ""
#define MY_DEVICE 0
#define MY_CHANNEL 0
#define MY_MODE BL_MODE_FAST
#define MY_RATE 1000000
#define MY_SIZE 4
int main(int argc, char *argv[]) {
printf("\nStarting: Attempting to open %d device%s...\n",MY_DEVICES,MY_DEVICES!=1?"s":"");
if ( ! BL_Open(MY_PROBE_FILE,MY_DEVICE) ) {
printf("Failed to find a devices.\n");
goto exit;
}
if ( BL_Select(BL_SELECT_DEVICE,MY_DEVICE) != MY_DEVICE ) {
printf("Failed to select device %d.\n",MY_DEVICE);
goto exit;
}
if ( BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL) != MY_CHANNEL ) {
printf("Failed to select channel %d.\n",MY_CHANNEL);
goto exit;
}
if ( BL_Mode(MY_MODE) != MY_MODE ) {
printf("Failed to select mode %d.\n",MY_MODE);
goto exit;
}
BL_Intro(BL_ZERO);
BL_Delay(BL_ZERO);
BL_Rate(MY_RATE);
BL_Size(MY_SIZE);
BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL);
BL_Trigger(BL_ZERO,BL_TRIG_RISE);
BL_Select(BL_SELECT_SOURCE,BL_SOURCE_POD);
BL_Range(BL_Count(BL_COUNT_RANGE));
BL_Offset(BL_ZERO);
BL_Enable(TRUE);
printf(" Trace: %d samples @ %.0fHz = %fs\n",BL_Size(BL_ASK),BL_Rate(BL_ASK), BL_Time(BL_ASK));
if ( BL_Trace(BL_TRACE_FORCED,BL_SYNCHRONOUS) ) {
int i, n = MY_SIZE; double d[n];
BL_Select(BL_SELECT_CHANNEL,MY_CHANNEL);
if ( BL_Acquire(n, d) == n ) {
printf("Acquired:");
for (i = 0; i < n; i++)
printf(" %f", d[i]);
printf("\n\n");
}
}
printf("Data acquisition complete. Dump Log...\n");
printf("%s\n",BL_Log());
exit:
BL_Close();
return 0;
}