Commit 06480e5f authored by Federico Vaga's avatar Federico Vaga

wrtd:rt: input application now use librt

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 f3f63f6d
......@@ -96,6 +96,24 @@
#define FD_HASH_ENTRIES 64
#define FD_MAX_QUEUE_PULSES 16
enum wrtd_in_variables_indexes {
IN_VAR_CHAN_ENABLE = 0,
IN_VAR_DEVICE_TIME_S,
IN_VAR_DEVICE_TIME_T,
IN_VAR_DEVICE_SENT_PACK,
IN_VAR_DEVICE_DEAD_TIME,
IN_VAR_DEVICE_CHAN_ENABLE,
__WRTD_IN_VAR_MAX,
};
enum wrtd_in_structures_indexes {
IN_STRUCT_DEVICE = 0,
IN_STRUCT_CHAN_0,
IN_STRUCT_CHAN_1,
IN_STRUCT_CHAN_2,
IN_STRUCT_CHAN_3,
IN_STRUCT_CHAN_4,
__WRTD_IN_STRUCT_MAX,
};
/**
* availables trigger mode
......@@ -275,4 +293,44 @@ static inline void ts_sub(struct wr_timestamp *a, const struct wr_timestamp *b)
}
#endif
/**
* Structure describing state of each TDC channel
* All fields must be 32bit (do not use enum because there are no guarantee)
*/
struct wrtd_in_channel_config {
struct wrtd_trig_id id; /**< Currently assigned trigger ID */
struct wr_timestamp delay; /**< Trigger delay, added to each timestamp */
struct wr_timestamp timebase_offset; /* Internal time base offset. Used
to compensate the TDC-to-WR
timebase lag. Not exposed to the
public, set from the internal
calibration data of the TDC
driver. */
uint32_t flags; /**< Channel flags (enum wrnc_io_flags) */
uint32_t log_level; /**< Log level (enum wrnc_log_level) */
uint32_t mode; /**< Triggering mode (enum wrtd_triger_mode) */
};
struct wrtd_in_channel_stats {
struct wr_timestamp last_tagged; /**< Timestamp of the last tagged
pulse */
struct wrtd_trigger_entry last_sent; /**< Last transmitted trigger */
uint32_t total_pulses; /**< Total tagged pulses */
uint32_t sent_pulses; /**< Total sent pulses */
uint32_t miss_no_timing; /**< Total missed pulses (no WR) */
uint32_t seq;
};
/* Structure describing state of each TDC channel*/
struct wrtd_in_channel {
int n;
struct wrtd_in_channel_stats stats;
struct wrtd_in_channel_config config;
};
struct wrtd_in {
uint32_t dead_time; /**< TDC dead time, in 8ns ticks */
};
#endif
This diff is collapsed.
......@@ -98,3 +98,13 @@ int wrtd_trivial_request(struct wrtd_node *dev,
return wrtd_validate_acknowledge(request_msg);
}
/**
* The embedded core is big endian, convert it to little endian (host)
*/
void wrtd_timestamp_endianess_fix(struct wr_timestamp *ts)
{
ts->seconds = ((ts->seconds & 0xFFFFFFFF) << 32) |
((ts->seconds >> 32) & 0xFFFFFFFF);
}
......@@ -41,4 +41,5 @@ extern int wrtd_trivial_request(struct wrtd_node *dev,
extern int wrtd_send_and_receive_sync(struct wrtd_desc *wrtd,
struct wrnc_msg *msg,
enum wrtd_core core);
extern void wrtd_timestamp_endianess_fix(struct wr_timestamp *ts);
#endif
......@@ -235,21 +235,44 @@ static int wrtd_log_level_set(struct wrtd_node *dev, unsigned int channel,
{
struct wrnc_msg msg = wrnc_msg_init(4);
uint32_t seq = 0;
uint32_t id = core ? WRTD_CMD_FD_CHAN_SET_LOG_LEVEL :
WRTD_CMD_TDC_CHAN_SET_LOG_LEVEL;
int n_chan = core ? FD_NUM_CHANNELS : TDC_NUM_CHANNELS;
if (channel >= n_chan) {
errno = EWRTD_INVALID_CHANNEL;
return -1;
}
if (core) { /* Output */
uint32_t id = WRTD_CMD_FD_CHAN_SET_LOG_LEVEL;
if (channel >= FD_NUM_CHANNELS) {
errno = EWRTD_INVALID_CHANNEL;
return -1;
}
/* Build the message */
wrnc_msg_header(&msg, &id, &seq);
wrnc_msg_uint32(&msg, &channel);
wrnc_msg_uint32(&msg, &log_level);
/* Build the message */
wrnc_msg_header(&msg, &id, &seq);
wrnc_msg_uint32(&msg, &channel);
wrnc_msg_uint32(&msg, &log_level);
return wrtd_trivial_request(dev, &msg, core);
} else { /* Input */
struct wrtd_desc *wrtd = (struct wrtd_desc *)dev;
struct wrtd_in_channel chan;
struct wrnc_structure_tlv tlv = {
.index = IN_STRUCT_CHAN_0 + channel,
.size = sizeof(struct wrtd_in_channel),
.structure = &chan,
};
int err;
if (channel >= TDC_NUM_CHANNELS) {
errno = EWRTD_INVALID_CHANNEL;
return -1;
}
err = wrnc_rt_structure_get(wrtd->wrnc, WRTD_IN_TDC_CONTROL,
WRTD_OUT_TDC_CONTROL, &tlv, 1);
if (err)
return err;
return wrtd_trivial_request(dev, &msg, core);
chan.config.log_level = log_level;
return wrnc_rt_structure_set(wrtd->wrnc, WRTD_IN_TDC_CONTROL,
WRTD_OUT_TDC_CONTROL, &tlv, 1, 1);
}
}
......
......@@ -5,4 +5,8 @@ WRNC = ../../../../
EXTRA_CFLAGS += -I../../include
EXTRA_CFLAGS += -I../common
EXTRA_CFLAGS += -D__MAX_ACTION_RECV=1
EXTRA_CFLAGS += -D__MAX_ACTION_SEND=0
EXTRA_CFLAGS += -DLIBRT_ERROR
RT_USE_LIBRT := 1
include $(WRNC)/applications/common/rt/Makefile
This diff is collapsed.
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