Skip to content

Commit a361c45

Browse files
fabiobaltierikartben
authored andcommitted
drivers: dp: use atomic APIs for pin set/reset
Use LL_GPIO_SetOutputPin and LL_GPIO_ResetOutputPin for the STM32 optimized DP functions. This yelds a speedup of the bit-banged interface from about 585kHz to 640kHz on an STM32C0. Suggested-by: Mathieu Choplain <[email protected]> Signed-off-by: Fabio Baltieri <[email protected]>
1 parent fd44146 commit a361c45

File tree

1 file changed

+2
-16
lines changed

1 file changed

+2
-16
lines changed

drivers/dp/swdp_ll_pin_stm32.h

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -35,29 +35,15 @@ static ALWAYS_INLINE void swdp_ll_pin_output(void *const base, uint8_t pin)
3535
static ALWAYS_INLINE void swdp_ll_pin_set(void *const base, uint8_t pin)
3636
{
3737
GPIO_TypeDef *gpio = base;
38-
uint32_t val;
3938

40-
z_stm32_hsem_lock(CFG_HW_GPIO_SEMID, HSEM_LOCK_DEFAULT_RETRY);
41-
42-
val = LL_GPIO_ReadOutputPort(gpio);
43-
val |= BIT(pin);
44-
LL_GPIO_WriteOutputPort(gpio, val);
45-
46-
z_stm32_hsem_unlock(CFG_HW_GPIO_SEMID);
39+
LL_GPIO_SetOutputPin(gpio, BIT(pin));
4740
}
4841

4942
static ALWAYS_INLINE void swdp_ll_pin_clr(void *const base, uint8_t pin)
5043
{
5144
GPIO_TypeDef *gpio = base;
52-
uint32_t val;
5345

54-
z_stm32_hsem_lock(CFG_HW_GPIO_SEMID, HSEM_LOCK_DEFAULT_RETRY);
55-
56-
val = LL_GPIO_ReadOutputPort(gpio);
57-
val &= ~BIT(pin);
58-
LL_GPIO_WriteOutputPort(gpio, val);
59-
60-
z_stm32_hsem_unlock(CFG_HW_GPIO_SEMID);
46+
LL_GPIO_ResetOutputPin(gpio, BIT(pin));
6147
}
6248

6349
static ALWAYS_INLINE uint32_t swdp_ll_pin_get(void *const base, uint8_t pin)

0 commit comments

Comments
 (0)