Custom board
This commit is contained in:
@@ -3,4 +3,4 @@ find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
|
|||||||
|
|
||||||
project(hellobt)
|
project(hellobt)
|
||||||
|
|
||||||
target_sources(app PRIVATE src/main.c)
|
target_sources(app PRIVATE src/main.cpp)
|
||||||
|
|||||||
6
boards/arm/nrf52840_test/Kconfig.board
Normal file
6
boards/arm/nrf52840_test/Kconfig.board
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
config BOARD_NRF52840_TEST
|
||||||
|
bool "nrf52840_test"
|
||||||
|
depends on SOC_NRF52840_QIAA
|
||||||
12
boards/arm/nrf52840_test/Kconfig.defconfig
Normal file
12
boards/arm/nrf52840_test/Kconfig.defconfig
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
if BOARD_NRF52840_TEST
|
||||||
|
|
||||||
|
config BOARD
|
||||||
|
default "nrf52840_test"
|
||||||
|
|
||||||
|
config BT_CTLR
|
||||||
|
default BT
|
||||||
|
|
||||||
|
endif
|
||||||
9
boards/arm/nrf52840_test/board.cmake
Normal file
9
boards/arm/nrf52840_test/board.cmake
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
board_runner_args(jlink "--device=nrf52" "--speed=4000")
|
||||||
|
board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000")
|
||||||
|
|
||||||
|
include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake)
|
||||||
|
include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake)
|
||||||
|
include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake)
|
||||||
23
boards/arm/nrf52840_test/nrf52840_test-pinctrl.dtsi
Normal file
23
boards/arm/nrf52840_test/nrf52840_test-pinctrl.dtsi
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
$pinctrl {
|
||||||
|
uart0_default: uart0_default {
|
||||||
|
group1 {
|
||||||
|
psels = <NRF_PSEL(UART_TX, 0, 6)>,
|
||||||
|
<NRF_PSEL(UART_RTS, 0, 5)>;
|
||||||
|
};
|
||||||
|
group2 {
|
||||||
|
psels = <NRF_PSEL(UART_RX, 0, 8)>,
|
||||||
|
<NRF_PSEL(UART_CTS, 0, 7)>;
|
||||||
|
bias-pull-up;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
uart0_sleep: uart0_sleep {
|
||||||
|
group1 {
|
||||||
|
psels = <NRF_PSEL(UART_TX, 0, 6)>,
|
||||||
|
<NRF_PSEL(UART_RX, 0, 8)>,
|
||||||
|
<NRF_PSEL(UART_RTS, 0, 5)>,
|
||||||
|
<NRF_PSEL(UART_CTS, 0, 7)>;
|
||||||
|
low-power-enable;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
106
boards/arm/nrf52840_test/nrf52840_test.dts
Normal file
106
boards/arm/nrf52840_test/nrf52840_test.dts
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
// Copyright (c) 2023 Nordic Semiconductor ASA
|
||||||
|
// SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
/dts-v1/;
|
||||||
|
#include <nordic/nrf52840_qiaa.dtsi>
|
||||||
|
|
||||||
|
/ {
|
||||||
|
model = "nrf52840_test";
|
||||||
|
compatible = "nrf52840-test";
|
||||||
|
|
||||||
|
chosen {
|
||||||
|
zephyr,console = &uart0;
|
||||||
|
zephyr,shell-uart = &uart0;
|
||||||
|
zephyr,uart-mcumgr = &uart0;
|
||||||
|
zephyr,bt-mon-uart = &uart0;
|
||||||
|
zephyr,bt-c2h-uart = &uart0;
|
||||||
|
zephyr,sram = &sram0;
|
||||||
|
zephyr,flash = &flash0;
|
||||||
|
zephyr,code-partition = &slot0_partition;
|
||||||
|
};
|
||||||
|
|
||||||
|
leds {
|
||||||
|
compatible = "gpio-leds";
|
||||||
|
led0: led_0 {
|
||||||
|
gpios = <&gpio0 23 0>;
|
||||||
|
};
|
||||||
|
|
||||||
|
led1: led_1 {
|
||||||
|
gpios = <&gpio0 22 0>;
|
||||||
|
};
|
||||||
|
|
||||||
|
led2: led_2 {
|
||||||
|
gpios = <&gpio0 24 0>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
buttons {
|
||||||
|
compatible = "gpio-keys";
|
||||||
|
button0: button_0 {
|
||||||
|
gpios = <&gpio0 18 (GPIO_ACTIVE_LOW | GPIO_PULL_UP)>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
aliases {
|
||||||
|
led0 = &led0;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&flash0 {
|
||||||
|
partitions {
|
||||||
|
compatible = "fixed-partitions";
|
||||||
|
#address-cells = <1>;
|
||||||
|
#size-cells = <1>;
|
||||||
|
|
||||||
|
boot_partition: partition@0 {
|
||||||
|
label = "mcuboot";
|
||||||
|
reg = <0x0 0xc000>;
|
||||||
|
};
|
||||||
|
slot0_partition: partition@c000 {
|
||||||
|
label = "image-0";
|
||||||
|
reg = <0xc000 0x72000>;
|
||||||
|
};
|
||||||
|
slot1_partition: partition@7e000 {
|
||||||
|
label = "image-1";
|
||||||
|
reg = <0x7e000 0x72000>;
|
||||||
|
};
|
||||||
|
scratch_partition: partition@f0000 {
|
||||||
|
label = "image-scratch";
|
||||||
|
reg = <0xf0000 0xa000>;
|
||||||
|
};
|
||||||
|
storage_partition: partition@fa000 {
|
||||||
|
label = "storage";
|
||||||
|
reg = <0xfa000 0x6000>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&gpio0 {
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
&uart0 {
|
||||||
|
status = "okay";
|
||||||
|
pinctrl-0 = <&uart0_default>;
|
||||||
|
pinctrl-names = "default";
|
||||||
|
current-speed = <115200>;
|
||||||
|
};
|
||||||
|
|
||||||
|
&pinctrl {
|
||||||
|
uart0_default: uart0_default {
|
||||||
|
group1 {
|
||||||
|
psels = <NRF_PSEL(UART_TX, 0, 6)>,
|
||||||
|
<NRF_PSEL(UART_RX, 0, 8)>,
|
||||||
|
<NRF_PSEL(UART_RTS, 0, 5)>,
|
||||||
|
<NRF_PSEL(UART_CTS, 0, 7)>;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
&adc {
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
|
|
||||||
|
&usbd {
|
||||||
|
status = "okay";
|
||||||
|
};
|
||||||
13
boards/arm/nrf52840_test/nrf52840_test.yaml
Normal file
13
boards/arm/nrf52840_test/nrf52840_test.yaml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
identifier: nrf52840_test
|
||||||
|
name: nrf52840_test
|
||||||
|
type: mcu
|
||||||
|
arch: arm
|
||||||
|
ram: 256
|
||||||
|
flash: 1024
|
||||||
|
toolchain:
|
||||||
|
- zephyr
|
||||||
|
- gnuarmemb
|
||||||
|
- xtools
|
||||||
27
boards/arm/nrf52840_test/nrf52840_test_defconfig
Normal file
27
boards/arm/nrf52840_test/nrf52840_test_defconfig
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
# Copyright (c) 2023 Nordic Semiconductor ASA
|
||||||
|
# SPDX-License-Identifier: Apache-2.0
|
||||||
|
|
||||||
|
CONFIG_SOC_SERIES_NRF52X=y
|
||||||
|
CONFIG_SOC_NRF52840_QIAA=y
|
||||||
|
CONFIG_BOARD_NRF52840_TEST=y
|
||||||
|
|
||||||
|
# Enable MPU
|
||||||
|
CONFIG_ARM_MPU=y
|
||||||
|
|
||||||
|
# Enable hardware stack protection
|
||||||
|
CONFIG_HW_STACK_PROTECTION=y
|
||||||
|
|
||||||
|
# Enable GPIO
|
||||||
|
CONFIG_GPIO=y
|
||||||
|
|
||||||
|
# Enable uart driver
|
||||||
|
CONFIG_SERIAL=y
|
||||||
|
|
||||||
|
# Enable console
|
||||||
|
CONFIG_CONSOLE=y
|
||||||
|
CONFIG_UART_CONSOLE=y
|
||||||
|
|
||||||
|
# Additional board options
|
||||||
|
CONFIG_GPIO_AS_PINRESET=y
|
||||||
|
|
||||||
|
CONFIG_PINCTRL=y
|
||||||
12
prj.conf
12
prj.conf
@@ -1 +1,13 @@
|
|||||||
|
# Enalbe C++20
|
||||||
|
CONFIG_CPP=y
|
||||||
|
CONFIG_STD_CPP20=y
|
||||||
|
CONFIG_CPP_MAIN=y
|
||||||
|
|
||||||
|
# Enable random number
|
||||||
|
CONFIG_ENTROPY_GENERATOR=y
|
||||||
|
|
||||||
|
# Enable Bluetooth
|
||||||
|
CONFIG_BT=y
|
||||||
|
CONFIG_BT_HCI=y
|
||||||
|
CONFIG_BT_CTLR=y
|
||||||
|
CONFIG_BT_LL_SW_SPLIT=y
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
#include <zephyr/kernel.h>
|
|
||||||
|
|
||||||
int main(void)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
18
src/main.cpp
Normal file
18
src/main.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
#include "zephyr/kernel.h"
|
||||||
|
#include "zephyr/drivers/gpio.h"
|
||||||
|
#include "zephyr/random/rand32.h"
|
||||||
|
|
||||||
|
#define LED_NODE DT_ALIAS(led0)
|
||||||
|
static gpio_dt_spec led = GPIO_DT_SPEC_GET(LED_NODE, gpios);
|
||||||
|
|
||||||
|
auto main() -> int {
|
||||||
|
if (!gpio_is_ready_dt(&led)) return 1;
|
||||||
|
if (gpio_pin_configure_dt(&led, GPIO_OUTPUT_ACTIVE) < 0) return 1;
|
||||||
|
|
||||||
|
gpio_pin_set_dt(&led, 0);
|
||||||
|
while (true) {
|
||||||
|
printk("Hello, World! %d - %u\n", 100'000, sys_rand32_get());
|
||||||
|
k_msleep(250);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user