From 79a3158de6dbd0b8f628fbf8cd5ffdeeea37bb6e Mon Sep 17 00:00:00 2001 From: Damien George Date: Thu, 27 Jan 2022 16:36:08 +1100 Subject: [PATCH] stm32/pin: Change remaining uses of "af" to "alt". The keyword "af" has been deprecated for some time and "alt" should be used instead (but "af" still works). Signed-off-by: Damien George --- docs/library/pyb.Pin.rst | 10 +++++----- ports/stm32/pin.c | 10 +++++----- ports/stm32/timer.c | 6 +++--- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/library/pyb.Pin.rst b/docs/library/pyb.Pin.rst index 97dfbffbcf..23ede48ed3 100644 --- a/docs/library/pyb.Pin.rst +++ b/docs/library/pyb.Pin.rst @@ -237,17 +237,17 @@ pin X3. For the pyboard, x3_af would contain: [Pin.AF1_TIM2, Pin.AF2_TIM5, Pin.AF3_TIM9, Pin.AF7_USART2] -Normally, each peripheral would configure the af automatically, but sometimes -the same function is available on multiple pins, and having more control -is desired. +Normally, each peripheral would configure the alternate function automatically, +but sometimes the same function is available on multiple pins, and having more +control is desired. To configure X3 to expose TIM2_CH3, you could use:: - pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, af=pyb.Pin.AF1_TIM2) + pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, alt=pyb.Pin.AF1_TIM2) or:: - pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, af=1) + pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, alt=1) Methods ------- diff --git a/ports/stm32/pin.c b/ports/stm32/pin.c index ad153311e3..b490a09b7f 100644 --- a/ports/stm32/pin.c +++ b/ports/stm32/pin.c @@ -230,9 +230,9 @@ STATIC void pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t mp_uint_t af_idx = pin_get_af(self); const pin_af_obj_t *af_obj = pin_find_af_by_index(self, af_idx); if (af_obj == NULL) { - mp_printf(print, ", af=%d)", af_idx); + mp_printf(print, ", alt=%d)", af_idx); } else { - mp_printf(print, ", af=Pin.%q)", af_obj->name); + mp_printf(print, ", alt=Pin.%q)", af_obj->name); } } else { mp_print_str(print, ")"); @@ -328,7 +328,7 @@ STATIC mp_obj_t pin_debug(size_t n_args, const mp_obj_t *args) { STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pin_debug_fun_obj, 1, 2, pin_debug); STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(pin_debug_obj, MP_ROM_PTR(&pin_debug_fun_obj)); -// init(mode, pull=None, af=-1, *, value, alt) +// init(mode, pull=None, alt=-1, *, value, alt) STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) { static const mp_arg_t allowed_args[] = { { MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT }, @@ -625,9 +625,9 @@ const mp_obj_type_t pin_type = { /// is desired. /// /// To configure X3 to expose TIM2_CH3, you could use: -/// pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, af=pyb.Pin.AF1_TIM2) +/// pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, alt=pyb.Pin.AF1_TIM2) /// or: -/// pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, af=1) +/// pin = pyb.Pin(pyb.Pin.board.X3, mode=pyb.Pin.AF_PP, alt=1) /// \method __str__() /// Return a string describing the alternate function. diff --git a/ports/stm32/timer.c b/ports/stm32/timer.c index c23e7e02d4..5a968ec56d 100644 --- a/ports/stm32/timer.c +++ b/ports/stm32/timer.c @@ -1110,14 +1110,14 @@ STATIC mp_obj_t pyb_timer_channel(size_t n_args, const mp_obj_t *pos_args, mp_ma const pin_obj_t *pin = MP_OBJ_TO_PTR(pin_obj); const pin_af_obj_t *af = pin_find_af(pin, AF_FN_TIM, self->tim_id); if (af == NULL) { - mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Pin(%q) doesn't have an af for Timer(%d)"), pin->name, self->tim_id); + mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Pin(%q) doesn't have an alt for Timer(%d)"), pin->name, self->tim_id); } - // pin.init(mode=AF_PP, af=idx) + // pin.init(mode=AF_PP, alt=idx) const mp_obj_t args2[6] = { MP_OBJ_FROM_PTR(&pin_init_obj), pin_obj, MP_OBJ_NEW_QSTR(MP_QSTR_mode), MP_OBJ_NEW_SMALL_INT(GPIO_MODE_AF_PP), - MP_OBJ_NEW_QSTR(MP_QSTR_af), MP_OBJ_NEW_SMALL_INT(af->idx) + MP_OBJ_NEW_QSTR(MP_QSTR_alt), MP_OBJ_NEW_SMALL_INT(af->idx) }; mp_call_method_n_kw(0, 2, args2); }