aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-10 12:11:02 +0000
committermifi <mifi@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-10 12:11:02 +0000
commite2e874aa1fb4a2d9c21974f7c3e0be53b928def8 (patch)
tree7707cc8f73180f57026c723b1ce4ea4ff3638b49
parentfcf674ced30d542caccba41a77f494b5a4df23e5 (diff)
- added support for ft2232/jtag_khz
git-svn-id: svn://svn.berlios.de/openocd/trunk@653 b42882b7-edfa-0310-969c-e2dbd0fdcd60
-rw-r--r--src/jtag/ft2232.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c
index 68de086f..f5453a30 100644
--- a/src/jtag/ft2232.c
+++ b/src/jtag/ft2232.c
@@ -61,6 +61,8 @@
int ft2232_execute_queue(void);
int ft2232_speed(int speed);
+int ft2232_speed_div(int speed, int *khz);
+int ft2232_khz(int khz, int *jtag_speed);
int ft2232_register_commands(struct command_context_s *cmd_ctx);
int ft2232_init(void);
int ft2232_quit(void);
@@ -157,6 +159,9 @@ jtag_interface_t ft2232_interface =
.execute_queue = ft2232_execute_queue,
.speed = ft2232_speed,
+ .speed_div = ft2232_speed_div,
+ .khz = ft2232_khz,
+
.register_commands = ft2232_register_commands,
.init = ft2232_init,
.quit = ft2232_quit,
@@ -259,6 +264,49 @@ int ft2232_speed(int speed)
return ERROR_OK;
}
+int ft2232_speed_div(int speed, int *khz)
+{
+ /*
+ * Take a look in the FT2232 manual,
+ * AN2232C-01 Command Processor for
+ * MPSSE and MCU Host Bus. Chapter 3.8
+ */
+ *khz = 6000 / (1+speed);
+
+ return ERROR_OK;
+}
+
+int ft2232_khz(int khz, int *jtag_speed)
+{
+ /*
+ * Take a look in the FT2232 manual,
+ * AN2232C-01 Command Processor for
+ * MPSSE and MCU Host Bus. Chapter 3.8
+ *
+ * We will calc here with a multiplier
+ * of 10 for better rounding later.
+ */
+
+ /* Calc speed, (6000 / khz) - 1 */
+ *jtag_speed = (60000 / khz) - 10;
+
+ /* Add 0.5 for rounding */
+ *jtag_speed += 5;
+
+ /* Calc real speed */
+ *jtag_speed = *jtag_speed / 10;
+
+ /* Check if speed is greater than 0 */
+ if (*jtag_speed < 0)
+ {
+ *jtag_speed = 0;
+ }
+
+ return ERROR_OK;
+}
+
+
+
int ft2232_register_commands(struct command_context_s *cmd_ctx)
{
register_command(cmd_ctx, NULL, "ft2232_device_desc", ft2232_handle_device_desc_command,