Merge pull request #182 from esden/bmpm21

Add BMPM V2.1 support
This commit is contained in:
Gareth McMullin 2017-01-09 14:38:33 +13:00 committed by GitHub
commit 334f6dac0a
2 changed files with 28 additions and 15 deletions

View File

@ -112,13 +112,13 @@ void platform_init(void)
gpio_set_mode(JTAG_PORT, GPIO_MODE_OUTPUT_50_MHZ, gpio_set_mode(JTAG_PORT, GPIO_MODE_OUTPUT_50_MHZ,
GPIO_CNF_OUTPUT_PUSHPULL, GPIO_CNF_OUTPUT_PUSHPULL,
TMS_PIN | TCK_PIN | TDI_PIN); TMS_DIR_PIN | TMS_PIN | TCK_PIN | TDI_PIN);
/* This needs some fixing... */ /* This needs some fixing... */
/* Toggle required to sort out line drivers... */ /* Toggle required to sort out line drivers... */
gpio_port_write(GPIOA, 0x8100); gpio_port_write(GPIOA, 0x8102);
gpio_port_write(GPIOB, 0x2000); gpio_port_write(GPIOB, 0x2000);
gpio_port_write(GPIOA, 0x8180); gpio_port_write(GPIOA, 0x8182);
gpio_port_write(GPIOB, 0x2002); gpio_port_write(GPIOB, 0x2002);
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ, gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
@ -135,9 +135,10 @@ void platform_init(void)
*/ */
platform_srst_set_val(false); platform_srst_set_val(false);
gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ, gpio_set_mode(SRST_PORT, GPIO_MODE_OUTPUT_50_MHZ,
(platform_hwversion() == 0 (((platform_hwversion() == 0) ||
? GPIO_CNF_OUTPUT_PUSHPULL (platform_hwversion() >= 3))
: GPIO_CNF_OUTPUT_OPENDRAIN), ? GPIO_CNF_OUTPUT_PUSHPULL
: GPIO_CNF_OUTPUT_OPENDRAIN),
SRST_PIN); SRST_PIN);
/* Enable internal pull-up on PWR_BR so that we don't drive /* Enable internal pull-up on PWR_BR so that we don't drive
@ -175,7 +176,8 @@ void platform_init(void)
void platform_srst_set_val(bool assert) void platform_srst_set_val(bool assert)
{ {
if (platform_hwversion() == 0) { if ((platform_hwversion() == 0) ||
(platform_hwversion() >= 3)) {
gpio_set_val(SRST_PORT, SRST_PIN, assert); gpio_set_val(SRST_PORT, SRST_PIN, assert);
} else { } else {
gpio_set_val(SRST_PORT, SRST_PIN, !assert); gpio_set_val(SRST_PORT, SRST_PIN, !assert);
@ -188,7 +190,9 @@ void platform_srst_set_val(bool assert)
bool platform_srst_get_val(void) bool platform_srst_get_val(void)
{ {
if (platform_hwversion() == 0) { if (platform_hwversion() == 0) {
return gpio_get(SRST_PORT, SRST_SENSE_PIN) == 0; return gpio_get(SRST_SENSE_PORT, SRST_SENSE_PIN) == 0;
} else if (platform_hwversion() >= 3) {
return gpio_get(SRST_SENSE_PORT, SRST_SENSE_PIN) != 0;
} else { } else {
return gpio_get(SRST_PORT, SRST_PIN) == 0; return gpio_get(SRST_PORT, SRST_PIN) == 0;
} }

View File

@ -48,12 +48,13 @@
* LED2 = PB11 (Red LED : Error) * LED2 = PB11 (Red LED : Error)
* *
* TPWR = RB0 (input) -- analogue on mini design ADC1, ch8 * TPWR = RB0 (input) -- analogue on mini design ADC1, ch8
* nTRST = PB1 [blackmagic] * nTRST = PB1 (output) [blackmagic]
* PWR_BR = PB1 [blackmagic_mini] -- supply power to the target, active low * PWR_BR = PB1 (output) [blackmagic_mini] -- supply power to the target, active low
* SRST_OUT = PA2 * TMS_DIR = PA1 (output) [blackmagic_mini v2.1] -- choose direction of the TCK pin, input low, output high
* TDI = PA3 * SRST_OUT = PA2 (output)
* TMS = PA4 (input for SWDP) * TDI = PA3 (output)
* TCK = PA5 * TMS = PA4 (input/output for SWDIO)
* TCK = PA5 (output SWCLK)
* TDO = PA6 (input) * TDO = PA6 (input)
* nSRST = PA7 (input) * nSRST = PA7 (input)
* *
@ -66,16 +67,20 @@
/* Hardware definitions... */ /* Hardware definitions... */
#define JTAG_PORT GPIOA #define JTAG_PORT GPIOA
#define TDI_PORT JTAG_PORT #define TDI_PORT JTAG_PORT
#define TMS_DIR_PORT JTAG_PORT
#define TMS_PORT JTAG_PORT #define TMS_PORT JTAG_PORT
#define TCK_PORT JTAG_PORT #define TCK_PORT JTAG_PORT
#define TDO_PORT JTAG_PORT #define TDO_PORT JTAG_PORT
#define TDI_PIN GPIO3 #define TDI_PIN GPIO3
#define TMS_DIR_PIN GPIO1
#define TMS_PIN GPIO4 #define TMS_PIN GPIO4
#define TCK_PIN GPIO5 #define TCK_PIN GPIO5
#define TDO_PIN GPIO6 #define TDO_PIN GPIO6
#define SWDIO_DIR_PORT JTAG_PORT
#define SWDIO_PORT JTAG_PORT #define SWDIO_PORT JTAG_PORT
#define SWCLK_PORT JTAG_PORT #define SWCLK_PORT JTAG_PORT
#define SWDIO_DIR_PIN TMS_DIR_PIN
#define SWDIO_PIN TMS_PIN #define SWDIO_PIN TMS_PIN
#define SWCLK_PIN TCK_PIN #define SWCLK_PIN TCK_PIN
@ -85,6 +90,7 @@
#define PWR_BR_PIN GPIO1 #define PWR_BR_PIN GPIO1
#define SRST_PORT GPIOA #define SRST_PORT GPIOA
#define SRST_PIN GPIO2 #define SRST_PIN GPIO2
#define SRST_SENSE_PORT GPIOA
#define SRST_SENSE_PIN GPIO7 #define SRST_SENSE_PIN GPIO7
#define USB_PU_PORT GPIOA #define USB_PU_PORT GPIOA
@ -104,12 +110,15 @@
#define LED_ERROR LED_2 #define LED_ERROR LED_2
#define TMS_SET_MODE() \ #define TMS_SET_MODE() \
gpio_set(TMS_DIR_PORT, TMS_DIR_PIN); \
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \ gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN); GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
#define SWDIO_MODE_FLOAT() \ #define SWDIO_MODE_FLOAT() \
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \ gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT, \
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN); GPIO_CNF_INPUT_FLOAT, SWDIO_PIN); \
gpio_clear(SWDIO_DIR_PORT, SWDIO_DIR_PIN);
#define SWDIO_MODE_DRIVE() \ #define SWDIO_MODE_DRIVE() \
gpio_set(SWDIO_DIR_PORT, SWDIO_DIR_PIN); \
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \ gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ, \
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN); GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);