Skip to content

Commit 0ba93b2

Browse files
committed
Setup flash pins on Sparkfun SAMD51 Micromod
1 parent f502703 commit 0ba93b2

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

ports/atmel-samd/boards/sparkfun_samd51_micromod/board.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@
2626

2727
#include "supervisor/board.h"
2828
#include "mpconfigboard.h"
29+
#include "common-hal/microcontroller/Pin.h"
30+
#include "hal/include/hal_gpio.h"
31+
#include "py/mphal.h"
2932

3033
void board_init(void) {
3134
}
@@ -39,3 +42,23 @@ void reset_board(void) {
3942

4043
void board_deinit(void) {
4144
}
45+
46+
void external_flash_setup(void) {
47+
// Do not reset the external flash write-protect and hold pins high
48+
never_reset_pin_number(PIN_PB22);
49+
never_reset_pin_number(PIN_PB23);
50+
51+
// note: using output instead of input+pullups because the pullups are a little weak
52+
// Set the WP pin high
53+
gpio_set_pin_function(PIN_PB22, GPIO_PIN_FUNCTION_OFF);
54+
gpio_set_pin_direction(PIN_PB22, GPIO_DIRECTION_OUT);
55+
gpio_set_pin_level(PIN_PB22, true);
56+
57+
// Set the HOLD pin high
58+
gpio_set_pin_function(PIN_PB23, GPIO_PIN_FUNCTION_OFF);
59+
gpio_set_pin_direction(PIN_PB23, GPIO_DIRECTION_OUT);
60+
gpio_set_pin_level(PIN_PB23, true);
61+
62+
// Add some delay to give the pins time to get set
63+
// mp_hal_delay_ms(3000);
64+
}

ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@
2727
// USB is always used internally so skip the pin objects for it.
2828
#define IGNORE_PIN_PA24 1
2929
#define IGNORE_PIN_PA25 1
30+
31+
// The external flash chip has WP (write-protect) and hold pins we should ignore
32+
#define IGNORE_PIN_PB22
33+
#define IGNORE_PIN_PB23

ports/atmel-samd/boards/sparkfun_samd51_micromod/mpconfigboard.mk

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ EXTERNAL_FLASH_DEVICES = W25Q128JVxM
1313
LONGINT_IMPL = MPZ
1414

1515
CIRCUITPY_PS2IO = 1
16+
CIRCUITPY_EXTERNAL_FLASH_SETUP = 1

0 commit comments

Comments
 (0)