aboutsummaryrefslogtreecommitdiff
path: root/stmhal
diff options
context:
space:
mode:
authorDamien George2017-06-15 11:54:41 +1000
committerDamien George2017-06-15 11:54:41 +1000
commit48d867b4a68e53901aac87c2ff0f2a7e65f735c7 (patch)
tree178bfc0dc13bcb3b9d77c8a99652e9a9dc057e7d /stmhal
parent1e70fda69fcb4991eb60ed43e610f664ea1319e6 (diff)
all: Make more use of mp_raise_{msg,TypeError,ValueError} helpers.
Diffstat (limited to 'stmhal')
-rw-r--r--stmhal/accel.c2
-rw-r--r--stmhal/can.c4
-rw-r--r--stmhal/dac.c2
-rw-r--r--stmhal/uart.c2
4 files changed, 5 insertions, 5 deletions
diff --git a/stmhal/accel.c b/stmhal/accel.c
index d0d4148ab..0e6eaf03d 100644
--- a/stmhal/accel.c
+++ b/stmhal/accel.c
@@ -90,7 +90,7 @@ STATIC void accel_start(void) {
}
if (status != HAL_OK) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_OSError, "accelerometer not found"));
+ mp_raise_msg(&mp_type_OSError, "accelerometer not found");
}
// set MMA to active mode
diff --git a/stmhal/can.c b/stmhal/can.c
index fe52d8678..afc1b367f 100644
--- a/stmhal/can.c
+++ b/stmhal/can.c
@@ -473,7 +473,7 @@ STATIC mp_obj_t pyb_can_send(mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_
pyb_buf_get_for_send(args[0].u_obj, &bufinfo, data);
if (bufinfo.len > 8) {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN data field too long"));
+ mp_raise_ValueError("CAN data field too long");
}
// send the data
@@ -738,7 +738,7 @@ STATIC mp_obj_t pyb_can_setfilter(mp_uint_t n_args, const mp_obj_t *pos_args, mp
return mp_const_none;
error:
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "CAN filter parameter error"));
+ mp_raise_ValueError("CAN filter parameter error");
}
STATIC MP_DEFINE_CONST_FUN_OBJ_KW(pyb_can_setfilter_obj, 1, pyb_can_setfilter);
diff --git a/stmhal/dac.c b/stmhal/dac.c
index 6524c6840..4ba37b135 100644
--- a/stmhal/dac.c
+++ b/stmhal/dac.c
@@ -189,7 +189,7 @@ STATIC mp_obj_t pyb_dac_init_helper(pyb_dac_obj_t *self, mp_uint_t n_args, const
if (args[0].u_int == 8 || args[0].u_int == 12) {
self->bits = args[0].u_int;
} else {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unsupported bits"));
+ mp_raise_ValueError("unsupported bits");
}
// reset state of DAC
diff --git a/stmhal/uart.c b/stmhal/uart.c
index b24813804..2d67411b1 100644
--- a/stmhal/uart.c
+++ b/stmhal/uart.c
@@ -597,7 +597,7 @@ STATIC mp_obj_t pyb_uart_init_helper(pyb_uart_obj_t *self, mp_uint_t n_args, con
} else if (bits == 9) {
init->WordLength = UART_WORDLENGTH_9B;
} else {
- nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "unsupported combination of bits and parity"));
+ mp_raise_ValueError("unsupported combination of bits and parity");
}
// stop bits