Made jtagtap.c and swdptap.c STM32 generic.
This commit is contained in:
parent
8d190cdbb9
commit
acff8d4497
|
@ -28,15 +28,7 @@
|
||||||
|
|
||||||
int jtagtap_init(void)
|
int jtagtap_init(void)
|
||||||
{
|
{
|
||||||
/* This needs some fixing... */
|
gpio_set_mode(TMS_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||||
/* Toggle required to sort out line drivers... */
|
|
||||||
gpio_port_write(GPIOA, 0x8100);
|
|
||||||
gpio_port_write(GPIOB, 0x2000);
|
|
||||||
|
|
||||||
gpio_port_write(GPIOA, 0x8180);
|
|
||||||
gpio_port_write(GPIOB, 0x2002);
|
|
||||||
|
|
||||||
gpio_set_mode(JTAG_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
GPIO_CNF_OUTPUT_PUSHPULL, TMS_PIN);
|
||||||
|
|
||||||
/* Go to JTAG mode for SWJ-DP */
|
/* Go to JTAG mode for SWJ-DP */
|
||||||
|
@ -50,33 +42,33 @@ int jtagtap_init(void)
|
||||||
void jtagtap_reset(void)
|
void jtagtap_reset(void)
|
||||||
{
|
{
|
||||||
volatile int i;
|
volatile int i;
|
||||||
gpio_clear(GPIOB, GPIO1);
|
gpio_clear(TRST_PORT, TRST_PIN);
|
||||||
for(i = 0; i < 10000; i++) asm("nop");
|
for(i = 0; i < 10000; i++) asm("nop");
|
||||||
gpio_set(GPIOB, GPIO1);
|
gpio_set(TRST_PORT, TRST_PIN);
|
||||||
jtagtap_soft_reset();
|
jtagtap_soft_reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
void jtagtap_srst(void)
|
void jtagtap_srst(void)
|
||||||
{
|
{
|
||||||
volatile int i;
|
volatile int i;
|
||||||
gpio_set(GPIOA, GPIO2);
|
gpio_set(SRST_PORT, SRST_PIN);
|
||||||
for(i = 0; i < 10000; i++) asm("nop");
|
for(i = 0; i < 10000; i++) asm("nop");
|
||||||
gpio_clear(GPIOA, GPIO2);
|
gpio_clear(SRST_PORT, SRST_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline uint8_t jtagtap_next(uint8_t dTMS, uint8_t dTDO)
|
inline uint8_t jtagtap_next(uint8_t dTMS, uint8_t dTDO)
|
||||||
{
|
{
|
||||||
uint8_t ret;
|
uint16_t ret;
|
||||||
|
|
||||||
gpio_set_val(JTAG_PORT, TMS_PIN, dTMS);
|
gpio_set_val(TMS_PORT, TMS_PIN, dTMS);
|
||||||
gpio_set_val(JTAG_PORT, TDI_PIN, dTDO);
|
gpio_set_val(TDI_PORT, TDI_PIN, dTDO);
|
||||||
gpio_set(JTAG_PORT, TCK_PIN);
|
gpio_set(TCK_PORT, TCK_PIN);
|
||||||
ret = gpio_get(JTAG_PORT, TDO_PIN);
|
ret = gpio_get(TDO_PORT, TDO_PIN);
|
||||||
gpio_clear(JTAG_PORT, TCK_PIN);
|
gpio_clear(TCK_PORT, TCK_PIN);
|
||||||
|
|
||||||
DEBUG("jtagtap_next(TMS = %d, TDO = %d) = %d\n", dTMS, dTDO, ret);
|
DEBUG("jtagtap_next(TMS = %d, TDO = %d) = %d\n", dTMS, dTDO, ret);
|
||||||
|
|
||||||
return ret;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -84,6 +84,14 @@ int platform_init(void)
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL,
|
GPIO_CNF_OUTPUT_PUSHPULL,
|
||||||
TMS_PIN | TCK_PIN | TDI_PIN);
|
TMS_PIN | TCK_PIN | TDI_PIN);
|
||||||
|
|
||||||
|
/* This needs some fixing... */
|
||||||
|
/* Toggle required to sort out line drivers... */
|
||||||
|
gpio_port_write(GPIOA, 0x8100);
|
||||||
|
gpio_port_write(GPIOB, 0x2000);
|
||||||
|
|
||||||
|
gpio_port_write(GPIOA, 0x8180);
|
||||||
|
gpio_port_write(GPIOB, 0x2002);
|
||||||
|
|
||||||
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
|
gpio_set_mode(LED_PORT, GPIO_MODE_OUTPUT_2_MHZ,
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL,
|
GPIO_CNF_OUTPUT_PUSHPULL,
|
||||||
LED_UART | LED_IDLE_RUN | LED_ERROR);
|
LED_UART | LED_IDLE_RUN | LED_ERROR);
|
||||||
|
|
|
@ -58,15 +58,25 @@
|
||||||
|
|
||||||
/* Hardware definitions... */
|
/* Hardware definitions... */
|
||||||
#define JTAG_PORT GPIOA
|
#define JTAG_PORT GPIOA
|
||||||
|
#define TDI_PORT JTAG_PORT
|
||||||
|
#define TMS_PORT JTAG_PORT
|
||||||
|
#define TCK_PORT JTAG_PORT
|
||||||
|
#define TDO_PORT JTAG_PORT
|
||||||
#define TDI_PIN GPIO3
|
#define TDI_PIN GPIO3
|
||||||
#define TMS_PIN GPIO4
|
#define TMS_PIN GPIO4
|
||||||
#define TCK_PIN GPIO5
|
#define TCK_PIN GPIO5
|
||||||
#define TDO_PIN GPIO6
|
#define TDO_PIN GPIO6
|
||||||
|
|
||||||
#define SWDP_PORT JTAG_PORT
|
#define SWDIO_PORT JTAG_PORT
|
||||||
|
#define SWCLK_PORT JTAG_PORT
|
||||||
#define SWDIO_PIN TMS_PIN
|
#define SWDIO_PIN TMS_PIN
|
||||||
#define SWCLK_PIN TCK_PIN
|
#define SWCLK_PIN TCK_PIN
|
||||||
|
|
||||||
|
#define TRST_PORT GPIOB
|
||||||
|
#define TRST_PIN GPIO1
|
||||||
|
#define SRST_PORT GPIOA
|
||||||
|
#define SRST_PIN GPIO2
|
||||||
|
|
||||||
#define USB_PU_PORT GPIOA
|
#define USB_PU_PORT GPIOA
|
||||||
#define USB_PU_PIN GPIO8
|
#define USB_PU_PIN GPIO8
|
||||||
|
|
||||||
|
|
|
@ -39,35 +39,35 @@ static void swdptap_turnaround(uint8_t dir)
|
||||||
olddir = dir;
|
olddir = dir;
|
||||||
|
|
||||||
if(dir)
|
if(dir)
|
||||||
gpio_set_mode(SWDP_PORT, GPIO_MODE_INPUT,
|
gpio_set_mode(SWDIO_PORT, GPIO_MODE_INPUT,
|
||||||
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
GPIO_CNF_INPUT_FLOAT, SWDIO_PIN);
|
||||||
gpio_set(SWDP_PORT, SWCLK_PIN);
|
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||||
gpio_clear(SWDP_PORT, SWCLK_PIN);
|
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||||
if(!dir)
|
if(!dir)
|
||||||
gpio_set_mode(SWDP_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
gpio_set_mode(SWDIO_PORT, GPIO_MODE_OUTPUT_50_MHZ,
|
||||||
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
GPIO_CNF_OUTPUT_PUSHPULL, SWDIO_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint8_t swdptap_bit_in(void)
|
static uint8_t swdptap_bit_in(void)
|
||||||
{
|
{
|
||||||
uint8_t ret;
|
uint16_t ret;
|
||||||
|
|
||||||
ret = gpio_get(SWDP_PORT, SWDIO_PIN);
|
ret = gpio_get(SWDIO_PORT, SWDIO_PIN);
|
||||||
gpio_set(SWDP_PORT, SWCLK_PIN);
|
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||||
gpio_clear(SWDP_PORT, SWCLK_PIN);
|
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||||
|
|
||||||
DEBUG("%d", ret?1:0);
|
DEBUG("%d", ret?1:0);
|
||||||
|
|
||||||
return ret;
|
return ret != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void swdptap_bit_out(uint8_t val)
|
static void swdptap_bit_out(uint8_t val)
|
||||||
{
|
{
|
||||||
DEBUG("%d", val);
|
DEBUG("%d", val);
|
||||||
|
|
||||||
gpio_set_val(SWDP_PORT, SWDIO_PIN, val);
|
gpio_set_val(SWDIO_PORT, SWDIO_PIN, val);
|
||||||
gpio_set(SWDP_PORT, SWCLK_PIN);
|
gpio_set(SWCLK_PORT, SWCLK_PIN);
|
||||||
gpio_clear(SWDP_PORT, SWCLK_PIN);
|
gpio_clear(SWCLK_PORT, SWCLK_PIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
int swdptap_init(void)
|
int swdptap_init(void)
|
||||||
|
|
Loading…
Reference in New Issue