Skip to content

Commit

Permalink
[rfc] lpc4322: swd using sgpio
Browse files Browse the repository at this point in the history
Signed-off-by: Adrian Negreanu <[email protected]>
  • Loading branch information
Adrian Negreanu committed Dec 7, 2021
1 parent 43e7e42 commit 3456a59
Show file tree
Hide file tree
Showing 4 changed files with 1,133 additions and 0 deletions.
1 change: 1 addition & 0 deletions records/hic_hal/lpc4322.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ common:
- INTERNAL_FLASH
- DAPLINK_HIC_ID=0x97969905 # DAPLINK_HIC_ID_LPC4322
- OS_CLOCK=120000000
- SWDP_SGPIO
includes:
- source/hic_hal/nxp/lpc4322
- source/hic_hal/nxp/lpc4322/RTE_Driver
Expand Down
16 changes: 16 additions & 0 deletions source/hic_hal/nxp/lpc4322/DAP_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,11 +300,13 @@ __STATIC_FORCEINLINE uint32_t PIN_SWDIO_IN(void)
*/
__STATIC_FORCEINLINE void PIN_SWDIO_OUT(uint32_t bit)
{
#ifndef SWDP_SGPIO
if (bit & 0x1) {
X_SET(SWDIO);
} else {
X_CLR(SWDIO);
}
#endif
}

/** SWDIO I/O pin: Switch to Output mode (used in SWD mode only).
Expand All @@ -313,8 +315,10 @@ called prior \ref PIN_SWDIO_OUT function calls.
*/
__STATIC_FORCEINLINE void PIN_SWDIO_OUT_ENABLE(void)
{
#ifndef SWDP_SGPIO
X_SET(SWDIO_TXE);
X_DIR_OUT(SWDIO);
#endif
}

/** SWDIO I/O pin: Switch to Input mode (used in SWD mode only).
Expand All @@ -323,8 +327,10 @@ called prior \ref PIN_SWDIO_IN function calls.
*/
__STATIC_FORCEINLINE void PIN_SWDIO_OUT_DISABLE(void)
{
#ifndef SWDP_SGPIO
X_DIR_IN(SWDIO);
X_CLR(SWDIO_TXE);
#endif
}


Expand Down Expand Up @@ -506,11 +512,21 @@ __STATIC_INLINE void DAP_SETUP(void)

while (!(LPC_CCU1->CLK_M4_GPIO_STAT & CCU_CLK_STAT_RUN));

#ifdef SWDP_SGPIO
/* Table 186. Pin multiplexing. */
/* SWCLK/TCK: PIN(P1_17) FUNC6(SGPIO11). TCK_SWCLK. Table 189. */
scu_pinmux(1, 17, CLK_OUT, FUNC6);
/* SWDIO/TMS: PIN(P1_6) FUNC6(SGPIO14). TMS_SWDIO. Table 188. */
scu_pinmux(1, 6, INBUF_ENABLE | PUP_DISABLE | SLEWRATE_FAST, FUNC6);
/* SWDIO/TXEN: PIN(P1_5) FUNC6(SGPIO15). TMS_SWDIO_TXEN. */
scu_pinmux(1, 5, PUP_DISABLE | SLEWRATE_FAST, FUNC6);
#else
/* Configure I/O pins: function number, input buffer enabled, */
/* no pull-up/down */
scu_pinmux(1, 17, GPIO_NOPULL, FUNC0); /* SWCLK/TCK: GPIO0[12] */
scu_pinmux(1, 6, GPIO_NOPULL, FUNC0); /* SWDIO/TMS: GPIO1[9] */
scu_pinmux(1, 5, GPIO_NOPULL, FUNC0); /* SWDIO_OE: GPIO1[8] */
#endif
}

/** Reset Target Device with custom specific I/O pin or command sequence.
Expand Down
5 changes: 5 additions & 0 deletions source/hic_hal/nxp/lpc4322/gpio.c
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,11 @@ void gpio_init(void)
X_DIR_IN(SWO);
#endif

#ifdef SWDP_SGPIO
extern void sgpio_init(void);
sgpio_init();
#endif

busy_wait(10000);
}

Expand Down
Loading

0 comments on commit 3456a59

Please sign in to comment.