@@ -318,7 +318,7 @@ STATIC mp_obj_t pyb_i2c_init_helper(pyb_i2c_obj_t *self, mp_arg_val_t *args) {
318318}
319319
320320STATIC const mp_arg_t pyb_i2c_init_args [] = {
321- { MP_QSTR_id , MP_ARG_OBJ , {.u_obj = mp_const_none } },
321+ { MP_QSTR_id , MP_ARG_INT , {.u_int = 0 } },
322322 { MP_QSTR_mode , MP_ARG_INT , {.u_int = PYBI2C_MASTER } },
323323 { MP_QSTR_baudrate , MP_ARG_KW_ONLY | MP_ARG_INT , {.u_int = 100000 } },
324324 { MP_QSTR_pins , MP_ARG_KW_ONLY | MP_ARG_OBJ , {.u_obj = MP_OBJ_NULL } },
@@ -330,17 +330,8 @@ STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n
330330 mp_arg_val_t args [MP_ARRAY_SIZE (pyb_i2c_init_args )];
331331 mp_arg_parse_all (n_args , all_args , & kw_args , MP_ARRAY_SIZE (args ), pyb_i2c_init_args , args );
332332
333- // work out the i2c id
334- uint i2c_id ;
335- if (args [0 ].u_obj == mp_const_none ) {
336- // default id
337- i2c_id = 0 ;
338- } else {
339- i2c_id = mp_obj_get_int (args [0 ].u_obj );
340- }
341-
342333 // check the peripheral id
343- if (i2c_id != 0 ) {
334+ if (args [ 0 ]. u_int != 0 ) {
344335 nlr_raise (mp_obj_new_exception_msg (& mp_type_OSError , mpexception_os_resource_not_avaliable ));
345336 }
346337
@@ -362,7 +353,6 @@ STATIC mp_obj_t pyb_i2c_init(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
362353}
363354STATIC MP_DEFINE_CONST_FUN_OBJ_KW (pyb_i2c_init_obj , 1 , pyb_i2c_init );
364355
365- /// \method deinit()
366356STATIC mp_obj_t pyb_i2c_deinit (mp_obj_t self_in ) {
367357 // disable the peripheral
368358 MAP_I2CMasterDisable (I2CA0_BASE );
@@ -375,7 +365,6 @@ STATIC mp_obj_t pyb_i2c_deinit(mp_obj_t self_in) {
375365}
376366STATIC MP_DEFINE_CONST_FUN_OBJ_1 (pyb_i2c_deinit_obj , pyb_i2c_deinit );
377367
378- /// \method scan()
379368STATIC mp_obj_t pyb_i2c_scan (mp_obj_t self_in ) {
380369 pyb_i2c_check_init (& pyb_i2c_obj );
381370 mp_obj_t list = mp_obj_new_list (0 , NULL );
@@ -399,7 +388,7 @@ STATIC mp_obj_t pyb_i2c_readfrom(mp_uint_t n_args, const mp_obj_t *pos_args, mp_
399388
400389 // parse args
401390 mp_arg_val_t args [MP_ARRAY_SIZE (pyb_i2c_readfrom_args )];
402- mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (pyb_i2c_readfrom_args ), pyb_i2c_readfrom_args , args );
391+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (args ), pyb_i2c_readfrom_args , args );
403392
404393 vstr_t vstr ;
405394 pyb_i2c_read_into (args , & vstr );
@@ -417,7 +406,7 @@ STATIC mp_obj_t pyb_i2c_readfrom_into(mp_uint_t n_args, const mp_obj_t *pos_args
417406
418407 // parse args
419408 mp_arg_val_t args [MP_ARRAY_SIZE (pyb_i2c_readfrom_into_args )];
420- mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (pyb_i2c_readfrom_into_args ), pyb_i2c_readfrom_into_args , args );
409+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (args ), pyb_i2c_readfrom_into_args , args );
421410
422411 vstr_t vstr ;
423412 pyb_i2c_read_into (args , & vstr );
@@ -436,7 +425,7 @@ STATIC mp_obj_t pyb_i2c_writeto(mp_uint_t n_args, const mp_obj_t *pos_args, mp_m
436425
437426 // parse args
438427 mp_arg_val_t args [MP_ARRAY_SIZE (pyb_i2c_writeto_args )];
439- mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (pyb_i2c_writeto_args ), pyb_i2c_writeto_args , args );
428+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (args ), pyb_i2c_writeto_args , args );
440429
441430 pyb_i2c_check_init (& pyb_i2c_obj );
442431
@@ -465,7 +454,7 @@ STATIC mp_obj_t pyb_i2c_readfrom_mem(mp_uint_t n_args, const mp_obj_t *pos_args,
465454
466455 // parse args
467456 mp_arg_val_t args [MP_ARRAY_SIZE (pyb_i2c_readfrom_mem_args )];
468- mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (pyb_i2c_readfrom_mem_args ), pyb_i2c_readfrom_mem_args , args );
457+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (args ), pyb_i2c_readfrom_mem_args , args );
469458
470459 vstr_t vstr ;
471460 pyb_i2c_readmem_into (args , & vstr );
@@ -483,7 +472,7 @@ STATIC const mp_arg_t pyb_i2c_readfrom_mem_into_args[] = {
483472STATIC mp_obj_t pyb_i2c_readfrom_mem_into (mp_uint_t n_args , const mp_obj_t * pos_args , mp_map_t * kw_args ) {
484473 // parse args
485474 mp_arg_val_t args [MP_ARRAY_SIZE (pyb_i2c_readfrom_mem_into_args )];
486- mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (pyb_i2c_readfrom_mem_into_args ), pyb_i2c_readfrom_mem_into_args , args );
475+ mp_arg_parse_all (n_args - 1 , pos_args + 1 , kw_args , MP_ARRAY_SIZE (args ), pyb_i2c_readfrom_mem_into_args , args );
487476
488477 // get the buffer to read into
489478 vstr_t vstr ;
0 commit comments