aboutsummaryrefslogtreecommitdiff
path: root/src/platforms/stlink/platform.c
diff options
context:
space:
mode:
authorPaul Fertser2013-05-05 00:46:48 +0400
committerGareth McMullin2013-05-14 12:34:53 +1200
commitcdaed128c1f2a53c195d3958427122296b37a570 (patch)
tree920cb7a5652cce93ffc9dea8a6852e824d6559ec /src/platforms/stlink/platform.c
parente0fc21a2a715893331f49d9d838bc0d4a69cf84c (diff)
stlink: add support for SRST handling
This enables SRST signals in open drain mode for both stlinkv1 and stlinkv2 hardware platforms. Signed-off-by: Paul Fertser <fercerpav@gmail.com>
Diffstat (limited to 'src/platforms/stlink/platform.c')
-rw-r--r--src/platforms/stlink/platform.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/platforms/stlink/platform.c b/src/platforms/stlink/platform.c
index e8435b9..08fcd32 100644
--- a/src/platforms/stlink/platform.c
+++ b/src/platforms/stlink/platform.c
@@ -98,6 +98,11 @@ int platform_init(void)
GPIO_CNF_OUTPUT_PUSHPULL, TCK_PIN);
gpio_set_mode(TDI_PORT, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, TDI_PIN);
+ uint16_t srst_pin = platform_hwversion() == 0 ?
+ SRST_PIN_V1 : SRST_PIN_V2;
+ gpio_set(SRST_PORT, srst_pin);
+ gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ,
+ GPIO_CNF_OUTPUT_OPENDRAIN, srst_pin);
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, led_idle_run);
@@ -127,6 +132,16 @@ void platform_delay(uint32_t delay)
while(timeout_counter);
}
+void platform_srst_set_val(bool assert)
+{
+ uint16_t pin;
+ pin = platform_hwversion() == 0 ? SRST_PIN_V1 : SRST_PIN_V2;
+ if (assert)
+ gpio_clear(SRST_PORT, pin);
+ else
+ gpio_set(SRST_PORT, pin);
+}
+
void sys_tick_handler(void)
{
if(running_status)