Commit 61fdf8eb authored by Tomasz Wlostowski's avatar Tomasz Wlostowski

tests: readback on enabled/disabled output test for CoHAL

parent 7a1a6681
OBJS=readback-test.o
CC = /acc/sys/L865/cdk/gcc -m32
CFLAGS = -I../lib -I../kernel
all: $(OBJS)
${CC} -o readback-test $(OBJS) -L../lib -lfdelay
#include <stdio.h>
#include <fdelay-lib.h>
void enable_output(struct fdelay_board *b, int out, int enable )
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
cfg.mode = enable ? FD_OUT_MODE_DELAY : FD_OUT_MODE_DISABLED;
fdelay_config_pulse_ps (b, out, &cfg);
}
int get_enabled(struct fdelay_board *b, int out )
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
return (cfg.mode & 0x7f) == FD_OUT_MODE_DELAY;
}
void set_delay(struct fdelay_board *b, int out, int64_t delay_ps)
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
fdelay_pico_to_time(&delay_ps, &cfg.start);
fdelay_config_pulse_ps (b, out, &cfg);
}
int64_t get_delay(struct fdelay_board *b, int out)
{
int64_t rv;
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
fdelay_time_to_pico(&cfg.start, &rv);
return rv;
}
void set_width(struct fdelay_board *b, int out, int64_t width_ps)
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
cfg.length = width_ps;
fdelay_config_pulse_ps (b, out, &cfg);
}
int64_t get_width(struct fdelay_board *b, int out)
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
return cfg.length;
}
void set_period(struct fdelay_board *b, int out, int64_t period_ps)
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
cfg.period = period_ps;
fdelay_config_pulse_ps (b, out, &cfg);
}
int64_t get_period(struct fdelay_board *b, int out)
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
return cfg.period;
}
void set_repeat(struct fdelay_board *b, int out, int repeat)
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
cfg.rep = repeat;
fdelay_config_pulse_ps (b, out, &cfg);
}
int get_repeat(struct fdelay_board *b, int out)
{
struct fdelay_pulse_ps cfg;
fdelay_get_config_pulse_ps(b, out, &cfg);
return cfg.rep;
}
main()
{
fdelay_init();
struct fdelay_board *b = fdelay_open_by_lun(0);
// 1) Consider the sequence: enable output -> read delay (X) -> disable output -> set delay to Y -> read delay
// - then you will read X, not Y - however, if you then enable output and read the delay again, you will read Y
// Hence, one cannot know the actual settings before enabling the output - this is a risk of error
// Same behaviour applies to pulse width and period.
// 3) If acquired delay = 600.000.000 when output is enabled, then acquired delay will be 600.127.500 if output is disabled (fixed offset)
// Width and period do not change depending of output enable/disable
printf("initial state (driver just loaded):\n");
printf("* read enable: %d\n", get_enabled(b, 0));
printf("* read delay: %lld ps\n", get_delay(b, 0));
printf("* read width: %lld ps\n", get_width(b, 0));
printf("* read period: %lld ps\n", get_period(b, 0));
printf("* read repeat: %d times\n", get_repeat(b, 0));
printf("\ntest cases 1 and 3 (readback/setting when output is disabled should assume delay mode)\n");
printf("* disable output\n");
enable_output ( b, 0, 0 );
printf("* set delay to 666000 ps\n");
set_delay ( b, 0, 666000 );
printf("* set width to 250000 ps\n");
set_width ( b, 0, 250000 );
printf("* set repeat to 1\n");
set_repeat ( b, 0, 1 );
printf("* read delay: %lld ps\n", get_delay(b, 0));
printf("* enable output\n");
enable_output ( b, 0, 1 );
printf("* set delay to 777000 ps\n");
set_delay ( b, 0, 777000 );
printf("* read delay: %lld ps\n", get_delay(b, 0));
printf("* disable output\n");
enable_output ( b, 0, 0 );
printf("* read delay: %lld ps\n", get_delay(b, 0));
printf("* enable output\n");
enable_output ( b, 0, 1 );
printf("* read delay: %lld ps\n", get_delay(b, 0));
printf("\ntest case 2 (setting width):\n");
printf("* disable output\n");
enable_output ( b, 0, 0);
printf("* set delay to 1234567 ps\n");
set_delay ( b, 0, 1234567 );
printf("* set width to 500000 ps\n");
set_width ( b, 0, 500000 );
printf("* set period to 1000000 ps\n");
set_period ( b, 0, 1000000 );
printf("* set repeat to 3 times\n");
set_repeat ( b, 0, 3 );
printf("* enable output\n");
enable_output ( b, 0, 1 );
printf("* read delay: %lld ps\n", get_delay(b, 0));
printf("* read width: %lld ps\n", get_width(b, 0));
printf("* read period: %lld ps\n", get_period(b, 0));
printf("* read repeat: %d times\n", get_repeat(b, 0));
return 0;
}
\ No newline at end of file
#!/bin/bash
cd ../kernel
./load-cdv06.sh
cd ../tests
sleep 1
./readback-test
\ No newline at end of file
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