diff --git a/app/boards/arm/adafruit_feather_nrf52840/Kconfig b/app/boards/arm/adafruit_feather_nrf52840/Kconfig new file mode 100644 index 00000000..3328e345 --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/Kconfig @@ -0,0 +1,10 @@ +# Adafruit Feather nRF52840 Express board configuration + +# Copyright (c) 2020 Tobias Svehagen +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ENABLE_DCDC + bool "Enable DCDC mode" + select SOC_DCDC_NRF52X + default y + depends on BOARD_ADAFRUIT_FEATHER_NRF52840 diff --git a/app/boards/arm/adafruit_feather_nrf52840/Kconfig.board b/app/boards/arm/adafruit_feather_nrf52840/Kconfig.board new file mode 100644 index 00000000..4e37d053 --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/Kconfig.board @@ -0,0 +1,8 @@ +# Adafruit Feather nRF52840 Express board configuration + +# Copyright (c) 2020 Tobias Svehagen +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ADAFRUIT_FEATHER_NRF52840 + bool "Adafruit Feather nRF52840 Express" + depends on SOC_NRF52840_QIAA diff --git a/app/boards/arm/adafruit_feather_nrf52840/Kconfig.defconfig b/app/boards/arm/adafruit_feather_nrf52840/Kconfig.defconfig new file mode 100644 index 00000000..b7e86319 --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/Kconfig.defconfig @@ -0,0 +1,33 @@ +# Adafruit Feather nRF52840 Express board configuration + +# Copyright (c) 2020 Tobias Svehagen +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_ADAFRUIT_FEATHER_NRF52840 + +config BOARD + default "adafruit_feather_nrf52840" + +if USB + +config USB_NRFX + default y + +config USB_DEVICE_STACK + default y + +endif # USB + +config BT_CTLR + default BT + +config ZMK_BLE + default y + +config ZMK_USB + default y + +config ZMK_BATTERY_VOLTAGE_DIVIDER + default y + +endif # BOARD_ADAFRUIT_FEATHER_NRF52840 diff --git a/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840.dts b/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840.dts new file mode 100644 index 00000000..129918cf --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840.dts @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2020 Tobias Svehagen + * + * SPDX-License-Identifier: Apache-2.0 + */ + + /dts-v1/; + #include + #include "feather_connector.dtsi" + + / { + model = "Adafruit Feather nRF52840 Express ZMK"; + compatible = "adafruit,feather-nrf52840-zmk"; + + chosen { + zephyr,code-partition = &code_partition; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,console = &cdc_acm_uart; + zmk,battery = &vbatt; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio1 15 0>; + label = "Red LED"; + }; + blue_led: led_1 { + gpios = <&gpio1 10 0>; + label = "Blue LED"; + }; + }; + + vbatt: vbatt { + compatible = "zmk,battery-voltage-divider"; + label = "VBATT"; + io-channels = <&adc 5>; + output-ohms = <100000>; + full-ohms = <(100000 + 100000)>; + }; + + /* These aliases are provided for compatibility with samples */ + aliases { + led0 = &led0; + led1 = &blue_led; + }; + }; + + &adc { + status = "okay"; + }; + + &gpiote { + status = "okay"; + }; + + &gpio0 { + status = "okay"; + }; + + &gpio1 { + status = "okay"; + }; + + &uart0 { + compatible = "nordic,nrf-uart"; + current-speed = <115200>; + status = "okay"; + tx-pin = <25>; + rx-pin = <24>; + }; + + &i2c0 { + status = "okay"; + sda-pin = <12>; + scl-pin = <11>; + }; + + &spi1 { + compatible = "nordic,nrf-spi"; + status = "okay"; + sck-pin = <14>; + mosi-pin = <13>; + miso-pin = <15>; + }; + + &qspi { + status = "okay"; + sck-pin = <19>; + io-pins = <17>, <22>, <23>, <21>; + csn-pins = <20>; + gd25q16: gd25q16@0 { + compatible = "nordic,qspi-nor"; + reg = <0>; + writeoc = "pp4io"; + readoc = "read4io"; + sck-frequency = <16000000>; + label = "GD25Q16"; + jedec-id = [c8 40 15]; + size = <16777216>; + has-dpd; + t-enter-dpd = <20000>; + t-exit-dpd = <20000>; + }; + }; + + &flash0 { + /* + * For more information, see: + * https://docs.zephyrproject.org/latest/guides/dts/legacy-macros.html#legacy-flash-partitions + */ + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + sd_partition: partition@0 { + label = "softdevice"; + reg = <0x00000000 0x00026000>; + }; + code_partition: partition@26000 { + label = "code_partition"; + reg = <0x00026000 0x000c6000>; + }; + + /* + * The flash starting at 0x000ec000 and ending at + * 0x000f3fff is reserved for use by the application. + */ + + /* + * Storage partition will be used by FCB/LittleFS/NVS + * if enabled. + */ + storage_partition: partition@ec000 { + label = "storage"; + reg = <0x000ec000 0x00008000>; + }; + + boot_partition: partition@f4000 { + label = "adafruit_boot"; + reg = <0x000f4000 0x0000c000>; + }; + }; + }; + + &usbd { + /*compatible = "nordic,nrf-usbd";*/ + status = "okay"; + cdc_acm_uart: cdc_acm_uart { + compatible = "zephyr,cdc-acm-uart"; + label = "CDC_ACM_0"; + }; + }; diff --git a/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840.yaml b/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840.yaml new file mode 100644 index 00000000..50fe9d3a --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840.yaml @@ -0,0 +1,19 @@ +identifier: adafruit_feather_nrf52840 +name: Adafruit Feather nRF52840 Express +type: mcu +arch: arm +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - usb_device + - usb_cdc + - ble + - ieee802154 + - watchdog + - counter + - feather_serial + - feather_i2c + - feather_spi diff --git a/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840_defconfig b/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840_defconfig new file mode 100644 index 00000000..241b13d5 --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/adafruit_feather_nrf52840_defconfig @@ -0,0 +1,31 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_ADAFRUIT_FEATHER_NRF52840=y + +# Enable MPU +CONFIG_ARM_MPU=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_USE_DT_CODE_PARTITION=y + +CONFIG_MPU_ALLOW_FLASH_WRITE=y +CONFIG_NVS=y +CONFIG_SETTINGS_NVS=y +CONFIG_FLASH=y +CONFIG_FLASH_PAGE_LAYOUT=y +CONFIG_FLASH_MAP=y +CONFIG_BUILD_OUTPUT_UF2=y diff --git a/app/boards/arm/adafruit_feather_nrf52840/board.cmake b/app/boards/arm/adafruit_feather_nrf52840/board.cmake new file mode 100644 index 00000000..bd901bdf --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/board.cmake @@ -0,0 +1,12 @@ +# SPDX-License-Identifier: Apache-2.0 + +# board_runner_args(jlink "--device=nrf52" "--speed=4000") +# board_runner_args(pyocd "--target=nrf52840" "--frequency=4000000") +# board_runner_args(blackmagicprobe "--gdb-serial=/dev/ttyBmpGdb") +# include(${ZEPHYR_BASE}/boards/common/jlink.board.cmake) +# include(${ZEPHYR_BASE}/boards/common/pyocd.board.cmake) +# include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) + +board_runner_args(nrfjprog "--nrf-family=NRF52" "--softreset") +include(${ZEPHYR_BASE}/boards/common/blackmagicprobe.board.cmake) +include(${ZEPHYR_BASE}/boards/common/nrfjprog.board.cmake) diff --git a/app/boards/arm/adafruit_feather_nrf52840/doc/img/adafruit_feather_nrf52840.jpg b/app/boards/arm/adafruit_feather_nrf52840/doc/img/adafruit_feather_nrf52840.jpg new file mode 100644 index 00000000..e83c5353 Binary files /dev/null and b/app/boards/arm/adafruit_feather_nrf52840/doc/img/adafruit_feather_nrf52840.jpg differ diff --git a/app/boards/arm/adafruit_feather_nrf52840/doc/index.rst b/app/boards/arm/adafruit_feather_nrf52840/doc/index.rst new file mode 100644 index 00000000..b5ebfe83 --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/doc/index.rst @@ -0,0 +1,147 @@ +.. _adafruit_feather_nrf52840: + +Adafruit Feather nRF52840 Express +################################# + +Overview +******** + +The Adafruit Feather nRF52840 provides support for the Nordic Semiconductor +nRF52840 ARM Cortex-M4F CPU and the following devices: + +* :abbr:`ADC (Analog to Digital Converter)` +* CLOCK +* FLASH +* :abbr:`GPIO (General Purpose Input Output)` +* :abbr:`I2C (Inter-Integrated Circuit)` +* :abbr:`MPU (Memory Protection Unit)` +* :abbr:`NVIC (Nested Vectored Interrupt Controller)` +* :abbr:`PWM (Pulse Width Modulation)` +* RADIO (Bluetooth Low Energy and 802.15.4) +* :abbr:`RTC (nRF RTC System Clock)` +* Segger RTT (RTT Console) +* :abbr:`SPI (Serial Peripheral Interface)` +* :abbr:`UART (Universal asynchronous receiver-transmitter)` +* :abbr:`USB (Universal Serial Bus)` +* :abbr:`WDT (Watchdog Timer)` + +.. figure:: img/adafruit_feather_nrf52840.jpg + :width: 640px + :align: center + :alt: Adafruit Feather nRF52840 Express + +Hardware +******** + +- nRF52840 ARM Cortex-M4F processor at 64 MHz +- 1 MB flash memory and 256 KB of SRAM +- Battery connector and charger for 3.7 V lithium polymer batteries +- Charging indicator LED +- 2 User LEDs +- 1 NeoPixel LED +- Reset button +- SWD connector + +Supported Features +================== + +The Adafruit Feather nRF52840 board configuration supports the +following hardware features: + ++-----------+------------+----------------------+ +| Interface | Controller | Driver/Component | ++===========+============+======================+ +| ADC | on-chip | adc | ++-----------+------------+----------------------+ +| CLOCK | on-chip | clock_control | ++-----------+------------+----------------------+ +| FLASH | on-chip | flash | ++-----------+------------+----------------------+ +| GPIO | on-chip | gpio | ++-----------+------------+----------------------+ +| I2C | on-chip | i2c | ++-----------+------------+----------------------+ +| MPU | on-chip | arch/arm | ++-----------+------------+----------------------+ +| NVIC | on-chip | arch/arm | ++-----------+------------+----------------------+ +| PWM | on-chip | pwm | ++-----------+------------+----------------------+ +| RADIO | on-chip | Bluetooth, | +| | | ieee802154 | ++-----------+------------+----------------------+ +| RTC | on-chip | system clock | ++-----------+------------+----------------------+ +| SPI | on-chip | spi | ++-----------+------------+----------------------+ +| UART | on-chip | serial | ++-----------+------------+----------------------+ +| USB | on-chip | usb | ++-----------+------------+----------------------+ +| WDT | on-chip | watchdog | ++-----------+------------+----------------------+ + +Other hardware features are not supported by the Zephyr kernel. + +Connections and IOs +=================== + +The `Adafruit Feather nRF52840 Express Learn site`_ has detailed +information about the board including `pinouts`_ and the `schematic`_. + +LED +--- + +* LED0 (red) = P1.15 +* LED1 (blue) = P1.10 + +Push buttons +------------ + +* SWITCH = P1.02 +* RESET = P0.18 + +Programming and Debugging +************************* + +Applications for the ``adafruit_feather_nrf52840`` board configuration +can be built and flashed in the usual way (see :ref:`build_an_application` +and :ref:`application_run` for more details). + +Flashing +======== + +Flashing Zephyr onto the ``adafruit_feather_nrf52480`` board requires +an external programmer. The programmer is attached to the SWD header. + +Build the Zephyr kernel and the :ref:`blinky-sample` sample application. + + .. zephyr-app-commands:: + :zephyr-app: samples/blinky + :board: adafruit_feather_nrf52840 + :goals: build + :compact: + +Flash the image. + + .. zephyr-app-commands:: + :zephyr-app: samples/blinky + :board: adafruit_feather_nrf52840 + :goals: flash + :compact: + +You should see the the red LED blink. + +References +********** + +.. target-notes:: + +.. _Adafruit Feather nRF52840 Express Learn site: + https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/ + +.. _pinouts: + https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/pinouts + +.. _schematic: + https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/downloads diff --git a/app/boards/arm/adafruit_feather_nrf52840/feather_connector.dtsi b/app/boards/arm/adafruit_feather_nrf52840/feather_connector.dtsi new file mode 100644 index 00000000..cbf0c139 --- /dev/null +++ b/app/boards/arm/adafruit_feather_nrf52840/feather_connector.dtsi @@ -0,0 +1,39 @@ +/* + * Copyright (c) 2020 Richard Osterloh + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/ { + feather_header: connector { + compatible = "adafruit-feather-header"; + #gpio-cells = <2>; + gpio-map-mask = <0xffffffff 0xffffffc0>; + gpio-map-pass-thru = <0 0x3f>; + gpio-map = <0 0 &gpio0 4 0>, /* A0 */ + <1 0 &gpio0 5 0>, /* A1 */ + <2 0 &gpio0 30 0>, /* A2 */ + <3 0 &gpio0 28 0>, /* A3 */ + <4 0 &gpio0 2 0>, /* A4 */ + <5 0 &gpio0 3 0>, /* A5 */ + <6 0 &gpio0 14 0>, /* SCK */ + <7 0 &gpio0 13 0>, /* MOSI */ + <8 0 &gpio0 15 0>, /* MISO */ + <9 0 &gpio0 24 0>, /* RXD */ + <10 0 &gpio0 25 0>, /* TXD */ + <11 0 &gpio0 10 0>, /* D2 (NFC2) */ + <12 0 &gpio0 12 0>, /* SDA */ + <13 0 &gpio0 11 0>, /* SCL */ + <14 0 &gpio1 8 0>, /* D5 */ + <15 0 &gpio0 7 0>, /* D6 */ + <16 0 &gpio0 26 0>, /* D9 */ + <17 0 &gpio0 27 0>, /* D10 */ + <18 0 &gpio0 6 0>, /* D11 */ + <19 0 &gpio0 8 0>, /* D12 */ + <20 0 &gpio1 9 0>; /* D13 */ + }; +}; + +feather_serial: &uart0 {}; +feather_i2c: &i2c0 {}; +feather_spi: &spi1 {};