3333#include "py/runtime.h"
3434#include "extmod/machine_i2c.h"
3535
36+ #include "supervisor/shared/translate.h"
37+
3638#if MICROPY_PY_MACHINE_I2C
3739
3840typedef mp_machine_soft_i2c_obj_t machine_i2c_obj_t ;
@@ -294,7 +296,7 @@ STATIC mp_obj_t machine_i2c_make_new(const mp_obj_type_t *type, size_t n_args, s
294296 extern mp_obj_t MICROPY_PY_MACHINE_I2C_MAKE_NEW (const mp_obj_type_t * type , size_t n_args , size_t n_kw , const mp_obj_t * all_args );
295297 return MICROPY_PY_MACHINE_I2C_MAKE_NEW (type , n_args , n_kw , args );
296298 #else
297- mp_raise_ValueError ("invalid I2C peripheral" );
299+ mp_raise_ValueError (translate ( "invalid I2C peripheral" ) );
298300 #endif
299301 }
300302 -- n_args ;
@@ -335,7 +337,7 @@ STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
335337 mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (self_in );
336338 mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
337339 if (i2c_p -> start == NULL ) {
338- mp_raise_msg (& mp_type_OSError , "I2C operation not supported" );
340+ mp_raise_msg (& mp_type_OSError , translate ( "I2C operation not supported" ) );
339341 }
340342 int ret = i2c_p -> start (self );
341343 if (ret != 0 ) {
@@ -349,7 +351,7 @@ STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
349351 mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (self_in );
350352 mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
351353 if (i2c_p -> stop == NULL ) {
352- mp_raise_msg (& mp_type_OSError , "I2C operation not supported" );
354+ mp_raise_msg (& mp_type_OSError , translate ( "I2C operation not supported" ) );
353355 }
354356 int ret = i2c_p -> stop (self );
355357 if (ret != 0 ) {
@@ -363,7 +365,7 @@ STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
363365 mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (args [0 ]);
364366 mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
365367 if (i2c_p -> read == NULL ) {
366- mp_raise_msg (& mp_type_OSError , "I2C operation not supported" );
368+ mp_raise_msg (& mp_type_OSError , translate ( "I2C operation not supported" ) );
367369 }
368370
369371 // get the buffer to read into
@@ -387,7 +389,7 @@ STATIC mp_obj_t machine_i2c_write(mp_obj_t self_in, mp_obj_t buf_in) {
387389 mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (self_in );
388390 mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
389391 if (i2c_p -> write == NULL ) {
390- mp_raise_msg (& mp_type_OSError , "I2C operation not supported" );
392+ mp_raise_msg (& mp_type_OSError , translate ( "I2C operation not supported" ) );
391393 }
392394
393395 // get the buffer to write from
0 commit comments