ipdbg-la: Consistently use the same naming everywhere.

Use "ipdbg-la" everywhere to refer to the driver, including
in function name prefixes etc. There's no need to encode
website details (.org) into the driver/function name(s).
This commit is contained in:
Uwe Hermann 2018-08-30 00:02:16 +02:00
parent ed18648423
commit 8a9788e2b7
6 changed files with 199 additions and 199 deletions

View File

@ -388,11 +388,11 @@ src_libdrivers_la_SOURCES += \
src/hardware/ikalogic-scanaplus/protocol.c \ src/hardware/ikalogic-scanaplus/protocol.c \
src/hardware/ikalogic-scanaplus/api.c src/hardware/ikalogic-scanaplus/api.c
endif endif
if HW_IPDBG_LOGIC_ANALYSER if HW_IPDBG_LA
src_libdrivers_la_SOURCES += \ src_libdrivers_la_SOURCES += \
src/hardware/ipdbg-logic-analyser/protocol.h \ src/hardware/ipdbg-la/protocol.h \
src/hardware/ipdbg-logic-analyser/protocol.c \ src/hardware/ipdbg-la/protocol.c \
src/hardware/ipdbg-logic-analyser/api.c src/hardware/ipdbg-la/api.c
endif endif
if HW_KECHENG_KC_330B if HW_KECHENG_KC_330B
src_libdrivers_la_SOURCES += \ src_libdrivers_la_SOURCES += \

View File

@ -250,7 +250,7 @@ SR_DRIVER([HP 3478A], [hp-3478a], [libgpib])
SR_DRIVER([Hung-Chang DSO-2100], [hung-chang-dso-2100], [libieee1284]) SR_DRIVER([Hung-Chang DSO-2100], [hung-chang-dso-2100], [libieee1284])
SR_DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2], [libusb]) SR_DRIVER([Ikalogic Scanalogic-2], [ikalogic-scanalogic2], [libusb])
SR_DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus], [libftdi]) SR_DRIVER([Ikalogic Scanaplus], [ikalogic-scanaplus], [libftdi])
SR_DRIVER([IPDBG_Logic_Analyser], [ipdbg-logic-analyser]) SR_DRIVER([IPDBG LA], [ipdbg-la])
SR_DRIVER([Kecheng KC-330B], [kecheng-kc-330b], [libusb]) SR_DRIVER([Kecheng KC-330B], [kecheng-kc-330b], [libusb])
SR_DRIVER([KERN scale], [kern-scale], [libserialport]) SR_DRIVER([KERN scale], [kern-scale], [libserialport])
SR_DRIVER([Korad KAxxxxP], [korad-kaxxxxp], [libserialport]) SR_DRIVER([Korad KAxxxxP], [korad-kaxxxxp], [libserialport])

View File

