4646#include "systick.h"
4747#include "readline.h"
4848#include "pyexec.h"
49- #include "usb.h"
50- #include "uart.h"
5149#include "pybstdio.h"
5250#include "genhdr/py-version.h"
5351
@@ -97,9 +95,9 @@ STATIC int parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_ki
9795 nlr_buf_t nlr ;
9896 uint32_t start = HAL_GetTick ();
9997 if (nlr_push (& nlr ) == 0 ) {
100- usb_vcp_set_interrupt_char ( VCP_CHAR_CTRL_C ); // allow ctrl-C to interrupt us
98+ mp_hal_set_interrupt_char ( CHAR_CTRL_C ); // allow ctrl-C to interrupt us
10199 mp_call_function_0 (module_fun );
102- usb_vcp_set_interrupt_char ( VCP_CHAR_NONE ); // disable interrupt
100+ mp_hal_set_interrupt_char ( -1 ); // disable interrupt
103101 nlr_pop ();
104102 ret = 1 ;
105103 if (exec_flags & EXEC_FLAG_PRINT_EOF ) {
@@ -108,7 +106,7 @@ STATIC int parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_ki
108106 } else {
109107 // uncaught exception
110108 // FIXME it could be that an interrupt happens just before we disable it here
111- usb_vcp_set_interrupt_char ( VCP_CHAR_NONE ); // disable interrupt
109+ mp_hal_set_interrupt_char ( -1 ); // disable interrupt
112110 // print EOF after normal output
113111 if (exec_flags & EXEC_FLAG_PRINT_EOF ) {
114112 stdout_tx_strn ("\x04" , 1 );
@@ -125,8 +123,8 @@ STATIC int parse_compile_execute(mp_lexer_t *lex, mp_parse_input_kind_t input_ki
125123
126124 // display debugging info if wanted
127125 if ((exec_flags & EXEC_FLAG_ALLOW_DEBUGGING ) && repl_display_debugging_info ) {
128- uint32_t ticks = HAL_GetTick () - start ; // TODO implement a function that does this properly
129- printf ("took %lu ms\n" , ticks );
126+ mp_uint_t ticks = HAL_GetTick () - start ; // TODO implement a function that does this properly
127+ printf ("took " UINT_FMT " ms\n" , ticks );
130128 gc_collect ();
131129 // qstr info
132130 {
@@ -166,19 +164,19 @@ int pyexec_raw_repl(void) {
166164 stdout_tx_str (">" );
167165 for (;;) {
168166 char c = stdin_rx_chr ();
169- if (c == VCP_CHAR_CTRL_A ) {
167+ if (c == CHAR_CTRL_A ) {
170168 // reset raw REPL
171169 goto raw_repl_reset ;
172- } else if (c == VCP_CHAR_CTRL_B ) {
170+ } else if (c == CHAR_CTRL_B ) {
173171 // change to friendly REPL
174172 stdout_tx_str ("\r\n" );
175173 vstr_clear (& line );
176174 pyexec_mode_kind = PYEXEC_MODE_FRIENDLY_REPL ;
177175 return 0 ;
178- } else if (c == VCP_CHAR_CTRL_C ) {
176+ } else if (c == CHAR_CTRL_C ) {
179177 // clear line
180178 vstr_reset (& line );
181- } else if (c == VCP_CHAR_CTRL_D ) {
179+ } else if (c == CHAR_CTRL_D ) {
182180 // input finished
183181 break ;
184182 } else if (c <= 127 ) {
@@ -230,7 +228,7 @@ int pyexec_friendly_repl(void) {
230228 for (;;) {
231229 nlr_buf_t nlr;
232230 printf("pyexec_repl: %p\n", x);
233- usb_vcp_set_interrupt_char(VCP_CHAR_CTRL_C );
231+ mp_hal_set_interrupt_char(CHAR_CTRL_C );
234232 if (nlr_push(&nlr) == 0) {
235233 for (;;) {
236234 }
@@ -246,21 +244,21 @@ int pyexec_friendly_repl(void) {
246244 vstr_reset (& line );
247245 int ret = readline (& line , ">>> " );
248246
249- if (ret == VCP_CHAR_CTRL_A ) {
247+ if (ret == CHAR_CTRL_A ) {
250248 // change to raw REPL
251249 stdout_tx_str ("\r\n" );
252250 vstr_clear (& line );
253251 pyexec_mode_kind = PYEXEC_MODE_RAW_REPL ;
254252 return 0 ;
255- } else if (ret == VCP_CHAR_CTRL_B ) {
253+ } else if (ret == CHAR_CTRL_B ) {
256254 // reset friendly REPL
257255 stdout_tx_str ("\r\n" );
258256 goto friendly_repl_reset ;
259- } else if (ret == VCP_CHAR_CTRL_C ) {
257+ } else if (ret == CHAR_CTRL_C ) {
260258 // break
261259 stdout_tx_str ("\r\n" );
262260 continue ;
263- } else if (ret == VCP_CHAR_CTRL_D ) {
261+ } else if (ret == CHAR_CTRL_D ) {
264262 // exit for a soft reset
265263 stdout_tx_str ("\r\n" );
266264 vstr_clear (& line );
@@ -272,11 +270,11 @@ int pyexec_friendly_repl(void) {
272270 while (mp_repl_continue_with_input (vstr_str (& line ))) {
273271 vstr_add_char (& line , '\n' );
274272 int ret = readline (& line , "... " );
275- if (ret == VCP_CHAR_CTRL_C ) {
273+ if (ret == CHAR_CTRL_C ) {
276274 // cancel everything
277275 stdout_tx_str ("\r\n" );
278276 goto input_restart ;
279- } else if (ret == VCP_CHAR_CTRL_D ) {
277+ } else if (ret == CHAR_CTRL_D ) {
280278 // stop entering compound statement
281279 break ;
282280 }
0 commit comments