[blackmagic] [PATCH 2/3] stlink: add support for SRST handling
An in-application debug probe for ARM Cortex-M microcontrollers.
Status: Beta
Brought to you by:
gsmcmullin
|
From: Paul F. <fer...@gm...> - 2013-05-04 20:47:19
|
This enables SRST signals in open drain mode for both stlinkv1 and
stlinkv2 hardware platforms.
Signed-off-by: Paul Fertser <fer...@gm...>
---
src/platforms/stlink/platform.c | 15 +++++++++++++++
src/platforms/stlink/platform.h | 8 ++++++++
2 files changed, 23 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)
diff --git a/src/platforms/stlink/platform.h b/src/platforms/stlink/platform.h
index cbfc0ba..1ee944c 100644
--- a/src/platforms/stlink/platform.h
+++ b/src/platforms/stlink/platform.h
@@ -79,6 +79,10 @@ extern usbd_device *usbdev;
#define SWDIO_PIN TMS_PIN
#define SWCLK_PIN TCK_PIN
+#define SRST_PORT GPIOB
+#define SRST_PIN_V1 GPIO1
+#define SRST_PIN_V2 GPIO0
+
#define LED_PORT GPIOA
/* Use PC14 for a "dummy" uart led. So we can observere at least with scope*/
#define LED_PORT_UART GPIOC
@@ -98,6 +102,9 @@ extern usbd_device *usbdev;
gpio_set_mode(USBUSART_PORT, GPIO_MODE_OUTPUT_2_MHZ, \
GPIO_CNF_OUTPUT_ALTFN_PUSHPULL, USBUSART_TX_PIN);
+#define SRST_SET_VAL(x) \
+ platform_srst_set_val(x)
+
#define USB_DRIVER stm32f103_usb_driver
#define USB_IRQ NVIC_USB_LP_CAN_RX0_IRQ
#define USB_ISR usb_lp_can_rx0_isr
@@ -152,6 +159,7 @@ int platform_init(void);
void morse(const char *msg, char repeat);
const char *platform_target_voltage(void);
void platform_delay(uint32_t delay);
+void platform_srst_set_val(bool assert);
/* <cdcacm.c> */
void cdcacm_init(void);
--
1.7.3.4
|