@@ -136,10 +136,10 @@ STATIC mp_obj_t pyb_i2c_scan(mp_obj_t self_in) {
136136
137137STATIC MP_DEFINE_CONST_FUN_OBJ_1 (pyb_i2c_scan_obj , pyb_i2c_scan );
138138
139- STATIC mp_obj_t pyb_i2c_read (uint n_args , const mp_obj_t * args ) {
140- pyb_i2c_obj_t * self = args [ 0 ] ;
141- machine_uint_t i2c_addr = mp_obj_get_int (args [ 1 ] ) << 1 ;
142- machine_uint_t n = mp_obj_get_int (args [ 2 ] );
139+ STATIC mp_obj_t pyb_i2c_read (mp_obj_t self_in , mp_obj_t i2c_addr_in , mp_obj_t n_in ) {
140+ pyb_i2c_obj_t * self = self_in ;
141+ machine_uint_t i2c_addr = mp_obj_get_int (i2c_addr_in ) << 1 ;
142+ machine_uint_t n = mp_obj_get_int (n_in );
143143
144144 byte * data ;
145145 mp_obj_t o = mp_obj_str_builder_start (& mp_type_bytes , n , & data );
@@ -153,18 +153,18 @@ STATIC mp_obj_t pyb_i2c_read(uint n_args, const mp_obj_t *args) {
153153 return mp_obj_str_builder_end (o );
154154}
155155
156- STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (pyb_i2c_read_obj , 3 , 3 , pyb_i2c_read );
156+ STATIC MP_DEFINE_CONST_FUN_OBJ_3 (pyb_i2c_read_obj , pyb_i2c_read );
157157
158- STATIC mp_obj_t pyb_i2c_write (uint n_args , const mp_obj_t * args ) {
159- pyb_i2c_obj_t * self = args [ 0 ] ;
160- machine_uint_t i2c_addr = mp_obj_get_int (args [ 1 ] ) << 1 ;
158+ STATIC mp_obj_t pyb_i2c_write (mp_obj_t self_in , mp_obj_t i2c_addr_in , mp_obj_t data_in ) {
159+ pyb_i2c_obj_t * self = self_in ;
160+ machine_uint_t i2c_addr = mp_obj_get_int (i2c_addr_in ) << 1 ;
161161 HAL_StatusTypeDef status ;
162- if (MP_OBJ_IS_INT (args [ 2 ] )) {
163- uint8_t data [1 ] = {mp_obj_get_int (args [ 2 ] )};
162+ if (MP_OBJ_IS_INT (data_in )) {
163+ uint8_t data [1 ] = {mp_obj_get_int (data_in )};
164164 status = HAL_I2C_Master_Transmit (self -> i2c_handle , i2c_addr , data , 1 , 500 );
165165 } else {
166166 buffer_info_t bufinfo ;
167- mp_get_buffer_raise (args [ 2 ] , & bufinfo );
167+ mp_get_buffer_raise (data_in , & bufinfo );
168168 status = HAL_I2C_Master_Transmit (self -> i2c_handle , i2c_addr , bufinfo .buf , bufinfo .len , 500 );
169169 }
170170
@@ -176,7 +176,7 @@ STATIC mp_obj_t pyb_i2c_write(uint n_args, const mp_obj_t *args) {
176176 return mp_const_none ;
177177}
178178
179- STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN (pyb_i2c_write_obj , 3 , 3 , pyb_i2c_write );
179+ STATIC MP_DEFINE_CONST_FUN_OBJ_3 (pyb_i2c_write_obj , pyb_i2c_write );
180180
181181STATIC mp_obj_t pyb_i2c_mem_read (uint n_args , const mp_obj_t * args ) {
182182 pyb_i2c_obj_t * self = args [0 ];
0 commit comments