From f2650df73189285b787ed7cf251f554463e5dd80 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Wed, 6 Apr 2016 19:20:43 -0700 Subject: [PATCH 1/2] Fixed a hardware version detection glitch. If you try to read out the GPIO immediately after setting the weak pull on the pin it is possible that you will not read the correct value on a floating pin. We need to use a busy wait loop instead of the platform_delay because the platform timing is not initialized yet. We also can not initialize the platform_delay code yet because it requires LED gpio to be configured. A busy wait seems to do the job and is easier than refactoring the codebase to use the platform_delay function. --- src/platforms/native/platform.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/platforms/native/platform.c b/src/platforms/native/platform.c index 9526ce7..a5a3508 100644 --- a/src/platforms/native/platform.c +++ b/src/platforms/native/platform.c @@ -41,6 +41,7 @@ static void setup_vbus_irq(void); /* Pins PB[7:5] are used to detect hardware revision. * 000 - Original production build. * 001 - Mini production build. + * 010 - Mini V2.0e and later. */ int platform_hwversion(void) { @@ -57,6 +58,10 @@ int platform_hwversion(void) /* Enable the weak pull up. */ gpio_set(GPIOB, hwversion_pins); + + /* Wait a little to make sure the pull up is in effect... */ + for(int i = 0; i < 100; i++) asm("nop"); + /* Get all pins that are pulled low in hardware. * This also sets all the "unused" pins to 1. */ @@ -64,10 +69,13 @@ int platform_hwversion(void) /* Enable the weak pull down. */ gpio_clear(GPIOB, hwversion_pins); + + /* Wait a little to make sure the pull down is in effect... */ + for(int i = 0; i < 100; i++) asm("nop"); + /* Get all the pins that are pulled high in hardware. */ uint16_t pins_positive = gpio_get(GPIOB, hwversion_pins); - /* Hardware version is the id defined by the pins that are * asserted low or high by the hardware. This means that pins * that are left floating are 0 and those that are either From 8e8a53ef12fe102b1fdbb7f29fdc00f147ccb321 Mon Sep 17 00:00:00 2001 From: Piotr Esden-Tempski Date: Wed, 6 Apr 2016 19:23:17 -0700 Subject: [PATCH 2/2] Added support for Black Magic Probe Mini V2.0e. All BMPM2 prototypes after revision a have their LED0 and LED2 inverted. Because of that we have bumped the hardware revision to swap the LEDs in software. This is easier than messing up the routing of the LEDs. --- src/platforms/native/platform.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/platforms/native/platform.h b/src/platforms/native/platform.h index 4a25fee..fd8c3ec 100644 --- a/src/platforms/native/platform.h +++ b/src/platforms/native/platform.h @@ -93,9 +93,9 @@ #define LED_0 GPIO2 #define LED_1 GPIO10 #define LED_2 GPIO11 -#define LED_UART LED_2 +#define LED_UART (platform_hwversion() < 2 ? LED_2 : LED_0) #define LED_IDLE_RUN LED_1 -#define LED_ERROR LED_0 +#define LED_ERROR (platform_hwversion() < 2 ? LED_0 : LED_2) #define TMS_SET_MODE() \ gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \