forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Adding SparkFun nRF52840 Mini board support #1367
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f67814f
Adding SparkFun nRF52840 Mini board support.
jimblom 09316b3
remove non-broken-out nrf pins. re-organize pins.c list.
jimblom 8a981dc
Merge remote-tracking branch 'adafruit/master' into sfe840
tannewt 8fc72e8
Add SPI and I2C to SparkFun nRF52840 mini definition and add it to Tr…
tannewt File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,48 @@ | ||
| # SparkFun Pro nRF52840 Mini Breakout | ||
|
|
||
| The [SparkFun Pro nRF52840 Mini](https://www.sparkfun.com/products/15025) small breakout board for Raytac's MDBT50Q-P1M module, which features an nRF52840. It breaks out as many pins as it can in an Arduino Pro Mini footprint. Also included on the board are a qwiic (I<sup>2</sup>C) connector, LiPo battery charger, and on/off switch. | ||
|
|
||
| Note: the SparkFun Pro nRF52840 Mini Breakout does not include a QSPI external flash. Any Python code will need to be stored on the internal flash filesystem. | ||
|
|
||
| ## CircuitPython Pin Defs | ||
|
|
||
| CircuitPython pin definitions try to follow those of the [Arduino Pro Mini](https://www.sparkfun.com/products/11113), which the footprint is based on. | ||
|
|
||
| This can be somewhat confusing, especially around the analog pins. Here's a quick pin-map: | ||
|
|
||
| <table> | ||
| <tr><th>Board pin label</th><th>Digital Pin Reference</th><th>Additional Pin Capabilities</th><th>Pin/Port Reference</th></tr> | ||
| <tr><td>17</td><td>D1</td><td>TX</td><td>P0_17</td></tr> | ||
| <tr><td>15</td><td>D0</td><td>RX</td><td>P0_15</td></tr> | ||
| <tr><td>8</td><td></td><td>SDA</td><td>P0_08</td></tr> | ||
| <tr><td>11</td><td></td><td>SCL</td><td>P0_11</td></tr> | ||
| <tr><td>19</td><td>D3</td><td></td><td>P0_19</td></tr> | ||
| <tr><td>20</td><td>D4</td><td></td><td>P0_20</td></tr> | ||
| <tr><td>21</td><td>D5</td><td></td><td>P0_21</td></tr> | ||
| <tr><td>22</td><td>D6</td><td></td><td>P0_22</td></tr> | ||
| <tr><td>23</td><td>D7</td><td></td><td>P0_23</td></tr> | ||
| <tr><td>9</td><td>D8</td><td></td><td>P0_09</td></tr> | ||
| <tr><td>10</td><td>D9</td><td></td><td>P0_10</td></tr> | ||
| <tr><td>2</td><td>D10</td><td>A0</td><td>P0_02</td></tr> | ||
| <tr><td>3</td><td>D11</td><td>MOSI, A1</td><td>P0_03</td></tr> | ||
| <tr><td>31</td><td>D12</td><td>MISO, A7</td><td>P0_31</td></tr> | ||
| <tr><td>30</td><td>D13</td><td>SCK, A6</td><td>P0_31</td></tr> | ||
| <tr><td>29</td><td></td><td>A5</td><td>P0_29</td></tr> | ||
| <tr><td>28</td><td></td><td>A4</td><td>P0_28</td></tr> | ||
| <tr><td>5</td><td></td><td>A3</td><td>P0_05</td></tr> | ||
| <tr><td>4</td><td></td><td>A2</td><td>P0_04</td></tr> | ||
| </table> | ||
|
|
||
| If a pin isn't defined as D0, D1, etc., standard port/pin references should work -- e.g. `P0_17` is pin 17, `P0_02` is pin 2, etc. | ||
|
|
||
| ## Bootloader Notes | ||
|
|
||
| The nRF52840 Mini ships with a slightly modified (i.e pin defs and USB defs) version of the Adafruit nRF52 bootloader, which supports UF2 and CDC bootloading. | ||
|
|
||
| ## Hardware Reference | ||
|
|
||
| The nRF52840 Mini hardware layout is open source: | ||
|
|
||
| * [Schematic](https://cdn.sparkfun.com/assets/learn_tutorials/8/2/0/nrf52840-breakout-mdbt50q-v10.pdf) | ||
| * [Eagle Files](https://cdn.sparkfun.com/assets/learn_tutorials/8/2/0/nrf52840-breakout-mdbt50q-v10.zip) | ||
| * [Hookup Guide](https://learn.sparkfun.com/tutorials/sparkfun-pro-nrf52840-mini-hookup-guide) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| /* | ||
| * This file is part of the MicroPython project, http://micropython.org/ | ||
| * | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2017 Scott Shawcroft for Adafruit Industries | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
|
|
||
| #include "boards/board.h" | ||
|
|
||
| void board_init(void) { | ||
| } | ||
|
|
||
| bool board_requests_safe_mode(void) { | ||
| return false; | ||
| } | ||
|
|
||
| void reset_board(void) { | ||
|
|
||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| /* | ||
| * This file is part of the MicroPython project, http://micropython.org/ | ||
| * | ||
| * The MIT License (MIT) | ||
| * | ||
| * Copyright (c) 2016 Glenn Ruben Bakke | ||
| * | ||
| * Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| * of this software and associated documentation files (the "Software"), to deal | ||
| * in the Software without restriction, including without limitation the rights | ||
| * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| * copies of the Software, and to permit persons to whom the Software is | ||
| * furnished to do so, subject to the following conditions: | ||
| * | ||
| * The above copyright notice and this permission notice shall be included in | ||
| * all copies or substantial portions of the Software. | ||
| * | ||
| * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
| * THE SOFTWARE. | ||
| */ | ||
|
|
||
| #include "nrfx/hal/nrf_gpio.h" | ||
|
|
||
| #define MICROPY_HW_BOARD_NAME "SparkFun Pro nRF52840 Mini" | ||
| #define MICROPY_HW_MCU_NAME "nRF52840" | ||
| #define MICROPY_PY_SYS_PLATFORM "SFE_NRF52840_Mini" | ||
|
|
||
| #define PORT_HEAP_SIZE (128 * 1024) | ||
| #define CIRCUITPY_AUTORELOAD_DELAY_MS 500 | ||
|
|
||
| #define DEFAULT_I2C_BUS_SCL (&pin_P0_11) | ||
| #define DEFAULT_I2C_BUS_SDA (&pin_P0_08) | ||
|
|
||
| #define DEFAULT_SPI_BUS_SCK (&pin_P0_30) | ||
| #define DEFAULT_SPI_BUS_MOSI (&pin_P0_03) | ||
| #define DEFAULT_SPI_BUS_MISO (&pin_P0_31) | ||
|
|
||
| #define DEFAULT_UART_BUS_RX (&pin_P0_15) | ||
| #define DEFAULT_UART_BUS_TX (&pin_P0_17) | ||
|
|
||
| /* Note: Flash chip is not provided on SparkFun nRF52840 Mini. | ||
| * Leaving this as a reminder for future/similar versions of the board. */ | ||
| // Flash operation mode is determined by MICROPY_QSPI_DATAn pin configuration. | ||
| // A pin config is valid if it is defined and its value is not 0xFF. | ||
| // Quad mode: If all DATA0 --> DATA3 are valid | ||
| // Dual mode: If DATA0 and DATA1 are valid while either DATA2 and/or DATA3 are invalid | ||
| // Single mode: If only DATA0 is valid | ||
| /*#ifdef QSPI_FLASH_FILESYSTEM | ||
| #define MICROPY_QSPI_DATA0 NRF_GPIO_PIN_MAP(0, 20) | ||
| #define MICROPY_QSPI_DATA1 NRF_GPIO_PIN_MAP(0, 21) | ||
| #define MICROPY_QSPI_DATA2 NRF_GPIO_PIN_MAP(0, 22) | ||
| #define MICROPY_QSPI_DATA3 NRF_GPIO_PIN_MAP(0, 23) | ||
| #define MICROPY_QSPI_SCK NRF_GPIO_PIN_MAP(0, 19) | ||
| #define MICROPY_QSPI_CS NRF_GPIO_PIN_MAP(0, 17) | ||
| #endif | ||
|
|
||
| #ifdef SPI_FLASH_FILESYSTEM | ||
| #define SPI_FLASH_MOSI_PIN &pin_P0_20 | ||
| #define SPI_FLASH_MISO_PIN &pin_P0_21 | ||
| #define SPI_FLASH_SCK_PIN &pin_P0_19 | ||
| #define SPI_FLASH_CS_PIN &pin_P0_17 | ||
| #endif*/ | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| USB_VID = 0x1B4F | ||
| USB_PID = 0x5289 | ||
| USB_PRODUCT = "SFE_nRF52840_Mini" | ||
| USB_MANUFACTURER = "SparkFun Electronics" | ||
|
|
||
| MCU_SERIES = m4 | ||
| MCU_VARIANT = nrf52 | ||
| MCU_SUB_VARIANT = nrf52840 | ||
| MCU_CHIP = nrf52840 | ||
| SD ?= s140 | ||
| SOFTDEV_VERSION ?= 6.1.0 | ||
|
|
||
| BOOT_SETTING_ADDR = 0xFF000 | ||
|
|
||
| ifeq ($(SD),) | ||
| LD_FILE = boards/nrf52840_1M_256k.ld | ||
| else | ||
| LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld | ||
| endif | ||
|
|
||
| NRF_DEFINES += -DNRF52840_XXAA -DNRF52840 | ||
|
|
||
| QSPI_FLASH_FILESYSTEM = 0 | ||
| EXTERNAL_FLASH_DEVICE_COUNT = 0 | ||
| EXTERNAL_FLASH_DEVICES = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| #include "shared-bindings/board/__init__.h" | ||
|
|
||
| #include "board_busses.h" | ||
|
|
||
| STATIC const mp_rom_map_elem_t board_module_globals_table[] = { | ||
| { MP_ROM_QSTR(MP_QSTR_D0), MP_ROM_PTR(&pin_P1_15) }, // D1/TX | ||
| { MP_ROM_QSTR(MP_QSTR_D1), MP_ROM_PTR(&pin_P0_17) }, // D0/RX | ||
| // D2 on qwiic gap | ||
| { MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P0_19) }, // D3 | ||
| { MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P0_20) }, // D4 | ||
| { MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P0_21) }, // D5 | ||
| { MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P0_22) }, // D6 | ||
| { MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_23) }, // D7 | ||
| { MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_09) }, // D8 | ||
| { MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_10) }, // D9 | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P0_02) }, // D10 | ||
| { MP_ROM_QSTR(MP_QSTR_D11), MP_ROM_PTR(&pin_P0_03) }, // D11 | ||
| { MP_ROM_QSTR(MP_QSTR_D12), MP_ROM_PTR(&pin_P0_31) }, // D12 | ||
| { MP_ROM_QSTR(MP_QSTR_D13), MP_ROM_PTR(&pin_P0_30) }, // D13 | ||
| { MP_ROM_QSTR(MP_QSTR_D14), MP_ROM_PTR(&pin_P0_29) }, // D14 | ||
| { MP_ROM_QSTR(MP_QSTR_D15), MP_ROM_PTR(&pin_P0_28) }, // D15 | ||
| { MP_ROM_QSTR(MP_QSTR_D16), MP_ROM_PTR(&pin_P0_05) }, // D16 | ||
| { MP_ROM_QSTR(MP_QSTR_D17), MP_ROM_PTR(&pin_P0_04) }, // D17 | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_02) }, // A0 | ||
| { MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_03) }, // A1 | ||
| { MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_04) }, // A2 | ||
| { MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_05) }, // A3 | ||
| { MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_28) }, // A4 | ||
| { MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_29) }, // A5 | ||
| { MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_30) }, // A6 | ||
| { MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_31) }, // A7 | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_08) }, // 8 - SDA | ||
| { MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_11) }, // 11 - SCL | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P0_31) }, // 31 - MISO | ||
| { MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P0_03) }, // 3 - MOSI | ||
| { MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_30) }, // 30 - SCK | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_LED1), MP_ROM_PTR(&pin_P0_07) }, // 7 - Blue LED | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_BUTTON1), MP_ROM_PTR(&pin_P0_13) }, // 13 - Button | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P0_15) }, // 15 - UART RX | ||
| { MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P0_17) }, // 17 - UART TX | ||
|
|
||
| { MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_QWIIC), MP_ROM_PTR(&board_i2c_obj) }, | ||
| { MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) }, | ||
| }; | ||
|
|
||
| MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table); | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you want I2C and SPI default buses here too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jimblom see this too?