Commit e3dedb4f authored by Miguel Gómez Sexto's avatar Miguel Gómez Sexto Committed by Samuel Iglesias Gonsálvez

Updated library API and tests for channel activation and termination

Signed-off-by: Miguel Gómez Sexto's avatarMiguel Gomez <magomez@igalia.com>
Signed-off-by: Samuel Iglesias Gonsálvez's avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
parent 644e5918
......@@ -263,10 +263,9 @@ int tdc_get_timestamp_threshold(struct tdc_board *b, uint32_t *thres)
return __tdc_sysfs_get(b, "tstamp_thresh", thres);
}
int tdc_set_active_channels(struct tdc_board *b, uint32_t config)
int tdc_set_channels_term(struct tdc_board *b, uint32_t config)
{
int res = 0;
int i;
/* Clear other bits than the 5 smaller */
config = config & 0x1f;
......@@ -279,37 +278,22 @@ int tdc_set_active_channels(struct tdc_board *b, uint32_t config)
return res;
}
/* ZIO deactivation */
for (i = 0; i <= 4; i++) {
char file[20];
sprintf(file, "tdc-cset%i/enable", i);
if (config & (1 << i)) {
res = __tdc_sysfs_set(b, file, 1);
} else {
res = __tdc_sysfs_set(b, file, 0);
}
if (res) {
printf("Error setting ZIO chan config in cset %i\n", i);
return res;
}
}
return res;
}
int tdc_get_active_channels(struct tdc_board *b, uint32_t *config)
int tdc_get_channels_term(struct tdc_board *b, uint32_t *config)
{
*config = b->chan_config & ~TDC_INPUT_ENABLE_FLAG;
return 0;
}
int tdc_activate_all_channels(struct tdc_board *b)
int tdc_activate_channels(struct tdc_board *b)
{
b->chan_config |= TDC_INPUT_ENABLE_FLAG;
return __tdc_sysfs_set(b, "channel_term", b->chan_config);
}
int tdc_deactivate_all_channels(struct tdc_board *b)
int tdc_deactivate_channels(struct tdc_board *b)
{
b->chan_config &= ~TDC_INPUT_ENABLE_FLAG;
return __tdc_sysfs_set(b, "channel_term", b->chan_config);
......@@ -352,13 +336,6 @@ static int __tdc_valid_channel(struct tdc_board *b, int chan)
return 0;
}
if (!(b->chan_config & (1 << chan))) {
fprintf(stderr, "%s: Channel not enabled: %i\n",
__func__, chan);
errno = EINVAL;
return 0;
}
return 1;
}
......
......@@ -50,11 +50,11 @@ extern int tdc_get_time_threshold(struct tdc_board *b, uint32_t *thres);
extern int tdc_set_timestamp_threshold(struct tdc_board *b, uint32_t thres);
extern int tdc_get_timestamp_threshold(struct tdc_board *b, uint32_t *thres);
extern int tdc_set_active_channels(struct tdc_board *b, uint32_t config);
extern int tdc_get_active_channels(struct tdc_board *b, uint32_t *config);
extern int tdc_set_channels_term(struct tdc_board *b, uint32_t config);
extern int tdc_get_channels_term(struct tdc_board *b, uint32_t *config);
extern int tdc_activate_all_channels(struct tdc_board *b);
extern int tdc_deactivate_all_channels(struct tdc_board *b);
extern int tdc_activate_channels(struct tdc_board *b);
extern int tdc_deactivate_channels(struct tdc_board *b);
extern int tdc_get_circular_buffer_pointer(struct tdc_board *b, uint32_t *ptr);
......
......@@ -66,8 +66,8 @@ int main(int argc, char **argv)
/* read from valid chan */
tdc_set_host_utc_time(b);
tdc_activate_all_channels(b);
tdc_set_active_channels(b, chan);
tdc_activate_channels(b);
tdc_set_channels_term(b, chan);
tdc_set_time_threshold(b, time_thres);
tdc_set_timestamp_threshold(b, tstamp_thres);
tdc_start_acquisition(b);
......
......@@ -129,19 +129,19 @@ class Cli(cmd.Cmd):
else:
print "No device open"
def do_activate_all_channels (self, arg):
def do_activate_channels (self, arg):
"Activate all channels"
if (self.tdc_open):
self.libtdc.tdc_activate_all_channels(self.tdc)
self.libtdc.tdc_activate_channels(self.tdc)
else:
print "No device open"
def do_deactivate_all_channels (self, arg):
def do_deactivate_channels (self, arg):
"Deactivate all channels"
if (self.tdc_open):
self.libtdc.tdc_deactivate_all_channels(self.tdc)
self.libtdc.tdc_deactivate_channels(self.tdc)
else:
print "No device open"
......@@ -193,7 +193,7 @@ class Cli(cmd.Cmd):
val = c_uint32(int(arg))
self.libtdc.tdc_set_time_threshold(self.tdc, val)
def do_active_channels (self, arg):
def do_channels_term (self, arg):
"get/set active channels: active_channels [value]"
if (self.tdc_open == 0):
......@@ -202,11 +202,11 @@ class Cli(cmd.Cmd):
if arg == "":
val = c_uint32(0)
self.libtdc.tdc_get_active_channels(self.tdc, byref(val))
self.libtdc.tdc_getchannels_term(self.tdc, byref(val))
print val
else:
val = c_uint32(chan_mask(arg))
self.libtdc.tdc_set_active_channels(self.tdc, val)
self.libtdc.tdc_set_channels_term(self.tdc, val)
def do_read (self, arg):
"read samples from a channel: read [chan] [samples]"
......
......@@ -153,8 +153,8 @@ int main(int argc, char **argv)
/* read from valid chan */
tdc_set_host_utc_time(b);
tdc_activate_all_channels(b);
tdc_set_active_channels(b, CHAN0);
tdc_activate_channels(b);
tdc_set_channels_term(b, CHAN0);
tdc_set_time_threshold(b, 10);
tdc_set_timestamp_threshold(b, 10);
tdc_start_acquisition(b);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment