Skip to content

Commit c083829

Browse files
committed
add comments
1 parent b76ff29 commit c083829

File tree

1 file changed

+23
-17
lines changed

1 file changed

+23
-17
lines changed

source/hic_hal/nxp/lpc11u35/DAP_config.h

Lines changed: 23 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,7 @@ Provides definitions about:
4242
// Configure JTAG option
4343
#if defined(BOARD_BAMBINO_210) || defined(BOARD_BAMBINO_210E)
4444
// LPC43xx multicore targets require JTAG to debug slave cores
45-
#define CONF_JTAG
46-
#endif
47-
48-
// Configure SWD option by default
49-
#if !defined(CONF_JTAG) && !defined(CONF_SWD)
50-
#define CONF_SWD
45+
#define DAP_JTAG 1
5146
#endif
5247

5348
/// Processor Clock of the Cortex-M MCU used in the Debug Unit.
@@ -64,18 +59,14 @@ Provides definitions about:
6459

6560
/// Indicate that Serial Wire Debug (SWD) communication mode is available at the Debug Access Port.
6661
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
67-
#if defined(CONF_SWD)
62+
#ifndef DAP_SWD
6863
#define DAP_SWD 1 ///< SWD Mode: 1 = available, 0 = not available
69-
#else
70-
#define DAP_SWD 0 ///< SWD Mode: 1 = available, 0 = not available
7164
#endif
7265

7366
/// Indicate that JTAG communication mode is available at the Debug Port.
7467
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
75-
#if defined(CONF_JTAG)
76-
#define DAP_JTAG 1 ///< JTAG Mode: 1 = available
77-
#else
78-
#define DAP_JTAG 0 ///< JTAG Mode: 0 = not available
68+
#ifndef DAP_JTAG
69+
#define DAP_JTAG 0 ///< JTAG Mode: 1 = available, 0 = not available
7970
#endif
8071

8172
/// Configure maximum number of JTAG devices on the scan chain connected to the Debug Access Port.
@@ -84,10 +75,12 @@ Provides definitions about:
8475

8576
/// Default communication mode on the Debug Access Port.
8677
/// Used for the command \ref DAP_Connect when Port Default mode is selected.
87-
#if (DAP_SWD != 0)
78+
#if (DAP_SWD == 1)
8879
#define DAP_DEFAULT_PORT 1 ///< Default JTAG/SWJ Port Mode: 1 = SWD, 2 = JTAG.
89-
#else
80+
#elif (DAP_JTAG == 1)
9081
#define DAP_DEFAULT_PORT 2 ///< Default JTAG/SWJ Port Mode: 1 = SWD, 2 = JTAG.
82+
#else
83+
#error Must enable DAP_SWD and/or DAP_JTAG
9184
#endif
9285

9386
/// Default communication speed on the Debug Access Port for SWD and JTAG mode.
@@ -189,15 +182,23 @@ __STATIC_INLINE void PORT_JTAG_SETUP(void)
189182
LPC_GPIO->SET[PIN_SWCLK_PORT] = PIN_SWCLK;
190183
LPC_GPIO->SET[PIN_SWDIO_PORT] = PIN_SWDIO;
191184
#if !defined(PIN_nRESET_FET_DRIVE)
192-
// open drain logic
185+
/* Open drain logic (for ordinary board).
186+
* nRESET line should be pulled up by the board.
187+
* To output high level (reset release signal),
188+
* set as input direction. */
193189
LPC_GPIO->DIR[PIN_nRESET_PORT] &= ~PIN_nRESET;
194190
LPC_GPIO->CLR[PIN_nRESET_PORT] = PIN_nRESET;
195191
#else
196-
// FET drive logic
192+
/* FET drive logic (for special board like as blueninja)
193+
* This setting treats nRESET line as positive logic.
194+
* High level indicates that reset signal is asserted.
195+
* Low level indicates that reset signal is deasserted. */
197196
LPC_GPIO->DIR[PIN_nRESET_PORT] |= PIN_nRESET;
198197
LPC_GPIO->CLR[PIN_nRESET_PORT] = PIN_nRESET;
199198
#endif
199+
// SWCLK and TCK are aliases for the same line.
200200
LPC_GPIO->DIR[PIN_SWCLK_PORT] |= PIN_SWCLK;
201+
// SWDIO and TMS are aliases for the same line.
201202
LPC_GPIO->DIR[PIN_SWDIO_PORT] |= PIN_SWDIO;
202203

203204
LPC_GPIO->SET[PIN_TDI_PORT] = PIN_TDI;
@@ -420,8 +421,13 @@ __STATIC_FORCEINLINE void PIN_nTRST_OUT(uint32_t bit)
420421
__STATIC_FORCEINLINE uint32_t PIN_nRESET_IN(void)
421422
{
422423
#if !defined(PIN_nRESET_FET_DRIVE)
424+
// open drain logic
423425
return LPC_GPIO->B[PIN_nRESET_BIT + PIN_nRESET_PORT * 32] & 0x1;
424426
#else
427+
/* FET drive logic (for special board like as blueninja)
428+
* This setting treats nRESET line as positive logic.
429+
* High level indicates that reset signal is asserted.
430+
* Low level indicates that reset signal is deasserted. */
425431
return (LPC_GPIO->B[PIN_nRESET_BIT + PIN_nRESET_PORT * 32] & 0x1) == 1 ? 0 : 1;
426432
#endif
427433
}

0 commit comments

Comments
 (0)