CMSIS-DAP: CMSIS-DAP Hardware I/O Pin Access

| CMSIS-DAP Version 1.2.0 (Proposal) Interface Firmware for CoreSight Debug Access Port

- Main Page
- Usage and Description
- Reference

All Functions Groups Pages
Functions
CMSIS-DAP Hardware I/O Pin Access
Configure I/O Ports and Debug Unit

Standard I/O Pins of the CMSIS-DAP Hardware Debug Port support standard JTAG mode and Serial Wire Debug (SWD) mode. More...

## Functions
static __inline void | PORT_JTAG_SETUP (void)
| Setup JTAG I/O pins: TCK, TMS, TDI, TDO, nTRST, and nRESET. More...
static __inline void | PORT_SWD_SETUP (void)
| Setup SWD I/O pins: SWCLK, SWDIO, and nRESET. More...
static __inline void | PORT_OFF (void)
| Disable JTAG/SWD I/O Pins. More...
static __forceinline uint32_t | PIN_SWCLK_TCK_IN (void)
| SWCLK/TCK I/O pin: Get Input. More...
static __forceinline void | PIN_SWCLK_TCK_SET (void)
| SWCLK/TCK I/O pin: Set Output to High. More...
static __forceinline void | PIN_SWCLK_TCK_CLR (void)
| SWCLK/TCK I/O pin: Set Output to Low. More...
static __forceinline uint32_t | PIN_SWDIO_TMS_IN (void)
| SWDIO/TMS I/O pin: Get Input. More...
static __forceinline void | PIN_SWDIO_TMS_SET (void)
| SWDIO/TMS I/O pin: Set Output to High. More...
static __forceinline void | PIN_SWDIO_TMS_CLR (void)
| SWDIO/TMS I/O pin: Set Output to Low. More...
static __forceinline uint32_t | PIN_SWDIO_IN (void)
| SWDIO I/O pin: Get Input (used in SWD mode only). More...
static __forceinline void | PIN_SWDIO_OUT (uint32_t bit)
| SWDIO I/O pin: Set Output (used in SWD mode only). More...
static __forceinline void | PIN_SWDIO_OUT_ENABLE (void)
| SWDIO I/O pin: Switch to Output mode (used in SWD mode only). More...
static __forceinline void | PIN_SWDIO_OUT_DISABLE (void)
| SWDIO I/O pin: Switch to Input mode (used in SWD mode only). More...
static __forceinline uint32_t | PIN_TDI_IN (void)
| TDI I/O pin: Get Input. More...
static __forceinline void | PIN_TDI_OUT (uint32_t bit)
| TDI I/O pin: Set Output. More...
static __forceinline uint32_t | PIN_TDO_IN (void)
| TDO I/O pin: Get Input. More...
static __forceinline uint32_t | PIN_nTRST_IN (void)
| nTRST I/O pin: Get Input. More...
static __forceinline void | PIN_nTRST_OUT (uint32_t bit)
| nTRST I/O pin: Set Output. More...
static __forceinline uint32_t | PIN_nRESET_IN (void)
| nRESET I/O pin: Get Input. More...
static __forceinline void | PIN_nRESET_OUT (uint32_t bit)
| nRESET I/O pin: Set Output. More...

## Description

Standard I/O Pins of the CMSIS-DAP Hardware Debug Port support standard JTAG mode and Serial Wire Debug (SWD) mode.

In SWD mode only 2 pins are required to implement the debug interface of a device. The following I/O Pins are provided:

JTAG I/O Pin | SWD I/O Pin | CMSIS-DAP Hardware pin mode
--- | --- | ---
TCK: Test Clock | SWCLK: Clock | Output Push/Pull
TMS: Test Mode Select | SWDIO: Data I/O | Output Push/Pull; Input (for receiving data)
TDI: Test Data Input |  | Output Push/Pull
TDO: Test Data Output |  | Input
nTRST: Test Reset (optional) |  | Output Open Drain with pull-up resistor
nRESET: Device Reset | nRESET: Device Reset | Output Open Drain with pull-up resistor

## DAP Hardware I/O Pin Access Functions

The various I/O Pins are accessed by functions that implement the Read, Write, Set, or Clear to these I/O Pins.

For the SWDIO I/O Pin there are additional functions that are called in SWD I/O mode only. This functions are provided to achieve faster I/O that is possible with some advanced GPIO peripherals that can independently write/read a single I/O pin without affecting any other pins of the same I/O port. The following SWDIO I/O Pin functions are provided:

- PIN_SWDIO_OUT_ENABLE to enable the output mode from the DAP hardware.
- PIN_SWDIO_OUT_DISABLE to enable the input mode to the DAP hardware.
- PIN_SWDIO_IN to read from the SWDIO I/O pin with utmost possible speed.
- PIN_SWDIO_OUT to write to the SWDIO I/O pin with utmost possible speed.

## Function Documentation

static __forceinline uint32_t PIN_nRESET_IN | ( | void |  | ) |
| static

