--- /dev/null
+ccdbg
+*.o
KERNEL=/local/src/linux-2.6-aiko-64
KINC=$(KERNEL)/drivers/usb/serial
-CFLAGS=-g -I$(KINC)
+WARN=-Wall -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes\
+ -Wmissing-declarations -Wnested-externs -fno-strict-aliasing
+CFLAGS=-g -I$(KINC) $(WARN)
-OBJS=ccdbg-command.o ccdbg-io.o cccp.o
+OBJS=ccdbg.o ccdbg-command.o ccdbg-io.o cccp.o
INCS=ccdbg.h cccp.h
PROG=ccdbg
set = (mask) | (value << 8);
dbg->debug_data = (dbg->debug_data & ~mask) | (value & mask);
+ printf (" -> %02x\n", dbg->debug_data);
ret = ioctl(dbg->fd, CP2101_IOCTL_GPIOSET, &set);
if (ret < 0)
perror("CP2101_IOCTL_GPIOSET");
perror("CP2101_IOCTL_GPIOGET");
get = 0;
}
+ printf (" <- %02x\n", get);
return get & mask;
}
void
cccp_init(struct ccdbg *dbg);
+void
+cccp_fini(struct ccdbg *dbg);
+
#endif /* _CCCP_H_ */
return dbg;
}
+void
+ccdbg_close(struct ccdbg *dbg)
+{
+ cccp_fini(dbg);
+ close (dbg->fd);
+ free (dbg);
+}
+
void
ccdbg_clock_1_0(struct ccdbg *dbg)
{
--- /dev/null
+/*
+ * Copyright © 2008 Keith Packard <keithp@keithp.com>
+ *
+ * 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 2 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, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+#include "ccdbg.h"
+
+int
+main (int argc, char **argv)
+{
+ struct ccdbg *dbg;
+ uint8_t status;
+
+ dbg = ccdbg_open("/dev/ttyUSB0");
+ if (!dbg)
+ exit (1);
+ ccdbg_reset(dbg);
+ status = ccdbg_read_status(dbg);
+ printf("Status: 0x%02x\n", status);
+ ccdbg_close(dbg);
+ exit (0);
+}
#include <stdio.h>
#include <stdint.h>
#include <assert.h>
+#include <fcntl.h>
#include <sys/types.h>
#include <sys/ioctl.h>
+#include <sys/stat.h>
#include <cp2101.h>
#define CC_DATA CP2101_GPIO_MASK(0)
#define CC_RESET_N CP2101_GPIO_MASK(2)
/* painfully slow for now */
-#define CC_CLOCK_US (2 * 1000)
+#define CC_CLOCK_US (1000 * 1000)
struct ccdbg {
int fd;
#define CC_STEP_REPLACE (0x64|(n))
#define CC_GET_CHIP_ID 0x68
+/* ccdbg-command.c */
+void
+ccdbg_reset(struct ccdbg *dbg);
+
+uint8_t
+ccdbg_read_status(struct ccdbg *dbg);
+
+uint8_t
+ccdbg_rd_config(struct ccdbg *dbg);
+
+/* ccdbg-io.c */
+void
+ccdbg_quarter_clock(struct ccdbg *dbg);
+
+struct ccdbg *
+ccdbg_open(char *file);
+
+void
+ccdbg_close(struct ccdbg *dbg);
+
+void
+ccdbg_clock_1_0(struct ccdbg *dbg);
+
+void
+ccdbg_clock_0_1(struct ccdbg *dbg);
+
+void
+ccdbg_write_bit(struct ccdbg *dbg, uint8_t bit);
+
+void
+ccdbg_write_byte(struct ccdbg *dbg, uint8_t byte);
+
+uint8_t
+ccdbg_read_bit(struct ccdbg *dbg);
+
+uint8_t
+ccdbg_read_byte(struct ccdbg *dbg);
+
+void
+ccdbg_cmd_write(struct ccdbg *dbg, uint8_t cmd, uint8_t *data, int len);
+
+uint8_t
+ccdbg_cmd_write_read8(struct ccdbg *dbg, uint8_t cmd, uint8_t *data, int len);
+
+uint16_t
+ccdbg_cmd_write_read16(struct ccdbg *dbg, uint8_t cmd, uint8_t *data, int len);
+
#endif /* _CCDBG_H_ */