stmhal/mphalport.h: use single GPIOx->BSRR register

This commit is contained in:
Krzysztof Blazewicz 2016-11-14 16:59:18 +01:00
parent 13400e1375
commit 4d9dce7759

View File

@ -57,13 +57,8 @@ static inline mp_uint_t mp_hal_ticks_cpu(void) {
#define mp_hal_pin_input(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_INPUT, MP_HAL_PIN_PULL_NONE, 0)
#define mp_hal_pin_output(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_OUTPUT, MP_HAL_PIN_PULL_NONE, 0)
#define mp_hal_pin_open_drain(p) mp_hal_pin_config((p), MP_HAL_PIN_MODE_OPEN_DRAIN, MP_HAL_PIN_PULL_NONE, 0)
#if defined(MCU_SERIES_F7) || defined(MCU_SERIES_L4)
#define mp_hal_pin_high(p) (((p)->gpio->BSRR) = (p)->pin_mask)
#define mp_hal_pin_low(p) (((p)->gpio->BSRR) = ((p)->pin_mask << 16))
#else
#define mp_hal_pin_high(p) (((p)->gpio->BSRRL) = (p)->pin_mask)
#define mp_hal_pin_low(p) (((p)->gpio->BSRRH) = (p)->pin_mask)
#endif
#define mp_hal_pin_od_low(p) mp_hal_pin_low(p)
#define mp_hal_pin_od_high(p) mp_hal_pin_high(p)
#define mp_hal_pin_read(p) (((p)->gpio->IDR >> (p)->pin) & 1)