Skip to content

Commit cea5503

Browse files
committed
Fixup warnings from merge about undefined macro values, switch to
VM keyboard exception and switch to FATFS reader.
1 parent dfb61f0 commit cea5503

File tree

13 files changed

+25
-55
lines changed

13 files changed

+25
-55
lines changed

atmel-samd/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ SRC_C = \
197197
lib/fatfs/ff.c \
198198
lib/fatfs/option/ccsbcs.c \
199199
lib/timeutils/timeutils.c \
200+
lib/utils/interrupt_char.c \
200201
lib/utils/pyexec.c \
201202
lib/utils/pyhelp.c \
202203
lib/utils/stdout_helpers.c \

atmel-samd/autoreset.c

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,23 +27,22 @@
2727
#include "autoreset.h"
2828

2929
#include "asf/sam0/drivers/tc/tc_interrupt.h"
30+
#include "lib/utils/interrupt_char.h"
3031
#include "py/mphal.h"
3132

32-
void mp_keyboard_interrupt(void);
33-
3433
volatile uint32_t autoreset_delay_ms = 0;
3534
bool autoreset_enabled = false;
3635
volatile bool reset_next_character = false;
3736

3837
inline void autoreset_tick() {
39-
if (autoreset_delay_ms == 0) {
40-
return;
41-
}
42-
if (autoreset_delay_ms == 1 && autoreset_enabled && !reset_next_character) {
43-
mp_keyboard_interrupt();
44-
reset_next_character = true;
45-
}
46-
autoreset_delay_ms--;
38+
if (autoreset_delay_ms == 0) {
39+
return;
40+
}
41+
if (autoreset_delay_ms == 1 && autoreset_enabled && !reset_next_character) {
42+
mp_keyboard_interrupt();
43+
reset_next_character = true;
44+
}
45+
autoreset_delay_ms--;
4746
}
4847

4948
void autoreset_enable() {

atmel-samd/main.c

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,6 @@ void reset_mp(void) {
125125
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash));
126126
mp_obj_list_append(mp_sys_path, MP_OBJ_NEW_QSTR(MP_QSTR__slash_flash_slash_lib));
127127
mp_obj_list_init(mp_sys_argv, 0);
128-
129-
MP_STATE_PORT(mp_kbd_exception) = mp_obj_new_exception(&mp_type_KeyboardInterrupt);
130128
}
131129

132130
#ifdef EXPRESS_BOARD
@@ -480,16 +478,6 @@ void gc_collect(void) {
480478
gc_collect_end();
481479
}
482480

