#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
+#undef USE_KERNEL
+#ifdef USE_KERNEL
#include <cp2101.h>
-
-#define CC_DATA CP2101_GPIO_MASK(0)
-#define CC_CLOCK CP2101_GPIO_MASK(1)
+#define CC_CLOCK CP2101_GPIO_MASK(0)
+#define CC_DATA CP2101_GPIO_MASK(1)
#define CC_RESET_N CP2101_GPIO_MASK(2)
+#else
+#define CC_CLOCK 0x1
+#define CC_DATA 0x2
+#define CC_RESET_N 0x4
+#include <usb.h>
+#endif
+
/* painfully slow for now */
-#define CC_CLOCK_US (1000 * 1000)
+#define CC_CLOCK_US (100)
struct ccdbg {
+ usb_dev_handle *usb_dev;
+ uint8_t gpio;
+#ifdef USE_KERNEL
int fd;
+#endif
uint8_t debug_data;
int clock;
};
#define CC_GET_CHIP_ID 0x68
/* ccdbg-command.c */
+void
+ccdbg_debug_mode(struct ccdbg *dbg);
+
void
ccdbg_reset(struct ccdbg *dbg);
uint8_t
ccdbg_rd_config(struct ccdbg *dbg);
+uint16_t
+ccdbg_get_chip_id(struct ccdbg *dbg);
+
/* ccdbg-io.c */
void
ccdbg_quarter_clock(struct ccdbg *dbg);
+void
+ccdbg_half_clock(struct ccdbg *dbg);
+
+int
+ccdbg_write(struct ccdbg *dbg, uint8_t mask, uint8_t value);
+
+uint8_t
+ccdbg_read(struct ccdbg *dbg);
+
struct ccdbg *
ccdbg_open(char *file);
uint16_t
ccdbg_cmd_write_read16(struct ccdbg *dbg, uint8_t cmd, uint8_t *data, int len);
+/* cp-usb.c */
+void
+cp_usb_init(struct ccdbg *dbg);
+
+void
+cp_usb_fini(struct ccdbg *dbg);
+
+void
+cp_usb_write(struct ccdbg *dbg, uint8_t mask, uint8_t value);
+
+uint8_t
+cp_usb_read(struct ccdbg *dbg);
+
#endif /* _CCDBG_H_ */