Commit e7d82165 authored by Federico Vaga's avatar Federico Vaga

Merge branch '7-fmc-fdelay-pulse-by-default-does-not-set-pulse-width-to-50' into 'master'

Resolve "fmc-fdelay-pulse by default does not set pulse width to 50%"

Closes #7

See merge request be-cem-edl/fec/hardware-modules/fmc-delay-1ns-8cha!5
parents ea383df1 dd94e5aa
......@@ -34,8 +34,8 @@ void help(char *name)
" -T <period> period, e.g. \"50m-20n\" -- use m,u,n,p and add/sub\n"
" -w <width> like period; defaults to 50%% period\n"
" -t wait for trigger before exiting\n"
" -p pulse per seconds (sets -D -T -w)\n"
" -1 10MHz (sets -D -T -w)\n"
" -p pulse per seconds (sets -D <now> -T 1 -w 1u)\n"
" -1 10MHz (sets -D <now> -T 100ns -w 48ns)\n"
" -v verbose (report action)\n");
fprintf(stderr,"By default, the tool generates a continuous train of pulses (10 Hz frequency) on a given output.\n");
exit(1);
......@@ -215,6 +215,18 @@ void parse_width(struct fdelay_pulse *p, char *s)
parse_time(s, &t_width);
}
static void width_set_duty_cycle_50(struct fdelay_time *period,
struct fdelay_time *width)
{
memset(width, 0, sizeof(struct fdelay_time));
width->utc = period->utc / 2;
width->coarse = period->coarse / 2;
width->frac = period->frac / 2;
if (period->utc & 0x1)
width->coarse += 62500000;
if (period->coarse & 0x1)
width->frac += 2048;
}
int main(int argc, char **argv)
{
......@@ -224,7 +236,7 @@ int main(int argc, char **argv)
int count = 0, channel = -1;
int trigger_wait = 0, verbose = 0;
struct fdelay_pulse p;
int has_custom_width = 0;
/* Standard part of the file (repeated code) */
if (tools_need_help(argc, argv))
......@@ -307,6 +319,7 @@ int main(int argc, char **argv)
break;
case 'w':
parse_width(&p, optarg);
has_custom_width = 1;
break;
case 't':
trigger_wait = 1;
......@@ -331,6 +344,10 @@ int main(int argc, char **argv)
exit(1);
}
/* If no custom value, set duty-cyle 50% */
if (!has_custom_width)
width_set_duty_cycle_50(&p.loop, &t_width);
b = fdelay_open(dev);
if (!b) {
fprintf(stderr, "%s: fdelay_open(): %s\n", argv[0],
......
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