mirror of
https://github.com/micropython/micropython.git
synced 2026-01-06 20:20:14 +01:00
all: Use MP_ERROR_TEXT for all error messages.
This commit is contained in:
committed by
Damien George
parent
85858e72df
commit
def76fe4d9
@@ -200,7 +200,7 @@ STATIC void i2c_set_baudrate(I2C_InitTypeDef *init, uint32_t baudrate) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
mp_raise_msg_varg(&mp_type_ValueError, "Unsupported I2C baudrate: %u", baudrate);
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("Unsupported I2C baudrate: %u"), baudrate);
|
||||
}
|
||||
|
||||
uint32_t pyb_i2c_get_baudrate(I2C_HandleTypeDef *i2c) {
|
||||
@@ -690,13 +690,13 @@ STATIC mp_obj_t pyb_i2c_make_new(const mp_obj_type_t *type, size_t n_args, size_
|
||||
i2c_id = 4;
|
||||
#endif
|
||||
} else {
|
||||
mp_raise_msg_varg(&mp_type_ValueError, "I2C(%s) doesn't exist", port);
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("I2C(%s) doesn't exist"), port);
|
||||
}
|
||||
} else {
|
||||
i2c_id = mp_obj_get_int(args[0]);
|
||||
if (i2c_id < 1 || i2c_id > MP_ARRAY_SIZE(pyb_i2c_obj)
|
||||
|| pyb_i2c_obj[i2c_id - 1].i2c == NULL) {
|
||||
mp_raise_msg_varg(&mp_type_ValueError, "I2C(%d) doesn't exist", i2c_id);
|
||||
mp_raise_msg_varg(&mp_type_ValueError, MP_ERROR_TEXT("I2C(%d) doesn't exist"), i2c_id);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,7 +733,7 @@ STATIC mp_obj_t pyb_i2c_is_ready(mp_obj_t self_in, mp_obj_t i2c_addr_o) {
|
||||
pyb_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
if (!in_master_mode(self)) {
|
||||
mp_raise_TypeError("I2C must be a master");
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("I2C must be a master"));
|
||||
}
|
||||
|
||||
mp_uint_t i2c_addr = mp_obj_get_int(i2c_addr_o) << 1;
|
||||
@@ -756,7 +756,7 @@ STATIC mp_obj_t pyb_i2c_scan(mp_obj_t self_in) {
|
||||
pyb_i2c_obj_t *self = MP_OBJ_TO_PTR(self_in);
|
||||
|
||||
if (!in_master_mode(self)) {
|
||||
mp_raise_TypeError("I2C must be a master");
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("I2C must be a master"));
|
||||
}
|
||||
|
||||
mp_obj_t list = mp_obj_new_list(0, NULL);
|
||||
@@ -814,7 +814,7 @@ STATIC mp_obj_t pyb_i2c_send(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
|
||||
if (use_dma) {
|
||||
dma_deinit(self->tx_dma_descr);
|
||||
}
|
||||
mp_raise_TypeError("addr argument required");
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("addr argument required"));
|
||||
}
|
||||
mp_uint_t i2c_addr = args[1].u_int << 1;
|
||||
if (!use_dma) {
|
||||
@@ -890,7 +890,7 @@ STATIC mp_obj_t pyb_i2c_recv(size_t n_args, const mp_obj_t *pos_args, mp_map_t *
|
||||
HAL_StatusTypeDef status;
|
||||
if (in_master_mode(self)) {
|
||||
if (args[1].u_int == PYB_I2C_MASTER_ADDRESS) {
|
||||
mp_raise_TypeError("addr argument required");
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("addr argument required"));
|
||||
}
|
||||
mp_uint_t i2c_addr = args[1].u_int << 1;
|
||||
if (!use_dma) {
|
||||
@@ -957,7 +957,7 @@ STATIC mp_obj_t pyb_i2c_mem_read(size_t n_args, const mp_obj_t *pos_args, mp_map
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(pyb_i2c_mem_read_allowed_args), pyb_i2c_mem_read_allowed_args, args);
|
||||
|
||||
if (!in_master_mode(self)) {
|
||||
mp_raise_TypeError("I2C must be a master");
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("I2C must be a master"));
|
||||
}
|
||||
|
||||
// get the buffer to read into
|
||||
@@ -1025,7 +1025,7 @@ STATIC mp_obj_t pyb_i2c_mem_write(size_t n_args, const mp_obj_t *pos_args, mp_ma
|
||||
mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args, MP_ARRAY_SIZE(pyb_i2c_mem_read_allowed_args), pyb_i2c_mem_read_allowed_args, args);
|
||||
|
||||
if (!in_master_mode(self)) {
|
||||
mp_raise_TypeError("I2C must be a master");
|
||||
mp_raise_TypeError(MP_ERROR_TEXT("I2C must be a master"));
|
||||
}
|
||||
|
||||
// get the buffer to write from
|
||||
|
||||
Reference in New Issue
Block a user