From: Gerhard Sittig Date: Thu, 19 Dec 2019 19:30:00 +0000 (+0100) Subject: asix-sigma: comment on trigger/stop position, silence warning X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=dc40081706b0bb77dde412a08f6234809fca4946;p=libsigrok.git asix-sigma: comment on trigger/stop position, silence warning Add a comment on the logic which skips the upper 64 bytes of a 512 bytes chunk in the Asix Sigma's sample memory. Move the initial assignment and the subsequent update from a value which was retrieved from a hardware register closer together for awareness during maintenance. Pre-setting a high position value that will never match when the feature is not in use is very appropriate. Adjust the sigma_read_pos() routine to handle triggerpos identically to stoppos. The test condition's intention is to check whether a decrement of the position ends up in the meta data section of a chunk. The previous implementation tested whether a pointer to the position variable ended in 0x1ff when decremented -- which is unrelated to the driver's operation. It's assumed that no harm was done because the trigger feature is unsupported (see bug #359). This silences the compiler warning reported in bug #1411. --- diff --git a/src/hardware/asix-sigma/protocol.c b/src/hardware/asix-sigma/protocol.c index 94fd8de0..93d26239 100644 --- a/src/hardware/asix-sigma/protocol.c +++ b/src/hardware/asix-sigma/protocol.c @@ -168,11 +168,17 @@ static int sigma_read_pos(uint32_t *stoppos, uint32_t *triggerpos, *triggerpos = result[0] | (result[1] << 8) | (result[2] << 16); *stoppos = result[3] | (result[4] << 8) | (result[5] << 16); - /* Not really sure why this must be done, but according to spec. */ + /* + * These "position" values point to after the event (end of + * capture data, trigger condition matched). This is why they + * get decremented here. Sample memory consists of 512-byte + * chunks with meta data in the upper 64 bytes. Thus when the + * decrements takes us into this upper part of the chunk, then + * further move backwards to the end of the chunk's data part. + */ if ((--*stoppos & 0x1ff) == 0x1ff) *stoppos -= 64; - - if ((*--triggerpos & 0x1ff) == 0x1ff) + if ((--*triggerpos & 0x1ff) == 0x1ff) *triggerpos -= 64; return 1; @@ -1009,8 +1015,6 @@ static int download_capture(struct sr_dev_inst *sdi) devc = sdi->priv; dl_events_in_line = 64 * 7; - trg_line = ~0; - trg_event = ~0; dram_line = g_try_malloc0(chunks_per_read * sizeof(*dram_line)); if (!dram_line) @@ -1038,6 +1042,8 @@ static int download_capture(struct sr_dev_inst *sdi) /* Check if trigger has fired. */ modestatus = sigma_get_register(READ_MODE, devc); + trg_line = ~0; + trg_event = ~0; if (modestatus & RMR_TRIGGERED) { trg_line = triggerpos >> 9; trg_event = triggerpos & 0x1ff;