Description
A possible way to support timestamps would be to add the following functions to libiio
struct meta_command
{
uint64 timestamp,
uint64 num_samples,
enum type
{
send_timed,
send_untimed // timestamp is ignored
receive_timed,
receive_untimed
},
uint64 command_counter
};
set_timestamp_mode(bool mode)
{
// write mode to mode iio attribute of timestamper core
// if mode is false, everything should behave like now
}
write_timed_command(meta_command cmd)
{
// write cmd to command iio channel of timestamper core
}
For getting the timestamp from HDL to user there could be a timestamp added to each block. The disadvantage of this would be, that the blocksize would not be num_samples * sample_size anymore. Also inside the axi_dmac it would be a bit more complicated, because the internal fifo size is calculated like burst_size * num_bursts.
I think the cleanest way would be to add a receive channel to the timestamper module, that gives out a timestamp for every meta command. The difficulty here would be to match the received timestamp to the meta command (probably easy for sync reads and more difficult for async/non-blocking reads). One could add a command_id to the meta_command struct to make this easier. Or add a get_timestamp() function to libiio that matches timestamps to received data blocks. But one would have to make sure, that this matching also works correctly in case of overflows in the HDL. So adding a command_counter to meta_command would probably be the easiest. The command_counter value could then also just be a field of the received_timestamp struct
struct received_timestamp
{
uint64 timestamp,
command_counter
}
get_received_timestamp(received_timestamp ×tamp)
{
// read an item from the rx timestamp channel of the timestamper core
}