@@ -280,6 +280,8 @@ static mp_obj_t pin_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_
280
280
}
281
281
}
282
282
283
+ #if MICROPY_PY_MACHINE_PIN_LEGACY
284
+
283
285
/// \classmethod mapper([fun])
284
286
/// Get or set the pin mapper function.
285
287
static mp_obj_t pin_mapper (size_t n_args , const mp_obj_t * args ) {
@@ -304,20 +306,6 @@ static mp_obj_t pin_map_dict(size_t n_args, const mp_obj_t *args) {
304
306
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (pin_map_dict_fun_obj , 1 , 2 , pin_map_dict ) ;
305
307
static MP_DEFINE_CONST_CLASSMETHOD_OBJ (pin_map_dict_obj , MP_ROM_PTR (& pin_map_dict_fun_obj )) ;
306
308
307
- /// \classmethod af_list()
308
- /// Returns an array of alternate functions available for this pin.
309
- static mp_obj_t pin_af_list (mp_obj_t self_in ) {
310
- machine_pin_obj_t * self = MP_OBJ_TO_PTR (self_in );
311
- mp_obj_t result = mp_obj_new_list (0 , NULL );
312
-
313
- const pin_af_obj_t * af = self -> af ;
314
- for (mp_uint_t i = 0 ; i < self -> num_af ; i ++ , af ++ ) {
315
- mp_obj_list_append (result , MP_OBJ_FROM_PTR (af ));
316
- }
317
- return result ;
318
- }
319
- static MP_DEFINE_CONST_FUN_OBJ_1 (pin_af_list_obj , pin_af_list ) ;
320
-
321
309
/// \classmethod debug([state])
322
310
/// Get or set the debugging state (`True` or `False` for on or off).
323
311
static mp_obj_t pin_debug (size_t n_args , const mp_obj_t * args ) {
@@ -330,6 +318,8 @@ static mp_obj_t pin_debug(size_t n_args, const mp_obj_t *args) {
330
318
static MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (pin_debug_fun_obj , 1 , 2 , pin_debug ) ;
331
319
static MP_DEFINE_CONST_CLASSMETHOD_OBJ (pin_debug_obj , MP_ROM_PTR (& pin_debug_fun_obj )) ;
332
320
321
+ #endif // MICROPY_PY_MACHINE_PIN_LEGACY
322
+
333
323
// init(mode, pull=None, alt=-1, *, value, alt)
334
324
static mp_obj_t pin_obj_init_helper (const machine_pin_obj_t * self , size_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
335
325
static const mp_arg_t allowed_args [] = {
@@ -442,6 +432,8 @@ static mp_obj_t pin_irq(size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_ar
442
432
}
443
433
static MP_DEFINE_CONST_FUN_OBJ_KW (pin_irq_obj , 1 , pin_irq ) ;
444
434
435
+ #if MICROPY_PY_MACHINE_PIN_LEGACY
436
+
445
437
/// \method name()
446
438
/// Get the pin name.
447
439
static mp_obj_t pin_name (mp_obj_t self_in ) {
@@ -469,6 +461,20 @@ static mp_obj_t pin_names(mp_obj_t self_in) {
469
461
}
470
462
static MP_DEFINE_CONST_FUN_OBJ_1 (pin_names_obj , pin_names ) ;
471
463
464
+ /// \classmethod af_list()
465
+ /// Returns an array of alternate functions available for this pin.
466
+ static mp_obj_t pin_af_list (mp_obj_t self_in ) {
467
+ machine_pin_obj_t * self = MP_OBJ_TO_PTR (self_in );
468
+ mp_obj_t result = mp_obj_new_list (0 , NULL );
469
+
470
+ const pin_af_obj_t * af = self -> af ;
471
+ for (mp_uint_t i = 0 ; i < self -> num_af ; i ++ , af ++ ) {
472
+ mp_obj_list_append (result , MP_OBJ_FROM_PTR (af ));
473
+ }
474
+ return result ;
475
+ }
476
+ static MP_DEFINE_CONST_FUN_OBJ_1 (pin_af_list_obj , pin_af_list ) ;
477
+
472
478
/// \method port()
473
479
/// Get the pin port.
474
480
static mp_obj_t pin_port (mp_obj_t self_in ) {
@@ -520,6 +526,8 @@ static mp_obj_t pin_af(mp_obj_t self_in) {
520
526
}
521
527
static MP_DEFINE_CONST_FUN_OBJ_1 (pin_af_obj , pin_af ) ;
522
528
529
+ #endif // MICROPY_PY_MACHINE_PIN_LEGACY
530
+
523
531
static const mp_rom_map_elem_t pin_locals_dict_table [] = {
524
532
// instance methods
525
533
{ MP_ROM_QSTR (MP_QSTR_init ), MP_ROM_PTR (& pin_init_obj ) },
@@ -531,6 +539,7 @@ static const mp_rom_map_elem_t pin_locals_dict_table[] = {
531
539
// Legacy names as used by pyb.Pin
532
540
{ MP_ROM_QSTR (MP_QSTR_low ), MP_ROM_PTR (& pin_off_obj ) },
533
541
{ MP_ROM_QSTR (MP_QSTR_high ), MP_ROM_PTR (& pin_on_obj ) },
542
+ #if MICROPY_PY_MACHINE_PIN_LEGACY
534
543
{ MP_ROM_QSTR (MP_QSTR_name ), MP_ROM_PTR (& pin_name_obj ) },
535
544
{ MP_ROM_QSTR (MP_QSTR_names ), MP_ROM_PTR (& pin_names_obj ) },
536
545
{ MP_ROM_QSTR (MP_QSTR_af_list ), MP_ROM_PTR (& pin_af_list_obj ) },
@@ -540,11 +549,14 @@ static const mp_rom_map_elem_t pin_locals_dict_table[] = {
540
549
{ MP_ROM_QSTR (MP_QSTR_mode ), MP_ROM_PTR (& pin_mode_obj ) },
541
550
{ MP_ROM_QSTR (MP_QSTR_pull ), MP_ROM_PTR (& pin_pull_obj ) },
542
551
{ MP_ROM_QSTR (MP_QSTR_af ), MP_ROM_PTR (& pin_af_obj ) },
552
+ #endif
543
553
554
+ #if MICROPY_PY_MACHINE_PIN_LEGACY
544
555
// class methods
545
556
{ MP_ROM_QSTR (MP_QSTR_mapper ), MP_ROM_PTR (& pin_mapper_obj ) },
546
557
{ MP_ROM_QSTR (MP_QSTR_dict ), MP_ROM_PTR (& pin_map_dict_obj ) },
547
558
{ MP_ROM_QSTR (MP_QSTR_debug ), MP_ROM_PTR (& pin_debug_obj ) },
559
+ #endif
548
560
549
561
// class attributes
550
562
{ MP_ROM_QSTR (MP_QSTR_board ), MP_ROM_PTR (& pin_board_pins_obj_type ) },
@@ -562,12 +574,14 @@ static const mp_rom_map_elem_t pin_locals_dict_table[] = {
562
574
{ MP_ROM_QSTR (MP_QSTR_IRQ_RISING ), MP_ROM_INT (GPIO_MODE_IT_RISING ) },
563
575
{ MP_ROM_QSTR (MP_QSTR_IRQ_FALLING ), MP_ROM_INT (GPIO_MODE_IT_FALLING ) },
564
576
577
+ #if MICROPY_PY_MACHINE_PIN_LEGACY
565
578
// legacy class constants
566
579
{ MP_ROM_QSTR (MP_QSTR_OUT_PP ), MP_ROM_INT (GPIO_MODE_OUTPUT_PP ) },
567
580
{ MP_ROM_QSTR (MP_QSTR_OUT_OD ), MP_ROM_INT (GPIO_MODE_OUTPUT_OD ) },
568
581
{ MP_ROM_QSTR (MP_QSTR_AF_PP ), MP_ROM_INT (GPIO_MODE_AF_PP ) },
569
582
{ MP_ROM_QSTR (MP_QSTR_AF_OD ), MP_ROM_INT (GPIO_MODE_AF_OD ) },
570
583
{ MP_ROM_QSTR (MP_QSTR_PULL_NONE ), MP_ROM_INT (GPIO_NOPULL ) },
584
+ #endif
571
585
572
586
#include "genhdr/pins_af_const.h"
573
587
};
0 commit comments