diff --git a/stmhal/accel.c b/stmhal/accel.c index 434a92a008..34e9d8e0e1 100644 --- a/stmhal/accel.c +++ b/stmhal/accel.c @@ -89,15 +89,17 @@ STATIC void accel_start(void) { HAL_StatusTypeDef status; - //printf("IsDeviceReady\n"); for (int i = 0; i < 10; i++) { status = HAL_I2C_IsDeviceReady(&I2CHandle1, MMA_ADDR, 10, 200); - //printf(" got %d\n", status); if (status == HAL_OK) { break; } } + if (status != HAL_OK) { + nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "accelerometer not found")); + } + // set MMA to active mode uint8_t data[1] = {1}; // active mode status = HAL_I2C_Mem_Write(&I2CHandle1, MMA_ADDR, MMA_REG_MODE, I2C_MEMADD_SIZE_8BIT, data, 1, 200);