Skip to content

Commit c90a2d9

Browse files
committed
atmel-samd: Fix SAMD51 SWCLK reset so we can connect the JLink
while CircuitPython is running.
1 parent e267b2c commit c90a2d9

File tree

1 file changed

+6
-10
lines changed
  • ports/atmel-samd/common-hal/microcontroller

1 file changed

+6
-10
lines changed

ports/atmel-samd/common-hal/microcontroller/Pin.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,12 +52,9 @@ void reset_all_pins(void) {
5252
uint32_t pin_mask[PORT_BITS / 32 + 1] = PORT_OUT_IMPLEMENTED;
5353

5454
// Do not full reset USB or SWD lines.
55-
pin_mask[0] &= ~(PORT_PA24 | PORT_PA25 | PORT_PA30);
55+
pin_mask[0] &= ~(PORT_PA24 | PORT_PA25 | PORT_PA30 | PORT_PA31);
5656

57-
// The SWO pin changes between the 21 and 51.
58-
#ifdef PORT_PB30H_CM4_SWO
59-
pin_mask[1] &= ~(PORT_PB30);
60-
#else
57+
#ifdef SAMD21
6158
pin_mask[0] &= ~(PORT_PA31);
6259
#endif
6360

@@ -71,11 +68,10 @@ void reset_all_pins(void) {
7168
#endif
7269

7370
// Configure SWD
74-
gpio_set_pin_direction(PIN_PA30, GPIO_DIRECTION_OUT);
7571
#ifdef SAMD51
76-
gpio_set_pin_function(PIN_PB30, MUX_PB30H_CM4_SWO);
77-
gpio_set_pin_direction(PIN_PB30, GPIO_DIRECTION_OUT);
78-
gpio_set_pin_function(PIN_PB30, MUX_PB30H_CM4_SWO);
72+
gpio_set_pin_function(PIN_PA30, MUX_PA30H_CM4_SWCLK);
73+
// SWDIO will be automatically switched on PA31 when a signal is input on
74+
// SWCLK.
7975
#endif
8076
#ifdef SAMD21
8177
//gpio_set_pin_function(PIN_PA30, GPIO_PIN_FUNCTION_G);
@@ -126,7 +122,7 @@ void reset_pin(uint8_t pin) {
126122

127123
if (pin == PIN_PA30
128124
#ifdef SAMD51
129-
|| pin == PIN_PB30) {
125+
) {
130126
gpio_set_pin_function(pin, GPIO_PIN_FUNCTION_H);
131127
#endif
132128
#ifdef SAMD21

0 commit comments

Comments
 (0)