summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGlenn Ruben Bakke <glennbakke@gmail.com>2017-08-15 23:37:14 +0200
committerglennrub <glennbakke@gmail.com>2017-10-04 20:49:49 +0200
commit4468731e3d039a3f72ac25aa43e936cf5ebb3f78 (patch)
tree166def27c9cf4b9bce0ea53cd776d5dcd7dcd2f3
parent795116b432826496043a5a4f68f391b1706ba664 (diff)
nrf: Aligning with upstream the use of nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, ...)
-rw-r--r--nrf/modules/machine/pin.c2
-rw-r--r--nrf/modules/music/modmusic.c8
-rw-r--r--nrf/modules/uos/moduos.c2
3 files changed, 6 insertions, 6 deletions
diff --git a/nrf/modules/machine/pin.c b/nrf/modules/machine/pin.c
index 126ec02d3..62160d785 100644
--- a/nrf/modules/machine/pin.c
+++ b/nrf/modules/machine/pin.c
@@ -125,7 +125,7 @@ const pin_obj_t *pin_find(mp_obj_t user_obj) {
pin_obj = mp_call_function_1(MP_STATE_PORT(pin_class_mapper), user_obj);
if (pin_obj != mp_const_none) {
if (!MP_OBJ_IS_TYPE(pin_obj, &pin_type)) {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Pin.mapper didn't return a Pin object"));
+ mp_raise_ValueError("Pin.mapper didn't return a Pin object");
}
if (pin_class_debug) {
printf("Pin.mapper maps ");
diff --git a/nrf/modules/music/modmusic.c b/nrf/modules/music/modmusic.c
index 13efc18bf..c2afc341c 100644
--- a/nrf/modules/music/modmusic.c
+++ b/nrf/modules/music/modmusic.c
@@ -287,7 +287,7 @@ STATIC mp_obj_t microbit_music_stop(mp_uint_t n_args, const mp_obj_t *args) {
#ifdef MICROPY_HW_MUSIC_PIN
pin = &MICROPY_HW_MUSIC_PIN;
#else
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given"));
+ mp_raise_ValueError("pin parameter not given");
#endif
} else {
pin = (pin_obj_t *)args[0];
@@ -340,7 +340,7 @@ STATIC mp_obj_t microbit_music_play(mp_uint_t n_args, const mp_obj_t *pos_args,
#ifdef MICROPY_HW_MUSIC_PIN
pin = &MICROPY_HW_MUSIC_PIN;
#else
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given"));
+ mp_raise_ValueError("pin parameter not given");
#endif
} else {
pin = (pin_obj_t *)args[1].u_obj;
@@ -395,7 +395,7 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args,
#ifdef MICROPY_HW_MUSIC_PIN
pin = &MICROPY_HW_MUSIC_PIN;
#else
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "pin parameter not given"));
+ mp_raise_ValueError("pin parameter not given");
#endif
} else {
pin = (pin_obj_t *)args[2].u_obj;
@@ -411,7 +411,7 @@ STATIC mp_obj_t microbit_music_pitch(mp_uint_t n_args, const mp_obj_t *pos_args,
//TODO: pwm_release(pin->name);
} else if (pwm_set_period_us(1000000/frequency)) {
pwm_release(pin->pin); // TODO: remove pin setting.
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "invalid pitch"));
+ mp_raise_ValueError("invalid pitch");
}
if (duration >= 0) {
// use async machinery to stop the pitch after the duration
diff --git a/nrf/modules/uos/moduos.c b/nrf/modules/uos/moduos.c
index 50ca9a90e..84671bc59 100644
--- a/nrf/modules/uos/moduos.c
+++ b/nrf/modules/uos/moduos.c
@@ -121,7 +121,7 @@ STATIC mp_obj_t os_dupterm(mp_uint_t n_args, const mp_obj_t *args) {
} else if (mp_obj_get_type(args[0]) == &machine_hard_uart_type) {
MP_STATE_PORT(pyb_stdio_uart) = args[0];
} else {
- nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "need a UART object"));
+ mp_raise_ValueError("need a UART object");
}
return mp_const_none;
}