Skip to content

Commit eeaacd4

Browse files
committed
extmod/modexperimental: use MP_ERROR_TEXT
Forgot to do this for the new exceptions. Also remove unnecessary HAL_I2C_IsDeviceReady
1 parent af67a2a commit eeaacd4

File tree

1 file changed

+5
-10
lines changed

1 file changed

+5
-10
lines changed

extmod/modexperimental.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -68,22 +68,17 @@ STATIC mp_obj_t mod_experimental_IMU_make_new(const mp_obj_type_t *otype, size_t
6868
HAL_StatusTypeDef ret = HAL_I2C_Init(&hi2c);
6969
if (ret != HAL_OK) {
7070
hi2c.Instance = NULL;
71-
mp_raise_msg(&mp_type_RuntimeError, "failed to init I2C");
71+
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("failed to init I2C"));
7272
}
7373
}
7474

75-
HAL_StatusTypeDef ret = HAL_I2C_IsDeviceReady(&hi2c, LSM6DS3TR_C_I2C_ADD_L, 10, 200);
76-
if (ret != HAL_OK) {
77-
mp_raise_msg(&mp_type_RuntimeError, "device is not ready");
78-
}
79-
8075
uint8_t id;
8176
if (lsm6ds3tr_c_device_id_get(&self->ctx, &id) != 0) {
82-
mp_raise_msg(&mp_type_RuntimeError, "failed to get device id");
77+
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("failed to get device id"));
8378
}
8479

8580
if (id != LSM6DS3TR_C_ID) {
86-
mp_raise_msg(&mp_type_RuntimeError, "incorrect device id");
81+
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("incorrect device id"));
8782
}
8883

8984
// Init based on data polling example
@@ -138,7 +133,7 @@ STATIC mp_obj_t mod_experimental_IMU_accel(mp_obj_t self_in) {
138133
int16_t data[3];
139134

140135
if (lsm6ds3tr_c_acceleration_raw_get(&self->ctx, (uint8_t *)data) != 0) {
141-
mp_raise_msg(&mp_type_RuntimeError, "failed to read data");
136+
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("failed to read data"));
142137
}
143138

144139
mp_obj_t values[3];
@@ -155,7 +150,7 @@ STATIC mp_obj_t mod_experimental_IMU_gyro(mp_obj_t self_in) {
155150
int16_t data[3];
156151

157152
if (lsm6ds3tr_c_angular_rate_raw_get(&self->ctx, (uint8_t *)data) != 0) {
158-
mp_raise_msg(&mp_type_RuntimeError, "failed to read data");
153+
mp_raise_msg(&mp_type_RuntimeError, MP_ERROR_TEXT("failed to read data"));
159154
}
160155

161156
mp_obj_t values[3];

0 commit comments

Comments
 (0)