33
33
#include "py/runtime.h"
34
34
#include "extmod/machine_i2c.h"
35
35
36
+ #include "supervisor/shared/translate.h"
37
+
36
38
#if MICROPY_PY_MACHINE_I2C
37
39
38
40
typedef 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
294
296
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 );
295
297
return MICROPY_PY_MACHINE_I2C_MAKE_NEW (type , n_args , n_kw , args );
296
298
#else
297
- mp_raise_ValueError ("invalid I2C peripheral" );
299
+ mp_raise_ValueError (translate ( "invalid I2C peripheral" ) );
298
300
#endif
299
301
}
300
302
-- n_args ;
@@ -335,7 +337,7 @@ STATIC mp_obj_t machine_i2c_start(mp_obj_t self_in) {
335
337
mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (self_in );
336
338
mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
337
339
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" ) );
339
341
}
340
342
int ret = i2c_p -> start (self );
341
343
if (ret != 0 ) {
@@ -349,7 +351,7 @@ STATIC mp_obj_t machine_i2c_stop(mp_obj_t self_in) {
349
351
mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (self_in );
350
352
mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
351
353
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" ) );
353
355
}
354
356
int ret = i2c_p -> stop (self );
355
357
if (ret != 0 ) {
@@ -363,7 +365,7 @@ STATIC mp_obj_t machine_i2c_readinto(size_t n_args, const mp_obj_t *args) {
363
365
mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (args [0 ]);
364
366
mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
365
367
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" ) );
367
369
}
368
370
369
371
// 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) {
387
389
mp_obj_base_t * self = (mp_obj_base_t * )MP_OBJ_TO_PTR (self_in );
388
390
mp_machine_i2c_p_t * i2c_p = (mp_machine_i2c_p_t * )self -> type -> protocol ;
389
391
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" ) );
391
393
}
392
394
393
395
// get the buffer to write from
0 commit comments