Skip to content

Commit

Permalink
samples: subsys: usb: add dapusb sample
Browse files Browse the repository at this point in the history
Signed-off-by: Maximilian Deubel <[email protected]>
  • Loading branch information
maxd-nordic committed Jul 4, 2023
1 parent 8837a59 commit 730e783
Show file tree
Hide file tree
Showing 14 changed files with 608 additions and 139 deletions.
5 changes: 3 additions & 2 deletions samples/subsys/dap/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
# Copyright (c) 2023 Nordic Semiconductor ASA
# SPDX-License-Identifier: Apache-2.0

cmake_minimum_required(VERSION 3.20.0)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})
project(dap)
project(webusb)

target_include_directories(app PRIVATE ${ZEPHYR_BASE}/subsys/usb)

FILE(GLOB app_sources src/*.c)
target_sources(app PRIVATE ${app_sources})
14 changes: 10 additions & 4 deletions samples/subsys/dap/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,20 @@ Overview
********

This sample app demonstrates use of a SWDP interface driver and CMSIS DAP
controller through USB HID interface.
controller through USB Bulk interface.

Requirements
************

This sample requires simple circuit consisting of a few Dual-Supply Bus
Transceivers connected to Arduino GPIOs, look for ARM microcontroller-based
Hardware Interface Circuits (HICs) for detailed information.
This sample supports multiple hardware configurations:

The simplest configuration would be to connect `SWDIO` to `dio`, `SWDCLK` to `clk`
and optionally `nRESET` to `reset`.
The optional `noe` pin is used to enable the port, e.g. if the SWD connections are multiplexed.

If you are using bus transceivers and require separate
input and output pins along with an output-enable pin, set `CONFIG_SWDP_BITBANG_DRIVER_SEPARATE_IN_OUT=y`.
In this case the `din`, `dout` and `dnoe` pins are used.

Building and Running
********************
Expand Down
4 changes: 4 additions & 0 deletions samples/subsys/dap/boards/nrf52840dk_nrf52840.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
CONFIG_SWDP_BITBANG_DRIVER_SEPARATE_IN_OUT=n

CONFIG_CMSIS_DAP_DEVICE_VENDOR="Raspberry Pi"
CONFIG_CMSIS_DAP_DEVICE_NAME="rp2040"
26 changes: 26 additions & 0 deletions samples/subsys/dap/boards/nrf52840dk_nrf52840.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
dp0 {
compatible = "zephyr,swdp-gpio";
status = "okay";
clk-gpios = <&arduino_header 10 GPIO_ACTIVE_HIGH>; /* D4 */
dout-gpios = <&arduino_header 9 GPIO_ACTIVE_HIGH>; /* D3 */
din-gpios = <&arduino_header 8 GPIO_PULL_UP>; /* D2 */
dio-gpios = <&arduino_header 8 GPIO_PULL_UP>; /* D2 */
dnoe-gpios = <&arduino_header 12 GPIO_ACTIVE_HIGH>; /* D6 */
noe-gpios = <&arduino_header 11 GPIO_ACTIVE_HIGH>; /* D5 */
reset-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
port-write-cycles = <2>;
};
};

&zephyr_udc0 {
cdc_acm_uart0 {
compatible = "zephyr,cdc-acm-uart";
};
};
3 changes: 3 additions & 0 deletions samples/subsys/dap/boards/nrf7002dk_nrf5340_cpuapp.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
CONFIG_SWDP_BITBANG_DRIVER_SEPARATE_IN_OUT=n
CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor"
CONFIG_CMSIS_DAP_DEVICE_NAME="nrf9160_xxaa"
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@
* SPDX-License-Identifier: Apache-2.0
*/

/ {
/ {
dp0 {
compatible = "zephyr,swdp-gpio";
status = "okay";
clk-gpios = <&arduino_header 10 GPIO_ACTIVE_HIGH>; /* D4 */
dout-gpios = <&arduino_header 9 GPIO_ACTIVE_HIGH>; /* D3 */
din-gpios = <&arduino_header 8 GPIO_PULL_UP>; /* D2 */
dio-gpios = <&arduino_header 8 GPIO_PULL_UP>; /* D2 */
dnoe-gpios = <&arduino_header 12 GPIO_ACTIVE_HIGH>; /* D6 */
noe-gpios = <&arduino_header 11 GPIO_ACTIVE_HIGH>; /* D5 */
reset-gpios = <&arduino_header 13 GPIO_ACTIVE_HIGH>; /* D7 */
Expand Down
5 changes: 5 additions & 0 deletions samples/subsys/dap/boards/thingy91_nrf52840.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_REMOTE_WAKEUP=n
CONFIG_USB_MAX_POWER=250
CONFIG_CMSIS_DAP_DEVICE_VENDOR="Nordic Semiconductor"
CONFIG_CMSIS_DAP_DEVICE_NAME="nrf9160_xxaa"
17 changes: 17 additions & 0 deletions samples/subsys/dap/boards/thingy91_nrf52840.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2023 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: Apache-2.0
*/


/ {
dp0 {
compatible = "zephyr,swdp-gpio";
status = "okay";
clk-gpios = <&gpio1 5 GPIO_ACTIVE_HIGH>;
dio-gpios = <&gpio0 14 GPIO_ACTIVE_HIGH>;
noe-gpios = <&gpio0 17 GPIO_ACTIVE_HIGH>;
port-write-cycles = <2>;
};
};
24 changes: 13 additions & 11 deletions samples/subsys/dap/prj.conf
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
CONFIG_STDOUT_CONSOLE=y
CONFIG_USB_DEVICE_STACK=y
CONFIG_USB_DEVICE_BOS=y
CONFIG_SERIAL=y
CONFIG_USB_DEVICE_PRODUCT="Zephyr CMSIS-DAP"
CONFIG_USB_DEVICE_PID=0x0204
CONFIG_UART_INTERRUPT_DRIVEN=y
CONFIG_UART_LINE_CTRL=y
CONFIG_USB_DEVICE_INITIALIZE_AT_BOOT=n

CONFIG_USB_DEVICE_HID=y
CONFIG_ENABLE_HID_INT_OUT_EP=y
CONFIG_HID_INTERRUPT_EP_MPS=64
CONFIG_USB_HID_POLL_INTERVAL_MS=1
CONFIG_LOG=y

# Change to VID/PID from a known HIC or it will not be recognized.
CONFIG_USB_DEVICE_VID=0x2fe3
CONFIG_USB_DEVICE_PID=0x0204
CONFIG_USB_COMPOSITE_DEVICE=y

CONFIG_DAP=y
CONFIG_NET_BUF=y

CONFIG_LOG=y
CONFIG_USB_DRIVER_LOG_LEVEL_INF=y
CONFIG_USB_DEVICE_LOG_LEVEL_INF=y
CONFIG_DAP_LOG_LEVEL_INF=y
CONFIG_DP_DRIVER_LOG_LEVEL_INF=y
CONFIG_DAP=y
CONFIG_GPIO=y
CONFIG_NET_BUF=y
2 changes: 1 addition & 1 deletion samples/subsys/dap/sample.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
sample:
name: DAP HID
name: DAP USB
tests:
sample.dap.hid:
build_only: true
Expand Down
Loading

0 comments on commit 730e783

Please sign in to comment.