WIP
This commit is contained in:
parent
bda100ec0f
commit
b0ccd64d02
|
@ -483,7 +483,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
devc->cb_data = cb_data;
|
devc->cb_data = cb_data;
|
||||||
devc->num_samples = 0;
|
devc->sent_samples = 0;
|
||||||
|
devc->acq_aborted = FALSE;
|
||||||
devc->empty_transfer_count = 0;
|
devc->empty_transfer_count = 0;
|
||||||
|
|
||||||
timeout = fx2lafw_get_timeout(devc);
|
timeout = fx2lafw_get_timeout(devc);
|
||||||
|
|
|
@ -330,14 +330,16 @@ SR_PRIV int fx2lafw_configure_channels(const struct sr_dev_inst *sdi)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (stage == -1)
|
if (stage == -1) {
|
||||||
/*
|
/*
|
||||||
* We didn't configure any triggers, make sure acquisition
|
* We didn't configure any triggers, make sure acquisition
|
||||||
* doesn't wait for any.
|
* doesn't wait for any.
|
||||||
*/
|
*/
|
||||||
devc->trigger_stage = TRIGGER_FIRED;
|
devc->trigger_fired = TRUE;
|
||||||
else
|
} else {
|
||||||
|
devc->trigger_fired = FALSE;
|
||||||
devc->trigger_stage = 0;
|
devc->trigger_stage = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return SR_OK;
|
return SR_OK;
|
||||||
}
|
}
|
||||||
|
@ -364,7 +366,7 @@ SR_PRIV void fx2lafw_abort_acquisition(struct dev_context *devc)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
devc->num_samples = -1;
|
devc->acq_aborted = TRUE;
|
||||||
|
|
||||||
for (i = devc->num_transfers - 1; i >= 0; i--) {
|
for (i = devc->num_transfers - 1; i >= 0; i--) {
|
||||||
if (devc->transfers[i])
|
if (devc->transfers[i])
|
||||||
|
@ -429,8 +431,8 @@ SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
||||||
struct sr_datafeed_packet packet;
|
struct sr_datafeed_packet packet;
|
||||||
struct sr_datafeed_logic logic;
|
struct sr_datafeed_logic logic;
|
||||||
struct dev_context *devc;
|
struct dev_context *devc;
|
||||||
int trigger_offset, i, sample_width, cur_sample_count;
|
int cur_sample_count, num_samples, trigger_offset, sample_width;
|
||||||
int trigger_offset_bytes;
|
int i;
|
||||||
uint8_t *cur_buf;
|
uint8_t *cur_buf;
|
||||||
uint16_t cur_sample;
|
uint16_t cur_sample;
|
||||||
|
|
||||||
|
@ -440,7 +442,7 @@ SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
||||||
* If acquisition has already ended, just free any queued up
|
* If acquisition has already ended, just free any queued up
|
||||||
* transfer that come in.
|
* transfer that come in.
|
||||||
*/
|
*/
|
||||||
if (devc->num_samples == -1) {
|
if (devc->acq_aborted) {
|
||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -484,9 +486,8 @@ SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
||||||
}
|
}
|
||||||
|
|
||||||
trigger_offset = 0;
|
trigger_offset = 0;
|
||||||
if (devc->trigger_stage >= 0) {
|
if (!devc->trigger_fired) {
|
||||||
for (i = 0; i < cur_sample_count; i++) {
|
for (i = 0; i < cur_sample_count; i++) {
|
||||||
|
|
||||||
cur_sample = devc->sample_wide ?
|
cur_sample = devc->sample_wide ?
|
||||||
*((uint16_t *)cur_buf + i) :
|
*((uint16_t *)cur_buf + i) :
|
||||||
*((uint8_t *)cur_buf + i);
|
*((uint8_t *)cur_buf + i);
|
||||||
|
@ -517,11 +518,16 @@ SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.payload = &logic;
|
packet.payload = &logic;
|
||||||
logic.unitsize = sample_width;
|
logic.unitsize = sample_width;
|
||||||
logic.length = devc->trigger_stage * logic.unitsize;
|
if (devc->trigger_stage > devc->limit_samples)
|
||||||
|
num_samples = devc->trigger_stage;
|
||||||
|
else
|
||||||
|
num_samples = devc->limit_samples;
|
||||||
|
logic.length = num_samples * sample_width;
|
||||||
logic.data = devc->trigger_buffer;
|
logic.data = devc->trigger_buffer;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(devc->cb_data, &packet);
|
||||||
|
devc->sent_samples += num_samples;
|
||||||
|
|
||||||
devc->trigger_stage = TRIGGER_FIRED;
|
devc->trigger_fired = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (devc->trigger_stage > 0) {
|
} else if (devc->trigger_stage > 0) {
|
||||||
|
@ -541,19 +547,22 @@ SR_PRIV void fx2lafw_receive_transfer(struct libusb_transfer *transfer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (devc->trigger_stage == TRIGGER_FIRED) {
|
if (devc->trigger_fired) {
|
||||||
/* Send the incoming transfer to the session bus. */
|
/* Send the incoming transfer to the session bus. */
|
||||||
trigger_offset_bytes = trigger_offset * sample_width;
|
|
||||||
packet.type = SR_DF_LOGIC;
|
packet.type = SR_DF_LOGIC;
|
||||||
packet.payload = &logic;
|
packet.payload = &logic;
|
||||||
logic.length = transfer->actual_length - trigger_offset_bytes;
|
if (devc->sent_samples + cur_sample_count > devc->limit_samples)
|
||||||
|
num_samples = devc->limit_samples - devc->sent_samples;
|
||||||
|
else
|
||||||
|
num_samples = cur_sample_count;
|
||||||
|
logic.length = num_samples * sample_width;
|
||||||
logic.unitsize = sample_width;
|
logic.unitsize = sample_width;
|
||||||
logic.data = cur_buf + trigger_offset_bytes;
|
logic.data = cur_buf + trigger_offset * sample_width;
|
||||||
sr_session_send(devc->cb_data, &packet);
|
sr_session_send(devc->cb_data, &packet);
|
||||||
|
|
||||||
devc->num_samples += cur_sample_count;
|
devc->sent_samples += cur_sample_count;
|
||||||
if (devc->limit_samples &&
|
if (devc->limit_samples &&
|
||||||
(unsigned int)devc->num_samples > devc->limit_samples) {
|
(unsigned int)devc->sent_samples > devc->limit_samples) {
|
||||||
fx2lafw_abort_acquisition(devc);
|
fx2lafw_abort_acquisition(devc);
|
||||||
free_transfer(transfer);
|
free_transfer(transfer);
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -48,9 +48,6 @@
|
||||||
/* 6 delay states of up to 256 clock ticks */
|
/* 6 delay states of up to 256 clock ticks */
|
||||||
#define MAX_SAMPLE_DELAY (6 * 256)
|
#define MAX_SAMPLE_DELAY (6 * 256)
|
||||||
|
|
||||||
/* Software trigger implementation: positive values indicate trigger stage. */
|
|
||||||
#define TRIGGER_FIRED -1
|
|
||||||
|
|
||||||
#define DEV_CAPS_16BIT_POS 0
|
#define DEV_CAPS_16BIT_POS 0
|
||||||
|
|
||||||
#define DEV_CAPS_16BIT (1 << DEV_CAPS_16BIT_POS)
|
#define DEV_CAPS_16BIT (1 << DEV_CAPS_16BIT_POS)
|
||||||
|
@ -83,13 +80,15 @@ struct dev_context {
|
||||||
uint64_t limit_samples;
|
uint64_t limit_samples;
|
||||||
|
|
||||||
/* Operational settings */
|
/* Operational settings */
|
||||||
|
gboolean trigger_fired;
|
||||||
|
gboolean acq_aborted;
|
||||||
gboolean sample_wide;
|
gboolean sample_wide;
|
||||||
uint16_t trigger_mask[NUM_TRIGGER_STAGES];
|
uint16_t trigger_mask[NUM_TRIGGER_STAGES];
|
||||||
uint16_t trigger_value[NUM_TRIGGER_STAGES];
|
uint16_t trigger_value[NUM_TRIGGER_STAGES];
|
||||||
int trigger_stage;
|
unsigned int trigger_stage;
|
||||||
uint16_t trigger_buffer[NUM_TRIGGER_STAGES];
|
uint16_t trigger_buffer[NUM_TRIGGER_STAGES];
|
||||||
|
|
||||||
int num_samples;
|
unsigned int sent_samples;
|
||||||
int submitted_transfers;
|
int submitted_transfers;
|
||||||
int empty_transfer_count;
|
int empty_transfer_count;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue