File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -77,15 +77,26 @@ void target_clock_setup(void) {
7777
7878void target_gpio_setup (void ) {
7979 /* Enable GPIO clocks */
80- if (USES_GPIOA ) {
81- rcc_periph_clock_enable (RCC_GPIOA );
82- }
83- if (USES_GPIOB ) {
84- rcc_periph_clock_enable (RCC_GPIOB );
85- }
86- if (USES_GPIOC ) {
87- rcc_periph_clock_enable (RCC_GPIOC );
80+ #if USES_GPIOA
81+ rcc_periph_clock_enable (RCC_GPIOA );
82+ #endif
83+ #if USES_GPIOB
84+ rcc_periph_clock_enable (RCC_GPIOB );
85+ #endif
86+ #if USES_GPIOC
87+ rcc_periph_clock_enable (RCC_GPIOC );
88+ #endif
89+
90+ /* Disable SWD if PA13 and/or PA14 are used for another purpose */
91+ #if ((HAVE_LED && LED_GPIO_PORT == GPIOA && (LED_GPIO_PORT == GPIO13 || LED_GPIO_PORT == GPIO14 )) || \
92+ (HAVE_BUTTON && BUTTON_GPIO_PORT == GPIOA && (BUTTON_GPIO_PIN == GPIO13 || BUTTON_GPIO_PIN == GPIO14 )) || \
93+ (HAVE_USB_PULLUP_CONTROL && USB_PULLUP_GPIO_PORT == GPIOA && \
94+ (USB_PULLUP_GPIO_PIN == GPIO13 || USB_PULLUP_GPIO_PIN == GPIO14 )))
95+ {
96+ rcc_periph_clock_enable (RCC_AFIO );
97+ gpio_primary_remap (AFIO_MAPR_SWJ_CFG_JTAG_OFF_SW_OFF , 0 );
8898 }
99+ #endif
89100
90101 /* Setup LEDs */
91102#if HAVE_LED
You can’t perform that action at this time.
0 commit comments