mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-01-17 05:32:45 +01:00
cpu/gd32v: Allow configuration of SWJ_CFG
Expose the compile time configuration knob `CONFIG_AFIO_PCF0_SWJ_CFG` to allow freeing some/all JTAG pins and use them as GPIOs. As default, PB4 is remapped from NJTRST to be usable as regular GPIO. This still allows using the JTAG interface for debugging/flashing, but makes an GPIO exposed by some boards available.
This commit is contained in:
parent
3b5ed6d390
commit
8b1c43afb0
@ -33,6 +33,15 @@ void cpu_init(void)
|
|||||||
periph_clk_en(APB1, RCU_APB1EN_PMUEN_Msk);
|
periph_clk_en(APB1, RCU_APB1EN_PMUEN_Msk);
|
||||||
/* Common RISC-V initialization */
|
/* Common RISC-V initialization */
|
||||||
riscv_init();
|
riscv_init();
|
||||||
|
|
||||||
|
/* Apply configured SWJ_CFG, unless it is configured to the reset value */
|
||||||
|
if (CONFIG_AFIO_PCF0_SWJ_CFG != SWJ_CFG_FULL_JTAG) {
|
||||||
|
/* The remapping periph clock must first be enabled */
|
||||||
|
RCU->APB2EN |= RCU_APB2EN_AFEN_Msk;
|
||||||
|
/* Then the remap can occur */
|
||||||
|
AFIO->PCF0 |= CONFIG_AFIO_PCF0_SWJ_CFG;
|
||||||
|
}
|
||||||
|
|
||||||
early_init();
|
early_init();
|
||||||
periph_init();
|
periph_init();
|
||||||
}
|
}
|
||||||
|
@ -46,6 +46,34 @@ extern "C" {
|
|||||||
#define CPU_FLASH_BASE 0x08000000
|
#define CPU_FLASH_BASE 0x08000000
|
||||||
/** @} */
|
/** @} */
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Possible values of the `SWJ_CFG` field in the AFIO->PCF0 register
|
||||||
|
*/
|
||||||
|
typedef enum {
|
||||||
|
/**
|
||||||
|
* @brief Full JTAG interface (reset value)
|
||||||
|
*/
|
||||||
|
SWJ_CFG_FULL_JTAG = 0,
|
||||||
|
/**
|
||||||
|
* @brief JTAG enabled, but NJTRST disabled and pin PB4 usable as GPIO
|
||||||
|
*/
|
||||||
|
SWJ_CFG_NO_NJTRST = 1U << AFIO_PCF0_SWJ_CFG_Pos,
|
||||||
|
/**
|
||||||
|
* @brief JTAG disabled, all debug pins usable as GPIOs
|
||||||
|
*/
|
||||||
|
SWJ_CFG_NO_JTAG = 4U << AFIO_PCF0_SWJ_CFG_Pos,
|
||||||
|
} afio_pcf0_swj_cfg_t;
|
||||||
|
|
||||||
|
#ifndef CONFIG_AFIO_PCF0_SWJ_CFG
|
||||||
|
/**
|
||||||
|
* @brief By default, enable JTAG but disable NJTRST
|
||||||
|
*
|
||||||
|
* This default makes PB4 usable as GPIO while still being able to debug and
|
||||||
|
* flash via JTAG.
|
||||||
|
*/
|
||||||
|
#define CONFIG_AFIO_PCF0_SWJ_CFG SWJ_CFG_NO_NJTRST
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user