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 <damien@micropython.org>
pull/8215/head
Damien George 2022-01-27 16:36:08 +11:00
rodzic 30b6ce86be
commit 79a3158de6
3 zmienionych plików z 13 dodań i 13 usunięć

Wyświetl plik

@ -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
-------

Wyświetl plik

@ -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.

Wyświetl plik

@ -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);
}