Exemplo n.º 1
0
/*
 * Issues the specified vendor-specific write request.
 */
static int ezusb_write (
    int					device,
    char				*label,
    unsigned char			opcode,
    unsigned short			addr,
    const unsigned char			*data,
    size_t				len
) {
    int					status;

    if (verbose)
	fprintf (stderr, "%s, addr 0x%04x len %4d (0x%04x)\n",
		label, addr, len, len);
    status = ctrl_msg (device,
	USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, opcode,
	addr, 0,
	(unsigned char *) data, len);
    if (status != len) {
	if (status < 0)
	    perror (label);
	else
	    fprintf (stderr, "%s ==> %d\n", label, status);
    }
    return status;
}
Exemplo n.º 2
0
/*
 * Modifies the CPUCS register to stop or reset the CPU.
 * Returns false on error.
 */
static int ezusb_cpucs (
    int			device,
    unsigned short	addr,
    int			doRun
) {
    int			status;
    unsigned char	data = doRun ? 0 : 1;

    if (verbose)
	fprintf (stderr, "%s\n", data ? "stop CPU" : "reset CPU");
    status = ctrl_msg (device,
	USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE,
	RW_INTERNAL,
	addr, 0,
	&data, 1);
    if (status != 1) {
	char *mesg = "can't modify CPUCS";
	if (status < 0)
	    perror (mesg);
	else
	    fprintf (stderr, "%s\n", mesg);
	return 0;
    } else
	return 1;
}
Exemplo n.º 3
0
/*
 * Issues the specified vendor-specific write request.
 */
static int ezusb_write (
    usb_dev_handle			*device,
    char				*label,
    unsigned char			opcode,
    unsigned short			addr,
    const unsigned char			*data,
    size_t				len
) {
    int					status;

    if (verbose)
	printf("%s, addr 0x%04x len %4d (0x%04x)\n", label, addr, (int)len, (int)len);
    status = ctrl_msg (device,
	USB_DIR_OUT | USB_TYPE_VENDOR | USB_RECIP_DEVICE, opcode,
	addr, 0,
	(unsigned char *) data, len);
    if (status != (int)len) {
	if (status < 0)
	    printf("%s: %s\n", label, strerror(errno));
	else
	    printf("%s ==> %d\n", label, status);
    }
    return status;
}