summaryrefslogtreecommitdiff
path: root/src/jtag
diff options
context:
space:
mode:
authorntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-12 09:01:38 +0000
committerntfreak <ntfreak@b42882b7-edfa-0310-969c-e2dbd0fdcd60>2008-05-12 09:01:38 +0000
commitf1e72cf029f28a337679ca787003c54d5c1e2bde (patch)
tree837d1267ff9693d9304a261097c686a5eb8bf50a /src/jtag
parent342d77e881ae148aafe0372482fde9c9f0de2520 (diff)
downloadopenocd+libswd-f1e72cf029f28a337679ca787003c54d5c1e2bde.tar.gz
openocd+libswd-f1e72cf029f28a337679ca787003c54d5c1e2bde.tar.bz2
openocd+libswd-f1e72cf029f28a337679ca787003c54d5c1e2bde.tar.xz
openocd+libswd-f1e72cf029f28a337679ca787003c54d5c1e2bde.zip
- restored tabs and formatting
git-svn-id: svn://svn.berlios.de/openocd/trunk@657 b42882b7-edfa-0310-969c-e2dbd0fdcd60
Diffstat (limited to 'src/jtag')
-rw-r--r--src/jtag/ft2232.c174
-rw-r--r--src/jtag/parport.c40
2 files changed, 101 insertions, 113 deletions
diff --git a/src/jtag/ft2232.c b/src/jtag/ft2232.c
index 0b2e79c9..e3d92dce 100644
--- a/src/jtag/ft2232.c
+++ b/src/jtag/ft2232.c
@@ -153,15 +153,11 @@ static int ft2232_expect_read = 0;
jtag_interface_t ft2232_interface =
{
-
.name = "ft2232",
-
.execute_queue = ft2232_execute_queue,
-
.speed = ft2232_speed,
- .speed_div = ft2232_speed_div,
- .khz = ft2232_khz,
-
+ .speed_div = ft2232_speed_div,
+ .khz = ft2232_khz,
.register_commands = ft2232_register_commands,
.init = ft2232_init,
.quit = ft2232_quit,
@@ -266,48 +262,43 @@ int ft2232_speed(int speed)
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);
-
+ /* 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 */
- /* Use 65000 for better rounding */
- *jtag_speed = (60000 / khz) - 10;
-
- /* Add 0.9 for rounding */
- *jtag_speed += 9;
-
- /* Calc real speed */
- *jtag_speed = *jtag_speed / 10;
-
- /* Check if speed is greater than 0 */
- if (*jtag_speed < 0)
- {
- *jtag_speed = 0;
- }
-
+ /* 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 */
+ /* Use 65000 for better rounding */
+ *jtag_speed = (60000 / khz) - 10;
+
+ /* Add 0.9 for rounding */
+ *jtag_speed += 9;
+
+ /* 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,
@@ -1024,20 +1015,20 @@ void olimex_jtag_reset(int trst, int srst)
high_output |= nTRST;
}
- if (srst == 1)
- {
- high_output |= nSRST;
- }
- else if (srst == 0)
- {
- high_output &= ~nSRST;
- }
-
- /* command "set data bits high byte" */
- BUFFER_ADD = 0x82;
- BUFFER_ADD = high_output;
- BUFFER_ADD = high_direction;
- LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
+ if (srst == 1)
+ {
+ high_output |= nSRST;
+ }
+ else if (srst == 0)
+ {
+ high_output &= ~nSRST;
+ }
+
+ /* command "set data bits high byte" */
+ BUFFER_ADD = 0x82;
+ BUFFER_ADD = high_output;
+ BUFFER_ADD = high_direction;
+ LOG_DEBUG("trst: %i, srst: %i, high_output: 0x%2.2x, high_direction: 0x%2.2x", trst, srst, high_output, high_direction);
}
void flyswatter_reset(int trst, int srst)
@@ -1051,20 +1042,20 @@ void flyswatter_reset(int trst, int srst)
low_output |= nTRST;
}
- if (srst == 1)
- {
- low_output |= nSRST;
- }
- else if (srst == 0)
- {
- low_output &= ~nSRST;
- }
-
- /* command "set data bits low byte" */
- BUFFER_ADD = 0x80;
- BUFFER_ADD = low_output;
- BUFFER_ADD = low_direction;
- LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction);
+ if (srst == 1)
+ {
+ low_output |= nSRST;
+ }
+ else if (srst == 0)
+ {
+ low_output &= ~nSRST;
+ }
+
+ /* command "set data bits low byte" */
+ BUFFER_ADD = 0x80;
+ BUFFER_ADD = low_output;
+ BUFFER_ADD = low_direction;
+ LOG_DEBUG("trst: %i, srst: %i, low_output: 0x%2.2x, low_direction: 0x%2.2x", trst, srst, low_output, low_direction);
}
void turtle_reset(int trst, int srst)
@@ -1098,14 +1089,14 @@ void comstick_reset(int trst, int srst)
high_output |= nTRST;
}
- if (srst == 1)
- {
- high_output &= ~nSRST;
- }
- else if (srst == 0)
- {
- high_output |= nSRST;
- }
+ if (srst == 1)
+ {
+ high_output &= ~nSRST;
+ }
+ else if (srst == 0)
+ {
+ high_output |= nSRST;
+ }
/* command "set data bits high byte" */
BUFFER_ADD = 0x82;
@@ -1125,14 +1116,14 @@ void stm32stick_reset(int trst, int srst)
high_output |= nTRST;
}
- if (srst == 1)
- {
- low_output &= ~nSRST;
- }
- else if (srst == 0)
- {
- low_output |= nSRST;
- }
+ if (srst == 1)
+ {
+ low_output &= ~nSRST;
+ }
+ else if (srst == 0)
+ {
+ low_output |= nSRST;
+ }
/* command "set data bits low byte" */
BUFFER_ADD = 0x80;
@@ -1501,17 +1492,17 @@ static int ft2232_init_libftdi(u16 vid, u16 pid, int more, int *try_more)
u8 latency_timer;
LOG_DEBUG("'ft2232' interface using libftdi with '%s' layout (%4.4x:%4.4x)",
- ft2232_layout, vid, pid);
+ ft2232_layout, vid, pid);
if (ftdi_init(&ftdic) < 0)
return ERROR_JTAG_INIT_FAILED;
/* context, vendor id, product id */
if (ftdi_usb_open_desc(&ftdic, vid, pid, ft2232_device_desc,
- ft2232_serial) < 0) {
+ ft2232_serial) < 0) {
if (more)
LOG_WARNING("unable to open ftdi device (trying more): %s",
- ftdic.error_str);
+ ftdic.error_str);
else
LOG_ERROR("unable to open ftdi device: %s", ftdic.error_str);
*try_more = 1;
@@ -1608,10 +1599,10 @@ int ft2232_init(void)
#if BUILD_FT2232_FTD2XX == 1
retval = ft2232_init_ftd2xx(ft2232_vid[i], ft2232_pid[i],
- more, &try_more);
+ more, &try_more);
#elif BUILD_FT2232_LIBFTDI == 1
retval = ft2232_init_libftdi(ft2232_vid[i], ft2232_pid[i],
- more, &try_more);
+ more, &try_more);
#endif
if (retval >= 0)
break;
@@ -2076,7 +2067,6 @@ void turtle_jtag_blink(void)
BUFFER_ADD = high_direction;
}
-
int ft2232_quit(void)
{
#if BUILD_FT2232_FTD2XX == 1
@@ -2142,7 +2132,7 @@ int ft2232_handle_vid_pid_command(struct command_context_s *cmd_ctx, char *cmd,
if (argc > MAX_USB_IDS*2) {
LOG_WARNING("ignoring extra IDs in ft2232_vid_pid "
- "(maximum is %d pairs)", MAX_USB_IDS);
+ "(maximum is %d pairs)", MAX_USB_IDS);
argc = MAX_USB_IDS*2;
}
if (argc < 2 || (argc & 1))
@@ -2178,5 +2168,3 @@ int ft2232_handle_latency_command(struct command_context_s *cmd_ctx, char *cmd,
return ERROR_OK;
}
-
-
diff --git a/src/jtag/parport.c b/src/jtag/parport.c
index e56d65c6..e9934974 100644
--- a/src/jtag/parport.c
+++ b/src/jtag/parport.c
@@ -276,26 +276,26 @@ int parport_register_commands(struct command_context_s *cmd_ctx)
#if PARPORT_USE_GIVEIO == 1
int parport_get_giveio_access()
{
- HANDLE h;
- OSVERSIONINFO version;
-
- version.dwOSVersionInfoSize = sizeof version;
- if (!GetVersionEx( &version )) {
- errno = EINVAL;
- return -1;
- }
- if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
- return 0;
-
- h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
- if (h == INVALID_HANDLE_VALUE) {
- errno = ENODEV;
- return -1;
- }
-
- CloseHandle( h );
-
- return 0;
+ HANDLE h;
+ OSVERSIONINFO version;
+
+ version.dwOSVersionInfoSize = sizeof version;
+ if (!GetVersionEx( &version )) {
+ errno = EINVAL;
+ return -1;
+ }
+ if (version.dwPlatformId != VER_PLATFORM_WIN32_NT)
+ return 0;
+
+ h = CreateFile( "\\\\.\\giveio", GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL );
+ if (h == INVALID_HANDLE_VALUE) {
+ errno = ENODEV;
+ return -1;
+ }
+
+ CloseHandle( h );
+
+ return 0;
}
#endif