Skip to content

Commit 7bb78fb

Browse files
bikeNomaddpgeorge
authored andcommitted
zephyr/boards: Add XIAO BLE NRF52840 SENSE board.
This commit adds Zephyr support for the XIAO BLE NRF52840 SENSE board from Seeed Studio. It also provides a good example of a richer Zephyr port than the default, adding: - Frozen modules (including asyncio, upysh, aioble and aiorepl). - Enough MicroPython features to support using aioble (at least for the `temp_sensor.py` example). - JSON, random, re, struct, etc. Signed-off-by: Ned Konz <[email protected]>
1 parent 4c11f64 commit 7bb78fb

File tree

4 files changed

+164
-0
lines changed

4 files changed

+164
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Kconfig configuration for Seeed Studio's XIAO nRF52840 Sense
2+
3+
CONFIG_NETWORKING=n
4+
CONFIG_CONSOLE_SUBSYS=n
5+
6+
# for PDM microphone, set these three to y
7+
# and also enable in overlay
8+
CONFIG_AUDIO=n
9+
CONFIG_AUDIO_DMIC=n
10+
CONFIG_AUDIO_DMIC_NRFX_PDM=n
11+
12+
# Enable Bluetooth
13+
CONFIG_BT=y
14+
CONFIG_BT_PERIPHERAL=y
15+
CONFIG_BT_CENTRAL=y
16+
CONFIG_BT_DEVICE_NAME="XIAO BLE nRF52840 Sense"
17+
CONFIG_BT_GATT_DYNAMIC_DB=y
18+
CONFIG_BT_DEVICE_NAME_DYNAMIC=y
19+
CONFIG_BT_GATT_CLIENT=y
20+
CONFIG_BT_L2CAP_TX_MTU=252
21+
CONFIG_BT_BUF_ACL_RX_SIZE=256
22+
CONFIG_BT_GATT_ENFORCE_SUBSCRIPTION=n
23+
24+
CONFIG_MICROPY_HEAP_SIZE=98304
25+
CONFIG_MAIN_STACK_SIZE=8192
26+
27+
# Enable drivers for peripherals
28+
CONFIG_GPIO=y
29+
CONFIG_I2C=y
30+
CONFIG_SPI=y
31+
CONFIG_PWM=y
32+
CONFIG_ADC=y
33+
34+
CONFIG_FLASH=y
35+
CONFIG_FLASH_MAP=y
36+
CONFIG_FLASH_PAGE_LAYOUT=y
37+
38+
CONFIG_DISK_ACCESS=n
39+
40+
CONFIG_MICROPY_FROZEN_MODULES=y
41+
CONFIG_MICROPY_FROZEN_MANIFEST="boards/xiao_ble_nrf52840_sense/manifest.py"
42+
CONFIG_MICROPY_CONFIGFILE="boards/xiao_ble_nrf52840_sense/mpconfigport.h"
43+
44+
# CONFIG_DYNAMIC_THREAD=y
45+
CONFIG_THREAD_CUSTOM_DATA=y
46+
CONFIG_THREAD_MONITOR=y
47+
CONFIG_THREAD_STACK_INFO=y
48+
49+
CONFIG_LOG=n
50+
CONFIG_FP16=n
51+
CONFIG_BOOT_BANNER=n
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
/*
2+
* Copyright (c) 2025 NED KONZ <[email protected]>
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
// Replace default on-chip flash with external flash
8+
/delete-node/ &storage_partition;
9+
10+
// 16Mib (2MiB) flash, mount as /flash
11+
&p25q16h {
12+
partitions {
13+
compatible = "fixed-partitions";
14+
#address-cells = <1>;
15+
#size-cells = <1>;
16+
17+
storage_partition: partition@0 {
18+
label = "storage";
19+
reg = <0x00000000 0x200000>;
20+
};
21+
};
22+
};
23+
24+
/ {
25+
zephyr,user {
26+
io-channels = <&adc 0>, <&adc 1>, <&adc 4>, <&adc 5>, <&adc 7>;
27+
};
28+
};
29+
30+
&adc {
31+
#address-cells = <1>;
32+
#size-cells = <0>;
33+
34+
channel@0 {
35+
reg = <0>;
36+
zephyr,gain = "ADC_GAIN_1_6";
37+
zephyr,reference = "ADC_REF_INTERNAL";
38+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
39+
zephyr,input-positive = <NRF_SAADC_AIN0>; /* P0.02 */
40+
zephyr,resolution = <12>;
41+
};
42+
43+
channel@1 {
44+
reg = <1>;
45+
zephyr,gain = "ADC_GAIN_1_6";
46+
zephyr,reference = "ADC_REF_INTERNAL";
47+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
48+
zephyr,input-positive = <NRF_SAADC_AIN1>; /* P0.03 */
49+
zephyr,resolution = <12>;
50+
};
51+
52+
channel@4 {
53+
reg = <4>;
54+
zephyr,gain = "ADC_GAIN_1_6";
55+
zephyr,reference = "ADC_REF_INTERNAL";
56+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
57+
zephyr,input-positive = <NRF_SAADC_AIN4>; /* P0.28 */
58+
zephyr,resolution = <12>;
59+
};
60+
61+
channel@5 {
62+
reg = <5>;
63+
zephyr,gain = "ADC_GAIN_1_6";
64+
zephyr,reference = "ADC_REF_INTERNAL";
65+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
66+
zephyr,input-positive = <NRF_SAADC_AIN5>; /* P0.29 */
67+
zephyr,resolution = <12>;
68+
};
69+
70+
// AIN7: battery reading
71+
channel@7 {
72+
reg = <7>;
73+
zephyr,gain = "ADC_GAIN_1_6";
74+
zephyr,reference = "ADC_REF_INTERNAL";
75+
zephyr,acquisition-time = <ADC_ACQ_TIME_DEFAULT>;
76+
zephyr,input-positive = <NRF_SAADC_AIN7>; /* P0.31 */
77+
zephyr,resolution = <12>;
78+
};
79+
};
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
include("$(MPY_DIR)/extmod/asyncio")
2+
3+
freeze("$(PORT_DIR)/modules")
4+
5+
require("upysh")
6+
require("aioble")
7+
require("aiorepl")
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*
2+
* This file is part of the MicroPython project, http://micropython.org/
3+
*
4+
* The MIT License (MIT)
5+
*
6+
* Permission is hereby granted, free of charge, to any person obtaining a copy
7+
* of this software and associated documentation files (the "Software"), to deal
8+
* in the Software without restriction, including without limitation the rights
9+
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10+
* copies of the Software, and to permit persons to whom the Software is
11+
* furnished to do so, subject to the following conditions:
12+
*
13+
* The above copyright notice and this permission notice shall be included in
14+
* all copies or substantial portions of the Software.
15+
*
16+
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17+
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18+
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19+
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20+
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21+
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22+
* THE SOFTWARE.
23+
*/
24+
25+
#define MICROPY_CONFIG_ROM_LEVEL (MICROPY_CONFIG_ROM_LEVEL_EXTRA_FEATURES)
26+
27+
#include "../mpconfigport.h"

0 commit comments

Comments
 (0)