Skip to content

Commit 6042786

Browse files
committed
stmhal: Move I2C objects to ROM.
1 parent 8f19317 commit 6042786

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

stmhal/i2c.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ typedef struct _pyb_i2c_obj_t {
7575
I2C_HandleTypeDef *i2c_handle;
7676
} pyb_i2c_obj_t;
7777

78-
STATIC pyb_i2c_obj_t pyb_i2c_obj[PYB_NUM_I2C] = {{{&pyb_i2c_type}, &I2cHandle_X}, {{&pyb_i2c_type}, &I2cHandle_Y}};
78+
STATIC const pyb_i2c_obj_t pyb_i2c_obj[PYB_NUM_I2C] = {{{&pyb_i2c_type}, &I2cHandle_X}, {{&pyb_i2c_type}, &I2cHandle_Y}};
7979

8080
STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const mp_obj_t *args) {
8181
// check arguments
@@ -90,12 +90,12 @@ STATIC mp_obj_t pyb_i2c_make_new(mp_obj_t type_in, uint n_args, uint n_kw, const
9090
}
9191

9292
// get i2c object
93-
pyb_i2c_obj_t *i2c_obj = &pyb_i2c_obj[i2c_id];
93+
const pyb_i2c_obj_t *i2c_obj = &pyb_i2c_obj[i2c_id];
9494

9595
// start the peripheral
9696
i2c_start(i2c_obj->i2c_handle);
9797

98-
return &pyb_i2c_obj;
98+
return (mp_obj_t)i2c_obj;
9999
}
100100

101101
STATIC mp_obj_t pyb_i2c_is_ready(mp_obj_t self_in, mp_obj_t i2c_addr_o) {

0 commit comments

Comments
 (0)