* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-#include "protocol.h"
-
#include <stdint.h>
#include <string.h>
#include <glib.h>
#include <math.h>
#include "libsigrok.h"
#include "libsigrok-internal.h"
+#include "protocol.h"
#define FPGA_FIRMWARE_18 FIRMWARE_DIR"/saleae-logic16-fpga-18.bitstream"
#define FPGA_FIRMWARE_33 FIRMWARE_DIR"/saleae-logic16-fpga-33.bitstream"
usb = sdi->conn;
if (cmd_len < 1 || cmd_len > 64 || reply_len > 64 ||
- command == NULL || (reply_len > 0 && reply == NULL))
+ !command || (reply_len > 0 && !reply))
return SR_ERR_ARG;
encrypt(buf, command, cmd_len);
uint8_t chunk, command[64];
int ret;
- if (cnt < 1 || cnt + offset > 64 || table == NULL)
+ if (cnt < 1 || cnt + offset > 64 || !table)
return SR_ERR_ARG;
while (cnt > 0) {
}
sr_info("Uploading FPGA bitstream at %s.", filename);
- if ((fw = g_fopen(filename, "rb")) == NULL) {
+ if (!(fw = g_fopen(filename, "rb"))) {
sr_err("Unable to open bitstream file %s for reading: %s.",
filename, strerror(errno));
return SR_ERR;
reg1 &= ~0x20;
if (devc->fpga_variant == FPGA_VARIANT_ORIGINAL && reg1 != 0x08) {
- sr_dbg("Invalid state at acquisition setup: 0x%02x != 0x08.", reg1);
- return SR_ERR;
+ sr_dbg("Invalid state at acquisition setup register 1: 0x%02x != 0x08. "
+ "Proceeding anyway.", reg1);
}
if ((ret = write_fpga_register(sdi, 1, 0x40)) != SR_OK)
return ret;
if (devc->fpga_variant == FPGA_VARIANT_ORIGINAL && reg1 != 0x48) {
- sr_dbg("Invalid state at acquisition setup: 0x%02x != 0x48. "
+ sr_dbg("Invalid state at acquisition setup register 1: 0x%02x != 0x48. "
"Proceeding anyway.", reg1);
}
return ret;
if (devc->fpga_variant == FPGA_VARIANT_ORIGINAL && reg10 != clock_select) {
- sr_dbg("Invalid state at acquisition setup: 0x%02x != 0x%02x.",
- reg10, clock_select);
- return SR_ERR;
+ sr_dbg("Invalid state at acquisition setup register 10: 0x%02x != 0x%02x. "
+ "Proceeding anyway.", reg10, clock_select);
}
return SR_OK;
return ret;
}
-SR_PRIV void logic16_receive_transfer(struct libusb_transfer *transfer)
+SR_PRIV void LIBUSB_CALL logic16_receive_transfer(struct libusb_transfer *transfer)
{
gboolean packet_has_error = FALSE;
struct sr_datafeed_packet packet;
return;
}
- sr_info("receive_transfer(): status %d received %d bytes.",
- transfer->status, transfer->actual_length);
+ sr_info("receive_transfer(): status %s received %d bytes.",
+ libusb_error_name(transfer->status), transfer->actual_length);
switch (transfer->status) {
case LIBUSB_TRANSFER_NO_DEVICE: