asix-sigma: check for successful register access in sample download
The previous implementation got stuck in an infinite loop when data acquisition started, but the device got disconnected before the data acquisition terminates. An implementation detail ignored communication errors, and never saw the expected condition that was required to continue in the sample download sequence. Unbreak that code path.
This commit is contained in:
parent
f5c863e572
commit
f73b00b647
|
@ -134,18 +134,6 @@ static int sigma_read_register(uint8_t reg, uint8_t *data, size_t len,
|
|||
return sigma_read(data, len, devc);
|
||||
}
|
||||
|
||||
static uint8_t sigma_get_register(uint8_t reg, struct dev_context *devc)
|
||||
{
|
||||
uint8_t value;
|
||||
|
||||
if (1 != sigma_read_register(reg, &value, 1, devc)) {
|
||||
sr_err("sigma_get_register: 1 byte expected");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static int sigma_read_pos(uint32_t *stoppos, uint32_t *triggerpos,
|
||||
struct dev_context *devc)
|
||||
{
|
||||
|
@ -1031,7 +1019,10 @@ static int download_capture(struct sr_dev_inst *sdi)
|
|||
*/
|
||||
sigma_set_register(WRITE_MODE, WMR_FORCESTOP | WMR_SDRAMWRITEEN, devc);
|
||||
do {
|
||||
modestatus = sigma_get_register(READ_MODE, devc);
|
||||
if (sigma_read_register(READ_MODE, &modestatus, 1, devc) != 1) {
|
||||
sr_err("sigma: failed while waiting for RMR_POSTTRIGGERED bit");
|
||||
return FALSE;
|
||||
}
|
||||
} while (!(modestatus & RMR_POSTTRIGGERED));
|
||||
|
||||
/* Set SDRAM Read Enable. */
|
||||
|
@ -1041,7 +1032,10 @@ static int download_capture(struct sr_dev_inst *sdi)
|
|||
sigma_read_pos(&stoppos, &triggerpos, devc);
|
||||
|
||||
/* Check if trigger has fired. */
|
||||
modestatus = sigma_get_register(READ_MODE, devc);
|
||||
if (sigma_read_register(READ_MODE, &modestatus, 1, devc) != 1) {
|
||||
sr_err("sigma: failed to read READ_MODE register");
|
||||
return FALSE;
|
||||
}
|
||||
trg_line = ~0;
|
||||
trg_event = ~0;
|
||||
if (modestatus & RMR_TRIGGERED) {
|
||||
|
|
Loading…
Reference in New Issue