From c395c6f73a220cd6da26ff3b48afde8487b6199f Mon Sep 17 00:00:00 2001 From: Michael Tharp Date: Fri, 4 Oct 2013 21:24:53 -0400 Subject: [PATCH] Configure SRST output as open-drain for BMP Mini hardware --- src/platforms/native/platform.c | 11 ++++++++--- src/platforms/native/platform.h | 1 + 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/platforms/native/platform.c b/src/platforms/native/platform.c index 44a5793..640ba58 100644 --- a/src/platforms/native/platform.c +++ b/src/platforms/native/platform.c @@ -98,10 +98,15 @@ int platform_init(void) * to release the device from reset if this floats. */ gpio_set_mode(GPIOA, GPIO_MODE_OUTPUT_2_MHZ, GPIO_CNF_OUTPUT_PUSHPULL, GPIO7); - /* Enable SRST output */ - gpio_set_val(SRST_PORT, SRST_PIN, platform_hwversion() > 0); + /* Enable SRST output. Original uses a NPN to pull down, so setting the + * output HIGH asserts. Mini is directly connected so use open drain output + * and set LOW to assert. + */ + platform_srst_set_val(false); gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ, - GPIO_CNF_OUTPUT_PUSHPULL, + (platform_hwversion() == 0 + ? GPIO_CNF_OUTPUT_PUSHPULL + : GPIO_CNF_OUTPUT_OPENDRAIN), SRST_PIN); /* Enable internal pull-up on PWR_BR so that we don't drive diff --git a/src/platforms/native/platform.h b/src/platforms/native/platform.h index 40dd620..20d1510 100644 --- a/src/platforms/native/platform.h +++ b/src/platforms/native/platform.h @@ -220,3 +220,4 @@ static inline uint16_t _gpio_get(uint32_t gpioport, uint16_t gpios) #define disconnect_usb() gpio_set_mode(USB_PU_PORT, GPIO_MODE_INPUT, 0, USB_PU_PIN); void assert_boot_pin(void); void setup_vbus_irq(void); +void platform_srst_set_val(bool assert);