diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig new file mode 100644 index 00000000000..9895b069ceb --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig @@ -0,0 +1,14 @@ +# Adafruit ItsyBitsy nRF52840 Express board configuration + +# Copyright (c) 2022 Embla Flatlandsmo +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ENABLE_DCDC + bool "DCDC mode" + select SOC_DCDC_NRF52X + default y + depends on BOARD_ADAFRUIT_ITSYBITSY_NRF52840 + +config BOARD_ENABLE_USB_CDC + bool "USB CDC" + default y diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.board b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.board new file mode 100644 index 00000000000..f0a4444fd91 --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.board @@ -0,0 +1,8 @@ +# Adafruit ItsyBitsy nRF52840 Express board configuration + +# Copyright (c) 2022 Embla Flatlandsmo +# SPDX-License-Identifier: Apache-2.0 + +config BOARD_ADAFRUIT_ITSYBITSY_NRF52840 + bool "Adafruit ItsyBitsy nRF52840 Express" + depends on SOC_NRF52840_QIAA diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.defconfig b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.defconfig new file mode 100644 index 00000000000..964bd85868e --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/Kconfig.defconfig @@ -0,0 +1,51 @@ +# Adafruit ItsyBitsy nRF52840 Express board configuration + +# Copyright (c) 2022 Embla Flatlandsmo +# SPDX-License-Identifier: Apache-2.0 + +if BOARD_ADAFRUIT_ITSYBITSY_NRF52840 + +config BOARD + default "adafruit_itsybitsy_nrf52840" + +config BT_CTLR + default BT + +if BOARD_ENABLE_USB_CDC + +config USB_DEVICE_STACK + default y + +config USB_CDC_ACM + default y + +config UART_CONSOLE + default CONSOLE + +config USB_DEVICE_INITIALIZE_AT_BOOT + default y + +config SHELL_BACKEND_SERIAL_CHECK_DTR + default SHELL + +config USB_DEVICE_REMOTE_WAKEUP + default n + +if LOG + +# Set USB and CDC log level to error only +config USB_CDC_ACM_LOG_LEVEL + default 1 + +config USB_DEVICE_LOG_LEVEL + default 1 + +# Wait 1500ms at startup for logging +config LOG_PROCESS_THREAD_STARTUP_DELAY_MS + default 1500 + +endif # LOG + +endif # BOARD_ENABLE_USB_CDC + +endif # BOARD_ADAFRUIT_ITSYBITSY_NRF52840 diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840-pinctrl.dtsi b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840-pinctrl.dtsi new file mode 100644 index 00000000000..ea7d0e81e61 --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840-pinctrl.dtsi @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2022 Embla Flatlandsmo + * SPDX-License-Identifier: Apache-2.0 + */ + +&pinctrl { + uart0_default: uart0_default { + group1 { + psels = , + ; + }; + }; + + uart0_sleep: uart0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + i2c0_default: i2c0_default { + group1 { + psels = , + ; + }; + }; + + i2c0_sleep: i2c0_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + spi2_default: spi2_default { + group1 { + psels = , + ; + }; + }; + + spi2_sleep: spi2_sleep { + group1 { + psels = , + ; + low-power-enable; + }; + }; + + spi1_default: spi1_default { + group1 { + psels = , + , + ; + }; + }; + + spi1_sleep: spi1_sleep { + group1 { + psels = , + , + ; + low-power-enable; + }; + }; + + qspi_default: qspi_default { + group1 { + psels = , + , + , + , + , + ; + }; + }; + + qspi_sleep: qspi_sleep { + group1 { + psels = , + , + , + , + , + ; + low-power-enable; + }; + }; +}; diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840.dts b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840.dts new file mode 100644 index 00000000000..2b05371899b --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840.dts @@ -0,0 +1,179 @@ +/* + * Copyright (c) 2022 Embla Flatlandsmo + * + * SPDX-License-Identifier: Apache-2.0 + */ + +/dts-v1/; +#include +#include "adafruit_itsybitsy_nrf52840-pinctrl.dtsi" + +/ { + model = "Adafruit ItsyBitsy nRF52840 Express"; + compatible = "adafruit,itsybitsy-nrf52840"; + + chosen { + zephyr,console = &cdc_acm_uart0; + zephyr,shell-uart = &cdc_acm_uart0; + zephyr,uart-mcumgr = &cdc_acm_uart0; + zephyr,bt-mon-uart = &cdc_acm_uart0; + zephyr,bt-c2h-uart = &cdc_acm_uart0; + zephyr,sram = &sram0; + zephyr,flash = &flash0; + zephyr,code-partition = &code_partition; + }; + + leds { + compatible = "gpio-leds"; + led0: led_0 { + gpios = <&gpio0 6 GPIO_ACTIVE_HIGH>; + label = "Red LED"; + }; + }; + + buttons { + compatible = "gpio-keys"; + button0: button_0 { + gpios = <&gpio0 29 (GPIO_PULL_UP | GPIO_ACTIVE_LOW)>; + label = "Push button switch"; + }; + }; + + /* These aliases are provided for compatibility with samples */ + aliases { + led0 = &led0; + sw0 = &button0; + watchdog0 = &wdt0; + spi-flash0 = &gd25q16; + }; +}; + +&adc { + status = "okay"; +}; + +&gpiote { + status = "okay"; +}; + +&gpio0 { + status = "okay"; +}; + +&gpio1 { + status = "okay"; +}; + +&uart0 { + compatible = "nordic,nrf-uarte"; + current-speed = <115200>; + status = "disabled"; + pinctrl-0 = <&uart0_default>; + pinctrl-1 = <&uart0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&i2c0 { + compatible = "nordic,nrf-twi"; + status = "okay"; + pinctrl-0 = <&i2c0_default>; + pinctrl-1 = <&i2c0_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&spi1 { + compatible = "nordic,nrf-spi"; + status = "okay"; + pinctrl-0 = <&spi1_default>; + pinctrl-1 = <&spi1_sleep>; + pinctrl-names = "default", "sleep"; +}; + +&spi2 { + compatible = "nordic,nrf-spi"; + status = "okay"; + pinctrl-0 = <&spi2_default>; + pinctrl-1 = <&spi2_sleep>; + pinctrl-names = "default", "sleep"; + apa102: apa102@0 { + compatible = "apa,apa102"; + reg = <0>; + spi-max-frequency = <5250000>; + }; +}; + +&qspi { + status = "okay"; + pinctrl-0 = <&qspi_default>; + pinctrl-1 = <&qspi_sleep>; + pinctrl-names = "default", "sleep"; + gd25q16: gd25q16@0 { + compatible = "nordic,qspi-nor"; + reg = <0>; + writeoc = "pp4o"; + readoc = "read4io"; + sck-frequency = <32000000>; + jedec-id = [c8 40 15]; + size = <16777216>; + has-dpd; + t-enter-dpd = <20000>; + t-exit-dpd = <20000>; + quad-enable-requirements = "S2B1v1"; + }; +}; + +&flash0 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + + /* To enable flashing with UF2 bootloader, we + * must reserve a partition for SoftDevice. + * See https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather?view=all#hathach-memory-map + */ + reserved_partition_0: partition@0 { + label = "SoftDevice"; + reg = <0x000000000 DT_SIZE_K(152)>; + }; + code_partition: partition@26000 { + label = "Application"; + reg = <0x00026000 DT_SIZE_K(796)>; + }; + + /* + * The flash starting at 0x000ed000 and ending at + * 0x000f4000 is reserved for use by the application. + */ + storage_partition: partition@ed000 { + label = "storage"; + reg = <0x0000ed000 DT_SIZE_K(28)>; + }; + + boot_partition: partition@f4000 { + label = "UF2"; + reg = <0x000f4000 DT_SIZE_K(48)>; + }; + }; +}; + +&gd25q16 { + partitions { + compatible = "fixed-partitions"; + #address-cells = <1>; + #size-cells = <1>; + lfs_partition: partition@0 { + label = "lfs_storage"; + reg = <0x00000000 DT_SIZE_M(2)>; + }; + }; +}; + +zephyr_udc0: &usbd { + compatible = "nordic,nrf-usbd"; + status = "okay"; + + cdc_acm_uart0: cdc_acm_uart0 { + compatible = "zephyr,cdc-acm-uart"; + }; +}; diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840.yaml b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840.yaml new file mode 100644 index 00000000000..eba07de2022 --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840.yaml @@ -0,0 +1,21 @@ +identifier: adafruit_itsybitsy_nrf52840 +name: Adafruit ItsyBitsy nRF52840 Express +type: mcu +arch: arm +ram: 256 +flash: 1024 +toolchain: + - zephyr + - gnuarmemb + - xtools +supported: + - adc + - ble + - counter + - gpio + - i2c + - pwm + - spi + - usb_cdc + - usb_device + - watchdog diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840_defconfig b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840_defconfig new file mode 100644 index 00000000000..bc27efcdd29 --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840_defconfig @@ -0,0 +1,26 @@ +# SPDX-License-Identifier: Apache-2.0 + +CONFIG_SOC_SERIES_NRF52X=y +CONFIG_SOC_NRF52840_QIAA=y +CONFIG_BOARD_ADAFRUIT_ITSYBITSY_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_PINCTRL=y + +# Flashing +CONFIG_USE_DT_CODE_PARTITION=y +CONFIG_BUILD_OUTPUT_UF2=y diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/board.cmake b/boards/arm/adafruit_itsybitsy_nrf52840/board.cmake new file mode 100644 index 00000000000..6366e4775ec --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/board.cmake @@ -0,0 +1,9 @@ +# SPDX-License-Identifier: Apache-2.0 + +include(${ZEPHYR_BASE}/boards/common/bossac.board.cmake) +board_runner_args(jlink "--device=nRF52840_xxAA" "--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) +include(${ZEPHYR_BASE}/boards/common/openocd-nrf5.board.cmake) diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/doc/img/adafruit_itsybitsy_nrf52840.jpeg b/boards/arm/adafruit_itsybitsy_nrf52840/doc/img/adafruit_itsybitsy_nrf52840.jpeg new file mode 100644 index 00000000000..1af742675a9 Binary files /dev/null and b/boards/arm/adafruit_itsybitsy_nrf52840/doc/img/adafruit_itsybitsy_nrf52840.jpeg differ diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/doc/index.rst b/boards/arm/adafruit_itsybitsy_nrf52840/doc/index.rst new file mode 100644 index 00000000000..699e2151194 --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/doc/index.rst @@ -0,0 +1,192 @@ +.. _adafruit_itsybitsy_nrf52840: + +Adafruit ItsyBitsy nRF52840 +########################### + +Overview +******** + +The Adafruit ItsyBitsy nRF52840 Express is a small (36 mm x 18 mm) ARM +development board with an onboard RGB LED, USB port, 2 MB of QSPI flash, +and range of I/O broken out onto 21 GPIO pins. + +This development kit has the following features: + +* :abbr:`ADC (Analog to Digital Converter)` +* CLOCK +* FLASH +* :abbr:`GPIO (General Purpose Input Output)` +* :abbr:`I2C (Inter-Integrated Circuit)` +* :abbr:`I2S (Inter-Integrated Sound)` +* :abbr:`MPU (Memory Protection Unit)` +* :abbr:`NVIC (Nested Vectored Interrupt Controller)` +* :abbr:`PWM (Pulse Width Modulation)` +* :abbr:`QSPI (Quad Serial Peripheral Interface)` +* RADIO (Bluetooth Low Energy and 802.15.4) +* :abbr:`RTC (nRF RTC System Clock)` +* :abbr:`SPI (Serial Peripheral Interface)` +* :abbr:`UARTE (Universal asynchronous receiver-transmitter)` +* :abbr:`USB (Universal Serial Bus)` +* :abbr:`WDT (Watchdog Timer)` + +.. image:: img/adafruit_itsybitsy_nrf52840.jpeg + :align: center + :alt: Adafruit ItsyBitsy nRF52840 Express + +Hardware +******** +- nRF52840 ARM Cortex-M4F CPU at 64MHz +- 1 MB of flash memory and 256 KB of SRAM +- 2 MB of QSPI flash +- A user LED +- A user switch +- An RGB DotStar LED +- Native USB port +- One reset button + +Supported Features +================== + +The Adafruit ItsyBitsy 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 | ++-----------+------------+----------------------+ +| QSPI(M) | on-chip | nor | ++-----------+------------+----------------------+ +| RADIO | on-chip | Bluetooth, | +| | | ieee802154 | ++-----------+------------+----------------------+ +| RTC | on-chip | system clock | ++-----------+------------+----------------------+ +| SPI | on-chip | spi | ++-----------+------------+----------------------+ +| UARTE | on-chip | serial | ++-----------+------------+----------------------+ +| USB | on-chip | usb | ++-----------+------------+----------------------+ +| WDT | on-chip | watchdog | ++-----------+------------+----------------------+ + +Other hardware features have not been enabled yet for this board. + +Connections and IOs +=================== + +The `Adafruit ItsyBitsy nRF52840 Express Learn site`_ has detailed +information about the board including `pinouts`_ and the `schematic`_. + +LED +--- + +* LED0 (red) = P0.06 + +* LED1 (Adafruit DotStar) + + * DATA = P0.08 + + * CLK = P1.09 + +Push buttons +------------ + +* SWITCH = P0.29 + +* RESET = P0.18 + +Logging +------- + +Logging is done using the USB-CDC port. See the :ref:`logger_sample` +or the :ref:`cdc-acm-console` sample applications to see how this works. + +Testing LEDs and buttons on the Adafruit ItsyBitsy nRF52840 Express +******************************************************************* +The :ref:`button-sample` sample lets you test the buttons (switches) and the red LED. +The :ref:`blinky-sample` sample lets you test the red LED. + +The DotStar LED has been implemented as a SPI device and can be tested +with the :ref:`led_apa102_sample` sample application. + +You can build and flash the examples to make sure Zephyr is running correctly on +your board. The button and LED definitions can be found in +:zephyr_file:`boards/arm/adafruit_itsybitsy_nrf52840/adafruit_itsybitsy_nrf52840.dts`. + +Programming and Debugging +************************* +The ItsyBitsy ships with the BOSSA compatible UF2 bootloader. The +bootloader can be entered by quickly tapping the reset button twice. + +First time setup +================ +Some versions of this board were shipped with a buggy bootloader. +Ensure that the bootloader is up to date by following the +`Adafruit UF2 Bootloader update`_ tutorial. Note that this tutorial +was made for the Adafruit Feather nRF52840, but the steps to update +the bootloader are the same for the ItsyBitsy. The files for the +ItsyBitsy bootloader can be found in the `Adafruit nRF52 Bootloader repo`_. + +The building and flashing of Zephyr applications have been tested with +release 0.7.0 of the UF2 bootloader. + +Flashing +======== +Flashing is done by dragging and dropping the built Zephyr UF2-file +into the :code:`ITSY840BOOT` drive. + +#. Build the Zephyr kernel and the :ref:`blinky-sample` + sample application: + + .. zephyr-app-commands:: + :zephyr-app: samples/basic/blinky + :board: adafruit_itsybitsy_nrf52840 + :goals: build + :compact: + +#. Connect the ItsyBitsy to your host computer using USB + +#. Tap the reset button twice quickly to enter bootloader mode + +#. Flash the image: + + Drag and drop the file :code:`samples/basic/blinky/build/zephyr/zephyr.uf2` + into :code:`ITSY840BOOT` + +The device will disconnect and you should see the red LED blink. + +References +********** + +.. target-notes:: + +.. _Adafruit ItsyBitsy nRF52840 Express Learn site: + https://learn.adafruit.com/adafruit-itsybitsy-nrf52840-express + +.. _pinouts: + https://learn.adafruit.com/adafruit-itsybitsy-nrf52840-express/pinouts + +.. _schematic: + https://learn.adafruit.com/adafruit-itsybitsy-nrf52840-express/downloads + +.. _Adafruit UF2 Bootloader update: + https://learn.adafruit.com/introducing-the-adafruit-nrf52840-feather/update-bootloader + +.. _Adafruit nRF52 Bootloader repo: + https://github.com/adafruit/Adafruit_nRF52_Bootloader/releases diff --git a/boards/arm/adafruit_itsybitsy_nrf52840/pre_dt_board.cmake b/boards/arm/adafruit_itsybitsy_nrf52840/pre_dt_board.cmake new file mode 100644 index 00000000000..8bdaab48eb9 --- /dev/null +++ b/boards/arm/adafruit_itsybitsy_nrf52840/pre_dt_board.cmake @@ -0,0 +1,7 @@ +# Copyright (c) 2022 Embla Flatlandsmo +# SPDX-License-Identifier: Apache-2.0 + +# Suppress "unique_unit_address_if_enabled" to handle the following overlaps: +# - power@40000000 & clock@40000000 & bprot@40000000 +# - acl@4001e000 & flash-controller@4001e000 +list(APPEND EXTRA_DTC_FLAGS "-Wno-unique_unit_address_if_enabled") diff --git a/tests/drivers/adc/adc_api/src/test_adc.c b/tests/drivers/adc/adc_api/src/test_adc.c index 1614e91e6ba..4ef8df520df 100644 --- a/tests/drivers/adc/adc_api/src/test_adc.c +++ b/tests/drivers/adc/adc_api/src/test_adc.c @@ -48,6 +48,7 @@ defined(CONFIG_BOARD_BL654_SENSOR_BOARD) || \ defined(CONFIG_BOARD_DEGU_EVK) || \ defined(CONFIG_BOARD_ADAFRUIT_FEATHER_NRF52840) || \ + defined(CONFIG_BOARD_ADAFRUIT_ITSYBITSY_NRF52840) || \ defined(CONFIG_BOARD_RUUVI_RUUVITAG) || \ defined(CONFIG_BOARD_BT510) || \ defined(CONFIG_BOARD_PINNACLE_100_DVK) || \