diff options
Diffstat (limited to 'stm')
| -rw-r--r-- | stm/adc.c | 8 | ||||
| -rw-r--r-- | stm/file.c | 2 | ||||
| -rw-r--r-- | stm/i2c.c | 2 | ||||
| -rw-r--r-- | stm/led.c | 2 | ||||
| -rw-r--r-- | stm/main.c | 19 | ||||
| -rw-r--r-- | stm/sdcard.c | 2 | ||||
| -rw-r--r-- | stm/servo.c | 2 | ||||
| -rw-r--r-- | stm/usart.c | 2 | ||||
| -rw-r--r-- | stm/usb.c | 3 |
9 files changed, 20 insertions, 22 deletions
@@ -332,7 +332,7 @@ static const mp_method_t adc_all_methods[] = { }; static const mp_obj_type_t adc_all_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_ADC, .print = adc_all_print, .methods = adc_all_methods, @@ -386,7 +386,7 @@ static const mp_method_t adc_methods[] = { }; static const mp_obj_type_t adc_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_ADC, .print = adc_print, .methods = adc_methods, @@ -427,7 +427,7 @@ mp_obj_t pyb_ADC(mp_obj_t pin_name_obj) { } if (i == ADC_NUM_CHANNELS) { - nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_ValueError, "pin %s does not have ADC capabilities", pin_name)); + nlr_jump(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "pin %s does not have ADC capabilities", pin_name)); } // init ADC just for this channel @@ -438,7 +438,7 @@ mp_obj_t pyb_ADC(mp_obj_t pin_name_obj) { return o; pin_error: - nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_ValueError, "pin %s does not exist", pin_name)); + nlr_jump(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "pin %s does not exist", pin_name)); } MP_DEFINE_CONST_FUN_OBJ_1(pyb_ADC_obj, pyb_ADC); diff --git a/stm/file.c b/stm/file.c index f50d3771a..283159a69 100644 --- a/stm/file.c +++ b/stm/file.c @@ -60,7 +60,7 @@ static const mp_method_t file_methods[] = { }; static const mp_obj_type_t file_obj_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_File, .print = file_obj_print, .methods = file_methods, @@ -335,7 +335,7 @@ static const mp_method_t i2c_methods[] = { }; static const mp_obj_type_t i2c_obj_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_I2C, .print = i2c_obj_print, .methods = i2c_methods, @@ -148,7 +148,7 @@ static const mp_method_t led_methods[] = { }; static const mp_obj_type_t led_obj_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_Led, .print = led_obj_print, .methods = led_methods, diff --git a/stm/main.c b/stm/main.c index 3484fd28d..2bf7c1ba3 100644 --- a/stm/main.c +++ b/stm/main.c @@ -24,6 +24,7 @@ #include "lexerfatfs.h" #include "parse.h" #include "obj.h" +#include "parsehelper.h" #include "compile.h" #include "runtime0.h" #include "runtime.h" @@ -404,15 +405,13 @@ void do_repl(void) { } mp_lexer_t *lex = mp_lexer_new_from_str_len(MP_QSTR__lt_stdin_gt_, vstr_str(&line), vstr_len(&line), 0); - qstr parse_exc_id; - const char *parse_exc_msg; - mp_parse_node_t pn = mp_parse(lex, MP_PARSE_SINGLE_INPUT, &parse_exc_id, &parse_exc_msg); + mp_parse_error_kind_t parse_error_kind; + mp_parse_node_t pn = mp_parse(lex, MP_PARSE_SINGLE_INPUT, &parse_error_kind); qstr source_name = mp_lexer_source_name(lex); if (pn == MP_PARSE_NODE_NULL) { // parse error - mp_lexer_show_error_pythonic_prefix(lex); - printf("%s: %s\n", qstr_str(parse_exc_id), parse_exc_msg); + mp_parse_show_exception(lex, parse_error_kind); mp_lexer_free(lex); } else { // parse okay @@ -456,15 +455,13 @@ bool do_file(const char *filename) { return false; } - qstr parse_exc_id; - const char *parse_exc_msg; - mp_parse_node_t pn = mp_parse(lex, MP_PARSE_FILE_INPUT, &parse_exc_id, &parse_exc_msg); + mp_parse_error_kind_t parse_error_kind; + mp_parse_node_t pn = mp_parse(lex, MP_PARSE_FILE_INPUT, &parse_error_kind); qstr source_name = mp_lexer_source_name(lex); if (pn == MP_PARSE_NODE_NULL) { // parse error - mp_lexer_show_error_pythonic_prefix(lex); - printf("%s: %s\n", qstr_str(parse_exc_id), parse_exc_msg); + mp_parse_show_exception(lex, parse_error_kind); mp_lexer_free(lex); return false; } @@ -536,7 +533,7 @@ mp_obj_t pyb_gpio(uint n_args, mp_obj_t *args) { } pin_error: - nlr_jump(mp_obj_new_exception_msg_varg(MP_QSTR_ValueError, "pin %s does not exist", pin_name)); + nlr_jump(mp_obj_new_exception_msg_varg(&mp_type_ValueError, "pin %s does not exist", pin_name)); } MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(pyb_gpio_obj, 1, 2, pyb_gpio); diff --git a/stm/sdcard.c b/stm/sdcard.c index c98bab4d9..0b5fdb2c8 100644 --- a/stm/sdcard.c +++ b/stm/sdcard.c @@ -202,7 +202,7 @@ static const mp_method_t sdcard_methods[] = { }; static const mp_obj_type_t sdcard_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_SDcard, .methods = sdcard_methods, }; diff --git a/stm/servo.c b/stm/servo.c index 4b69eefcf..4943a6442 100644 --- a/stm/servo.c +++ b/stm/servo.c @@ -144,7 +144,7 @@ static const mp_method_t servo_methods[] = { }; static const mp_obj_type_t servo_obj_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_Servo, .print = servo_obj_print, .methods = servo_methods, diff --git a/stm/usart.c b/stm/usart.c index e24211a83..6478f0115 100644 --- a/stm/usart.c +++ b/stm/usart.c @@ -242,7 +242,7 @@ static const mp_method_t usart_methods[] = { }; static const mp_obj_type_t usart_obj_type = { - { &mp_const_type }, + { &mp_type_type }, .name = MP_QSTR_Usart, .print = usart_obj_print, .methods = usart_methods, @@ -41,7 +41,7 @@ void pyb_usb_dev_init(void) { dev_is_enabled = 1; // create an exception object for interrupting by VCP - mp_const_vcp_interrupt = mp_obj_new_exception(qstr_from_str("VCPInterrupt")); + mp_const_vcp_interrupt = mp_obj_new_exception_msg(&mp_type_OSError, "VCPInterrupt"); #endif } @@ -66,6 +66,7 @@ void usb_vcp_receive(const char *buf, uint32_t len) { // catch special interrupt character if (buf[i] == interrupt_char) { // raise exception when interrupts are finished + mp_obj_exception_clear_traceback(mp_const_vcp_interrupt); pendsv_nlr_jump(mp_const_vcp_interrupt); interrupt_char = VCP_CHAR_NONE; continue; |
