Skip to content

Commit 78c5193

Browse files
authored
Merge pull request ARMmbed#544 from kkitayam/support_jtag
Add JTAG support into LPC11U35
2 parents 1c8d620 + c083829 commit 78c5193

File tree

1 file changed

+42
-5
lines changed

1 file changed

+42
-5
lines changed

source/hic_hal/nxp/lpc11u35/DAP_config.h

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +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
45+
#define DAP_JTAG 1
4646
#endif
4747

4848
/// Processor Clock of the Cortex-M MCU used in the Debug Unit.
@@ -59,14 +59,14 @@ Provides definitions about:
5959

6060
/// Indicate that Serial Wire Debug (SWD) communication mode is available at the Debug Access Port.
6161
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
62+
#ifndef DAP_SWD
6263
#define DAP_SWD 1 ///< SWD Mode: 1 = available, 0 = not available
64+
#endif
6365

6466
/// Indicate that JTAG communication mode is available at the Debug Port.
6567
/// This information is returned by the command \ref DAP_Info as part of <b>Capabilities</b>.
66-
#if defined(CONF_JTAG)
67-
#define DAP_JTAG 1 ///< JTAG Mode: 1 = available
68-
#else
69-
#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
7070
#endif
7171

7272
/// Configure maximum number of JTAG devices on the scan chain connected to the Debug Access Port.
@@ -75,7 +75,13 @@ Provides definitions about:
7575

7676
/// Default communication mode on the Debug Access Port.
7777
/// Used for the command \ref DAP_Connect when Port Default mode is selected.
78+
#if (DAP_SWD == 1)
7879
#define DAP_DEFAULT_PORT 1 ///< Default JTAG/SWJ Port Mode: 1 = SWD, 2 = JTAG.
80+
#elif (DAP_JTAG == 1)
81+
#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
84+
#endif
7985

8086
/// Default communication speed on the Debug Access Port for SWD and JTAG mode.
8187
/// Used to initialize the default SWD/JTAG clock frequency.
@@ -173,6 +179,28 @@ Configures the DAP Hardware I/O pins for JTAG mode:
173179
__STATIC_INLINE void PORT_JTAG_SETUP(void)
174180
{
175181
#if (DAP_JTAG != 0)
182+
LPC_GPIO->SET[PIN_SWCLK_PORT] = PIN_SWCLK;
183+
LPC_GPIO->SET[PIN_SWDIO_PORT] = PIN_SWDIO;
184+
#if !defined(PIN_nRESET_FET_DRIVE)
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. */
189+
LPC_GPIO->DIR[PIN_nRESET_PORT] &= ~PIN_nRESET;
190+
LPC_GPIO->CLR[PIN_nRESET_PORT] = PIN_nRESET;
191+
#else
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. */
196+
LPC_GPIO->DIR[PIN_nRESET_PORT] |= PIN_nRESET;
197+
LPC_GPIO->CLR[PIN_nRESET_PORT] = PIN_nRESET;
198+
#endif
199+
// SWCLK and TCK are aliases for the same line.
200+
LPC_GPIO->DIR[PIN_SWCLK_PORT] |= PIN_SWCLK;
201+
// SWDIO and TMS are aliases for the same line.
202+
LPC_GPIO->DIR[PIN_SWDIO_PORT] |= PIN_SWDIO;
203+
176204
LPC_GPIO->SET[PIN_TDI_PORT] = PIN_TDI;
177205
LPC_GPIO->DIR[PIN_TDI_PORT] |= PIN_TDI;
178206
LPC_GPIO->DIR[PIN_TDO_PORT] &= ~PIN_TDO;
@@ -392,7 +420,16 @@ __STATIC_FORCEINLINE void PIN_nTRST_OUT(uint32_t bit)
392420
*/
393421
__STATIC_FORCEINLINE uint32_t PIN_nRESET_IN(void)
394422
{
423+
#if !defined(PIN_nRESET_FET_DRIVE)
424+
// open drain logic
395425
return LPC_GPIO->B[PIN_nRESET_BIT + PIN_nRESET_PORT * 32] & 0x1;
426+
#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. */
431+
return (LPC_GPIO->B[PIN_nRESET_BIT + PIN_nRESET_PORT * 32] & 0x1) == 1 ? 0 : 1;
432+
#endif
396433
}
397434

398435
/** nRESET I/O pin: Set Output.

0 commit comments

Comments
 (0)