aboutsummaryrefslogtreecommitdiff
path: root/src/platforms
diff options
context:
space:
mode:
authorMarc Singer2013-09-06 21:19:37 -0700
committerGareth McMullin2013-10-05 13:14:03 +0800
commit40820a2354bd76b86e429dbd9f213375dfe05af4 (patch)
treeb7886abba110f198f4e7d3fb9797dd36f8713598 /src/platforms
parente5d253bf812daf1cab020d1f5acceeb4e8e5ae13 (diff)
Added internal pull-up to PWR_BR.
o Prevent probe from inadvertently powering target. If PWR_BR is allowed to float, the gate on Q1 (blackmagic_mini) will tend to be close enough to zero to turn the transistor on. We activate the internal pull-up on this IO pin to force the transistor off.
Diffstat (limited to 'src/platforms')
-rw-r--r--src/platforms/native/platform.c9
-rw-r--r--src/platforms/native/platform.h5
2 files changed, 13 insertions, 1 deletions
diff --git a/src/platforms/native/platform.c b/src/platforms/native/platform.c
index 3228fff..44a5793 100644
--- a/src/platforms/native/platform.c
+++ b/src/platforms/native/platform.c
@@ -104,6 +104,15 @@ int platform_init(void)
GPIO_CNF_OUTPUT_PUSHPULL,
SRST_PIN);
+ /* Enable internal pull-up on PWR_BR so that we don't drive
+ TPWR locally or inadvertently supply power to the target. */
+ if (platform_hwversion () > 0) {
+ gpio_set (PWR_BR_PORT, PWR_BR_PIN);
+ gpio_set_mode(PWR_BR_PORT, GPIO_MODE_INPUT,
+ GPIO_CNF_INPUT_PULL_UPDOWN,
+ PWR_BR_PIN);
+ }
+
/* Setup heartbeat timer */
systick_set_clocksource(STK_CTRL_CLKSOURCE_AHB_DIV8);
systick_set_reload(900000); /* Interrupt us at 10 Hz */
diff --git a/src/platforms/native/platform.h b/src/platforms/native/platform.h
index 77382dc..40dd620 100644
--- a/src/platforms/native/platform.h
+++ b/src/platforms/native/platform.h
@@ -51,7 +51,8 @@ extern usbd_device *usbdev;
* LED2 = PB11 (Red LED : Error)
*
* TPWR = RB0 (input) -- analogue on mini design ADC1, ch8
- * nTRST = PB1
+ * nTRST = PB1 [blackmagic]
+ * PWR_BR = PB1 [blackmagic_mini] -- supply power to the target, active low
* SRST_OUT = PA2
* TDI = PA3
* TMS = PA4 (input for SWDP)
@@ -83,6 +84,8 @@ extern usbd_device *usbdev;
#define TRST_PORT GPIOB
#define TRST_PIN GPIO1
+#define PWR_BR_PORT GPIOB
+#define PWR_BR_PIN GPIO1
#define SRST_PORT GPIOA
#define SRST_PIN GPIO2