Encapsulate the jtag_trst and jtag_srst variables:
authorzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 9 Jun 2009 08:39:50 +0000 (08:39 +0000)
committerzwelch <zwelch@b42882b7-edfa-0310-969c-e2dbd0fdcd60>
Tue, 9 Jun 2009 08:39:50 +0000 (08:39 +0000)
- Add accessor functions to return their value.
- Use new SRST accessor in cortex_m3.c and mips_m4k.c

git-svn-id: svn://svn.berlios.de/openocd/trunk@2157 b42882b7-edfa-0310-969c-e2dbd0fdcd60

src/jtag/core.c
src/jtag/jtag.h
src/target/cortex_m3.c
src/target/mips_m4k.c

index 5dae1775ec61e40a32f8ca55ad32dd8879ad64b7..45ece3c4cf017891f191ad157d871d57fe488848 100644 (file)
@@ -63,8 +63,8 @@ const Jim_Nvp nvp_jtag_tap_event[] = {
        { .name = NULL, .value = -1 }
 };
 
-int jtag_trst = 0;
-int jtag_srst = 0;
+static int jtag_trst = 0;
+static int jtag_srst = 0;
 
 /**
  * List all TAPs that have been created.
@@ -1250,6 +1250,15 @@ int jtag_add_statemove(tap_state_t goal_state)
        return ERROR_OK;
 }
 
+int jtag_get_trst(void)
+{
+       return jtag_trst;
+}
+int jtag_get_srst(void)
+{
+       return jtag_srst;
+}
+
 void jtag_set_nsrst_delay(unsigned delay)
 {
        jtag_nsrst_delay = delay;
index a3e61e3bad5e1ff4c690dd6dfc822559980bb359..40639dce63fee70788028d4a4e213bb555e1f795 100644 (file)
@@ -243,8 +243,10 @@ struct jtag_tap_event_action_s
        jtag_tap_event_action_t* next;
 };
 
-extern int jtag_trst;
-extern int jtag_srst;
+/// @returns The current state of TRST.
+int jtag_get_trst(void);
+/// @returns The current state of SRST.
+int jtag_get_srst(void);
 
 typedef struct jtag_event_callback_s
 {
index d105fe3311461c4cec8f1138bf524fcf9b555538..efa94ea4f1eb55e35604e7f149ef2c9568b01059 100644 (file)
@@ -544,7 +544,7 @@ int cortex_m3_halt(target_t *target)
 
        if (target->state == TARGET_RESET)
        {
-               if ((jtag_reset_config & RESET_SRST_PULLS_TRST) && jtag_srst)
+               if ((jtag_reset_config & RESET_SRST_PULLS_TRST) && jtag_get_srst())
                {
                        LOG_ERROR("can't request a halt while in reset if nSRST pulls nTRST");
                        return ERROR_TARGET_FAILURE;
index d69a0a0aa3c5aa9d83d5125b37c2b4c120f4d792..466e0a2d5025c0b6041ae7b4b3e9e4513f67a7df 100644 (file)
@@ -235,7 +235,7 @@ int mips_m4k_halt(struct target_s *target)
 
        if (target->state == TARGET_RESET)
        {
-               if ((jtag_reset_config & RESET_SRST_PULLS_TRST) && jtag_srst)
+               if ((jtag_reset_config & RESET_SRST_PULLS_TRST) && jtag_get_srst())
                {
                        LOG_ERROR("can't request a halt while in reset if nSRST pulls nTRST");
                        return ERROR_TARGET_FAILURE;