483-
mp_lexer_t *fat_vfs_lexer_new_from_file(const char *filename);
484-
mp_lexer_t *mp_lexer_new_from_file(const char *filename) {
485-
#if MICROPY_VFS_FAT
486-
return fat_vfs_lexer_new_from_file(filename);
487-
#else
488-
(void)filename;
489-
return NULL;
490-
#endif
491-
}
492-
493481
mp_import_stat_t fat_vfs_import_stat(const char *path);
494482
mp_import_stat_t mp_import_stat(const char *path) {
495483
#if MICROPY_VFS_FAT
@@ -500,10 +488,6 @@ mp_import_stat_t mp_import_stat(const char *path) {
500488
#endif
501489
}
502490

503-
void mp_keyboard_interrupt(void) {
504-
MP_STATE_VM(mp_pending_exception) = MP_STATE_PORT(mp_kbd_exception);
505-
}
506-
507491
void nlr_jump_fail(void *val) {
508492
}
509493

atmel-samd/mpconfigport.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,12 @@
8686
#define MICROPY_USE_INTERNAL_PRINTF (1)
8787
#define MICROPY_PY_SYS_STDFILES (1)
8888
#define MICROPY_PY_IO_FILEIO (1)
89+
#define MICROPY_READER_FATFS (1)
8990
#define MICROPY_PERSISTENT_CODE_LOAD (1)
9091
#define MICROPY_PY_BUILTINS_STR_UNICODE (1)
9192

93+
#define MICROPY_KBD_EXCEPTION (1)
94+
9295
// type definitions for the specific machine
9396

9497
#define BYTES_PER_WORD (4)
@@ -172,7 +175,6 @@ extern const struct _mp_obj_module_t samd_module;
172175
#define MICROPY_PORT_ROOT_POINTERS \
173176
const char *readline_hist[8]; \
174177
vstr_t *repl_line; \
175-
mp_obj_t mp_kbd_exception; \
176178
FLASH_ROOT_POINTERS \
177179

178180
bool udi_msc_process_trans(void);

atmel-samd/mphalport.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include "asf/sam0/drivers/port/port.h"
99
#include "asf/sam0/drivers/sercom/usart/usart.h"
1010
#include "lib/mp-readline/readline.h"
11+
#include "lib/utils/interrupt_char.h"
1112
#include "py/mphal.h"
1213
#include "py/mpstate.h"
1314
#include "py/smallint.h"
@@ -34,9 +35,6 @@ volatile uint8_t usb_rx_count;
3435

3536
volatile bool mp_cdc_enabled = false;
3637

37-
void mp_keyboard_interrupt(void);
38-
int interrupt_char;
39-
4038
extern struct usart_module usart_instance;
4139

4240
static volatile bool mp_msc_enabled = false;
@@ -106,7 +104,7 @@ void usb_rx_notify(void)
106104
// character!
107105
c = udi_cdc_getc();
108106

109-
if (c == interrupt_char) {
107+
if (c == mp_interrupt_char) {
110108
// We consumed a character rather than adding it to the rx
111109
// buffer so undo the modifications we made to count and the
112110
// tail.
@@ -219,14 +217,6 @@ void mp_hal_stdout_tx_strn(const char *str, size_t len) {
219217
#endif
220218
}
221219

222-
extern int interrupt_char;
223-
void mp_hal_set_interrupt_char(int c) {
224-
if (c != -1) {
225-
mp_obj_exception_clear_traceback(MP_STATE_PORT(mp_kbd_exception));
226-
}
227-
interrupt_char = c;
228-
}
229-
230220
void mp_hal_delay_ms(mp_uint_t delay) {
231221
// If mass storage is enabled measure the time ourselves and run any mass
232222
// storage transactions in the meantime.
@@ -239,7 +229,7 @@ void mp_hal_delay_ms(mp_uint_t delay) {
239229
MICROPY_VM_HOOK_LOOP
240230
#endif
241231
// Check to see if we've been CTRL-Ced by autoreset or the user.
242-
if(MP_STATE_VM(mp_pending_exception) == MP_STATE_PORT(mp_kbd_exception)) {
232+
if(MP_STATE_VM(mp_pending_exception) == MP_OBJ_FROM_PTR(&MP_STATE_VM(mp_kbd_exception))) {
243233
break;
244234
}
245235
duration = (common_hal_time_monotonic() - start_tick);

extmod/modframebuf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ STATIC mp_obj_t framebuf_blit(size_t n_args, const mp_obj_t *args) {
353353
int cx1 = x1;
354354
for (int cx0 = x0; cx0 < x0end; ++cx0) {
355355
color = getpixel(source, cx1, y1);
356-
if (color != key) {
356+
if (key == -1 || color != (uint32_t)key) {
357357
setpixel(self, cx0, y0, color);
358358
}
359359
++cx1;

py/asmarm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ void asm_arm_bcc_label(asm_arm_t *as, int cond, uint label);
122122
void asm_arm_b_label(asm_arm_t *as, uint label);
123123
void asm_arm_bl_ind(asm_arm_t *as, void *fun_ptr, uint fun_id, uint reg_temp);
124124

125-
#if GENERIC_ASM_API
125+
#ifdef GENERIC_ASM_API
126126

127127
// The following macros provide a (mostly) arch-independent API to
128128
// generate native code, and are used by the native emitter.

py/asmthumb.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ void asm_thumb_b_label(asm_thumb_t *as, uint label); // convenience: picks narro
237237
void asm_thumb_bcc_label(asm_thumb_t *as, int cc, uint label); // convenience: picks narrow or wide branch
238238
void asm_thumb_bl_ind(asm_thumb_t *as, void *fun_ptr, uint fun_id, uint reg_temp); // convenience
239239

240-
#if GENERIC_ASM_API
240+
#ifdef GENERIC_ASM_API
241241

242242
// The following macros provide a (mostly) arch-independent API to
243243
// generate native code, and are used by the native emitter.

py/asmx64.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void asm_x64_mov_r64_to_local(asm_x64_t* as, int src_r64, int dest_local_num);
114114
void asm_x64_mov_local_addr_to_r64(asm_x64_t* as, int local_num, int dest_r64);
115115
void asm_x64_call_ind(asm_x64_t* as, void* ptr, int temp_r32);
116116

117-
#if GENERIC_ASM_API
117+
#ifdef GENERIC_ASM_API
118118

119119
// The following macros provide a (mostly) arch-independent API to
120120
// generate native code, and are used by the native emitter.

py/asmx86.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ void asm_x86_mov_r32_to_local(asm_x86_t* as, int src_r32, int dest_local_num);
112112
void asm_x86_mov_local_addr_to_r32(asm_x86_t* as, int local_num, int dest_r32);
113113
void asm_x86_call_ind(asm_x86_t* as, void* ptr, mp_uint_t n_args, int temp_r32);
114114

115-
#if GENERIC_ASM_API
115+
#ifdef GENERIC_ASM_API
116116

117117
// The following macros provide a (mostly) arch-independent API to
118118
// generate native code, and are used by the native emitter.

0 commit comments

Comments
 (0)