Skip to content

Commit 4b67463

Browse files
committed
stmhal: Fix documentation; remove ability to specify af by str.
1 parent 5b7c0c4 commit 4b67463

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

stmhal/pin.c

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ STATIC mp_obj_t pin_map_dict(uint n_args, mp_obj_t *args) {
273273
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pin_map_dict_fun_obj, 1, 2, pin_map_dict);
274274
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(pin_map_dict_obj, (mp_obj_t)&pin_map_dict_fun_obj);
275275

276-
/// |classmethod af_list()
276+
/// \classmethod af_list()
277277
/// Returns an array of alternate functions available for this pin.
278278
STATIC mp_obj_t pin_af_list(mp_obj_t self_in) {
279279
pin_obj_t *self = self_in;
@@ -299,7 +299,7 @@ STATIC mp_obj_t pin_debug(uint n_args, mp_obj_t *args) {
299299
STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pin_debug_fun_obj, 1, 2, pin_debug);
300300
STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(pin_debug_obj, (mp_obj_t)&pin_debug_fun_obj);
301301

302-
/// \method init(mode, pull=Pin.PULL_NONE, af)
302+
/// \method init(mode, pull=Pin.PULL_NONE, af=None)
303303
/// Initialise the pin:
304304
///
305305
/// - `mode` can be one of:
@@ -320,7 +320,7 @@ STATIC MP_DEFINE_CONST_CLASSMETHOD_OBJ(pin_debug_obj, (mp_obj_t)&pin_debug_fun_o
320320
STATIC const mp_arg_t pin_init_args[] = {
321321
{ MP_QSTR_mode, MP_ARG_REQUIRED | MP_ARG_INT },
322322
{ MP_QSTR_pull, MP_ARG_INT, {.u_int = GPIO_NOPULL}},
323-
{ MP_QSTR_af, MP_ARG_KW_ONLY | MP_ARG_OBJ, {.u_obj = mp_const_none}},
323+
{ MP_QSTR_af, MP_ARG_OBJ, {.u_obj = mp_const_none}},
324324
};
325325
#define PIN_INIT_NUM_ARGS MP_ARRAY_SIZE(pin_init_args)
326326

@@ -345,17 +345,7 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp
345345
mp_int_t af_idx = -1;
346346
mp_obj_t af_obj = vals[2].u_obj;
347347
if (af_obj != mp_const_none) {
348-
if (MP_OBJ_IS_STR(af_obj)) {
349-
const pin_af_obj_t *af;
350-
const char *af_str = mp_obj_str_get_str(af_obj);
351-
af = pin_find_af_by_name(self, af_str);
352-
if (af == NULL) {
353-
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid pin af: %s", af_str));
354-
}
355-
af_idx = af->idx;
356-
} else {
357-
af_idx = mp_obj_get_int(af_obj);
358-
}
348+
af_idx = mp_obj_get_int(af_obj);
359349
}
360350
if ((mode == GPIO_MODE_AF_PP || mode == GPIO_MODE_AF_OD) && !IS_GPIO_AF(af_idx)) {
361351
nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "invalid pin af: %d", af_idx));
@@ -406,6 +396,7 @@ STATIC mp_obj_t pin_obj_init_helper(const pin_obj_t *self, uint n_args, const mp
406396

407397
return mp_const_none;
408398
}
399+
409400
STATIC mp_obj_t pin_obj_init(uint n_args, const mp_obj_t *args, mp_map_t *kw_args) {
410401
return pin_obj_init_helper(args[0], n_args - 1, args + 1, kw_args);
411402
}
@@ -542,6 +533,7 @@ STATIC const mp_map_elem_t pin_locals_dict_table[] = {
542533
{ MP_OBJ_NEW_QSTR(MP_QSTR_PULL_NONE), MP_OBJ_NEW_SMALL_INT(GPIO_NOPULL) },
543534
{ MP_OBJ_NEW_QSTR(MP_QSTR_PULL_UP), MP_OBJ_NEW_SMALL_INT(GPIO_PULLUP) },
544535
{ MP_OBJ_NEW_QSTR(MP_QSTR_PULL_DOWN), MP_OBJ_NEW_SMALL_INT(GPIO_PULLDOWN) },
536+
545537
#include "genhdr/pins-af-const.h"
546538
};
547539

0 commit comments

Comments
 (0)