10000 Merge pull request #2246 from dhalbert/nano-33-ble · tannewt/circuitpython@2b02750 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b02750

Browse files
authored
Merge pull request micropython#2246 from dhalbert/nano-33-ble
Arduino Nano 33 BLE board definition
2 parents 3683ee3 + 7dadf9b commit 2b02750

File tree

20 files changed

+198
-13
lines changed

20 files changed

+198
-13
lines changed

.github/workflows/build.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ jobs:
7575
board:
7676
- "arduino_mkr1300"
7777
- "arduino_mkrzero"
78+
- "arduino_nano_33_ble"
7879
- "arduino_zero"
7980
- "bast_pro_mini_m0"
8081
- "capablerobot_usbhub"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Arduino Nano 33 BLE and Nano 33 BLE Sense
2+
3+
The [Arduino Nano 33 BLE](https://store.arduino.cc/usa/nano-33-ble-with-headers) and
4+
[Arduino Nano 33 BLE Sense](https://store.arduino.cc/usa/nano-33-ble-sense) and
5+
are built around the NINA B306 module, based on Nordic nRF 52840 and containing
6+
a powerful Cortex M4F. Both include an onboard 9 axis Inertial Measurement Unit (IMU), the LSM9DS1.
7+
The Nano 33 BLE Sense adds an LPS22HB barometric pressure and temperature sensor,
8+
an ADPS-9960 digital proximity, ambient light, RGB, and gensture sensor,
9+
and an MP34DT05 digital microphone.
10+
11+
Note: the Arduino Nano 33 BLE and BLE Sense do not include a QSPI external
12+
flash. Any Python code will need to be stored on the internal flash
13+
filesystem.
14+
15+
I2C pins `board.SCL1` and `board.SDA1` are not exposed and are used for onboard peripherals.
16+
Pin `board.R_PULLUP` must be set to high to enable the `SCL1` and `SDA1` pullups for proper operation.
17+
18+
Pin `board.VDD_ENV` applies power to the LSM9DS1, and must be high for it to be operational.
19+
20+
Pins `board.MIC_PWR`, `board.PDMDIN`, and `board.PDMCLK` are for the Nano 33 BLE Sense onboard microphone.
21+
22+
Pin `board.INT_ADPS` is the interrupt pin from the ADPS-9960.
23+
24+
Pins `board.RGB_LED_R`, `board.RGB_LED_G`, and `board.RGB_LED_B`
25+
are the red, green and blue LEDS in the onboard RGB LED.
26+
27+
Pins `board.LED_G` and `board.LED_Y` are onboard green and red LEDs. `board.LED_Y` is also `board.SCK`.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Copyright (c) 2017 Scott Shawcroft for Adafruit Industries
7+
*
8+
* Permission is hereby granted, free of charge, to any person obtaining a copy
9+
* of this software and associated documentation files (the "Software"), to deal
10+
* in the Software without restriction, including without limitation the rights
11+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12+
* copies of the Software, and to permit persons to whom the Software is
13+
* furnished to do so, subject to the following conditions:
14+
*
15+
* The above copyright notice and this permission notice shall be included in
16+
* all copies or substantial portions of the Software.
17+
*
18+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24+
* THE SOFTWARE.
25+
*/
26+
27+
#include "boards/board.h"
28+
#include "nrf.h"
29+
#include "nrf_rtc.h"
30+
31+
void board_init(void) {
32+
// Initializations below from Arduino variant.cpp.
33+
34+
// // turn power LED on
35+
// pinMode(LED_PWR, OUTPUT);
36+
// digitalWrite(LED_PWR, HIGH);
37+
38+
// Errata Nano33BLE - I2C pullup is on SWO line, need to disable TRACE
39+
// was being enabled by nrfx_clock_anomaly_132
40+
CoreDebug->DEMCR = 0;
41+
NRF_CLOCK->TRACECONFIG = 0;
42+
43+
// FIXME: bootloader enables interrupt on COMPARE[0], which we don't handle
44+
// Disable it here to avoid getting stuck when OVERFLOW irq is triggered
45+
nrf_rtc_event_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK);
46+
nrf_rtc_int_disable(NRF_RTC1, NRF_RTC_INT_COMPARE0_MASK);
47+
48+
// // FIXME: always enable I2C pullup and power @startup
49+
// // Change for maximum powersave
50+
// pinMode(PIN_ENABLE_SENSORS_3V3, OUTPUT);
51+
// pinMode(PIN_ENABLE_I2C_PULLUP, OUTPUT);
52+
53+
// digitalWrite(PIN_ENABLE_SENSORS_3V3, HIGH);
54+
// digitalWrite(PIN_ENABLE_I2C_PULLUP, HIGH);
55+
}
56+
57+
bool board_requests_safe_mode(void) {
58+
return false;
59+
}
60+
61+
void reset_board(void) {
62+
63+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#include "nrfx/hal/nrf_gpio.h"
2+
3+
#define MICROPY_HW_BOARD_NAME "Arduino Nano 33 BLE"
4+
#define MICROPY_HW_MCU_NAME "nRF52840"
5+
6+
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
7+
8+
#define DEFAULT_I2C_BUS_SCL (&pin_P0_02)
9+
#define DEFAULT_I2C_BUS_SDA (&pin_P0_31)
10+
11+
#define DEFAULT_SPI_BUS_SCK (&pin_P0_13)
12+
#define DEFAULT_SPI_BUS_MOSI (&pin_P0_01)
13+
#define DEFAULT_SPI_BUS_MISO (&pin_P1_08)
14+
15+
#define DEFAULT_UART_BUS_RX (&pin_P1_10)
16+
#define DEFAULT_UART_BUS_TX (&pin_P1_03)
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
USB_VID = 0x2341
2+
USB_PID = 0x805A
3+
USB_PRODUCT = "Arduino_Nano_33_BLE"
4+
USB_MANUFACTURER = "Arduino"
5+
6+
MCU_SERIES = m4
7+
MCU_VARIANT = nrf52
8+
MCU_SUB_VARIANT = nrf52840
9+
MCU_CHIP = nrf52840
10+
SD ?= s140
11+
SOFTDEV_VERSION ?= 6.1.0
12+
13+
BOOT_SETTING_ADDR = 0xFF000
14+
15+
ifeq ($(SD),)
16+
LD_FILE = boards/nrf52840_1M_256k.ld
17+
else
18+
LD_FILE = boards/adafruit_$(MCU_SUB_VARIANT)_$(SD_LOWER)_v$(firstword $(subst ., ,$(SOFTDEV_VERSION))).ld
19+
CIRCUITPY_BLEIO = 1
20+
endif
21+
22+
NRF_DEFINES += -DNRF52840_XXAA -DNRF52840
23+
24+
INTERNAL_FLASH_FILESYSTEM = 1
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#include "shared-bindings/board/__init__.h"
2+
3+
STATIC const mp_rom_map_elem_t board_module_globals_table[] = {
4+
{ MP_ROM_QSTR(MP_QSTR_D2), MP_ROM_PTR(&pin_P1_11) },
5+
{ MP_ROM_QSTR(MP_QSTR_D3), MP_ROM_PTR(&pin_P1_12) },
6+
{ MP_ROM_QSTR(MP_QSTR_D4), MP_ROM_PTR(&pin_P1_15) },
7+
{ MP_ROM_QSTR(MP_QSTR_D5), MP_ROM_PTR(&pin_P1_13) },
8+
{ MP_ROM_QSTR(MP_QSTR_D6), MP_ROM_PTR(&pin_P1_14) },
9+
{ MP_ROM_QSTR(MP_QSTR_D7), MP_ROM_PTR(&pin_P0_23) },
10+
{ MP_ROM_QSTR(MP_QSTR_D8), MP_ROM_PTR(&pin_P0_21) },
11+
{ MP_ROM_QSTR(MP_QSTR_D9), MP_ROM_PTR(&pin_P0_27) },
12+
{ MP_ROM_QSTR(MP_QSTR_D10), MP_ROM_PTR(&pin_P1_02) },
13+
14+
{ MP_ROM_QSTR(MP_QSTR_A0), MP_ROM_PTR(&pin_P0_04) },
15+
{ MP_ROM_QSTR(MP_QSTR_A1), MP_ROM_PTR(&pin_P0_05) },
16+
{ MP_ROM_QSTR(MP_QSTR_A2), MP_ROM_PTR(&pin_P0_30) },
17+
{ MP_ROM_QSTR(MP_QSTR_A3), MP_ROM_PTR(&pin_P0_29) },
18+
19+
{ MP_ROM_QSTR(MP_QSTR_A4), MP_ROM_PTR(&pin_P0_31) },
20+
{ MP_ROM_QSTR(MP_QSTR_SDA), MP_ROM_PTR(&pin_P0_31) },
21+
22+
{ MP_ROM_QSTR(MP_QSTR_A5), MP_ROM_PTR(&pin_P0_02) },
23+
{ MP_ROM_QSTR(MP_QSTR_SCL), MP_ROM_PTR(&pin_P0_02) },
24+
25+
{ MP_ROM_QSTR(MP_QSTR_A6), MP_ROM_PTR(&pin_P0_28) },
26+
{ MP_ROM_QSTR(MP_QSTR_A7), MP_ROM_PTR(&pin_P0_03) },
27+
28+
{ MP_ROM_QSTR(MP_QSTR_SDA1), MP_ROM_PTR(&pin_P0_14) },
29+
{ MP_ROM_QSTR(MP_QSTR_SCL1), MP_ROM_PTR(&pin_P0_15) },
30+
31+
{ MP_ROM_QSTR(MP_QSTR_MOSI), MP_ROM_PTR(&pin_P1_01) },
32+
{ MP_ROM_QSTR(MP_QSTR_MISO), MP_ROM_PTR(&pin_P1_08) },
33+
34+
{ MP_ROM_QSTR(MP_QSTR_SCK), MP_ROM_PTR(&pin_P0_13) },
35+
{ MP_ROM_QSTR(MP_QSTR_LED_Y), MP_ROM_PTR(&pin_P0_13) },
36+
37+
{ MP_ROM_QSTR(MP_QSTR_LED_G), MP_ROM_PTR(&pin_P1_09) },
38+
39+
{ MP_ROM_QSTR(MP_QSTR_RGB_LED_R), MP_ROM_PTR(&pin_P0_24) },
40+
{ MP_ROM_QSTR(MP_QSTR_RGB_LED_G), MP_ROM_PTR(&pin_P0_16) },
41+
{ MP_ROM_QSTR(MP_QSTR_RGB_LED_B), MP_ROM_PTR(&pin_P0_06) },
42+
43+
// Power line to LSM9DS1.
44+
{ MP_ROM_QSTR(MP_QSTR_VDD_ENV), MP_ROM_PTR(&pin_P0_22) },
45+
46+
// Pullup voltage for SDA1 and SCL1
47+
{ MP_ROM_QSTR(MP_QSTR_R_PULLUP), MP_ROM_PTR(&pin_P1_00) },
48+
49+
{ MP_ROM_QSTR(MP_QSTR_MIC_PWR), MP_ROM_PTR(&pin_P0_17) },
50+
{ MP_ROM_QSTR(MP_QSTR_PDMCLK), MP_ROM_PTR(&pin_P0_26) },
51+
{ MP_ROM_QSTR(MP_QSTR_PDMDIN), MP_ROM_PTR(&pin_P0_25) },
52+
53+
{ MP_ROM_QSTR(MP_QSTR_INT_APDS), MP_ROM_PTR(&pin_P0_19) },
54+
55+
{ MP_ROM_QSTR(MP_QSTR_TX), MP_ROM_PTR(&pin_P1_03) },
56+
{ MP_ROM_QSTR(MP_QSTR_RX), MP_ROM_PTR(&pin_P1_10) },
57+
58+
{ MP_ROM_QSTR(MP_QSTR_UART), MP_ROM_PTR(&board_uart_obj) },
59+
{ MP_ROM_QSTR(MP_QSTR_SPI), MP_ROM_PTR(&board_spi_obj) },
60+
{ MP_ROM_QSTR(MP_QSTR_I2C), MP_ROM_PTR(&board_i2c_obj) },
61+
};
62+
63+
MP_DEFINE_CONST_DICT(board_module_globals, board_module_globals_table);

ports/nrf/boards/circuitplayground_bluefruit/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#define MICROPY_HW_BOARD_NAME "Adafruit Circuit Playground Bluefruit"
3131
#define MICROPY_HW_MCU_NAME "nRF52840"
32-
#define MICROPY_PY_SYS_PLATFORM "CircuitPlaygroundBluefruit"
3332

3433
#define FLASH_SIZE (0x100000)
3534
#define FLASH_PAGE_SIZE (4096)

ports/nrf/boards/electronut_labs_blip/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
#define MICROPY_HW_BOARD_NAME "Electronut Labs Blip"
3434
#define MICROPY_HW_MCU_NAME "nRF52840"
35-
#define MICROPY_PY_SYS_PLATFORM "ElectronutLabsPapyr"
3635

3736
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
3837

ports/nrf/boards/electronut_labs_papyr/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131

< 9E46 /div>
3232
#define MICROPY_HW_BOARD_NAME "Electronut Labs Papyr"
3333
#define MICROPY_HW_MCU_NAME "nRF52840"
34-
#define MICROPY_PY_SYS_PLATFORM "ElectronutLabsPapyr"
3534

3635
#define CIRCUITPY_AUTORELOAD_DELAY_MS 500
3736

ports/nrf/boards/feather_nrf52840_express/mpconfigboard.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@
2929

3030
#define MICROPY_HW_BOARD_NAME "Adafruit Feather nRF52840 Express"
3131
#define MICROPY_HW_MCU_NAME "nRF52840"
32-
#define MICROPY_PY_SYS_PLATFORM "Feather52840Express"
3332

3433
#define FLASH_SIZE (0x100000)
3534
#define FLASH_PAGE_SIZE (4096)

0 commit comments

Comments
 (0)
0