X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;ds=sidebyside;f=src%2Fhardware%2Fzeroplus-logic-cube%2Fanalyzer.c;h=0617d227467e840548a93c823678c89c0c199ca1;hb=d8aad7281ebe4efde521bf96b7c009acc3d4c09a;hp=c404a66b73b04a47324f5c5c539c866fe8a0300e;hpb=155b680da482cea2381becb73c51cfb838bff31e;p=libsigrok.git diff --git a/src/hardware/zeroplus-logic-cube/analyzer.c b/src/hardware/zeroplus-logic-cube/analyzer.c index c404a66b..0617d227 100644 --- a/src/hardware/zeroplus-logic-cube/analyzer.c +++ b/src/hardware/zeroplus-logic-cube/analyzer.c @@ -29,8 +29,9 @@ * THE POSSIBILITY OF SUCH DAMAGE. */ +#include #include -#include "libsigrok.h" +#include #include "libsigrok-internal.h" #include "analyzer.h" #include "gl_usb.h" @@ -61,7 +62,7 @@ enum { TRIGGER_STATUS5, TRIGGER_STATUS6, TRIGGER_STATUS7, - TRIGGER_STATUS8, + TRIGGER_EDGE, TRIGGER_COUNT0 = 0x50, TRIGGER_COUNT1, @@ -107,7 +108,8 @@ enum { READ_RAM_STATUS = 0xa0, }; -static int g_trigger_status[9] = { 0 }; +static int g_trigger_status[8] = { 0 }; +static int g_trigger_edge = 0; static int g_trigger_count = 1; static int g_filter_status[8] = { 0 }; static int g_filter_enable = 0; @@ -309,7 +311,7 @@ static int __analyzer_set_freq(libusb_device_handle *devh, int freq, int scale) { 1, FREQ_SCALE_KHZ, 64, 5, 5 }, { 500, FREQ_SCALE_HZ, 64, 10, 5 }, { 100, FREQ_SCALE_HZ, 68, 5, 8 }, - { 0, 0, 0, 0, 0 } + ALL_ZERO }; int i; @@ -419,7 +421,7 @@ SR_PRIV void analyzer_read_start(libusb_device_handle *devh) } SR_PRIV int analyzer_read_data(libusb_device_handle *devh, void *buffer, - unsigned int size) + unsigned int size) { return gl_read_bulk(devh, buffer, size); } @@ -460,8 +462,9 @@ SR_PRIV void analyzer_configure(libusb_device_handle *devh) gl_reg_write(devh, CLOCK_SOURCE, 0x03); /* Set_Trigger_Status */ - for (i = 0; i < 9; i++) + for (i = 0; i < 8; i++) gl_reg_write(devh, TRIGGER_STATUS0 + i, g_trigger_status[i]); + gl_reg_write(devh, TRIGGER_EDGE, g_trigger_edge); __analyzer_set_trigger_count(devh, g_trigger_count); @@ -502,6 +505,9 @@ SR_PRIV int analyzer_add_triggers(const struct sr_dev_inst *sdi) if (!(trigger = sr_session_trigger_get(sdi->session))) return SR_OK; + memset(g_trigger_status, 0, sizeof(g_trigger_status)); + g_trigger_edge = 0; + for (l = trigger->stages; l; l = l->next) { stage = l->data; for (m = stage->matches; m; m = m->next) { @@ -514,9 +520,19 @@ SR_PRIV int analyzer_add_triggers(const struct sr_dev_inst *sdi) switch (match->match) { case SR_TRIGGER_ZERO: g_trigger_status[channel / 4] |= 2 << (channel % 4 * 2); + break; case SR_TRIGGER_ONE: g_trigger_status[channel / 4] |= 1 << (channel % 4 * 2); break; + case SR_TRIGGER_RISING: + g_trigger_edge = 0x40 | (channel & 0x1F); + break; + case SR_TRIGGER_FALLING: + g_trigger_edge = 0x80 | (channel & 0x1F); + break; + case SR_TRIGGER_EDGE: + g_trigger_edge = 0xc0 | (channel & 0x1F); + break; default: sr_err("Unsupported match %d", match->match); return SR_ERR; @@ -553,7 +569,7 @@ SR_PRIV void analyzer_add_filter(int channel, int type) } g_filter_status[i] |= - 1 << ((2 * channel) + (type == FILTER_LOW ? 1 : 0)); + 1 << ((2 * channel) + (type == FILTER_LOW ? 1 : 0)); g_filter_enable = 1; }