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>
This commit is contained in:
parent
30b6ce86be
commit
79a3158de6
|
@ -237,17 +237,17 @@ pin X3.
|
||||||
For the pyboard, x3_af would contain:
|
For the pyboard, x3_af would contain:
|
||||||
[Pin.AF1_TIM2, Pin.AF2_TIM5, Pin.AF3_TIM9, Pin.AF7_USART2]
|
[Pin.AF1_TIM2, Pin.AF2_TIM5, Pin.AF3_TIM9, Pin.AF7_USART2]
|
||||||
|
|
||||||
Normally, each peripheral would configure the af automatically, but sometimes
|
Normally, each peripheral would configure the alternate function automatically,
|
||||||
the same function is available on multiple pins, and having more control
|
but sometimes the same function is available on multiple pins, and having more
|
||||||
is desired.
|
control is desired.
|
||||||
|
|
||||||
To configure X3 to expose TIM2_CH3, you could use::
|
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::
|
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
|
Methods
|
||||||
-------
|
-------
|
||||||
|
|
|
@ -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);
|
mp_uint_t af_idx = pin_get_af(self);
|
||||||
const pin_af_obj_t *af_obj = pin_find_af_by_index(self, af_idx);
|
const pin_af_obj_t *af_obj = pin_find_af_by_index(self, af_idx);
|
||||||
if (af_obj == NULL) {
|
if (af_obj == NULL) {
|
||||||
mp_printf(print, ", af=%d)", af_idx);
|
mp_printf(print, ", alt=%d)", af_idx);
|
||||||
} else {
|
} else {
|
||||||
mp_printf(print, ", af=Pin.%q)", af_obj->name);
|
mp_printf(print, ", alt=Pin.%q)", af_obj->name);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
mp_print_str(print, ")");
|
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_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));
|
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 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[] = {
|
static const mp_arg_t allowed_args[] = {
|
||||||
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT },
|
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT },
|
||||||
|
@ -625,9 +625,9 @@ const mp_obj_type_t pin_type = {
|
||||||
/// is desired.
|
/// is desired.
|
||||||
///
|
///
|
||||||
/// To configure X3 to expose TIM2_CH3, you could use:
|
/// 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:
|
/// 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__()
|
/// \method __str__()
|
||||||
/// Return a string describing the alternate function.
|
/// Return a string describing the alternate function.
|
||||||
|
|
|
@ -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_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);
|
const pin_af_obj_t *af = pin_find_af(pin, AF_FN_TIM, self->tim_id);
|
||||||
if (af == NULL) {
|
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] = {
|
const mp_obj_t args2[6] = {
|
||||||
MP_OBJ_FROM_PTR(&pin_init_obj),
|
MP_OBJ_FROM_PTR(&pin_init_obj),
|
||||||
pin_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_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);
|
mp_call_method_n_kw(0, 2, args2);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue