Skip to content

Commit 9bde197

Browse files
pi-anldpgeorge
authored andcommitted
rp2: Add exception text wrappers.
Required in MICROPY_PREVIEW_VERSION_2. Signed-off-by: Andrew Leech <[email protected]>
1 parent b6dbc47 commit 9bde197

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

ports/rp2/machine_pin.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -193,7 +193,7 @@ const machine_pin_obj_t *machine_pin_find(mp_obj_t pin) {
193193
return &machine_pin_obj_table[wanted_pin];
194194
}
195195
}
196-
mp_raise_ValueError("invalid pin");
196+
mp_raise_ValueError(MP_ERROR_TEXT("invalid pin"));
197197
}
198198

199199
static void machine_pin_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
@@ -259,11 +259,11 @@ static mp_obj_t machine_pin_obj_init_helper(const machine_pin_obj_t *self, size_
259259
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
260260

261261
if (is_ext_pin(self) && args[ARG_pull].u_obj != mp_const_none) {
262-
mp_raise_ValueError("pulls are not supported for external pins");
262+
mp_raise_ValueError(MP_ERROR_TEXT("pulls are not supported for external pins"));
263263
}
264264

265265
if (is_ext_pin(self) && args[ARG_alt].u_int != GPIO_FUNC_SIO) {
266-
mp_raise_ValueError("alternate functions are not supported for external pins");
266+
mp_raise_ValueError(MP_ERROR_TEXT("alternate functions are not supported for external pins"));
267267
}
268268

269269
// get initial value of pin (only valid for OUT and OPEN_DRAIN modes)

ports/rp2/machine_pin_cyw43.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ void machine_pin_ext_config(machine_pin_obj_t *self, int mode, int value) {
7070
self->is_output = true;
7171
}
7272
} else {
73-
mp_raise_ValueError("only Pin.OUT and Pin.IN are supported for this pin");
73+
mp_raise_ValueError(MP_ERROR_TEXT("only Pin.OUT and Pin.IN are supported for this pin"));
7474
}
7575

7676
if (value != -1) {

ports/rp2/rp2_pio.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ void rp2_pio_irq_set_exclusive_handler(PIO pio, uint irq) {
126126
irq_handler_t current = irq_get_exclusive_handler(irq);
127127
// If the IRQ is set and isn't our handler, or a shared handler is set, then raise an error
128128
if ((current && current != rp2_pio_get_irq_handler(pio)) || irq_has_shared_handler(irq)) {
129-
mp_raise_ValueError("irq claimed by external resource");
129+
mp_raise_ValueError(MP_ERROR_TEXT("irq claimed by external resource"));
130130
// If the IRQ is not set, add our handler
131131
} else if (!current) {
132132
irq_set_exclusive_handler(irq, rp2_pio_get_irq_handler(pio));
@@ -304,7 +304,7 @@ static mp_obj_t rp2_pio_make_new(const mp_obj_type_t *type, size_t n_args, size_
304304
// Get the PIO object.
305305
int pio_id = mp_obj_get_int(args[0]);
306306
if (!(0 <= pio_id && pio_id < MP_ARRAY_SIZE(rp2_pio_obj))) {
307-
mp_raise_ValueError("invalid PIO");
307+
mp_raise_ValueError(MP_ERROR_TEXT("invalid PIO"));
308308
}
309309
const rp2_pio_obj_t *self = &rp2_pio_obj[pio_id];
310310

@@ -353,7 +353,7 @@ static mp_obj_t rp2_pio_remove_program(size_t n_args, const mp_obj_t *args) {
353353
length = bufinfo.len / 2;
354354
offset = mp_obj_get_int(prog[PROG_OFFSET_PIO0 + pio_get_index(self->pio)]);
355355
if (offset < 0) {
356-
mp_raise_ValueError("prog not in instruction memory");
356+
mp_raise_ValueError(MP_ERROR_TEXT("prog not in instruction memory"));
357357
}
358358
// Invalidate the program offset in the program object.
359359
prog[PROG_OFFSET_PIO0 + pio_get_index(self->pio)] = MP_OBJ_NEW_SMALL_INT(-1);
@@ -374,7 +374,7 @@ static mp_obj_t rp2_pio_state_machine(size_t n_args, const mp_obj_t *pos_args, m
374374
// Get and verify the state machine id.
375375
mp_int_t sm_id = mp_obj_get_int(pos_args[1]);
376376
if (!(0 <= sm_id && sm_id < 4)) {
377-
mp_raise_ValueError("invalid StateMachine");
377+
mp_raise_ValueError(MP_ERROR_TEXT("invalid StateMachine"));
378378
}
379379

380380
// Return the correct StateMachine object.
@@ -400,7 +400,7 @@ static mp_obj_t rp2_pio_gpio_base(size_t n_args, const mp_obj_t *args) {
400400

401401
// Must be 0 for GPIOs 0 to 31 inclusive, or 16 for GPIOs 16 to 48 inclusive.
402402
if (!(gpio_base == 0 || gpio_base == 16)) {
403-
mp_raise_ValueError("invalid GPIO base");
403+
mp_raise_ValueError(MP_ERROR_TEXT("invalid GPIO base"));
404404
}
405405

406406
if (pio_set_gpio_base(self->pio, gpio_base) != PICO_OK) {
@@ -556,14 +556,14 @@ static const rp2_state_machine_obj_t rp2_state_machine_obj[] = {
556556

557557
static const rp2_state_machine_obj_t *rp2_state_machine_get_object(mp_int_t sm_id) {
558558
if (!(0 <= sm_id && sm_id < MP_ARRAY_SIZE(rp2_state_machine_obj))) {
559-
mp_raise_ValueError("invalid StateMachine");
559+
mp_raise_ValueError(MP_ERROR_TEXT("invalid StateMachine"));
560560
}
561561

562562
const rp2_state_machine_obj_t *sm_obj = &rp2_state_machine_obj[sm_id];
563563

564564
if (!(rp2_state_machine_claimed_mask & (1 << sm_id))) {
565565
if (pio_sm_is_claimed(sm_obj->pio, sm_obj->sm)) {
566-
mp_raise_ValueError("StateMachine claimed by external resource");
566+
mp_raise_ValueError(MP_ERROR_TEXT("StateMachine claimed by external resource"));
567567
}
568568
pio_sm_claim(sm_obj->pio, sm_obj->sm);
569569
rp2_state_machine_claimed_mask |= 1 << sm_id;
@@ -830,7 +830,7 @@ static mp_obj_t rp2_state_machine_get(size_t n_args, const mp_obj_t *args) {
830830
*(uint32_t *)dest = value;
831831
dest += sizeof(uint32_t);
832832
} else {
833-
mp_raise_ValueError("unsupported buffer type");
833+
mp_raise_ValueError(MP_ERROR_TEXT("unsupported buffer type"));
834834
}
835835
if (dest >= dest_top) {
836836
return args[1];
@@ -868,7 +868,7 @@ static mp_obj_t rp2_state_machine_put(size_t n_args, const mp_obj_t *args) {
868868
value = *(uint32_t *)src;
869869
src += sizeof(uint32_t);
870870
} else {
871-
mp_raise_ValueError("unsupported buffer type");
871+
mp_raise_ValueError(MP_ERROR_TEXT("unsupported buffer type"));
872872
}
873873
while (pio_sm_is_tx_fifo_full(self->pio, self->sm)) {
874874
// This delay must be fast.

0 commit comments

Comments
 (0)