ipdbg-la: Adjust to sigrok indentation style
This commit is contained in:
parent
7f4c9a0444
commit
9d2e5483dc
|
@ -45,9 +45,8 @@ static const int32_t ipdbg_org_la_trigger_matches[] = {
|
|||
|
||||
SR_PRIV struct sr_dev_driver ipdbg_la_driver_info;
|
||||
|
||||
|
||||
|
||||
static void ipdbg_org_la_split_addr_port(const char *conn, char **addr, char **port)
|
||||
static void ipdbg_org_la_split_addr_port(const char *conn, char **addr,
|
||||
char **port)
|
||||
{
|
||||
char **strs = g_strsplit(conn, "/", 3);
|
||||
|
||||
|
@ -89,7 +88,6 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
if (!tcp->address)
|
||||
return NULL;
|
||||
|
||||
|
||||
if (ipdbg_org_la_tcp_open(tcp) != SR_OK)
|
||||
return NULL;
|
||||
|
||||
|
@ -114,7 +112,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
|
|||
|
||||
ipdbg_org_la_get_addrwidth_and_datawidth(tcp, devc);
|
||||
|
||||
sr_dbg("addr_width = %d, data_width = %d\n", devc->ADDR_WIDTH, devc->DATA_WIDTH);
|
||||
sr_dbg("addr_width = %d, data_width = %d\n", devc->ADDR_WIDTH,
|
||||
devc->DATA_WIDTH);
|
||||
sr_dbg("limit samples = %" PRIu64 "\n", devc->limit_samples_max);
|
||||
|
||||
for (uint32_t i = 0; i < devc->DATA_WIDTH; i++) {
|
||||
|
@ -253,19 +252,31 @@ static int config_list(uint32_t key, GVariant **data,
|
|||
switch (key) {
|
||||
case SR_CONF_SCAN_OPTIONS:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
ipdbg_org_la_scanopts, ARRAY_SIZE(ipdbg_org_la_scanopts), sizeof(uint32_t));
|
||||
ipdbg_org_la_scanopts,
|
||||
ARRAY_SIZE
|
||||
(ipdbg_org_la_scanopts),
|
||||
sizeof(uint32_t));
|
||||
break;
|
||||
case SR_CONF_DEVICE_OPTIONS:
|
||||
if (!sdi)
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
ipdbg_org_la_drvopts, ARRAY_SIZE(ipdbg_org_la_drvopts), sizeof(uint32_t));
|
||||
ipdbg_org_la_drvopts,
|
||||
ARRAY_SIZE
|
||||
(ipdbg_org_la_drvopts),
|
||||
sizeof(uint32_t));
|
||||
else
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_UINT32,
|
||||
ipdbg_org_la_devopts, ARRAY_SIZE(ipdbg_org_la_devopts), sizeof(uint32_t));
|
||||
ipdbg_org_la_devopts,
|
||||
ARRAY_SIZE
|
||||
(ipdbg_org_la_devopts),
|
||||
sizeof(uint32_t));
|
||||
break;
|
||||
case SR_CONF_TRIGGER_MATCH:
|
||||
*data = g_variant_new_fixed_array(G_VARIANT_TYPE_INT32,
|
||||
ipdbg_org_la_trigger_matches, ARRAY_SIZE(ipdbg_org_la_trigger_matches), sizeof(int32_t));
|
||||
ipdbg_org_la_trigger_matches,
|
||||
ARRAY_SIZE
|
||||
(ipdbg_org_la_trigger_matches),
|
||||
sizeof(int32_t));
|
||||
break;
|
||||
default:
|
||||
return SR_ERR_NA;
|
||||
|
@ -294,7 +305,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
|
|||
|
||||
ipdbg_org_la_convert_trigger(sdi);
|
||||
ipdbg_org_la_send_trigger(devc, tcp);
|
||||
ipdbg_org_la_send_delay(devc, tcp);;
|
||||
ipdbg_org_la_send_delay(devc, tcp);
|
||||
|
||||
/* 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.
|
||||
|
@ -315,7 +326,8 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi)
|
|||
uint8_t byte;
|
||||
|
||||
if (devc->num_transfers > 0) {
|
||||
while (devc->num_transfers < (devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) {
|
||||
while (devc->num_transfers <
|
||||
(devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) {
|
||||
ipdbg_org_la_tcp_receive(tcp, &byte);
|
||||
devc->num_transfers++;
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@
|
|||
|
||||
#include <sys/ioctl.h>
|
||||
|
||||
|
||||
#define BUFFER_SIZE 4
|
||||
|
||||
/* Top-level command opcodes */
|
||||
|
@ -69,7 +68,6 @@
|
|||
/* LA subfunction command opcodes */
|
||||
#define CMD_LA_DELAY 0x1F
|
||||
|
||||
|
||||
SR_PRIV int data_available(struct ipdbg_org_la_tcp *tcp)
|
||||
{
|
||||
#ifdef __WIN32__
|
||||
|
@ -105,7 +103,6 @@ SR_PRIV void ipdbg_org_la_tcp_free(struct ipdbg_org_la_tcp *tcp)
|
|||
g_free(tcp->port);
|
||||
}
|
||||
|
||||
|
||||
SR_PRIV int ipdbg_org_la_tcp_open(struct ipdbg_org_la_tcp *tcp)
|
||||
{
|
||||
struct addrinfo hints;
|
||||
|
@ -120,8 +117,8 @@ SR_PRIV int ipdbg_org_la_tcp_open(struct ipdbg_org_la_tcp *tcp)
|
|||
err = getaddrinfo(tcp->address, tcp->port, &hints, &results);
|
||||
|
||||
if (err) {
|
||||
sr_err("Address lookup failed: %s:%s: %s", tcp->address, tcp->port,
|
||||
gai_strerror(err));
|
||||
sr_err("Address lookup failed: %s:%s: %s", tcp->address,
|
||||
tcp->port, gai_strerror(err));
|
||||
return SR_ERR;
|
||||
}
|
||||
|
||||
|
@ -192,7 +189,8 @@ SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp,
|
|||
return received;
|
||||
}
|
||||
|
||||
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, uint8_t *buf)
|
||||
SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp,
|
||||
uint8_t *buf)
|
||||
{
|
||||
int received = 0;
|
||||
|
||||
|
@ -208,8 +206,7 @@ SR_PRIV int ipdbg_org_la_tcp_receive(struct ipdbg_org_la_tcp *tcp, uint8_t *buf)
|
|||
}
|
||||
|
||||
return received;
|
||||
}
|
||||
else
|
||||
} else
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -261,7 +258,8 @@ SR_PRIV int ipdbg_org_la_convert_trigger(const struct sr_dev_inst *sdi)
|
|||
devc->trigger_edge_mask[byte_idx] &= ~match_bit;
|
||||
} else if (match->match == SR_TRIGGER_RISING) {
|
||||
devc->trigger_value[byte_idx] |= match_bit;
|
||||
devc->trigger_value_last[byte_idx] &= ~match_bit;
|
||||
devc->trigger_value_last[byte_idx] &=
|
||||
~match_bit;
|
||||
devc->trigger_mask[byte_idx] |= match_bit;
|
||||
devc->trigger_mask_last[byte_idx] |= match_bit;
|
||||
devc->trigger_edge_mask[byte_idx] &= ~match_bit;
|
||||
|
@ -310,11 +308,13 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
|
|||
}
|
||||
}
|
||||
|
||||
if (devc->num_transfers < (devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) {
|
||||
if (devc->num_transfers <
|
||||
(devc->limit_samples_max * devc->DATA_WIDTH_BYTES)) {
|
||||
uint8_t byte;
|
||||
|
||||
if (ipdbg_org_la_tcp_receive(tcp, &byte) == 1) {
|
||||
if (devc->num_transfers < (devc->limit_samples * devc->DATA_WIDTH_BYTES))
|
||||
if (devc->num_transfers <
|
||||
(devc->limit_samples * devc->DATA_WIDTH_BYTES))
|
||||
devc->raw_sample_buf[devc->num_transfers] = byte;
|
||||
|
||||
devc->num_transfers++;
|
||||
|
@ -337,9 +337,11 @@ SR_PRIV int ipdbg_org_la_receive_data(int fd, int revents, void *cb_data)
|
|||
/* Send post-trigger samples. */
|
||||
packet.type = SR_DF_LOGIC;
|
||||
packet.payload = &logic;
|
||||
logic.length = (devc->limit_samples - devc->delay_value) * devc->DATA_WIDTH_BYTES;
|
||||
logic.length = (devc->limit_samples - devc->delay_value) *
|
||||
devc->DATA_WIDTH_BYTES;
|
||||
logic.unitsize = devc->DATA_WIDTH_BYTES;
|
||||
logic.data = devc->raw_sample_buf + (devc->delay_value * devc->DATA_WIDTH_BYTES);
|
||||
logic.data = devc->raw_sample_buf +
|
||||
(devc->delay_value * devc->DATA_WIDTH_BYTES);
|
||||
sr_session_send(cb_data, &packet);
|
||||
|
||||
g_free(devc->raw_sample_buf);
|
||||
|
@ -365,7 +367,8 @@ SR_PRIV int ipdbg_org_la_send_delay(struct ipdbg_org_la_dev_context *devc,
|
|||
uint8_t delay_buf[4] = { devc->delay_value & 0x000000ff,
|
||||
(devc->delay_value >> 8) & 0x000000ff,
|
||||
(devc->delay_value >> 16) & 0x000000ff,
|
||||
(devc->delay_value >> 24) & 0x000000ff};
|
||||
(devc->delay_value >> 24) & 0x000000ff
|
||||
};
|
||||
|
||||
for (uint64_t i = 0; i < devc->ADDR_WIDTH_BYTES; i++)
|
||||
send_escaping(tcp, &(delay_buf[devc->ADDR_WIDTH_BYTES - 1 - i]), 1);
|
||||
|
@ -387,7 +390,8 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
|
|||
ipdbg_org_la_tcp_send(tcp, &buf, 1);
|
||||
|
||||
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
|
||||
send_escaping(tcp, devc->trigger_mask + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
send_escaping(tcp,
|
||||
devc->trigger_mask + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
|
||||
/* Value */
|
||||
buf = CMD_CFG_TRIGGER;
|
||||
|
@ -398,7 +402,8 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
|
|||
ipdbg_org_la_tcp_send(tcp, &buf, 1);
|
||||
|
||||
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
|
||||
send_escaping(tcp, devc->trigger_value + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
send_escaping(tcp,
|
||||
devc->trigger_value + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
|
||||
/* Mask_last */
|
||||
buf = CMD_CFG_TRIGGER;
|
||||
|
@ -409,7 +414,8 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
|
|||
ipdbg_org_la_tcp_send(tcp, &buf, 1);
|
||||
|
||||
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
|
||||
send_escaping(tcp, devc->trigger_mask_last + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
send_escaping(tcp,
|
||||
devc->trigger_mask_last + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
|
||||
/* Value_last */
|
||||
buf = CMD_CFG_TRIGGER;
|
||||
|
@ -420,7 +426,8 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
|
|||
ipdbg_org_la_tcp_send(tcp, &buf, 1);
|
||||
|
||||
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
|
||||
send_escaping(tcp, devc->trigger_value_last + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
send_escaping(tcp,
|
||||
devc->trigger_value_last + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
|
||||
/* Edge_mask */
|
||||
buf = CMD_CFG_TRIGGER;
|
||||
|
@ -431,12 +438,14 @@ SR_PRIV int ipdbg_org_la_send_trigger(struct ipdbg_org_la_dev_context *devc,
|
|||
ipdbg_org_la_tcp_send(tcp, &buf, 1);
|
||||
|
||||
for (size_t i = 0; i < devc->DATA_WIDTH_BYTES; i++)
|
||||
send_escaping(tcp, devc->trigger_edge_mask + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
send_escaping(tcp,
|
||||
devc->trigger_edge_mask + devc->DATA_WIDTH_BYTES - 1 - i, 1);
|
||||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
SR_PRIV int send_escaping(struct ipdbg_org_la_tcp *tcp, uint8_t *dataToSend, uint32_t length)
|
||||
SR_PRIV int send_escaping(struct ipdbg_org_la_tcp *tcp, uint8_t *dataToSend,
|
||||
uint32_t length)
|
||||
{
|
||||
uint8_t escape = CMD_ESCAPE;
|
||||
|
||||
|
@ -458,8 +467,8 @@ SR_PRIV int send_escaping(struct ipdbg_org_la_tcp *tcp, uint8_t *dataToSend, uin
|
|||
return SR_OK;
|
||||
}
|
||||
|
||||
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 void ipdbg_org_la_get_addrwidth_and_datawidth(
|
||||
struct ipdbg_org_la_tcp *tcp, struct ipdbg_org_la_dev_context *devc)
|
||||
{
|
||||
uint8_t buf[8];
|
||||
uint8_t read_cmd = CMD_GET_BUS_WIDTHS;
|
||||
|
@ -482,8 +491,11 @@ SR_PRIV void ipdbg_org_la_get_addrwidth_and_datawidth(struct ipdbg_org_la_tcp *t
|
|||
|
||||
uint8_t HOST_WORD_SIZE = 8;
|
||||
|
||||
devc->DATA_WIDTH_BYTES = (devc->DATA_WIDTH + HOST_WORD_SIZE - 1) / HOST_WORD_SIZE;
|
||||
devc->ADDR_WIDTH_BYTES = (devc->ADDR_WIDTH + HOST_WORD_SIZE - 1) / HOST_WORD_SIZE;
|
||||
devc->DATA_WIDTH_BYTES =
|
||||
(devc->DATA_WIDTH + HOST_WORD_SIZE - 1) / HOST_WORD_SIZE;
|
||||
devc->ADDR_WIDTH_BYTES =
|
||||
(devc->ADDR_WIDTH + HOST_WORD_SIZE - 1) / HOST_WORD_SIZE;
|
||||
|
||||
devc->limit_samples_max = (0x01 << devc->ADDR_WIDTH);
|
||||
devc->limit_samples = devc->limit_samples_max;
|
||||
|
||||
|
@ -550,4 +562,3 @@ SR_PRIV int ipdbg_org_la_send_start(struct ipdbg_org_la_tcp *tcp)
|
|||
|
||||
return SR_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
#define LOG_PREFIX "ipdbg-org-la"
|
||||
|
||||
|
||||
struct ipdbg_org_la_tcp {
|
||||
char *address;
|
||||
char *port;
|
||||
|
@ -35,8 +34,7 @@ struct ipdbg_org_la_tcp {
|
|||
};
|
||||
|
||||
/** Private, per-device-instance driver context. */
|
||||
struct ipdbg_org_la_dev_context
|
||||
{
|
||||
struct ipdbg_org_la_dev_context {
|
||||
uint32_t DATA_WIDTH;
|
||||
uint32_t DATA_WIDTH_BYTES;
|
||||
uint32_t ADDR_WIDTH;
|
||||
|
@ -62,22 +60,30 @@ 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_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 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_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);
|
||||
SR_PRIV int ipdbg_org_la_tcp_receive_blocking(struct ipdbg_org_la_tcp *tcp,
|
||||
uint8_t * buf, int bufsize);
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue