Commit ec3dc106 authored by DreamSourceLab's avatar DreamSourceLab
Browse files

firmware/hdl updated, fix initialization issue and improve stability

parent 0b9fe223
......@@ -19,8 +19,6 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
#include <cassert>
#include <QDebug>
......
......@@ -523,8 +523,8 @@ void MainWindow::show_error()
ch_status += (i > 9 ? " " : "");
error_pattern >>= 1;
}
details = tr("the received data are not consist with pre-defined test data!\n") +
tr("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15\n") + ch_status;
details = tr("the received data are not consist with pre-defined test data!") + "\n" +
tr("0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15")+ "\n" + ch_status;
break;
case SigSession::Pkt_data_err:
title = tr("Packet Error");
......@@ -723,6 +723,13 @@ bool MainWindow::load_session(QString name)
return false;
}
// clear decoders
#ifdef ENABLE_DECODE
if (sdi->mode == LOGIC) {
_protocol_widget->del_all_protocol();
}
#endif
// load device settings
GVariant *gvar_opts;
gsize num_opts;
......
......@@ -445,7 +445,6 @@ bool SigSession::get_capture_status(bool &triggered, int &progress)
sr_status status;
if (sr_status_get(_dev_inst->dev_inst(), &status, SR_STATUS_TRIG_BEGIN, SR_STATUS_TRIG_END) == SR_OK){
triggered = status.trig_hit & 0x01;
const bool captured_cnt_dec = status.trig_hit & 0x02;
uint64_t captured_cnt = status.trig_hit >> 2;
captured_cnt = ((uint64_t)status.captured_cnt0 +
((uint64_t)status.captured_cnt1 << 8) +
......@@ -454,7 +453,7 @@ bool SigSession::get_capture_status(bool &triggered, int &progress)
(captured_cnt << 32));
if (_dev_inst->dev_inst()->mode == DSO)
captured_cnt = captured_cnt * _signals.size() / get_ch_num(SR_CHANNEL_DSO);
if (captured_cnt_dec)
if (triggered)
progress = (sample_limits - captured_cnt) * 100.0 / sample_limits;
else
progress = captured_cnt * 100.0 / sample_limits;
......@@ -1057,8 +1056,10 @@ void SigSession::data_feed_in(const struct sr_dev_inst *sdi,
case SR_DF_OVERFLOW:
{
_error = Data_overflow;
session_error();
if (_error == No_err) {
_error = Data_overflow;
session_error();
}
break;
}
case SR_DF_END:
......
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
File added
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
......@@ -23,6 +23,7 @@ noinst_LTLIBRARIES = libsigrok4DSL_hw_dsl.la
libsigrok4DSL_hw_dsl_la_SOURCES = \
command.c \
dsl.c \
dslogic.c \
dscope.c
......
......@@ -19,179 +19,22 @@
#include "libsigrok.h"
#include "libsigrok-internal.h"
//#include <libusb.h>
#include "command.h"
//#include "libsigrok.h"
#include "dsl.h"
#include <assert.h>
SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl,
struct version_info *vi)
{
int ret;
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_IN, CMD_GET_FW_VERSION, 0x0000, 0x0000,
(unsigned char *)vi, sizeof(struct version_info), 3000);
if (ret < 0) {
sr_err("Unable to get version info: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_get_revid_version(libusb_device_handle *devhdl,
uint8_t *revid)
{
int ret;
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_IN, CMD_GET_REVID_VERSION, 0x0000, 0x0000,
revid, 1, 3000);
if (ret < 0) {
sr_err("Unable to get REVID: %s.", libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl,
uint64_t samplerate, gboolean samplewide, gboolean la_mode)
{
struct cmd_start_acquisition cmd;
int delay = 0, ret;
(void) samplerate;
cmd.flags = la_mode ? CMD_START_FLAGS_MODE_LA : 0;
cmd.flags |= CMD_START_FLAGS_CLK_30MHZ;
delay = 0;
sr_info("GPIF delay = %d, clocksource = %sMHz.", delay,
(cmd.flags & CMD_START_FLAGS_CLK_48MHZ) ? "48" : "30");
// if (delay <= 0 || delay > MAX_SAMPLE_DELAY) {
// sr_err("Unable to sample at %" PRIu64 "Hz.", samplerate);
// return SR_ERR;
// }
cmd.sample_delay_h = (delay >> 8) & 0xff;
cmd.sample_delay_l = delay & 0xff;
/* Select the sampling width. */
cmd.flags |= samplewide ? CMD_START_FLAGS_SAMPLE_16BIT :
CMD_START_FLAGS_SAMPLE_8BIT;
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 3000);
if (ret < 0) {
sr_err("Unable to send start command: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_stop_acquisition(libusb_device_handle *devhdl)
{
struct cmd_start_acquisition cmd;
int ret;
/* stop acquisition command */
cmd.flags = CMD_START_FLAGS_STOP;
cmd.sample_delay_h = 0;
cmd.sample_delay_l = 0;
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_START, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 3000);
if (ret < 0) {
sr_err("Unable to send stop command: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_fpga_config(libusb_device_handle *devhdl)
SR_PRIV int command_ctl_wr(libusb_device_handle *devhdl, struct ctl_wr_cmd cmd)
{
struct cmd_cfg_count cmd;
int ret;
/* ... */
cmd.byte0 = (uint8_t)0;
cmd.byte1 = (uint8_t)0;
cmd.byte2 = (uint8_t)0;
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_CONFIG, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 3000);
if (ret < 0) {
sr_err("Unable to send FPGA configure command: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_fpga_setting(libusb_device_handle *devhdl, uint32_t setting_count)
{
struct cmd_setting_count cmd;
int ret;
/* ... */
cmd.byte0 = (uint8_t)setting_count;
cmd.byte1 = (uint8_t)(setting_count >> 8);
cmd.byte2 = (uint8_t)(setting_count >> 16);
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_SETTING, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 3000);
if (ret < 0) {
sr_err("Unable to send FPGA setting command: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_dso_ctrl(libusb_device_handle *devhdl, uint64_t command)
{
struct cmd_control cmd;
int ret;
/* ... */
cmd.byte0 = (uint8_t)command;
cmd.byte1 = (uint8_t)(command >> 8);
cmd.byte2 = (uint8_t)(command >> 16);
cmd.byte3 = (uint8_t)(command >> 24);
cmd.byte4 = (uint8_t)(command >> 32);
cmd.byte5 = (uint8_t)(command >> 40);
cmd.byte6 = (uint8_t)(command >> 48);
cmd.byte7 = (uint8_t)(command >> 56);
/* Send the control command. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_CONTROL, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 3000);
LIBUSB_ENDPOINT_OUT, CMD_CTL_WR, 0x0000, 0x0000,
(unsigned char *)&cmd, cmd.header.size+sizeof(struct ctl_header), 3000);
if (ret < 0) {
sr_err("Unable to send oscilloscope control command: %s.",
sr_err("Unable to send CMD_CTL_WR command(dest:%d/offset:%d/size:%d): %s.",
cmd.header.dest, cmd.header.offset, cmd.header.size,
libusb_error_name(ret));
return SR_ERR;
}
......@@ -199,129 +42,33 @@ SR_PRIV int command_dso_ctrl(libusb_device_handle *devhdl, uint64_t command)
return SR_OK;
}
SR_PRIV int command_get_status(libusb_device_handle *devhdl,
unsigned char *status, int begin, int end)
SR_PRIV int command_ctl_rd(libusb_device_handle *devhdl, struct ctl_rd_cmd cmd)
{
struct cmd_status_info cmd;
int ret;
/* status acquisition command */
assert(begin >= 0);
assert(end >= 0);
cmd.begin = begin;
cmd.end = end;
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_STATUS_INFO, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 3000);
LIBUSB_ENDPOINT_OUT, CMD_CTL_RD_PRE, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(struct ctl_header), 3000);
if (ret < 0) {
sr_err("Unable to send status info: %s.",
sr_err("Unable to send CMD_CTL_RD_PRE command(dest:%d/offset:%d/size:%d): %s.",
cmd.header.dest, cmd.header.offset, cmd.header.size,
libusb_error_name(ret));
return SR_ERR;
}
g_usleep(10*1000);
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_IN, CMD_STATUS, 0x0000, 0x0000,
(unsigned char *)status, CMD_STATUS_CNT, 3000);
if (ret < 0) {
sr_err("Unable to get status info: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_wr_reg(libusb_device_handle *devhdl, uint8_t value, uint8_t addr)
{
int ret;
uint16_t cmd;
cmd = value + (addr << 8);
/* Send the control command. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_WR_REG, 0x0000, 0x0000,
(unsigned char *)&cmd, sizeof(cmd), 3000);
if (ret < 0) {
sr_err("Unable to write REG @ address %d : %s.",
addr, libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_wr_nvm(libusb_device_handle *devhdl, unsigned char *ctx, uint8_t len)
{
int ret;
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_WR_NVM, 0x0000, 0x0000,
(unsigned char *)ctx, len, 3000);
LIBUSB_ENDPOINT_IN, CMD_CTL_RD, 0x0000, 0x0000,
(unsigned char *)cmd.data, cmd.header.size, 3000);
if (ret < 0) {
sr_err("Unable to get status info: %s.",
sr_err("Unable to send CMD_CTL_RD command: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_rd_nvm(libusb_device_handle *devhdl, unsigned char *ctx, uint16_t addr, uint8_t len)
{
int ret;
struct cmd_nvm_info nvm_info;
assert(len <= 32);
nvm_info.addr = addr;
nvm_info.len = len;
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_OUT, CMD_RD_NVM_PRE, 0x0000, 0x0000,
(unsigned char *)&nvm_info, sizeof(struct cmd_nvm_info), 3000);
if (ret < 0) {
sr_err("Unable to send CMD_RD_NVM_PRE command: %s.",
libusb_error_name(ret));
return SR_ERR;
}
g_usleep(10*1000);
/* Send the control message. */
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_IN, CMD_RD_NVM, 0x0000, 0x0000,
(unsigned char *)ctx, len, 3000);
if (ret < 0) {
sr_err("Unable to get zero info: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
SR_PRIV int command_get_hw_info(libusb_device_handle *devhdl, uint8_t *info)
{
int ret;
ret = libusb_control_transfer(devhdl, LIBUSB_REQUEST_TYPE_VENDOR |
LIBUSB_ENDPOINT_IN, CMD_GET_HW_INFO, 0x0000, 0x0000,
info, 1, 3000);
if (ret < 0) {
sr_err("Unable to get hardware info: %s.",
libusb_error_name(ret));
return SR_ERR;
}
return SR_OK;
}
......@@ -25,82 +25,54 @@
#include "libsigrok-internal.h"
/* Protocol commands */
#define CMD_GET_FW_VERSION 0xb0
#define CMD_GET_REVID_VERSION 0xb1
#define CMD_START 0xb2
#define CMD_CONFIG 0xb3
#define CMD_SETTING 0xb4
#define CMD_CONTROL 0xb5
#define CMD_STATUS 0xb6
#define CMD_STATUS_INFO 0xb7
#define CMD_WR_REG 0xb8
#define CMD_WR_NVM 0xb9
#define CMD_RD_NVM 0xba
#define CMD_RD_NVM_PRE 0xbb
#define CMD_GET_HW_INFO 0xbc
#define CMD_START_FLAGS_MODE_POS 4
#define CMD_START_FLAGS_WIDE_POS 5
#define CMD_START_FLAGS_CLK_SRC_POS 6
#define CMD_START_FLAGS_STOP_POS 7
#define CMD_START_FLAGS_MODE_LA (1 << CMD_START_FLAGS_MODE_POS)
#define CMD_START_FLAGS_SAMPLE_8BIT (0 << CMD_START_FLAGS_WIDE_POS)
#define CMD_START_FLAGS_SAMPLE_16BIT (1 << CMD_START_FLAGS_WIDE_POS)
#define CMD_START_FLAGS_CLK_30MHZ (0 << CMD_START_FLAGS_CLK_SRC_POS)
#define CMD_START_FLAGS_CLK_48MHZ (1 << CMD_START_FLAGS_CLK_SRC_POS)
#define CMD_START_FLAGS_STOP (1 << CMD_START_FLAGS_STOP_POS)
#define CMD_STATUS_CNT 32
#define CMD_CTL_WR 0xb0
#define CMD_CTL_RD_PRE 0xb1
#define CMD_CTL_RD 0xb2
#define bmGPIF_DONE (1 << 7)
#define bmFPGA_DONE (1 << 6)
#define bmFPGA_INIT_B (1 << 5)
#define bmSYS_OVERFLOW (1 << 4)
#define bmSYS_CLR (1 << 3)
#define bmSYS_EN (1 << 2)
#define bmLED_RED (1 << 1)
#define bmLED_GREEN (1 << 0)
#define bmWR_PROG_B (1 << 2)
#define bmWR_INTRDY (1 << 7)
#define bmWR_WORDWIDE (1 << 0)
#define VTH_ADDR 0x78
#define EEWP_ADDR 0x70
#define COMB_ADDR 0x68
#pragma pack(push, 1)
enum {
DSL_CTL_FW_VERSION = 0,
DSL_CTL_REVID_VERSION = 1,
DSL_CTL_HW_STATUS = 2,
DSL_CTL_PROG_B = 3,
DSL_CTL_SYS = 4,
DSL_CTL_LED = 5,
DSL_CTL_INTRDY = 6,
DSL_CTL_WORDWIDE = 7,
DSL_CTL_START = 8,
DSL_CTL_STOP = 9,
DSL_CTL_BULK_WR = 10,
DSL_CTL_REG = 11,
DSL_CTL_NVM = 12,
DSL_CTL_I2C_DSO = 13,
DSL_CTL_I2C_REG = 14,
DSL_CTL_DSO_MEASURE = 15,
};
#pragma pack(push, 1) // byte align
struct version_info {
uint8_t major;
uint8_t minor;
};
struct cmd_start_acquisition {
uint8_t flags;
uint8_t sample_delay_h;
uint8_t sample_delay_l;
};
struct cmd_setting_count {
uint8_t byte0;
uint8_t byte1;
uint8_t byte2;
};
struct cmd_cfg_count {
uint8_t byte0;
uint8_t byte1;
uint8_t byte2;
};
struct cmd_control {
uint8_t byte0;
uint8_t byte1;
uint8_t byte2;
uint8_t byte3;
uint8_t byte4;
uint8_t byte5;
uint8_t byte6;
uint8_t byte7;
};
struct cmd_status_info {
uint8_t begin;
uint8_t end;
};
struct cmd_zero_info {
uint8_t zero_addr;
uint8_t voff0;
......@@ -137,35 +109,23 @@ struct cmd_vga_info {
uint16_t vga7;
};
struct cmd_nvm_info {
uint16_t addr;
uint8_t len;
struct ctl_header {
uint8_t dest;
uint16_t offset;
uint8_t size;
};
struct ctl_wr_cmd {
struct ctl_header header;
uint8_t data[60];
};
struct ctl_rd_cmd {
struct ctl_header header;
uint8_t *data;
};
#pragma pack(pop)
SR_PRIV int command_get_fw_version(libusb_device_handle *devhdl,
struct version_info *vi);
SR_PRIV int command_get_revid_version(libusb_device_handle *devhdl,
uint8_t *revid);
SR_PRIV int command_start_acquisition(libusb_device_handle *devhdl,
uint64_t samplerate, gboolean samplewide, gboolean la_mode);
SR_PRIV int command_stop_acquisition(libusb_device_handle *devhdl);
SR_PRIV int command_fpga_config(libusb_device_handle *devhdl);
SR_PRIV int command_fpga_setting(libusb_device_handle *devhdl, uint32_t setting_count);
SR_PRIV int command_dso_ctrl(libusb_device_handle *devhdl, uint64_t command);
SR_PRIV int command_get_status(libusb_device_handle *devhdl,
unsigned char *status,
int begin, int end);
SR_PRIV int command_wr_reg(libusb_device_handle *devhdl, uint8_t value, uint8_t addr);
SR_PRIV int command_wr_nvm(libusb_device_handle *devhdl, unsigned char *ctx, uint8_t len);
SR_PRIV int command_rd_nvm(libusb_device_handle *devhdl, unsigned char *ctx, uint16_t addr, uint8_t len);
SR_PRIV int command_ctl_wr(libusb_device_handle *devhdl, struct ctl_wr_cmd cmd);
SR_PRIV int command_ctl_rd(libusb_device_handle *devhdl, struct ctl_rd_cmd cmd);
SR_PRIV int command_get_hw_info(libusb_device_handle *devhdl,
uint8_t *fpga_done);
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment