Commit 072c6ac3 authored by Federico Vaga's avatar Federico Vaga

wrtd:out: add dead_time configuration support

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>


NOTE
This commit has been created by `git subtree` on the Mock Turtle repository
on tag mock-turtle-2.0

This commit will not compile
parent b5ddf17d
......@@ -72,6 +72,7 @@
#define WRTD_CMD_FD_PING 0xa
#define WRTD_CMD_FD_BASE_TIME 0xb
#define WRTD_CMD_FD_CHAN_DEAD_TIME 0xc
#define WRTD_REP_ACK_ID 0x100
......
......@@ -569,17 +569,35 @@ int wrtd_out_pulse_width_set(struct wrtd_node *dev, unsigned int output,
/**
* It set the dead time for a given output channel. so, it applies on all
* triggers assigned to the given output channel
* triggers assigned to the given output channel.
*
* The function will round the value, so it may happen that you read back a
* different value. The reason is that the RT application measure the dead
* time in ticks, which are 8ns steps. So this function will internally
* convert the dead time in ticks.
* @param[in] dev device token
* @param[in] output index (0-based) of output channel
* @param[in] dead_time_ps dead time in pico-seconds
* @param[in] dead_time_ns dead time in nano-seconds
* @return 0 on success, -1 on error and errno is set appropriately
*/
int wrtd_out_dead_time_set(struct wrtd_node *dev, unsigned int output,
uint64_t dead_time_ps)
uint64_t dead_time_ns)
{
errno = EWRTD_NO_IMPLEMENTATION;
return -1;
struct wrnc_msg msg = wrnc_msg_init(5);
uint32_t id, seq = 0, ticks = dead_time_ns / 8;
if (output >= FD_NUM_CHANNELS) {
errno = EWRTD_INVALID_CHANNEL;
return -1;
}
dead_time_ns /= 8; /* Convert in ticks*/
id = WRTD_CMD_FD_CHAN_DEAD_TIME;
wrnc_msg_header (&msg, &id, &seq);
wrnc_msg_uint32 (&msg, &output);
wrnc_msg_uint32 (&msg, &ticks);
return wrtd_out_trivial_request (dev, &msg);
}
......
......@@ -1307,6 +1307,7 @@ static inline void do_control()
_CMD(WRTD_CMD_FD_READ_HASH, ctl_read_hash)
_CMD(WRTD_CMD_FD_BASE_TIME, ctl_base_time)
_CMD(WRTD_CMD_FD_PING, ctl_ping)
_CMD(WRTD_CMD_FD_CHAN_DEAD_TIME, ctl_chan_set_dead_time)
default:
break;
}
......
......@@ -372,7 +372,7 @@ static int wrtd_cmd_dead_time(struct wrtd_node *wrtd, int output,
return -1;
}
/* Get a trigger */
/* Get the dead time */
parse_delay(argv[0], &dtime);
return wrtd_out_dead_time_set(wrtd, output, dtime);
......
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