@ -20,21 +20,21 @@
#include <config.h> #include <config.h>
#include "protocol.h" #include "protocol.h"
static const uint32_t ipdbg_org_la_drvopts[] = { static const uint32_t ipdbg_la_drvopts[] = {
SR_CONF_LOGIC_ANALYZER, SR_CONF_LOGIC_ANALYZER,
}; };
static const uint32_t ipdbg_org_la_scanopts[] = { static const uint32_t ipdbg_la_scanopts[] = {
SR_CONF_CONN, SR_CONF_CONN,
}; };
static const uint32_t ipdbg_org_la_devopts[] = { static const uint32_t ipdbg_la_devopts[] = {
SR_CONF_TRIGGER_MATCH | SR_CONF_LIST | SR_CONF_SET, SR_CONF_TRIGGER_MATCH | SR_CONF_LIST | SR_CONF_SET,
SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET, SR_CONF_CAPTURE_RATIO | SR_CONF_GET | SR_CONF_SET,
SR_CONF_LIMIT_SAMPLES | SR_CONF_GET, SR_CONF_LIMIT_SAMPLES | SR_CONF_GET,
}; };
static const int32_t ipdbg_org_la_trigger_matches[] = { static const int32_t ipdbg_la_trigger_matches[] = {
SR_TRIGGER_ZERO, SR_TRIGGER_ZERO,
SR_TRIGGER_ONE, SR_TRIGGER_ONE,
SR_TRIGGER_RISING, SR_TRIGGER_RISING,
@ -44,7 +44,7 @@ static const int32_t ipdbg_org_la_trigger_matches[] = {
SR_PRIV struct sr_dev_driver ipdbg_la_driver_info; SR_PRIV struct sr_dev_driver ipdbg_la_driver_info;
static void ipdbg_org_la_split_addr_port(const char *conn, char **addr, static void ipdbg_la_split_addr_port(const char *conn, char **addr,
char **port) char **port)
{ {
char **strs = g_strsplit(conn, "/", 3); char **strs = g_strsplit(conn, "/", 3);
@ -80,20 +80,20 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
if (!conn) if (!conn)
return NULL; return NULL;
struct ipdbg_org_la_tcp *tcp = ipdbg_org_la_tcp_new(); struct ipdbg_la_tcp *tcp = ipdbg_la_tcp_new();
ipdbg_org_la_split_addr_port(conn, &tcp->address, &tcp->port); ipdbg_la_split_addr_port(conn, &tcp->address, &tcp->port);
if (!tcp->address) if (!tcp->address)
return NULL; return NULL;
if (ipdbg_org_la_tcp_open(tcp) != SR_OK) if (ipdbg_la_tcp_open(tcp) != SR_OK)
return NULL; return NULL;
ipdbg_org_la_send_reset(tcp); ipdbg_la_send_reset(tcp);
ipdbg_org_la_send_reset(tcp); ipdbg_la_send_reset(tcp);
if (ipdbg_org_la_request_id(tcp) != SR_OK) if (ipdbg_la_request_id(tcp) != SR_OK)
return NULL; return NULL;
struct sr_dev_inst *sdi = g_malloc0(sizeof(struct sr_dev_inst)); struct sr_dev_inst *sdi = g_malloc0(sizeof(struct sr_dev_inst));
@ -104,14 +104,14 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;
sdi->vendor = g_strdup("ipdbg.org"); sdi->vendor = g_strdup("ipdbg.org");
sdi->model = g_strdup("Logic Analyzer"); sdi->model = g_strdup("IPDBG LA");
sdi->version = g_strdup("v1.0"); sdi->version = g_strdup("v1.0");
sdi->driver = di; sdi->driver = di;
struct ipdbg_org_la_dev_context *devc = ipdbg_org_la_dev_new(); struct ipdbg_la_dev_context *devc = ipdbg_la_dev_new();
sdi->priv = devc; sdi->priv = devc;
ipdbg_org_la_get_addrwidth_and_datawidth(tcp, devc); ipdbg_la_get_addrwidth_and_datawidth(tcp, devc);
sr_dbg("addr_width = %d, data_width = %d\n", devc->ADDR_WIDTH, sr_dbg("addr_width = %d, data_width = %d\n", devc->ADDR_WIDTH,
devc->DATA_WIDTH); devc->DATA_WIDTH);
@ -127,7 +127,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
sdi->inst_type = SR_INST_USER; sdi->inst_type = SR_INST_USER;
sdi->conn = tcp; sdi->conn = tcp;
ipdbg_org_la_tcp_close(tcp); ipdbg_la_tcp_close(tcp);
devices = g_slist_append(devices, sdi); devices = g_slist_append(devices, sdi);
@ -143,10 +143,10 @@ static int dev_clear(const struct sr_dev_driver *di)
if (drvc) { if (drvc) {
for (l = drvc->instances; l; l = l->next) { for (l = drvc->instances; l; l = l->next) {
sdi = l->data; sdi = l->data;
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_la_tcp *tcp = sdi->conn;
if (tcp) { if (tcp) {
ipdbg_org_la_tcp_close(tcp); ipdbg_la_tcp_close(tcp);
ipdbg_org_la_tcp_free(tcp); ipdbg_la_tcp_free(tcp);
g_free(tcp); g_free(tcp);
} }
sdi->conn = NULL; sdi->conn = NULL;
@ -160,12 +160,12 @@ static int dev_open(struct sr_dev_inst *sdi)
{ {
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_la_tcp *tcp = sdi->conn;
if (!tcp) if (!tcp)
return SR_ERR; return SR_ERR;
if (ipdbg_org_la_tcp_open(tcp) != SR_OK) if (ipdbg_la_tcp_open(tcp) != SR_OK)
return SR_ERR; return SR_ERR;
sdi->status = SR_ST_ACTIVE; sdi->status = SR_ST_ACTIVE;
@ -176,10 +176,10 @@ static int dev_open(struct sr_dev_inst *sdi)
static int dev_close(struct sr_dev_inst *sdi) static int dev_close(struct sr_dev_inst *sdi)
{ {
// Should be called before a new call to scan() // Should be called before a new call to scan()
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_la_tcp *tcp = sdi->conn;
if (tcp) if (tcp)
ipdbg_org_la_tcp_close(tcp); ipdbg_la_tcp_close(tcp);
sdi->conn = NULL; sdi->conn = NULL;
sdi->status = SR_ST_INACTIVE; sdi->status = SR_ST_INACTIVE;
@ -194,7 +194,7 @@ static int config_get(uint32_t key, GVariant **data,
(void)cg; (void)cg;
struct ipdbg_org_la_dev_context *devc = sdi->priv; struct ipdbg_la_dev_context *devc = sdi->priv;
switch (key) { switch (key) {
case SR_CONF_CAPTURE_RATIO: case SR_CONF_CAPTURE_RATIO:
@ -221,7 +221,7 @@ static int config_set(uint32_t key, GVariant *data,
if (sdi->status != SR_ST_ACTIVE) if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
struct ipdbg_org_la_dev_context *devc = sdi->priv; struct ipdbg_la_dev_context *devc = sdi->priv;
switch (key) { switch (key) {
case SR_CONF_CAPTURE_RATIO: case SR_CONF_CAPTURE_RATIO:
@ -253,30 +253,30 @@ static int config_list(uint32_t key, GVariant **data,
switch (key) { switch (key) {
case SR_CONF_SCAN_OPTIONS: case SR_CONF_SCAN_OPTIONS:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
ipdbg_org_la_scanopts, ipdbg_la_scanopts,
ARRAY_SIZE ARRAY_SIZE
(ipdbg_org_la_scanopts), (ipdbg_la_scanopts),
sizeof(uint32_t)); sizeof(uint32_t));
break; break;
case SR_CONF_DEVICE_OPTIONS: case SR_CONF_DEVICE_OPTIONS:
if (!sdi) if (!sdi)
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
ipdbg_org_la_drvopts, ipdbg_la_drvopts,
ARRAY_SIZE ARRAY_SIZE
(ipdbg_org_la_drvopts), (ipdbg_la_drvopts),
sizeof(uint32_t)); sizeof(uint32_t));
else else
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32, *data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
ipdbg_org_la_devopts, ipdbg_la_devopts,
ARRAY_SIZE ARRAY_SIZE
(ipdbg_org_la_devopts), (ipdbg_la_devopts),
sizeof(uint32_t)); sizeof(uint32_t));
break; break;
case SR_CONF_TRIGGER_MATCH: case SR_CONF_TRIGGER_MATCH:
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32, *data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
ipdbg_org_la_trigger_matches, ipdbg_la_trigger_matches,
ARRAY_SIZE ARRAY_SIZE
(ipdbg_org_la_trigger_matches), (ipdbg_la_trigger_matches),
sizeof(int32_t)); sizeof(int32_t));
break; break;
default: default:
@ -301,48 +301,48 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
if (sdi->status != SR_ST_ACTIVE) if (sdi->status != SR_ST_ACTIVE)
return SR_ERR_DEV_CLOSED; return SR_ERR_DEV_CLOSED;
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_la_tcp *tcp = sdi->conn;
struct ipdbg_org_la_dev_context *devc = sdi->priv; struct ipdbg_la_dev_context *devc = sdi->priv;
ipdbg_org_la_convert_trigger(sdi); ipdbg_la_convert_trigger(sdi);
ipdbg_org_la_send_trigger(devc, tcp); ipdbg_la_send_trigger(devc, tcp);
ipdbg_org_la_send_delay(devc, tcp); ipdbg_la_send_delay(devc, tcp);
/* If the device stops sending for longer than it takes to send a byte, /* If the device stops sending for longer than it takes to send a byte,
* that means it's finished. But wait at least 100 ms to be safe. * that means it's finished. But wait at least 100 ms to be safe.
*/ */
sr_session_source_add(sdi->session, tcp->socket, G_IO_IN, 100, sr_session_source_add(sdi->session, tcp->socket, G_IO_IN, 100,
ipdbg_org_la_receive_data, (struct sr_dev_inst *)sdi); ipdbg_la_receive_data, (struct sr_dev_inst *)sdi);
ipdbg_org_la_send_start(tcp); ipdbg_la_send_start(tcp);
return SR_OK; return SR_OK;
} }
static int dev_acquisition_stop(struct sr_dev_inst *sdi) static int dev_acquisition_stop(struct sr_dev_inst *sdi)
{ {
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_la_tcp *tcp = sdi->conn;
struct ipdbg_org_la_dev_context *devc = sdi->priv; struct ipdbg_la_dev_context *devc = sdi->priv;
uint8_t byte; uint8_t byte;
if (devc->num_transfers > 0) { if (devc->num_transfers > 0) {
while (devc->num_transfers < while (devc->num_transfers <
(devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) { (devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) {
ipdbg_org_la_tcp_receive(tcp, &byte); ipdbg_la_tcp_receive(tcp, &byte);
devc->num_transfers++; devc->num_transfers++;
} }
} }
ipdbg_org_la_send_reset(tcp); ipdbg_la_send_reset(tcp);
ipdbg_org_la_abort_acquisition(sdi); ipdbg_la_abort_acquisition(sdi);
return SR_OK; return SR_OK;
} }
SR_PRIV struct sr_dev_driver ipdbg_la_driver_info = { SR_PRIV struct sr_dev_driver ipdbg_la_driver_info = {
.name = "ipdbg-org-la", .name = "ipdbg-la",
.longname = "ipdbg.org logic analyzer", .longname = "IPDBG LA",
.api_version = 1, .api_version = 1,
.init = init, .init = init,
.cleanup = std_cleanup, .cleanup = std_cleanup,

View File

@ -68,7 +68,7 @@
/* LA subfunction command opcodes */ /* LA subfunction command opcodes */
#define CMD_LA_DELAY 0x1F #define CMD_LA_DELAY 0x1F
SR_PRIV int data_available(struct ipdbg_org_la_tcp *tcp) SR_PRIV int data_available(struct ipdbg_la_tcp *tcp)
{ {
#ifdef __WIN32__ #ifdef __WIN32__
ioctlsocket(tcp->socket, FIONREAD, &bytes_available); ioctlsocket(tcp->socket, FIONREAD, &bytes_available);
@ -84,11 +84,11 @@ SR_PRIV int data_available(struct ipdbg_org_la_tcp *tcp)
#endif // __WIN32__ #endif // __WIN32__
} }
SR_PRIV struct ipdbg_org_la_tcp *ipdbg_org_la_tcp_new(void) SR_PRIV struct ipdbg_la_tcp *ipdbg_la_tcp_new(void)
{ {
struct ipdbg_org_la_tcp *tcp; struct ipdbg_la_tcp *tcp;
tcp = g_malloc0(sizeof(struct ipdbg_org_la_tcp)); tcp = g_malloc0(sizeof(struct ipdbg_la_tcp));
tcp->address = NULL; tcp->address = NULL;
tcp->port = NULL; tcp->port = NULL;
@ -97,13 +97,13 @@ SR_PRIV struct ipdbg_org_la_tcp *ipdbg_org_la_tcp_new(void)
return tcp; return tcp;
} }
SR_PRIV void ipdbg_org_la_tcp_free(struct ipdbg_org_la_tcp *tcp) SR_PRIV void ipdbg_la_tcp_free(struct ipdbg_la_tcp *tcp)
{ {
g_free(tcp->address); g_free(tcp->address);
g_free(tcp->port); g_free(tcp->port);
} }
SR_PRIV int ipdbg_org_la_tcp_open(struct ipdbg_org_la_tcp *tcp) SR_PRIV int ipdbg_la_tcp_open(struct ipdbg_la_tcp *tcp)
{ {
struct addrinfo hints; struct addrinfo hints;
struct addrinfo *results, *res; struct addrinfo *results, *res;
@ -145,7 +145,7 @@ SR_PRIV int ipdbg_org_la_tcp_open(struct ipdbg_org_la_tcp *tcp)
return SR_OK; return SR_OK;
} }
SR_PRIV int ipdbg_org_la_tcp_close(struct ipdbg_org_la_tcp *tcp) SR_PRIV int ipdbg_la_tcp_close(struct ipdbg_la_tcp *tcp)
{ {
int ret = SR_OK; int ret = SR_OK;
@ -157,7 +157,7 @@ SR_PRIV int ipdbg_org_la_tcp_close(struct ipdbg_org_la_tcp *tcp)
return ret; return ret;
} }
SR_PRIV int ipdbg_org_la_tcp_send(struct ipdbg_org_la_tcp *tcp, SR_PRIV int ipdbg_la_tcp_send(struct ipdbg_la_tcp *tcp,
const uint8_t *buf, size_t len) const uint8_t *buf, size_t len)
{ {
int out; int out;
@ -174,7 +174,7 @@ SR_PRIV int ipdbg_org_la_tcp_send(struct ipdbg_org_la_tcp *tcp,
return SR_OK; return SR_OK;
} }
SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp, SR_PRIV int ipdbg_la_tcp_receive_blocking(struct ipdbg_la_tcp *tcp,
uint8_t *buf, int bufsize) uint8_t *buf, int bufsize)
{ {
int received = 0; int received = 0;
@ -182,7 +182,7 @@ SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp,
/* Timeout after 500ms of not receiving data */ /* Timeout after 500ms of not receiving data */
while ((received < bufsize) && (error_count < 500)) { while ((received < bufsize) && (error_count < 500)) {
if (ipdbg_org_la_tcp_receive(tcp, buf) > 0) { if (ipdbg_la_tcp_receive(tcp, buf) > 0) {
buf++; buf++;
received++; received++;
} else { } else {
@ -194,7 +194,7 @@ SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp,
return received; return received;
} }
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, SR_PRIV int ipdbg_la_tcp_receive(struct ipdbg_la_tcp *tcp,
uint8_t *buf) uint8_t *buf)
{ {
int received = 0; int received = 0;
@ -215,9 +215,9 @@ SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp,
return -1; return -1;
} }
SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi) SR_PRIV int ipdbg_la_convert_trigger(const struct sr_dev_inst *sdi)
{ {
struct ipdbg_org_la_dev_context *devc; struct ipdbg_la_dev_context *devc;
struct sr_trigger *trigger; struct sr_trigger *trigger;
struct sr_trigger_stage *stage; struct sr_trigger_stage *stage;
struct sr_trigger_match *match; struct sr_trigger_match *match;
@ -285,10 +285,10 @@ SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi)
return SR_OK; return SR_OK;
} }
SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data) SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data)
{ {
const struct sr_dev_inst *sdi; const struct sr_dev_inst *sdi;
struct ipdbg_org_la_dev_context *devc; struct ipdbg_la_dev_context *devc;
(void)fd; (void)fd;
(void)revents; (void)revents;
@ -300,7 +300,7 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
if (!(devc = sdi->priv)) if (!(devc = sdi->priv))
return FALSE; return FALSE;
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_la_tcp *tcp = sdi->conn;
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
struct sr_datafeed_logic logic; struct sr_datafeed_logic logic;
@ -317,7 +317,7 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
(devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) { (devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) {
uint8_t byte; uint8_t byte;
if (ipdbg_org_la_tcp_receive(tcp, &byte) == 1) { if (ipdbg_la_tcp_receive(tcp, &byte) == 1) {
if (devc->num_transfers < if (devc->num_transfers <
(devc->limit_samples * devc->DATA_WIDTH_BYTES)) (devc->limit_samples * devc->DATA_WIDTH_BYTES))
devc->raw_sample_buf[devc->num_transfers] = byte; devc->raw_sample_buf[devc->num_transfers] = byte;
@ -352,22 +352,22 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
g_free(devc->raw_sample_buf); g_free(devc->raw_sample_buf);
devc->raw_sample_buf = NULL; devc->raw_sample_buf = NULL;
ipdbg_org_la_abort_acquisition(sdi); ipdbg_la_abort_acquisition(sdi);
} }
return TRUE; return TRUE;
} }
SR_PRIV int ipdbg_org_la_send_delay(struct ipdbg_org_la_dev_context *devc, SR_PRIV int ipdbg_la_send_delay(struct ipdbg_la_dev_context *devc,
struct ipdbg_org_la_tcp *tcp) struct ipdbg_la_tcp *tcp)
{ {
devc->delay_value = (devc->limit_samples / 100.0) * devc->capture_ratio; devc->delay_value = (devc->limit_samples / 100.0) * devc->capture_ratio;
uint8_t buf; uint8_t buf;
buf = CMD_CFG_LA; buf = CMD_CFG_LA;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_LA_DELAY; buf = CMD_LA_DELAY;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
uint8_t delay_buf[4] = { devc->delay_value & 0x000000ff, uint8_t delay_buf[4] = { devc->delay_value & 0x000000ff,
(devc->delay_value >> 8) & 0x000000ff, (devc->delay_value >> 8) & 0x000000ff,
@ -381,18 +381,18 @@ SR_PRIV int ipdbg_org_la_send_delay(struct ipdbg_org_la_dev_context *devc,
return SR_OK; return SR_OK;
} }
SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc, SR_PRIV int ipdbg_la_send_trigger(struct ipdbg_la_dev_context *devc,
struct ipdbg_org_la_tcp *tcp) struct ipdbg_la_tcp *tcp)
{ {
uint8_t buf; uint8_t buf;
/* Mask */ /* Mask */
buf = CMD_CFG_TRIGGER; buf = CMD_CFG_TRIGGER;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_MASKS; buf = CMD_TRIG_MASKS;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_MASK; buf = CMD_TRIG_MASK;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++) for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
send_escaping(tcp, send_escaping(tcp,
@ -400,11 +400,11 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
/* Value */ /* Value */
buf = CMD_CFG_TRIGGER; buf = CMD_CFG_TRIGGER;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_MASKS; buf = CMD_TRIG_MASKS;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_VALUE; buf = CMD_TRIG_VALUE;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++) for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
send_escaping(tcp, send_escaping(tcp,
@ -412,11 +412,11 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
/* Mask_last */ /* Mask_last */
buf = CMD_CFG_TRIGGER; buf = CMD_CFG_TRIGGER;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_MASKS_LAST; buf = CMD_TRIG_MASKS_LAST;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_MASK_LAST; buf = CMD_TRIG_MASK_LAST;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++) for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
send_escaping(tcp, send_escaping(tcp,
@ -424,11 +424,11 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
/* Value_last */ /* Value_last */
buf = CMD_CFG_TRIGGER; buf = CMD_CFG_TRIGGER;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_MASKS_LAST; buf = CMD_TRIG_MASKS_LAST;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_VALUE_LAST; buf = CMD_TRIG_VALUE_LAST;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++) for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
send_escaping(tcp, send_escaping(tcp,
@ -436,11 +436,11 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
/* Edge_mask */ /* Edge_mask */
buf = CMD_CFG_TRIGGER; buf = CMD_CFG_TRIGGER;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_SELECT_EDGE_MASK; buf = CMD_TRIG_SELECT_EDGE_MASK;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
buf = CMD_TRIG_SET_EDGE_MASK; buf = CMD_TRIG_SET_EDGE_MASK;
ipdbg_org_la_tcp_send(tcp, &buf, 1); ipdbg_la_tcp_send(tcp, &buf, 1);
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++) for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
send_escaping(tcp, send_escaping(tcp,
@ -449,7 +449,7 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
return SR_OK; return SR_OK;
} }
SR_PRIV int send_escaping(struct ipdbg_org_la_tcp *tcp, uint8_t *dataToSend, SR_PRIV int send_escaping(struct ipdbg_la_tcp *tcp, uint8_t *dataToSend,
uint32_t length) uint32_t length)
{ {
uint8_t escape = CMD_ESCAPE; uint8_t escape = CMD_ESCAPE;
@ -458,30 +458,30 @@ SR_PRIV int send_escaping(struct ipdbg_org_la_tcp *tcp, uint8_t *dataToSend,
uint8_t payload = *dataToSend++; uint8_t payload = *dataToSend++;
if (payload == (uint8_t) CMD_RESET) if (payload == (uint8_t) CMD_RESET)
if (ipdbg_org_la_tcp_send(tcp, &escape, 1) != SR_OK) if (ipdbg_la_tcp_send(tcp, &escape, 1) != SR_OK)
sr_warn("Couldn't send escape"); sr_warn("Couldn't send escape");
if (payload == (uint8_t) CMD_ESCAPE) if (payload == (uint8_t) CMD_ESCAPE)
if (ipdbg_org_la_tcp_send(tcp, &escape, 1) != SR_OK) if (ipdbg_la_tcp_send(tcp, &escape, 1) != SR_OK)
sr_warn("Couldn't send escape"); sr_warn("Couldn't send escape");
if (ipdbg_org_la_tcp_send(tcp, &payload, 1) != SR_OK) if (ipdbg_la_tcp_send(tcp, &payload, 1) != SR_OK)
sr_warn("Couldn't send data"); sr_warn("Couldn't send data");
} }
return SR_OK; return SR_OK;
} }
SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth( SR_PRIV void ipdbg_la_get_addrwidth_and_datawidth(
struct ipdbg_org_la_tcp *tcp, struct ipdbg_org_la_dev_context *devc) struct ipdbg_la_tcp *tcp, struct ipdbg_la_dev_context *devc)
{ {
uint8_t buf[8]; uint8_t buf[8];
uint8_t read_cmd = CMD_GET_BUS_WIDTHS; uint8_t read_cmd = CMD_GET_BUS_WIDTHS;
if (ipdbg_org_la_tcp_send(tcp, &read_cmd, 1) != SR_OK) if (ipdbg_la_tcp_send(tcp, &read_cmd, 1) != SR_OK)
sr_warn("Can't send read command"); sr_warn("Can't send read command");
if (ipdbg_org_la_tcp_receive_blocking(tcp, buf, 8) != 8) if (ipdbg_la_tcp_receive_blocking(tcp, buf, 8) != 8)
sr_warn("Can't get address and data width from device"); sr_warn("Can't get address and data width from device");
devc->DATA_WIDTH = buf[0] & 0x000000FF; devc->DATA_WIDTH = buf[0] & 0x000000FF;
@ -511,33 +511,33 @@ SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(
devc->trigger_edge_mask = g_malloc0(devc->DATA_WIDTH_BYTES); devc->trigger_edge_mask = g_malloc0(devc->DATA_WIDTH_BYTES);
} }
SR_PRIV struct ipdbg_org_la_dev_context *ipdbg_org_la_dev_new(void) SR_PRIV struct ipdbg_la_dev_context *ipdbg_la_dev_new(void)
{ {
struct ipdbg_org_la_dev_context *devc; struct ipdbg_la_dev_context *devc;
devc = g_malloc0(sizeof(struct ipdbg_org_la_dev_context)); devc = g_malloc0(sizeof(struct ipdbg_la_dev_context));
devc->capture_ratio = 50; devc->capture_ratio = 50;
return devc; return devc;
} }
SR_PRIV int ipdbg_org_la_send_reset(struct ipdbg_org_la_tcp *tcp) SR_PRIV int ipdbg_la_send_reset(struct ipdbg_la_tcp *tcp)
{ {
uint8_t buf = CMD_RESET; uint8_t buf = CMD_RESET;
if (ipdbg_org_la_tcp_send(tcp, &buf, 1) != SR_OK) if (ipdbg_la_tcp_send(tcp, &buf, 1) != SR_OK)
sr_warn("Couldn't send reset"); sr_warn("Couldn't send reset");
return SR_OK; return SR_OK;
} }
SR_PRIV int ipdbg_org_la_request_id(struct ipdbg_org_la_tcp *tcp) SR_PRIV int ipdbg_la_request_id(struct ipdbg_la_tcp *tcp)
{ {
uint8_t buf = CMD_GET_LA_ID; uint8_t buf = CMD_GET_LA_ID;
if (ipdbg_org_la_tcp_send(tcp, &buf, 1) != SR_OK) if (ipdbg_la_tcp_send(tcp, &buf, 1) != SR_OK)
sr_warn("Couldn't send ID request"); sr_warn("Couldn't send ID request");
char id[4]; char id[4];
if (ipdbg_org_la_tcp_receive_blocking(tcp, (uint8_t*)id, 4) != 4) { if (ipdbg_la_tcp_receive_blocking(tcp, (uint8_t*)id, 4) != 4) {
sr_err("Couldn't read device ID"); sr_err("Couldn't read device ID");
return SR_ERR; return SR_ERR;
} }
@ -551,20 +551,20 @@ SR_PRIV int ipdbg_org_la_request_id(struct ipdbg_org_la_tcp *tcp)
return SR_OK; return SR_OK;
} }
SR_PRIV void ipdbg_org_la_abort_acquisition(const struct sr_dev_inst *sdi) SR_PRIV void ipdbg_la_abort_acquisition(const struct sr_dev_inst *sdi)
{ {
struct ipdbg_org_la_tcp *tcp = sdi->conn; struct ipdbg_la_tcp *tcp = sdi->conn;
sr_session_source_remove(sdi->session, tcp->socket); sr_session_source_remove(sdi->session, tcp->socket);
std_session_send_df_end(sdi); std_session_send_df_end(sdi);
} }
SR_PRIV int ipdbg_org_la_send_start(struct ipdbg_org_la_tcp *tcp) SR_PRIV int ipdbg_la_send_start(struct ipdbg_la_tcp *tcp)
{ {
uint8_t buf = CMD_START; uint8_t buf = CMD_START;
if (ipdbg_org_la_tcp_send(tcp, &buf, 1) != SR_OK) if (ipdbg_la_tcp_send(tcp, &buf, 1) != SR_OK)
sr_warn("Couldn't send start"); sr_warn("Couldn't send start");
return SR_OK; return SR_OK;

View File

@ -0,0 +1,89 @@
/*
* This file is part of the libsigrok project.
*
* Copyright (C) 2016 danselmi <da@da>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBSIGROK_HARDWARE_IPDBG_LA_PROTOCOL_H
#define LIBSIGROK_HARDWARE_IPDBG_LA_PROTOCOL_H
#include <stdint.h>
#include <glib.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#define LOG_PREFIX "ipdbg-la"
struct ipdbg_la_tcp {
char *address;
char *port;
int socket;
};
/** Private, per-device-instance driver context. */
struct ipdbg_la_dev_context {
uint32_t DATA_WIDTH;
uint32_t DATA_WIDTH_BYTES;
uint32_t ADDR_WIDTH;
uint32_t ADDR_WIDTH_BYTES;
uint64_t limit_samples;
uint64_t limit_samples_max;
uint8_t capture_ratio;
uint8_t *trigger_mask;
uint8_t *trigger_value;
uint8_t *trigger_mask_last;
uint8_t *trigger_value_last;
uint8_t *trigger_edge_mask;
uint64_t delay_value;
int num_stages;
uint64_t num_transfers;
uint8_t *raw_sample_buf;
};
int data_available(struct ipdbg_la_tcp *tcp);
SR_PRIV struct ipdbg_la_tcp *ipdbg_la_tcp_new(void);
SR_PRIV void ipdbg_la_tcp_free(struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_tcp_open(struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_tcp_close(struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_tcp_send(struct ipdbg_la_tcp *tcp,
const uint8_t *buf, size_t len);
SR_PRIV int ipdbg_la_tcp_receive_blocking(struct ipdbg_la_tcp *tcp,
uint8_t *buf, int bufsize);
SR_PRIV int ipdbg_la_tcp_receive(struct ipdbg_la_tcp *tcp,
uint8_t *buf);
SR_PRIV int ipdbg_la_convert_trigger(const struct sr_dev_inst *sdi);
SR_PRIV struct ipdbg_la_dev_context *ipdbg_la_dev_new(void);
SR_PRIV void ipdbg_la_get_addrwidth_and_datawidth(
struct ipdbg_la_tcp *tcp, struct ipdbg_la_dev_context *devc);
SR_PRIV int send_escaping(struct ipdbg_la_tcp *tcp, uint8_t *dataToSend,
uint32_t length);
SR_PRIV int ipdbg_la_send_reset(struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_request_id(struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_send_start(struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_send_trigger(struct ipdbg_la_dev_context *devc,
struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_send_delay(struct ipdbg_la_dev_context *devc,
struct ipdbg_la_tcp *tcp);
SR_PRIV int ipdbg_la_receive_data(int fd, int revents, void *cb_data);
SR_PRIV void ipdbg_la_abort_acquisition(const struct sr_dev_inst *sdi);
SR_PRIV int ipdbg_la_tcp_receive_blocking(struct ipdbg_la_tcp *tcp,
uint8_t * buf, int bufsize);
#endif

View File

@ -1,89 +0,0 @@
/*
* This file is part of the libsigrok project.
*
* Copyright (C) 2016 danselmi <da@da>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef LIBSIGROK_HARDWARE_IPDBG_ORG_LA_PROTOCOL_H
#define LIBSIGROK_HARDWARE_IPDBG_ORG_LA_PROTOCOL_H
#include <stdint.h>
#include <glib.h>
#include <libsigrok/libsigrok.h>
#include "libsigrok-internal.h"
#define LOG_PREFIX "ipdbg-org-la"
struct ipdbg_org_la_tcp {
char *address;
char *port;
int socket;
};
/** Private, per-device-instance driver context. */
struct ipdbg_org_la_dev_context {
uint32_t DATA_WIDTH;
uint32_t DATA_WIDTH_BYTES;
uint32_t ADDR_WIDTH;
uint32_t ADDR_WIDTH_BYTES;
uint64_t limit_samples;
uint64_t limit_samples_max;
uint8_t capture_ratio;
uint8_t *trigger_mask;
uint8_t *trigger_value;
uint8_t *trigger_mask_last;
uint8_t *trigger_value_last;
uint8_t *trigger_edge_mask;
uint64_t delay_value;
int num_stages;
uint64_t num_transfers;
uint8_t *raw_sample_buf;
};
int data_available(struct ipdbg_org_la_tcp *tcp);
SR_PRIV struct ipdbg_org_la_tcp *ipdbg_org_la_tcp_new(void);
SR_PRIV void ipdbg_org_la_tcp_free(struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_tcp_open(struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_tcp_close(struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_tcp_send(struct ipdbg_org_la_tcp *tcp,
const uint8_t *buf, size_t len);
SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp,
uint8_t *buf, int bufsize);
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp,
uint8_t *buf);
SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi);
SR_PRIV struct ipdbg_org_la_dev_context *ipdbg_org_la_dev_new(void);
SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(
struct ipdbg_org_la_tcp *tcp, struct ipdbg_org_la_dev_context *devc);
SR_PRIV int send_escaping(struct ipdbg_org_la_tcp *tcp, uint8_t *dataToSend,
uint32_t length);
SR_PRIV int ipdbg_org_la_send_reset(struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_request_id(struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_send_start(struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_send_delay(struct ipdbg_org_la_dev_context *devc,
struct ipdbg_org_la_tcp *tcp);
SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data);
SR_PRIV void ipdbg_org_la_abort_acquisition(const struct sr_dev_inst *sdi);
SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp,
uint8_t * buf, int bufsize);
#endif