nRESET I/O pin: Get Input.

Returns
  Current status of the nRESET DAP hardware I/O pin.

static __forceinline void PIN_nRESET_OUT | ( | uint32_t | bit | ) |
| static

nRESET I/O pin: Set Output.

Parameters

  bit | target device hardware reset pin status: 0: issue a device hardware reset. 1: release device hardware reset.

static __forceinline uint32_t PIN_nTRST_IN | ( | void |  | ) |
| static

nTRST I/O pin: Get Input.

Returns
  Current status of the nTRST DAP hardware I/O pin.

static __forceinline void PIN_nTRST_OUT | ( | uint32_t | bit | ) |
| static

nTRST I/O pin: Set Output.

Parameters

  bit | JTAG TRST Test Reset pin status: 0: issue a JTAG TRST Test Reset. 1: release JTAG TRST Test Reset.

static __forceinline void PIN_SWCLK_TCK_CLR | ( | void |  | ) |
| static

SWCLK/TCK I/O pin: Set Output to Low.

Set the SWCLK/TCK DAP hardware I/O pin to low level.

static __forceinline uint32_t PIN_SWCLK_TCK_IN | ( | void |  | ) |
| static

SWCLK/TCK I/O pin: Get Input.

Returns
  Current status of the SWCLK/TCK DAP hardware I/O pin.

static __forceinline void PIN_SWCLK_TCK_SET | ( | void |  | ) |
| static

SWCLK/TCK I/O pin: Set Output to High.

Set the SWCLK/TCK DAP hardware I/O pin to high level.

static __forceinline uint32_t PIN_SWDIO_IN | ( | void |  | ) |
| static

SWDIO I/O pin: Get Input (used in SWD mode only).

Returns
  Current status of the SWDIO DAP hardware I/O pin.

static __forceinline void PIN_SWDIO_OUT | ( | uint32_t | bit | ) |
| static

SWDIO I/O pin: Set Output (used in SWD mode only).

Parameters

  bit | Output value for the SWDIO DAP hardware I/O pin.

static __forceinline void PIN_SWDIO_OUT_DISABLE | ( | void |  | ) |
| static

SWDIO I/O pin: Switch to Input mode (used in SWD mode only).

Configure the SWDIO DAP hardware I/O pin to input mode. This function is called prior PIN_SWDIO_IN function calls.

static __forceinline void PIN_SWDIO_OUT_ENABLE | ( | void |  | ) |
| static

SWDIO I/O pin: Switch to Output mode (used in SWD mode only).

Configure the SWDIO DAP hardware I/O pin to output mode. This function is called prior PIN_SWDIO_OUT function calls.

static __forceinline void PIN_SWDIO_TMS_CLR | ( | void |  | ) |
| static

SWDIO/TMS I/O pin: Set Output to Low.

Set the SWDIO/TMS DAP hardware I/O pin to low level.

static __forceinline uint32_t PIN_SWDIO_TMS_IN | ( | void |  | ) |
| static

SWDIO/TMS I/O pin: Get Input.

Returns
  Current status of the SWDIO/TMS DAP hardware I/O pin.

static __forceinline void PIN_SWDIO_TMS_SET | ( | void |  | ) |
| static

SWDIO/TMS I/O pin: Set Output to High.

Set the SWDIO/TMS DAP hardware I/O pin to high level.

static __forceinline uint32_t PIN_TDI_IN | ( | void |  | ) |
| static

TDI I/O pin: Get Input.

Returns
  Current status of the TDI DAP hardware I/O pin.

static __forceinline void PIN_TDI_OUT | ( | uint32_t | bit | ) |
| static

TDI I/O pin: Set Output.

Parameters

  bit | Output value for the TDI DAP hardware I/O pin.

static __forceinline uint32_t PIN_TDO_IN | ( | void |  | ) |
| static

TDO I/O pin: Get Input.

Returns
  Current status of the TDO DAP hardware I/O pin.

static __inline void PORT_JTAG_SETUP | ( | void |  | ) |
| static

Setup JTAG I/O pins: TCK, TMS, TDI, TDO, nTRST, and nRESET.

Configures the DAP Hardware I/O pins for JTAG mode:

- TCK, TMS, TDI, nTRST, nRESET to output mode and set to high level.
- TDO to input mode.

static __inline void PORT_OFF | ( | void |  | ) |
| static

Disable JTAG/SWD I/O Pins.

Disables the DAP Hardware I/O pins which configures:

- TCK/SWCLK, TMS/SWDIO, TDI, TDO, nTRST, nRESET to High-Z mode.

static __inline void PORT_SWD_SETUP | ( | void |  | ) |
| static

Setup SWD I/O pins: SWCLK, SWDIO, and nRESET.

Configures the DAP Hardware I/O pins for Serial Wire Debug (SWD) mode:

- SWCLK, SWDIO, nRESET to output mode and set to default high level.
- TDI, nTRST to HighZ mode (pins are unused in SWD mode).