Skip to content

Commit

Permalink
blackpill-f4: fixup! Review edits (bus turnaround)
Browse files Browse the repository at this point in the history
  • Loading branch information
ALTracer committed Dec 28, 2023
1 parent 5fa711e commit ebcc14d
Showing 1 changed file with 12 additions and 22 deletions.
34 changes: 12 additions & 22 deletions src/platforms/common/blackpill-f4/blackpill-f4.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,8 @@
#define SWDIO_PORT TMS_PORT
#define SWDIO_PIN TMS_PIN

#if 0
#define TMS_SET_MODE() gpio_mode_setup(TMS_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, TMS_PIN);
#define SWDIO_MODE_FLOAT() gpio_mode_setup(SWDIO_PORT, GPIO_MODE_INPUT, GPIO_PUPD_NONE, SWDIO_PIN);

#define SWDIO_MODE_DRIVE() gpio_mode_setup(SWDIO_PORT, GPIO_MODE_OUTPUT, GPIO_PUPD_NONE, SWDIO_PIN);

#else

#define SWDIO_MODE_REG_MULT_PB9 (1 << (9 << 1))
#define SWDIO_MODE_REG_MULT_PB8 (1 << (8 << 1))
#define SWDIO_MODE_REG_MULT_PB9 (1 << (9U << 1))
#define SWDIO_MODE_REG_MULT_PB8 (1 << (8U << 1))
/* Update when adding more alternative pinouts */
#define SWDIO_MODE_REG_MULT PINOUT_SWITCH(SWDIO_MODE_REG_MULT_PB9, SWDIO_MODE_REG_MULT_PB8)
#define SWDIO_MODE_REG GPIO_MODER(TMS_PORT)
Expand All @@ -134,22 +126,20 @@
gpio_set_output_options(TMS_PORT, GPIO_OTYPE_PP, GPIO_OSPEED_2MHZ, TMS_PIN);

/* Perform SWDIO bus turnaround faster than a gpio_mode_setup() call */
#define SWDIO_MODE_FLOAT() \
do { \
uint32_t mode_reg = SWDIO_MODE_REG; \
mode_reg &= ~(0x3 * SWDIO_MODE_REG_MULT); \
SWDIO_MODE_REG = mode_reg; \
#define SWDIO_MODE_FLOAT() \
do { \
uint32_t mode_reg = SWDIO_MODE_REG; \
mode_reg &= ~(3U * SWDIO_MODE_REG_MULT); \
SWDIO_MODE_REG = mode_reg; \
} while (0)

#define SWDIO_MODE_DRIVE() \
do { \
uint32_t mode_reg = SWDIO_MODE_REG; \
mode_reg |= (1 * SWDIO_MODE_REG_MULT); \
SWDIO_MODE_REG = mode_reg; \
#define SWDIO_MODE_DRIVE() \
do { \
uint32_t mode_reg = SWDIO_MODE_REG; \
mode_reg |= (1U * SWDIO_MODE_REG_MULT); \
SWDIO_MODE_REG = mode_reg; \
} while (0)

#endif

#define TRST_PORT PINOUT_SWITCH(GPIOA, GPIOB)
#define TRST_PIN PINOUT_SWITCH(GPIO6, GPIO3)

Expand Down

0 comments on commit ebcc14d

Please sign in to comment.